move to from olive to mcs
authorJb Evain <jbevain@gmail.com>
Wed, 20 Aug 2008 21:24:37 +0000 (21:24 -0000)
committerJb Evain <jbevain@gmail.com>
Wed, 20 Aug 2008 21:24:37 +0000 (21:24 -0000)
svn path=/trunk/mcs/; revision=111187

1153 files changed:
mcs/class/System.ServiceModel/Assembly/AssemblyInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Assembly/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/Makefile [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.CodeGeneration/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeAdd.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeAnd.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArgument.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArgumentReference.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArithmeticOperation.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArrayItem.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArrayLength.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeAssignment.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBinaryComparison.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBinaryOperation.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBlock.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBuilder.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeCast.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeClass.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeCustomAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeDecrement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeEquals.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeExpression.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeFieldReference.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeFor.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeForeach.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeGenerationHelper.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeIf.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeIncrement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeIs.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeItem.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeLiteral.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeMethod.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeMethodCall.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeModule.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeNew.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeNewArray.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeNotEquals.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeOr.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeProperty.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodePropertyReference.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeReturn.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeSelect.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeSelfIncrement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeUnaryOperation.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeValueReference.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeVariableDeclaration.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeVariableReference.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeWhen.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeWhile.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeWriter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.CodeGeneration/Exp.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Cryptography/MD5SHA1.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Cryptography/README.olive [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Cryptography/TlsHMAC.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/BitConverterLE.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/MessageBase.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/NtlmFlags.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/NtlmTargetInformation.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/NtlmVersion.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/Type1Message.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/Type2Message.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/Type3Message.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/README.olive [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/README.olive [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/README.olive [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/Alert.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherSuite.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherSuiteCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherSuiteFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ClientContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ClientRecordProtocol.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ClientSessionCache.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ContentType.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/Context.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/DebugHelper.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/HandshakeState.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/HashAlgorithmType.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/HttpsClientStream.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/README.olive [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/RecordProtocol.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SecurityCompressionType.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SecurityParameters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SecurityProtocolType.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ServerContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslCipherSuite.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslClientStream.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslHandshakeHash.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslServerStream.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslStreamBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsCipherSuite.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsClientSettings.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsServerSettings.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsStream.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Xml.XPath/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathDocument2.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathDocumentWriter2.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathNavigator2.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathNode2.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Mono.Xml.XPath/README [new file with mode: 0644]
mcs/class/System.ServiceModel/System.Collections.Generic/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/System.Collections.Generic/KeyedByTypeCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.Collections.Generic/SynchronizedCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.Collections.Generic/SynchronizedKeyedCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.Collections.Generic/SynchronizedReadOnlyCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Activation/AspNetIntegrationRequirementsAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Activation/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpModule.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Activation/IServiceHostFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Activation/ServiceHostFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Activation/ServiceHostFactoryBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/AddressHeader.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/AddressHeaderCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/AddressingVersion.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/AspNetReplyChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/AspNetRequestContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/AsymmetricSecurityBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncoder.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncoderFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncodingBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/Binding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingParameterCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/BodyWriter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/BufferManager.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/CachingCompiler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelFactoryBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelListenerBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelListenerBase_1.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelManagerBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelParameterCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelPoolSettings.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/CompilationException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/CompositeDuplexBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/CompositeDuplexBindingElementImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ConnectionOrientedTransportBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/CustomBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/DeliveryFailure.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/DeliveryStatus.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/DirectionalAction.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/DuplexSessionChannelBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/FaultConverter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HostedTransportConfiguration.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HtmlizedException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelListener.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelManager.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpReplyChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestMessageProperty.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpResponseMessageProperty.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpTransportBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpsTransportBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IBindingDeliveryCapabilities.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IBindingMulticastCapabilities.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IBindingRuntimePreferences.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IChannelFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IChannelListener.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IDuplexChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IDuplexSession.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IDuplexSessionChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IInputChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IInputSession.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IInputSessionChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IMessageProperty.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IOutputChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IOutputSession.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IOutputSessionChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IReplyChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IReplySessionChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IRequestChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/IRequestSessionChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ISecurityCapabilities.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ISession.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ISessionChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ITransactedBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ITransportTokenAssertionProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/InputChannelBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/InvalidChannelBindingException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredCommunicationObject.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredOutputChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredReplyChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredRequestChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/LocalClientSecuritySettings.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageBuffer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageBufferImpl.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncoder.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncoderFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncodingBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncodingBindingElementImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageFault.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageFaultBodyWriter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeader.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeaderInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeaders.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageProperties.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageSecurityBindingSupport.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageVersion.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqBindingElementBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqChannelFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqChannelListener.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqInputChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqMessageProperty.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqOutputChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqTransportBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MtomMessageEncoder.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MtomMessageEncoderFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/MtomMessageEncodingBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/NamedPipeConnectionPoolSettings.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/NamedPipetransportBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/OneWayBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/OneWayBindingElementImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/OutputChannelBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/PeerResolverBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/PeerTransportBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/PnrpPeerResolverBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReliableSessionBindingElementImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReplyChannelBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/RequestChannelBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/RequestContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageDecryptor.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityBindingElementImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityChannelFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityChannelListener.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityOutputChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityRequestChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityRequestContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ServiceHostParser.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SslStreamSecurityBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SslStreamSecurityUpgradeAcceptor.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SslStreamSecurityUpgradeProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/StandardBindingImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamSecurityUpgradeAcceptor.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamSecurityUpgradeInitiator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamSecurityUpgradeProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeAcceptor.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeInitiator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandlerFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/SymmetricSecurityBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpChannelFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpChannelListener.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpConnectionPoolSettings.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpDuplexSessionChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpTransportBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoderFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncodingBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionFlowBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionFlowBindingElementImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionMessageProperty.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransportBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransportBindingElementImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransportSecurityBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/UnderstoodHeaders.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/UseManagedPresentationBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/WSEncryptedXml.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/WSSecurityMessageHeader.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/WSSignedXml.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/WindowsStreamSecurityBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/XmlObjectSerializerBodyWriter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Channels/XmlReaderBodyWriter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.ComIntegration/Dummy.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AddressHeaderCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AllowedAudienceUriElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AllowedAudienceUriElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AuthenticationMode.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AuthorizationPolicyTypeElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AuthorizationPolicyTypeElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BaseAddressElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BaseAddressElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpMessageSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BehaviorExtensionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BehaviorsSection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BinaryMessageEncodingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BindingElementExtensionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BindingsSection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CallbackDebugElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CallbackTimeoutsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CertificateElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CertificateReferenceElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChannelEndpointElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChannelEndpointElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChannelPoolSettingsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClaimTypeElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClaimTypeElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClientCredentialsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClientSection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClientViaElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComContractElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComContractElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComContractsSection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComMethodElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComMethodElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComPersistableTypeElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComPersistableTypeElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComUdtElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComUdtElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CommonBehaviorsSection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CommonEndpointBehaviorElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CommonServiceBehaviorElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CompositeDuplexElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ConfigUtil.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ConnectionOrientedTransportElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CustomBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CustomBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CustomBindingElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/DataContractSerializerElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/DiagnosticSection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/DnsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EncodingConverter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EndpointAddressElementBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EndpointBehaviorElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EndpointBehaviorElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ExtensionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ExtensionElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ExtensionsSection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/FederatedMessageSecurityOverHttpElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HostElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HostTimeoutsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpDigestClientElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpTransportElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpTransportSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpsTransportElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IBindingConfigurationElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IPAddressConverter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IdentityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenClientBehaviorsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenClientBehaviorsElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenClientElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenParametersElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenParametersEndpointAddressElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenServiceElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/LocalClientSecuritySettingsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/LocalServiceSecuritySettingsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageLoggingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityOverHttpElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityOverMsmqElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityOverTcpElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityVersionConverter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageVersionConverter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MetadataElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MethodStubs.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexBindingBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpsBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpsBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexNamedPipeBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexNamedPipeBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexTcpBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexTcpBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqBindingElementBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqElementBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqTransportElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqTransportSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MtomMessageEncodingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedPipeConnectionPoolSettingsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedPipeTransportElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedPipeTransportSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedServiceModelExtensionCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetMsmqBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetMsmqBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetMsmqSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetNamedPipeBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetNamedPipeBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetNamedPipeSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetPeerTcpBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetPeerTcpBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetTcpBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetTcpBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetTcpSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NonDualMessageSecurityOverHttpElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/OneWayElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerCredentialElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerCustomResolverElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerResolverElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerTransportElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerTransportSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PnrpPeerResolverElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PolicyImporterElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PolicyImporterElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PolicyVersionConverter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PrivacyNoticeElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ReliableMessagingVersionConverter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ReliableSessionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/RsaElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecureConversationServiceElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecurityAlgorithmSuiteConverter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecurityElementBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceAuthorizationElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceBehaviorElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceBehaviorElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceCredentialsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceDebugElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceEndpointElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceEndpointElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceHostingEnvironmentSection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceMetadataPublishingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelConfigurationElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelEnhancedConfigurationElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelExtensionCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelExtensionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelSectionGroup.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServicePrincipalNameElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceSecurityAuditElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceThrottlingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceTimeoutsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServicesSection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SslStreamSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingOptionalReliableSessionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingReliableSessionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SynchronousReceiveElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TcpConnectionPoolSettingsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TcpTransportElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TcpTransportSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TextMessageEncodingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransactedBatchingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransactionFlowElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransactionProtocolConverter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransportConfigurationTypeElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransportConfigurationTypeElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransportElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/UseManagedPresentationElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/UserNameServiceElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/UserPrincipalNameElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007FederationHttpBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007FederationHttpBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007HttpBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007HttpBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSDualHttpBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSDualHttpBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSDualHttpSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSFederationHttpBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSFederationHttpBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSFederationHttpSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpBindingBaseElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpBindingCollectionElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpTransportSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WindowsClientElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WindowsServiceElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WindowsStreamSecurityElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WsdlImporterElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WsdlImporterElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509CertificateTrustedIssuerElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509CertificateTrustedIssuerElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ClientCertificateAuthenticationElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ClientCertificateCredentialsElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509DefaultServiceCertificateElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509InitiatorCertificateClientElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509InitiatorCertificateServiceElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509PeerCertificateAuthenticationElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509PeerCertificateElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509RecipientCertificateClientElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509RecipientCertificateServiceElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ScopedServiceCertificateElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ScopedServiceCertificateElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ServiceCertificateAuthenticationElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XPathMessageFilterElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XPathMessageFilterElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XPathMessageFilterElementComparer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XmlDictionaryReaderQuotasElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XmlElementElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XmlElementElementCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/CallbackDebugBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/CallbackTimeoutsBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ClientCredentials.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ClientViaBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescription.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/DataContractSerializerMessageContractImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/DataContractSerializerOperationBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/FaultDescription.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/FaultDescriptionCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/HostedBindingBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IContractBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IContractBehaviorAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IEndpointBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IMetadataExchange.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IOperationBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IOperationContractGenerationExtension.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IPolicyImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IServiceBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IServiceContractGenerationExtension.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IWsdlExporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IWsdlImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/IpolicyExporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/LocalServiceSecuritySettings.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageBodyDescription.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageDescription.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageDescriptionCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageHeaderDescription.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageHeaderDescriptionCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePartDescription.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePartDescriptionCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePropertyDescription.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePropertyDescriptionCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataBundle.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataConversionError.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataExchangeBindings.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataExchangeClient.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataExporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataLocation.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataReference.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataResolver.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataSection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataSectionSerializerBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/MustUnderstandBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/OperationContractGenerationContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/OperationDescription.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/OperationDescriptionCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/PolicyAssertionCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/PolicyConversionContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/PolicyVersion.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceAuthorizationBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceContractGenerationContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceContractGenerator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceCredentials.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceDebugBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceDescription.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpoint.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpointCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataExtension.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceSecurityAuditBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceThrottlingBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceTimeoutsBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/SynchronousReceiveBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/TransactedBatchingBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/TypedMessageConverter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/WSTrustMessageConverters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/WSTrustSTSContract.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/WebServiceHelper.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlContractConversionContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlEndpointConversionContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlExporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/XmlSerializerMessageContractImporter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Description/XmlSerializerOperationBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Diagnostics/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Diagnostics/PerformanceCounterScope.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ActionMessageFilter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ActionMessageFilterTable.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessor.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessorHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcherBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcherCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ClientOperation.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ClientRuntime.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DataContractSerializerServiceBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DefaultInstanceContextProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchOperation.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchRuntime.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointAddressMessageFilter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointAddressMessageFilterTable.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ErrorProcessingHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ExceptionHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/FaultContractInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/FilterInvalidBodyAccessException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/FinalizeProcessingHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ICallContextInitializer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IChannelInitializer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IClientMessageFormatter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IClientMessageInspector.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IClientOperationSelector.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IDispatchMessageFormatter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IDispatchMessageInspector.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IDispatchOperationSelector.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IErrorHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInputSessionShutdown.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInstanceContextInitializer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInstanceContextProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInstanceProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInteractiveChannelInitializer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IMessageFilterTable.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IOperationInvoker.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IParameterInspector.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InitializingHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InputOrReplyRequestProcessor.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InstanceBehavior.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InstanceContextIdleCallback.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InvalidBodyAccessException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MatchAllMessageFilter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MatchNoneMessageFilter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageFilter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageFilterNodeQuotaExceededException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageFilterTable.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageProcessingContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MexInstanceContextProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MultipleMessageFilterMatchesException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/NavigatorInvalidBodyAccessException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationContextScopeHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationInvokerHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/PostReceiveRequestHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/PrefixEndpointAddressMessageFilter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ReplyHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/SecurityHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/SeekableXPathNavigator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ServiceThrottle.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/SingletonInstanceContextProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathMessageContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathMessageFilter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathMessageFilterTable.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathNavigatorException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationMessageProperty.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationSecurity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqMessage.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/CustomPeerResolverService.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/IPeerResolverContract.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerCustomResolverSettings.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerReferralPolicy.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerResolverMode.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerResolverSettings.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RefreshInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RefreshResponseInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RefreshResult.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RegisterInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RegisterResponseInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ResolveInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ResolveResponseInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ServiceSettingsResponseInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/UnregisterInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/UpdateInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/AuthenticatorCommunicationObject.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/BinarySecretSecurityToken.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ClaimTypeRequirement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/CommunicationSecurityTokenAuthenticator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/CommunicationSecurityTokenProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/DerivedKeySecurityToken.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IIssuanceSecurityTokenAuthenticator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ISecurityContextSecurityTokenCache.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/InitiatorServiceModelSecurityTokenRequirement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/InternalEncryptedKeyIdentifierClause.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedSecurityTokenHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedSecurityTokenParameters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedSecurityTokenProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedTokenCommunicationObject.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/KerberosSecurityTokenParameters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ProviderCommunicationObject.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/RecipientServiceModelSecurityTokenRequirement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/RenewedSecurityTokenHandler.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/RsaSecurityTokenParameters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenAuthenticator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenParameters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityToken.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenAuthenticator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenResolver.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityTokenParameters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityTokenReferenceStyle.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenRequirement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenTypes.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SpnegoSecurityTokenAuthenticator.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SpnegoSecurityTokenProvider.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenAuthenticator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenParameters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslnegoCookieResolver.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiClientSecurityTokenAuthenticator.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiSecurityToken.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiSecurityTokenParameters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiSession.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SupportingTokenParameters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/TlsClientSession.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/TlsServerSession.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/UserNameSecurityTokenParameters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/WrappedKeySecurityToken.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/X509SecurityTokenParameters.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/BasicSecurityProfileVersion.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/BinarySecretKeyIdentifierClause.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog-System.ServiceModel.Security.Protocols [new file with mode: 0755]
mcs/class/System.ServiceModel/System.ServiceModel.Security/ChannelProtectionRequirements.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/DataProtectionSecurityStateEncoder.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/ExpiredSecurityTokenException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/HttpDigestClientCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/IEndpointIdentityProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/ISecureConversationSession.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/ISecuritySession.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/IdentityVerifier.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/InfocardInteractiveChannelInitializer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/IssuedTokenClientCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/IssuedTokenServiceCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/KeyEntropyMode.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/KeyNameIdentifierClause.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/MessagePartSpecification.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/MessageProtectionOrder.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/MessageSecurityException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/PeerCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/ScopedMessagePartSpecification.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SecureConversationServiceCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityAccessDeniedException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityAlgorithmSuite.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityContextKeyIdentifierClause.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityCredentialsManager.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityMessageProperty.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityNegotiationException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityStateEncoder.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityTokenAttachmentMode.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityTokenSpecification.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityVersion.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManager.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SspiSecurityTokenProvider.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/SupportingTokenSpecification.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/UnionSecurityTokenResolver.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/UserNamePasswordClientCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/UserNamePasswordServiceCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/WindowsClientCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/WindowsServiceCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateInitiatorClientCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateInitiatorServiceCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateRecipientClientCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateRecipientServiceCredential.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/X509ClientCertificateAuthentication.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/X509PeerCertificateAuthentication.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.Security/X509ServiceCertificateAuthentication.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.csproj [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel.dll.sources [new file with mode: 0755]
mcs/class/System.ServiceModel/System.ServiceModel/ActionNotSupportedException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/AddressAccessDeniedException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/AddressAlreadyInUseException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/AllEnums.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpMessageSecurity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpSecurity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/CallbackBehaviorAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ClientCredentialsSecurityTokenManager.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ClientProxyGenerator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/CommunicationException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/CommunicationObjectFaultedException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/Constants.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/DataContractFormatAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/DefaultCommunicationTimeouts.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/DeliveryRequirementsAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/DnsEndpointIdentity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/Dummy.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/DuplexChannelFactory.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/DuplexClientBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddress.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddress10.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddressAugust2004.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddressBuilder.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/EndpointIdentity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/EndpointNotFoundException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/EnvelopeVersion.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ExceptionDetail.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ExtensionCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/FaultCode.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/FaultContractAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/FaultException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/FaultException_1.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/FaultReason.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/FaultReasonText.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/FederatedMessageSecurityOverHttp.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/HttpTransportSecurity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/IClientChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ICommunicationObject.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/IContextChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/IDefaultCommunicationTimeouts.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/IDuplexClientChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/IExtensibleObject.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/IExtension.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/IExtensionCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/IServiceChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/InstanceContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/InvalidMessageContractException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageBodyAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageContractAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageContractMemberAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageHeaderArrayAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageHeaderAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageHeaderException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageHeader_1.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageParameterAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessagePropertyAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityOverHttp.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityOverMsmq.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityOverTcp.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityVersion.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MsmqBindingBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MsmqException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MsmqPoisonMessageException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/MsmqTransportSecurity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/NetMsmqBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/NetMsmqSecurity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/NetPeerTcpBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/NetTcpBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/NetTcpSecurity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/NonDualMessageSecurityOverHttp.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/OperationBehaviorAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/OperationContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/OperationContextScope.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/OperationContractAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/OptionalReliableSession.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/PeerMessagePropagationMessageFilter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/PeerNode.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/PeerNodeAddress.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/PeerResolver.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/PeerResolverImpl.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/PeerSecuritySettings.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/PoisonMessageException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ProtocolException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/QuotaExceededException.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ReliableMessagingVersion.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ReliableSession.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/RsaEndpointIdentity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ServiceAuthorizationManager.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ServiceBehaviorAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ServiceContractAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ServiceHost.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostingEnvironment.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ServiceKnownTypeAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ServiceRuntimeChannel.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/ServiceSecurityContext.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/SpnEndpointIdentity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/TcpTransportSecurity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/TransactionProtocol.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/TransferMode.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/UnknownMessageReceivedEventArgs.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/UpnEndpointIdentity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/UriSchemeKeyedCollection.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/WS2007FederationHttpBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/WS2007HttpBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/WSDualHttpBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/WSDualHttpSecurity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/WSFederationHttpBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/WSFederationHttpSecurity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/WSHttpBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/WSHttpBindingBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/WSHttpSecurity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/X509CertificateEndpointIdentity.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel/XmlSerializerFormatAttribute.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel_Test.csproj [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel_Test.csproj.user [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel_Test.sln [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel_test.dll.sources [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel_test_net_3_0.dll.config [new file with mode: 0644]
mcs/class/System.ServiceModel/System.ServiceModel_test_net_3_5.dll.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/AsyncCallTesterProxy.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/AsyncPatternServer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/DataContractTesterProxy.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/ExitProcessHelperServer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/FaultsTesterProxy.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/KnownTypeTesterProxy.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/MessageContractTesterProxy.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/OperationContractServer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/PrimitiveTester.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/UntypedMessageTesterProxy.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/AsyncCallTester.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/AsyncPatternContract.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/DataContractTester.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/DualContract.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/ExitpProcessHelper.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/FaultsTester.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/KnownTypeTester.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/MessageContractTester.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/OperationContract.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/OperationContractServer.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/PrimitiveTester.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/UntypedMessageTester.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/AsyncCallTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/AsyncPatternTester.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/DataContractSerializerTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/DualContractTester.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/ExitProcessHelper.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/FaultsTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/KnownTypeTest.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/MessageContractTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/OperationContractTester.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/PrimitiveTesterTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/UntypedMessageTest.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/XmlComparer.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/FeatureBased/TestFixtureBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/README.txt [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/Resources/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/Resources/test.cer [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/Resources/test.pfx [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/Resources/test2.pfx [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/SwitchMode/Program.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/SwitchMode/Properties/AssemblyInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/SwitchMode/SwitchMode.csproj [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/AddressHeaderTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/AddressingVersionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/AsymmetricSecurityBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/BindingContextTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/BindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/BindingTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/CalcSampleProxy.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/CommunicationObjectTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/CustomBindingTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/DebugBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/EmptyFaultExceptionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/EnvelopeVersionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultConverterTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultExceptionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/HandlerBodyWriter.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/HandlerTransportBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/HttpTransportBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/InterceptorBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/InvalidBindingElement.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/LocalClientSecuritySettingsTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageBufferTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageEncoderTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageEncodingBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageHeaderTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageHeadersTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageVersionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MsmqTransportBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/NamedPipeTransportBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/OneWayBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/OutputChannelBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/ReplyChannelBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/RequestChannelBase.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SecurityAssert.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SecurityBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SslStreamSecurityBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SymmetricSecurityBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/TcpTransportBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/TextMessageEncodingBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/TransactionFlowBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/AddressHeaderCollectionElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/BasicHttpBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/BehaviorsSectionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/BindingsSectionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ChannelEndpointElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/CustomBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/EndpointBehaviorElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ExtensionsSectionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/MetadataElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/MexBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/NetNamedPipeBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/NetPeerTcpBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/NetTcpBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceBehaviorElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceModelConfigurationElementCollectionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceModelSectionGroupTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/StandardBindingCollectionElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/StandardBindingElementCollectionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/StandardBindingElementTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/UserBinding.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ClientCredentialsTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ContractDescriptionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataResolverTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/OperationDescriptionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceAuthorizationBehaviorTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceCredentialsTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceDebugBehaviorTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceMetadataBehaviorTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/TypedMessageConverterTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/WsdlExporterTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/WsdlImporterTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/dump.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ActionFilterTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ChannelDispatcherTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/DispatchOperationTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/DispatchRuntimeTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/EndpointAddressMessageFilterTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/EndpointDispatcherTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ExceptionHandlerTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/FilterTableTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/InvalidBodyAccessExceptionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/PrefixEndpointAddressMessageFilterTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.PeerResolvers/CustomPeerResolverServiceTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/IssuedSecurityTokenParametersTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/IssuedSecurityTokenProviderTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/RsaSecurityTokenParametersTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenParametersTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SecurityTokenParametersTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenTypesTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SslSecurityTokenParametersTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SspiSecurityTokenParametersTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/UserNameSecurityTokenParametersTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/WrappedKeySecurityTokenTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/X509ListedCertificateValidator.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/X509SecurityTokenParametersTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ChannelProtectionRequirementsTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/MessagePartSpecificationTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ScopedMessagePartSpecificationTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SecurityAlgorithmSuiteTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SecurityMessagePropertyTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SecurityTokenSpeficicationTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManagerTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ServiceSecurityContextTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SupportingTokenParametersTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/BasicHttpBindingTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ChannelFactoryTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ChannelFactory_1Test.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ClientBaseTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ClientCredentialsSecurityTokenManagerTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/CommonUseCases.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointAddress10Test.cs [new file with mode: 0755]
mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointAddressBuilderTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointAddressTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointBehaviorCollectionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointIdentityTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ExtensionCollectionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/FaultCodeTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/FaultReasonTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/IntegratedConnectionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/MessageSecurityVersionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/NetMsmqBindingTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceAssert.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceEndpointCollectionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceEndpointTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceHostBaseTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceHostTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/SynchronizedReadOnlyCollectionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/TransactionProtocolTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/UriSchemeKeyedCollectionTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/WSFederationHttpBindingTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/System.ServiceModel/WSHttpBindingTest.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/WCFServers/Program.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/WCFServers/Properties/AssemblyInfo.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/WCFServers/WCFServers.csproj [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/ChangeLog [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/basicHttpBinding [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/basicHttpBinding.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/client.endpoint [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/client.endpoint.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/client.metadata [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/client.metadata.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/customBinding [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/customBinding.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/empty [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/empty.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/endpointBehaviors [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/endpointBehaviors.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/extensions [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/extensions.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/netTcpBinding [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/netTcpBinding.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/service [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/service.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/serviceBehaviors [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/serviceBehaviors.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/test1 [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/test1.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/userBinding [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/userBinding.config [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/wsHttpBinding [new file with mode: 0644]
mcs/class/System.ServiceModel/Test/config/wsHttpBinding.config [new file with mode: 0644]
mcs/class/System.ServiceModel/fixup-config.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/fixup-config.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/fixup-config2.cs [new file with mode: 0644]
mcs/class/System.ServiceModel/fixup-config2.xml [new file with mode: 0644]
mcs/class/System.ServiceModel/resources/ChangeLog [new file with mode: 0755]
mcs/class/System.ServiceModel/resources/WS-Addressing.schema [new file with mode: 0644]
mcs/class/System.ServiceModel/resources/ws-addr.xsd [new file with mode: 0755]
mcs/class/System.ServiceModel/run-tests.client.bat [new file with mode: 0644]
mcs/class/System.ServiceModel/run-tests.inproc.bat [new file with mode: 0644]

diff --git a/mcs/class/System.ServiceModel/Assembly/AssemblyInfo.cs b/mcs/class/System.ServiceModel/Assembly/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..cb3372b
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// AssemblyInfo.cs
+//
+// Author:
+//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//
+// (C) 2003 Ximian, Inc.  http://www.ximian.com
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Security;
+using System.Security.Permissions;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about the System.ServiceModel assembly
+// v3.0 Assembly
+
+[assembly: AssemblyTitle ("System.ServiceModel.dll")]
+[assembly: AssemblyDescription ("System.ServiceModel.dll")]
+[assembly: AssemblyDefaultAlias ("System.ServiceModel.dll")]
+
+[assembly: AssemblyCompany (Consts.MonoCompany)]
+[assembly: AssemblyProduct (Consts.MonoProduct)]
+[assembly: AssemblyCopyright (Consts.MonoCopyright)]
+[assembly: AssemblyVersion (Consts.FxVersion)]
+[assembly: SatelliteContractVersion (Consts.FxVersion)]
+[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
+[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
+
+[assembly: NeutralResourcesLanguage ("en-US")]
+[assembly: CLSCompliant (true)]
+[assembly: AssemblyDelaySign (true)]
+[assembly: AssemblyKeyFile ("../ecma.pub")]
+
+[assembly: ComVisible (false)]
+[assembly: ComCompatibleVersion (1, 0, 3300, 0)]
+[assembly: AllowPartiallyTrustedCallers]
+
+[assembly: CompilationRelaxations (CompilationRelaxations.NoStringInterning)]
+[assembly: Debuggable (DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
+[assembly: RuntimeCompatibility (WrapNonExceptionThrows = true)]
+[assembly: SecurityPermission (SecurityAction.RequestMinimum, SkipVerification = true)]
+[assembly: SecurityCritical (SecurityCriticalScope.Explicit)]
+
+[assembly: InternalsVisibleTo ("WireTool, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+[assembly: InternalsVisibleTo ("System.ServiceModel.Web, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
+[assembly: InternalsVisibleTo ("System.WorkflowServices, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
+[assembly: InternalsVisibleTo ("Indigo_ServiceModelUnitMetadata, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+[assembly: InternalsVisibleTo ("SequenceRangeTest, PublicKey=002400000480000094000000060200000024000052534131000400000100010063a6ca880757560d04bfaac03f3f98a49b2851207d8d507dbae9fb7cbedd0d9e557769aa81786f5ea853eddb3f068e67229328f7b149f14c103cb45d5fc56a0d11bbda40585fcaadbe4debab44c1347bd1679e57031c82502ff489daf6fa00b71223b19353efc93f7a46b4db91428b75c4189abf76d2f1b772a5e46dd63eb6d3")]
+[assembly: InternalsVisibleTo ("WsatLogEntrySerialization, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+[assembly: InternalsVisibleTo ("WsatSerialization, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+[assembly: InternalsVisibleTo ("IndigoDiscovery, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+[assembly: InternalsVisibleTo ("WsatTest, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+[assembly: InternalsVisibleTo ("System.ServiceModel.Friend, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+[assembly: InternalsVisibleTo ("Microsoft.Transactions.Bridge, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+[assembly: InternalsVisibleTo ("IndigoUdpTransport, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+[assembly: InternalsVisibleTo ("SMSvcHost, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+
+//[assembly: InternalsVisibleTo ("System.ServiceModel.WasHosting, PublicKey=00000000000000000400000000000000")]
diff --git a/mcs/class/System.ServiceModel/Assembly/ChangeLog b/mcs/class/System.ServiceModel/Assembly/ChangeLog
new file mode 100644 (file)
index 0000000..84fc685
--- /dev/null
@@ -0,0 +1,8 @@
+2008-04-25  Andreas Nahr <ClassDevelopment@A-SoftTech.com>
+
+       * AssemblyInfo.cs: Added missing attributes
+
+2005-09-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AssemblyInfo.cs : new file.
+
diff --git a/mcs/class/System.ServiceModel/ChangeLog b/mcs/class/System.ServiceModel/ChangeLog
new file mode 100755 (executable)
index 0000000..0a7ea14
--- /dev/null
@@ -0,0 +1,304 @@
+2008-05-22  Roei Erez  <roeie@mainsoft.com>
+       * fix ContractDescription.GetContract implementation
+       * Refactor Request processing
+       * Add support for message inspectors
+       * Add support for InstanceContextProvider & InstanceProvider, including lifecycles events
+       like: ReleaseServiceInstance, Open, Close...
+       * Add relevant test cases.
+
+2008-04-21  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * System.ServiceModel_test.dll.sources: Add ServiceDebugBehaviorTest.cs and
+       ServiceMetadataBehaviorTest.cs.
+
+2008-04-17  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * System.ServiceModel.dll.sources: added HttpChannelManager.cs
+
+2008-04-14  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * System.ServiceModel_test.dll.sources: Add ExtensionCollectionTest.cs.
+
+2008-04-13  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * added: System.ServiceModel_Test.csproj, visual studio tests project
+
+2008-04-10  Eyal Alaluf <eyala@mainsoft.com>
+
+       * System.ServiceModel.dll.sources, System.ServiceModel.csproj:
+         Moved System.ServiceModel.Dispatcher/DefaultMessageOperationFormatter.cs
+         to System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs.
+         Removed System.ServiceModel.Description/ServiceModelInternalConverter.cs.
+
+2008-04-01  Roei Erez <roeie@mainsoft.com>
+
+       * System.ServiceModel_test_net_3_0.dll.config: Added configurations for new tests.
+
+2008-04-01  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * System.ServiceModel_test.dll.sources: Add ServiceHostBaseTest.cs.
+
+2008-03-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : add System.ServiceModel_test_net_3_0.dll.config to
+         EXTRA_DISTFILES too.
+
+2008-03-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : include Test/config/* in EXTRA_DISTFILES to fix
+         nunit test failures.
+
+2008-03-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : more EXTRA_DISTFILES.
+
+2008-03-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : oops, wrong EXTRA_DISTFILES.
+
+2008-03-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : add EXTRA_DISTFILES.
+
+2008-02-28  Eyal Alaluf <eyala@mainsoft.com>
+
+       * System.ServiceModel_test_net_3_0.dll.config: Add configurations for
+         testing ClientBase<T> ctors.
+
+2008-02-27  Eyal Alaluf <eyala@mainsoft.com>
+
+       * Makefile: Ignore common warnings including use of obsolete API (since
+         Mono.Security.* has several such warnings).
+
+2007-12-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : added net_3_5 profile as a valid target.
+
+2007-08-18 Marcos Cobena (marcoscobena@gmail.com)
+
+       * System.ServiceModel_test.dll.sources: Updated with new tests for System.ServiceModel.PeerResolvers.
+       * Test/System.ServiceModel.PeerResolvers/CustomPeerResolverServiceTest.cs: New bunch of tests.
+
+2007-08-16 Marcos Cobena (marcoscobena@gmail.com)
+
+       * System.ServiceModel.dll.sources: Updated with System.ServiceModel.PeerResolvers/PeerReferralPolicy.cs.
+       * PeerReferralPolicy.cs: Moved and updated here from AllEnums.cs.
+       * PeerResolverMode.cs: Updated API.
+       * RefreshResult.cs: Updated API.
+       * RegisterInfo.cs: Almost finished, minus HasBody().
+       * AllEnums.cs: PeerReferralPolicy lives now inside System.ServiceModel.PeerResolvers.
+
+2007-07-19 Marcos Cobena (marcoscobena@gmail.com)
+
+       * PeerCustomResolverSettings.cs, PeerResolverMode.cs, PeerResolverSettings.cs, 
+               PeerSecuritySettings.cs: New implementations.
+       * System.ServiceModel.dll.sources, AllEnums.cs, Dummy.cs: Updated to added sources.
+       * NetPeerTcpBinding.cs: Added support to new above implementations.
+
+2007-07-18 Marcos Cobena (marcoscobena@gmail.com)
+
+       * TcpChannelListener.cs, TcpDuplexSessionChannel.cs: Text messaging now works 
+               (both Send() and Receive()), even mixing .NET version with Mono one.
+       * TcpChannelListener.cs: By default, it uses BinaryMessageEncoder.              
+
+2007-07-17 Marcos Cobena (marcoscobena@gmail.com)
+
+       * DuplexSessionChannelBase.cs, TcpChannelListener.cs, TcpDuplexSessionChannel.cs, 
+               TcpTransportBindingElement.cs: Thanks to Atsushi Eno, it starts messaging.
+
+2007-07-12 Marcos Cobena (marcoscobena@gmail.com)
+
+       * DuplexSessionChannelBase.cs, TcpChannelFactory.cs, TcpChannelListener.cs, 
+               TcpDuplexSessionChannel.cs: Added new implementations.
+       * NetTcpBinding.cs, TcpTransportBindingElement.cs: Modified to match new TCP implementations.
+       * System.ServiceModel.dll.sources: Updated to last classes set.
+
+2007-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       Makefile : added -r:System.Messaging.dll
+
+2007-06-28 Marcos Cobena (marcoscobena@gmail.com)
+
+       * System.ServiceModel.dll.sources, System.ServiceModel\Dummy.cs : 
+       Modified to match new files under System.ServiceModel.PeerResolvers.
+
+2007-04-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       Makefile : added ws-addr.xsd as a resource.
+
+2007-04-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * fixup-config.xml : updated config section types.
+
+2007-03-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       Makefile : added -r:Mono.Security.dll and some nowarns.
+
+2007-02-27  Wade Berrier  <wberrier@novell.com>
+
+       * Makefile: include resource files in EXTRA_DISTFILES
+
+2006-10-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * fixup-config2.cs, fixup-config2.xml :
+         It is used to add svc. -> SvcHttpHandler mapping in web.config.
+
+2006-10-04  Ankit Jain  <jankit@novell.com>
+
+       * System.ServiceModel.dll.sources: Update.
+
+2006-09-29  Ankit Jain  <jankit@novell.com>
+
+       * System.ServiceModel.dll.sources: Update.
+
+2006-09-26  Ankit Jain  <jankit@novell.com>
+
+       * System.ServiceModel.dll.sources: Update.
+
+2006-09-07  Ankit Jain  <jankit@novell.com>
+
+       * System.ServiceModel_test.dll.sources: Add WsdlExporterTest.cs
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : it used to be referenced by S.IM.Selectors.dll.
+         Nowadays it references S.IM.Selectors.dll.
+
+2006-07-13  Ankit Jain  <jankit@novell.com>
+
+       * System.ServiceModel_test.dll.sources: Add MetadataResolverTest.cs
+
+2006-07-12  Ankit Jain  <jankit@novell.com>
+
+       * System.ServiceModel.dll.sources: Update for June CTP changes. Add
+       EndpointAddress10.cs
+
+2006-07-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : add path to referenced assemblies as gmcs always loads
+         them from the GAC.
+
+2006-07-03  Ankit Jain  <jankit@novell.com>
+
+       * System.ServiceModel.dll.sources: Update for June CTP changes.
+
+2006-07-03  Ankit Jain  <jankit@novell.com>
+
+       * System.ServiceModel.dll.sources: Add IMetadataExchange.cs and
+       MetadataExchangeBinding.cs . Update to match changes in June CTP.
+
+2006-06-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * fixup-config.xml : updated to match June CTP config types.
+
+2006-06-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * fixup-config.xml : bindings section has binding sub sections.
+
+2006-06-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * fixup-config.cs : now it supports updating.
+       * fixup-config.xml : "bindings" is in fact just a section.
+         MS bad naming on class.
+
+2006-06-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * fixup-config.cs, fixup-config.xml : when you try configuration
+         support, you can run fixup-config.exe and then supplemental
+         config sections are added.
+
+2006-06-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : remove extra option.
+
+2006-06-12  Ankit Jain  <jankit@novell.com>
+
+       * System.ServiceModel.dll.sources: Add
+       System.ServiceModel.Description/MetadataSectionSerializerBase.cs
+       * System.ServiceModel_test.dll.sources: Add
+       System.ServiceModel.Description/WsdlImporterTest.cs
+
+2006-06-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : use Mono.CodeGeneration.
+
+2006-04-26  Ankit Jain  <jankit@novell.com>
+
+       * System.ServiceModel_test.dll.sources : Add
+       System.ServiceModel.Description/WebServiceHelper.cs .
+
+2006-02-11  Ankit Jain  <jankit@novell.com>
+
+       * System.ServiceModel_test.dll.sources : Add
+       ServiceHostTest.cs and UriSchemeKeyedCollectionTest.cs 
+
+2005-10-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * winfx.pub : new set of assembly, thus new public key.
+
+2005-10-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : eliminated some warning noises.
+
+2005-10-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : addded /r:System.Transactions.
+
+2005-09-29  Duncan Mak  <duncan@novell.com>
+
+       * Makefile (RESOURCE_FILES): Include
+       resources/WS-Addressing.schema.
+       (LIB_MCS_FLAGS): Add "/resource:" flag.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel_test.dll.sources : required for make run-test.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : regenerated to add new files.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : regenerated to add new files.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : reference to sys.configuration.dll.
+       * System.ServiceModel.dll.sources : regenerated to add new files.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : regenerated to add new files.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : further regen.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : regenerated to add new files.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : regenerated to add new files.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : regenerated to add new files.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : regenerated to add new files.
+
+2005-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : regenerated to add new files.
+
+2005-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.ServiceModel.dll.sources : added CommunicationErrorEventArgs.
+
+2005-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Makefile : so now update-dll-sources is common target to all libs.
diff --git a/mcs/class/System.ServiceModel/Makefile b/mcs/class/System.ServiceModel/Makefile
new file mode 100755 (executable)
index 0000000..addd796
--- /dev/null
@@ -0,0 +1,51 @@
+thisdir = class/System.ServiceModel
+SUBDIRS = 
+include ../../build/rules.make
+
+RESOURCE_FILES = \
+       resources/WS-Addressing.schema  \
+       resources/ws-addr.xsd
+
+LIBRARY = System.ServiceModel.dll
+LIB_MCS_FLAGS = \
+               /nowarn:414,169,67,3005,436,219,618 \
+               /unsafe \
+               /r:System.dll \
+               /r:System.Xml.dll \
+               /r:System.Configuration.dll \
+               /r:../lib/net_3_0/System.Runtime.Serialization.dll \
+               /r:System.Security.dll \
+               /r:../lib/net_3_0/System.IdentityModel.dll \
+               /r:../lib/net_3_0/System.IdentityModel.Selectors.dll \
+               /r:System.Transactions.dll \
+               /r:System.Messaging.dll \
+               /r:System.Web.dll \
+               /r:System.Web.Services.dll \
+               /r:Mono.Security.dll \
+               $(RESOURCE_FILES:%=/resource:%)
+
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
+
+TEST_EXTRA_FILES = \
+       System.ServiceModel_test_net_3_0.dll.config \
+       Test/config/* \
+       Test/Resources/* \
+       Test/System.ServiceModel.Description/dump.xml
+
+EXTRA_DISTFILES = $(RESOURCE_FILES) $(TEST_EXTRA_FILES)
+
+# This is a WinFX only assembly
+
+# Useful for debugging under Visual Studio 2005
+# NO_SIGN_ASSEMBLY = yes
+
+VALID_PROFILE := $(filter net_3_0 net_3_5, $(PROFILE))
+ifndef VALID_PROFILE
+LIBRARY_NAME = dummy-System.ServiceModel.dll
+NO_INSTALL = yes
+NO_SIGN_ASSEMBLY = yes
+NO_TEST = yes
+endif
+
+
+include ../../build/library.make
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/ChangeLog b/mcs/class/System.ServiceModel/Mono.CodeGeneration/ChangeLog
new file mode 100755 (executable)
index 0000000..5bfafe1
--- /dev/null
@@ -0,0 +1,71 @@
+2008-07-05  Eyal Alaluf <eyala@mainsoft.com>
+
+       * CodeGenerationHelper.cs: Correctly handle enum underlying types.
+
+2008-05-04  Eyal Alaluf <eyala@mainsoft.com>
+
+       * CodeArgumentReference.cs: Fix GetResultType () when argument type is
+         by-ref.
+
+2008-04-10  Eyal Alaluf <eyala@mainsoft.com>
+
+       * CodeArgumentReference.cs, CodeGenerationHelper.cs: Added ByRef support.
+
+2008-02-27  Eyal Alaluf <eyala@mainsoft.com>
+
+       * CodeCustomAttribute.cs CodeAssignment.cs: Fix compilation warnings.
+
+2006-06-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CodeArrayItem.cs, CodeAssignment.cs : some more ArgumentNull check.
+
+2006-06-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CodeExpression.cs : replaced all operator overloads with general
+         methods, especially since when operator== is overriden to have
+         different return type (CodeExpression) it is impossible to check
+         whether a variable is null or not.
+       * CodeForEach.cs : overriden operator < was used there.
+       * CodeBuilder.cs : added some null argument check.
+       * CodeMethodCall.cs : allow MethodBase.
+
+2006-06-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CodeClass.cs : removed some DefineField() overloads as they
+         easily brings ambiguous match at call.
+
+2006-06-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CodeCustomAttribute.cs : check named argument strictly (check if
+         the named args really exist).
+
+2006-06-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CodeLiteral.cs : added Value property (needed to extract value)
+       * CodeCustomAttribute.cs : CustomAttributeBuilder.ctor() takes
+         both properties and fields.
+       * CodeMethod.cs, CodeProperty.cs : add named-arg-less .ctor().
+
+2006-06-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CodeProperty.cs : setter and getter must match for each method
+         signature with related to the property type.
+
+2006-06-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CodeAdd.cs, CodeAnd.cs, CodeArgument.cs, CodeArgumentReference.cs,
+       CodeArithmeticOperation.cs, CodeArrayItem.cs, CodeArrayLength.cs,
+       CodeAssignment.cs, CodeBinaryComparison.cs, CodeBinaryOperation.cs,
+       CodeBlock.cs, CodeBuilder.cs, CodeCast.cs, CodeClass.cs,
+       CodeCustomAttribute.cs, CodeDecrement.cs, CodeEquals.cs,
+       CodeExpression.cs, CodeFieldReference.cs, CodeFor.cs,
+       CodeForeach.cs, CodeGenerationHelper.cs, CodeIf.cs,
+       CodeIncrement.cs, CodeIs.cs, CodeItem.cs, CodeLiteral.cs,
+       CodeMethod.cs, CodeMethodCall.cs, CodeModule.cs, CodeNew.cs,
+       CodeNewArray.cs, CodeNotEquals.cs, CodeOr.cs, CodeProperty.cs,
+       CodePropertyReference.cs, CodeReturn.cs, CodeSelect.cs,
+       CodeSelfIncrement.cs, CodeUnaryOperation.cs, CodeValueReference.cs,
+       CodeVariableDeclaration.cs, CodeVariableReference.cs, CodeWhen.cs,
+       CodeWhile.cs, CodeWriter.cs, Exp.cs :
+
+       initial import. See ../README.
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeAdd.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeAdd.cs
new file mode 100644 (file)
index 0000000..956e499
--- /dev/null
@@ -0,0 +1,2 @@
+// created on 01/09/2004 at 02:27
+
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeAnd.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeAnd.cs
new file mode 100644 (file)
index 0000000..c0cb338
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeAnd: CodeConditionExpression
+       {
+               CodeExpression exp1;
+               CodeExpression exp2;
+               Type t1;
+               Type t2;
+               
+               public CodeAnd (CodeExpression exp1, CodeExpression exp2)
+               {
+                       this.exp1 = exp1;
+                       this.exp2 = exp2;
+                       
+                       if (exp1.GetResultType () != typeof(bool) || exp1.GetResultType () != typeof(bool)) {
+                               if (t1 != t2)
+                                       throw new InvalidOperationException ("Can't compare values of different primitive types");
+                       }
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       Label falseLabel = gen.DefineLabel ();
+                       Label endLabel = gen.DefineLabel ();
+                       
+                       if (exp1 is CodeConditionExpression)
+                               ((CodeConditionExpression)exp1).GenerateForBranch (gen, falseLabel, false);
+                       else {
+                               exp1.Generate (gen);
+                               gen.Emit (OpCodes.Brfalse, falseLabel);
+                       }
+                               
+                       exp2.Generate (gen);
+                       gen.Emit (OpCodes.Br, endLabel);
+                       gen.MarkLabel(falseLabel);
+                       gen.Emit (OpCodes.Ldc_I4_0);
+                       gen.MarkLabel(endLabel);
+               }
+               
+               public override void GenerateForBranch (ILGenerator gen, Label label, bool branchCase)
+               {
+                       Label endLabel = gen.DefineLabel ();
+                       exp1.Generate (gen);
+                       
+                       if (exp1 is CodeConditionExpression) {
+                               if (branchCase)
+                                       ((CodeConditionExpression)exp1).GenerateForBranch (gen, endLabel, false);
+                               else
+                                       ((CodeConditionExpression)exp1).GenerateForBranch (gen, label, false);
+                       }
+                       else {
+                               exp1.Generate (gen);
+                               if (branchCase)
+                                       gen.Emit (OpCodes.Brfalse, endLabel);
+                               else
+                                       gen.Emit (OpCodes.Brfalse, label);
+                       }
+
+                       if (exp2 is CodeConditionExpression) {
+                               if (branchCase)
+                                       ((CodeConditionExpression)exp2).GenerateForBranch (gen, label, true);
+                               else
+                                       ((CodeConditionExpression)exp2).GenerateForBranch (gen, label, false);
+                       }
+                       else {
+                               exp2.Generate (gen);
+                               if (branchCase)
+                                       gen.Emit (OpCodes.Brtrue, label);
+                               else
+                                       gen.Emit (OpCodes.Brfalse, label);
+                       }
+                       
+                       gen.MarkLabel(endLabel);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       exp1.PrintCode (cp);
+                       cp.Write (" && ");
+                       exp2.PrintCode (cp);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return typeof (bool);
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArgument.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArgument.cs
new file mode 100644 (file)
index 0000000..f862b2f
--- /dev/null
@@ -0,0 +1,38 @@
+// created on 28/08/2004 at 17:07
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeArgument: CodeExpression
+       {
+               int argument;
+               
+               public CodeArgument (int arg, Type type)
+               {
+                       argument = arg;         
+               }
+               
+               public int Argument
+               {
+                       get { return argument; }
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       gen.Emit (OpCodes.Ldloc, var.LocalBuilder);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write ("arg" + argument);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return var.Type;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArgumentReference.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArgumentReference.cs
new file mode 100644 (file)
index 0000000..752ed82
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeArgumentReference: CodeValueReference
+       {
+               Type type;
+               int argNum;
+               string name;
+               
+               public CodeArgumentReference (Type type, int argNum, string name)
+               {
+                       this.type = type;
+                       this.argNum = argNum;
+                       this.name = name;               
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       switch (argNum) {
+                               case 0: gen.Emit (OpCodes.Ldarg_0); break;
+                               case 1: gen.Emit (OpCodes.Ldarg_1); break;
+                               case 2: gen.Emit (OpCodes.Ldarg_2); break;
+                               case 3: gen.Emit (OpCodes.Ldarg_3); break;
+                               default: gen.Emit (OpCodes.Ldarg, argNum); break;
+                       }
+                       if (type.IsByRef)
+                               CodeGenerationHelper.LoadFromPtr (gen, type.GetElementType ());
+               }
+               
+               public override void GenerateSet (ILGenerator gen, CodeExpression value)
+               {
+                       if (type.IsByRef) {
+                               gen.Emit (OpCodes.Ldarg, argNum);
+                               value.Generate (gen);
+                               CodeGenerationHelper.GenerateSafeConversion (gen, type.GetElementType (), value.GetResultType ());
+                               CodeGenerationHelper.SaveToPtr (gen, type.GetElementType ());
+                       }
+                       else {
+                               value.Generate (gen);
+                               CodeGenerationHelper.GenerateSafeConversion (gen, type, value.GetResultType ());
+                               gen.Emit (OpCodes.Starg, argNum);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write (name);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return type.IsByRef ? type.GetElementType () : type;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArithmeticOperation.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArithmeticOperation.cs
new file mode 100644 (file)
index 0000000..93bfbb2
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public abstract class CodeArithmeticOperation: CodeExpression
+       {
+               protected CodeExpression exp1;
+               protected CodeExpression exp2;
+               protected Type t1;
+               protected Type t2;
+               protected string symbol;
+               
+               protected CodeArithmeticOperation ()
+               {
+               }
+               
+               public CodeArithmeticOperation (CodeExpression exp1, CodeExpression exp2, string symbol)
+               {
+                       this.symbol = symbol;
+                       this.exp1 = exp1;
+                       this.exp2 = exp2;
+                       
+                       t1 = exp1.GetResultType ();
+                       t2 = exp2.GetResultType ();
+                       
+                       if (!t1.IsPrimitive || !t2.IsPrimitive || (t1 != t2)) {
+                               throw new InvalidOperationException ("Operator " + GetType().Name + " cannot be applied to operands of type '" + t1.Name + " and " + t2.Name);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       exp1.PrintCode (cp);
+                       cp.Write (" " + symbol + " ");
+                       exp2.PrintCode (cp);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return exp1.GetResultType();
+               }
+       }
+       
+       public class CodeAdd: CodeArithmeticOperation
+       {
+               public CodeAdd (CodeExpression exp1, CodeExpression exp2)
+               {
+                       this.symbol = "+";
+                       this.exp1 = exp1;
+                       this.exp2 = exp2;
+                       
+                       t1 = exp1.GetResultType ();
+                       t2 = exp2.GetResultType ();
+                       
+                       if ((!t1.IsPrimitive || !t2.IsPrimitive || (t1 != t2)) && (t1 != typeof(string) || t2 != typeof(string))) {
+                               throw new InvalidOperationException ("Operator " + GetType().Name + " cannot be applied to operands of type '" + t1.Name + " and " + t2.Name);
+                       }
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       if (exp1.GetResultType () == typeof(string)) {
+                               MethodInfo m = typeof(string).GetMethod ("Concat", new Type[] { typeof(string), typeof(string) });
+                               CodeGenerationHelper.GenerateMethodCall (gen, null, m, exp1, exp2);
+                       }
+                       else {
+                               exp1.Generate (gen);
+                               exp2.Generate (gen);
+                               gen.Emit (OpCodes.Add);
+                       }
+               }
+       }
+       
+       public class CodeMul: CodeArithmeticOperation
+       {
+               public CodeMul (CodeExpression exp1, CodeExpression exp2)
+               : base (exp1, exp2, "*")
+               {
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp1.Generate (gen);
+                       exp2.Generate (gen);
+                       gen.Emit (OpCodes.Mul);
+               }
+       }
+       
+       public class CodeDiv: CodeArithmeticOperation
+       {
+               public CodeDiv (CodeExpression exp1, CodeExpression exp2)
+               : base (exp1, exp2, "*")
+               {
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp1.Generate (gen);
+                       exp2.Generate (gen);
+                       gen.Emit (OpCodes.Div);
+               }
+       }
+       
+       public class CodeSub: CodeArithmeticOperation
+       {
+               public CodeSub (CodeExpression exp1, CodeExpression exp2)
+               : base (exp1, exp2, "-")
+               {
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp1.Generate (gen);
+                       exp2.Generate (gen);
+                       gen.Emit (OpCodes.Sub);
+               }
+       }       
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArrayItem.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArrayItem.cs
new file mode 100644 (file)
index 0000000..f5b05ad
--- /dev/null
@@ -0,0 +1,176 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeArrayItem: CodeValueReference
+       {
+               CodeExpression array;
+               CodeExpression index;
+               
+               public CodeArrayItem (CodeExpression array, CodeExpression index)
+               {
+                       if (array == null)
+                               throw new ArgumentNullException ("array");
+                       if (index == null)
+                               throw new ArgumentNullException ("index");
+                       this.array = array;
+                       this.index = index;             
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       array.Generate (gen);
+                       index.Generate (gen);
+                       
+                       Type t = array.GetResultType().GetElementType();
+                       if (t.IsEnum && t != typeof(Enum)) t = t.UnderlyingSystemType;
+                       
+                       switch (Type.GetTypeCode (t))
+                       {
+                               case TypeCode.Byte:
+                                       gen.Emit (OpCodes.Ldelem_U1);
+                                       break;
+
+                               case TypeCode.Double:
+                                       gen.Emit (OpCodes.Ldelem_R8);
+                                       break;
+                                       
+                               case TypeCode.Int16:
+                                       gen.Emit (OpCodes.Ldelem_I2);
+                                       break;
+                                       
+                               case TypeCode.UInt32:
+                                       gen.Emit (OpCodes.Ldelem_U4);
+                                       break;
+                                       
+                               case TypeCode.Int32:
+                                       gen.Emit (OpCodes.Ldelem_I4);
+                                       break;
+                                       
+                               case TypeCode.UInt64:
+                               case TypeCode.Int64:
+                                       gen.Emit (OpCodes.Ldelem_I8);
+                                       break;
+                                       
+                               case TypeCode.SByte:
+                                       gen.Emit (OpCodes.Ldelem_I1);
+                                       break;
+                                       
+                               case TypeCode.Single:
+                                       gen.Emit (OpCodes.Ldelem_R4);
+                                       break;
+                                       
+                               case TypeCode.UInt16:
+                                       gen.Emit (OpCodes.Ldelem_U2);
+                                       break;
+                                       
+                               default:
+                                       if (t.IsValueType) {
+                                               gen.Emit (OpCodes.Ldelema, t);
+                                               CodeGenerationHelper.LoadFromPtr (gen, t);
+                                       }
+                                       else
+                                               gen.Emit (OpCodes.Ldelem_Ref);
+                                       break;
+                       }               
+               }
+               
+               public override void GenerateSet (ILGenerator gen, CodeExpression value)
+               {
+                       if (value == null)
+                               throw new ArgumentNullException ("value");
+                       Type t = array.GetResultType().GetElementType();
+                       if (t.IsEnum && t != typeof(Enum)) t = t.UnderlyingSystemType;
+                       
+                       array.Generate (gen);
+                       index.Generate (gen);
+                       
+                       switch (Type.GetTypeCode (t))
+                       {
+                               case TypeCode.Byte:
+                               case TypeCode.SByte:
+                                       value.Generate (gen);
+                                       gen.Emit (OpCodes.Stelem_I1);
+                                       break;
+
+                               case TypeCode.Double:
+                                       value.Generate (gen);
+                                       gen.Emit (OpCodes.Stelem_R8);
+                                       break;
+                                       
+                               case TypeCode.UInt16:
+                               case TypeCode.Int16:
+                                       value.Generate (gen);
+                                       gen.Emit (OpCodes.Stelem_I2);
+                                       break;
+                                       
+                               case TypeCode.UInt32:
+                               case TypeCode.Int32:
+                                       value.Generate (gen);
+                                       gen.Emit (OpCodes.Stelem_I4);
+                                       break;
+                                       
+                               case TypeCode.UInt64:
+                               case TypeCode.Int64:
+                                       value.Generate (gen);
+                                       gen.Emit (OpCodes.Stelem_I8);
+                                       break;
+                                       
+                               case TypeCode.Single:
+                                       value.Generate (gen);
+                                       gen.Emit (OpCodes.Stelem_R4);
+                                       break;
+                                       
+                               default:
+                                       if (t.IsValueType) {
+                                               gen.Emit (OpCodes.Ldelema, t);
+                                               value.Generate (gen);
+                                               gen.Emit (OpCodes.Stobj, t);
+                                       }
+                                       else {
+                                               value.Generate (gen);
+                                               gen.Emit (OpCodes.Stelem_Ref);
+                                       }
+                                       break;
+                       }                               
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       array.PrintCode (cp);
+                       cp.Write ("[");
+                       index.PrintCode (cp);
+                       cp.Write ("]");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return array.GetResultType().GetElementType();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArrayLength.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeArrayLength.cs
new file mode 100644 (file)
index 0000000..9842c00
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeArrayLength: CodeExpression
+       {
+               CodeExpression array;
+               
+               public CodeArrayLength (CodeExpression array)
+               {
+                       if (!array.GetResultType().IsArray)
+                               throw new InvalidOperationException ("CodeArrayLength can only be applied to array expressions");
+                       this.array = array;
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       array.Generate (gen);
+                       gen.Emit (OpCodes.Ldlen);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       array.PrintCode (cp);
+                       cp.Write (".Length");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return typeof(int);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeAssignment.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeAssignment.cs
new file mode 100644 (file)
index 0000000..fc34a0a
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeAssignment: CodeExpression
+       {
+               new CodeValueReference var;
+               CodeExpression exp;
+               
+               public CodeAssignment (CodeValueReference var, CodeExpression exp)
+               {
+                       if (var == null)
+                               throw new ArgumentNullException ("var");
+                       if (exp == null)
+                               throw new ArgumentNullException ("exp");
+                       this.exp = exp;
+                       this.var = var;
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       var.GenerateSet (gen, exp);
+                       exp.Generate (gen);
+               }
+               
+               public override void GenerateAsStatement (ILGenerator gen)
+               {
+                       CodeExpression val = exp;
+                       if (var.GetResultType () == typeof(object) && exp.GetResultType ().IsValueType)
+                               var.GenerateSet (gen, new CodeCast (typeof(object), exp));
+                       else
+                               var.GenerateSet (gen, exp);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       var.PrintCode (cp);
+                       cp.Write (" = ");
+                       exp.PrintCode (cp);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return var.GetResultType ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBinaryComparison.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBinaryComparison.cs
new file mode 100644 (file)
index 0000000..d8cb665
--- /dev/null
@@ -0,0 +1,168 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public abstract class CodeBinaryComparison: CodeConditionExpression
+       {
+               protected CodeExpression exp1;
+               protected CodeExpression exp2;
+               protected Type t1;
+               protected Type t2;
+               string symbol;
+               
+               public CodeBinaryComparison (CodeExpression exp1, CodeExpression exp2, string symbol)
+               {
+                       this.symbol = symbol;
+                       this.exp1 = exp1;
+                       this.exp2 = exp2;
+                       
+                       t1 = exp1.GetResultType ();
+                       t2 = exp2.GetResultType ();
+                       
+                       if (!t1.IsPrimitive || !t2.IsPrimitive || (t1 != t2)) {
+                               throw new InvalidOperationException ("Operator " + GetType().Name + " cannot be applied to operands of type '" + t1.Name + " and " + t2.Name);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       exp1.PrintCode (cp);
+                       cp.Write (" " + symbol + " ");
+                       exp2.PrintCode (cp);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return typeof(bool);
+               }
+       }
+       
+       public class CodeGreaterThan: CodeBinaryComparison
+       {
+               public CodeGreaterThan (CodeExpression exp1, CodeExpression exp2)
+               : base (exp1, exp2, ">")
+               {
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp1.Generate (gen);
+                       exp2.Generate (gen);
+                       gen.Emit (OpCodes.Cgt);
+               }
+               
+               public override void GenerateForBranch (ILGenerator gen, Label label, bool branchCase)
+               {
+                       exp1.Generate (gen);
+                       exp2.Generate (gen);
+                       if (branchCase)
+                               gen.Emit (OpCodes.Bgt, label);
+                       else
+                               gen.Emit (OpCodes.Ble, label);
+               }
+       }
+       
+       public class CodeGreaterEqualThan: CodeBinaryComparison
+       {
+               public CodeGreaterEqualThan (CodeExpression exp1, CodeExpression exp2)
+               : base (exp1, exp2, ">=")
+               {
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp1.Generate (gen);
+                       exp2.Generate (gen);
+                       gen.Emit (OpCodes.Clt);
+                       gen.Emit (OpCodes.Ldc_I4_0);
+                       gen.Emit (OpCodes.Ceq);
+               }
+               
+               public override void GenerateForBranch (ILGenerator gen, Label label, bool branchCase)
+               {
+                       exp1.Generate (gen);
+                       exp2.Generate (gen);
+                       if (branchCase)
+                               gen.Emit (OpCodes.Bge, label);
+                       else
+                               gen.Emit (OpCodes.Blt, label);
+               }
+       }
+       
+       public class CodeLessThan: CodeBinaryComparison
+       {
+               public CodeLessThan (CodeExpression exp1, CodeExpression exp2)
+               : base (exp1, exp2, "<")
+               {
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp1.Generate (gen);
+                       exp2.Generate (gen);
+                       gen.Emit (OpCodes.Clt);
+               }
+               
+               public override void GenerateForBranch (ILGenerator gen, Label label, bool branchCase)
+               {
+                       exp1.Generate (gen);
+                       exp2.Generate (gen);
+                       if (branchCase)
+                               gen.Emit (OpCodes.Blt, label);
+                       else
+                               gen.Emit (OpCodes.Bge, label);
+               }
+       }
+       
+       public class CodeLessEqualThan: CodeBinaryComparison
+       {
+               public CodeLessEqualThan (CodeExpression exp1, CodeExpression exp2)
+               : base (exp1, exp2, "<=")
+               {
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp1.Generate (gen);
+                       exp2.Generate (gen);
+                       gen.Emit (OpCodes.Cgt);
+                       gen.Emit (OpCodes.Ldc_I4_0);
+                       gen.Emit (OpCodes.Ceq);
+               }
+               
+               public override void GenerateForBranch (ILGenerator gen, Label label, bool branchCase)
+               {
+                       exp1.Generate (gen);
+                       exp2.Generate (gen);
+                       if (branchCase)
+                               gen.Emit (OpCodes.Ble, label);
+                       else
+                               gen.Emit (OpCodes.Bgt, label);
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBinaryOperation.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBinaryOperation.cs
new file mode 100644 (file)
index 0000000..50d034b
--- /dev/null
@@ -0,0 +1,38 @@
+// created on 28/08/2004 at 17:30
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public abstract class CodeBinaryOperation: CodeConditionExpression
+       {
+               protected CodeExpression exp1;
+               protected CodeExpression exp2;
+               protected Type t1;
+               protected Type t2;
+               string symbol;
+               
+               public CodeBinaryOperation (CodeExpression exp1, CodeExpression exp2, string symbol)
+               {
+                       this.symbol = symbol;
+                       this.exp1 = exp1;
+                       this.exp2 = exp2;
+                       
+                       t1 = exp1.GetResultType ();
+                       t2 = exp2.GetResultType ();
+                       
+                       if (!t1.IsPrimitive || !t2.IsPrimitive || (t1 != t2)) {
+                               throw new InvalidOperationException ("Operator " + GetType().Name + " cannot be applied to operands of type '" + t1.Name + " and " + t2.Name);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       exp1.PrintCode (cp);
+                       cp.Write (" " + symbol + " ");
+                       exp2.PrintCode (cp);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBlock.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBlock.cs
new file mode 100644 (file)
index 0000000..92da989
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeBlock: CodeItem
+       {
+               ArrayList statements = new ArrayList ();
+               
+               public void Add (CodeItem code)
+               {
+                       statements.Add (code);
+               }
+               
+               public bool IsEmpty
+               {
+                       get { return statements.Count == 0; }
+               }
+               
+               public static CodeBlock operator+(CodeBlock cb, CodeExpression e)
+               {
+                       cb.Add (e);
+                       return cb;
+               }
+               
+               public CodeItem GetLastItem ()
+               {
+                       return (CodeItem) statements [statements.Count - 1];
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       foreach (CodeItem item in statements) {
+                               if (item is CodeExpression)
+                                       ((CodeExpression)item).GenerateAsStatement (gen);
+                               else
+                                       item.Generate (gen);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       foreach (CodeItem item in statements) {
+                               cp.BeginLine ();
+                               item.PrintCode (cp);
+                               cp.Write (";");
+                               cp.EndLine ();
+                       }
+               }
+       }
+       
+       internal class CodePop: CodeStatement
+       {
+               public override void Generate (ILGenerator gen)
+               {
+                       gen.Emit (OpCodes.Pop);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBuilder.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeBuilder.cs
new file mode 100644 (file)
index 0000000..db01ee1
--- /dev/null
@@ -0,0 +1,423 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Reflection.Emit;
+using System.Reflection;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeBuilder
+       {
+               CodeBlock mainBlock;
+               CodeBlock currentBlock;
+               Stack blockStack = new Stack ();
+               int varId;
+               Label returnLabel;
+               ArrayList nestedIfs = new ArrayList();
+               int currentIfSerie = -1;
+               CodeClass codeClass;
+
+               public CodeBuilder (CodeClass codeClass)
+               {
+                       this.codeClass = codeClass;
+                       mainBlock = new CodeBlock ();
+                       currentBlock = mainBlock;
+               }
+               
+               CodeBuilder (CodeBlock block)
+               {
+                       currentBlock = block;
+               }
+               
+               public CodeBlock CurrentBlock
+               {
+                       get {
+                               return currentBlock;
+                       }
+               }
+               
+               public CodeClass OwnerClass
+               {
+                       get { return codeClass; }
+               }
+               
+               public void Generate (ILGenerator gen)
+               {
+//                     try {
+                               mainBlock.Generate (gen);
+/*
+                       }
+                       catch (Exception ex) {
+                               string m = ex.Message + "\nCode block:\n";
+                               m += "-----------------------\n";
+                               m += PrintCode ();
+                               m += "-----------------------\n";
+                               throw new Exception (m, ex);
+                       }
+*/
+               }
+               
+               public string PrintCode ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       CodeWriter cw = new CodeWriter (sw);
+                       PrintCode (cw);
+                       return sw.ToString ();
+               }
+               
+               public void PrintCode (CodeWriter cp)
+               {
+                       mainBlock.PrintCode (cp);
+               }
+               
+               public CodeVariableReference DeclareVariable (Type type)
+               {
+                       return DeclareVariable (type, null);
+               }
+               
+               public CodeVariableReference DeclareVariable (Type type, object ob)
+               {
+                       return DeclareVariable (type, Exp.Literal(ob));
+               }
+               
+               public CodeVariableReference DeclareVariable (CodeExpression initValue)
+               {
+                       return DeclareVariable (initValue.GetResultType(), initValue);
+               }
+               
+               public CodeVariableReference DeclareVariable (Type type, CodeExpression initValue)
+               {
+                       string name = "v" + (varId++);
+                       CodeVariableDeclaration var = new CodeVariableDeclaration (type, name);
+                       currentBlock.Add (var);
+                       if (!object.ReferenceEquals (initValue, null)) 
+                               Assign (var.Variable, initValue);
+                       return var.Variable;
+               }
+               
+               public void Assign (CodeValueReference var, CodeExpression val)
+               {
+                       currentBlock.Add (new CodeAssignment (var, val)); 
+               }
+               
+               public void If (CodeExpression condition)
+               {
+                       currentBlock.Add (new CodeIf (condition));
+                       PushNewBlock ();
+                       nestedIfs.Add (0);
+               }
+               
+               public void ElseIf (CodeExpression condition)
+               {
+                       if (nestedIfs.Count == 0)
+                               throw new InvalidOperationException ("'Else' not allowed here");
+
+                       Else ();
+                       currentBlock.Add (new CodeIf (condition));
+                       PushNewBlock ();
+                       nestedIfs [nestedIfs.Count-1] = 1 + (int)nestedIfs [nestedIfs.Count-1];
+               }
+               
+               public void Else ()
+               {
+                       CodeBlock block = PopBlock ();
+                       CodeIf cif = currentBlock.GetLastItem () as CodeIf;
+                       
+                       if (cif == null || cif.TrueBlock != null)
+                               throw new InvalidOperationException ("'Else' not allowed here");
+                               
+                       cif.TrueBlock = block;
+                       PushNewBlock ();
+               }
+               
+               public void EndIf ()
+               {
+                       CodeBlock block = PopBlock ();
+                       CodeIf cif = currentBlock.GetLastItem () as CodeIf;
+                       
+                       if (cif == null || cif.FalseBlock != null || nestedIfs.Count == 0)
+                               throw new InvalidOperationException ("'EndIf' not allowed here");
+                       
+                       if (cif.TrueBlock == null)
+                               cif.TrueBlock = block;
+                       else
+                               cif.FalseBlock = block;
+                               
+                       int num = (int) nestedIfs [nestedIfs.Count-1];
+                       if (num > 0) {
+                               nestedIfs [nestedIfs.Count-1] = --num;
+                               EndIf ();
+                       }
+                       else {
+                               nestedIfs.RemoveAt (nestedIfs.Count - 1);
+                       }
+               }
+               
+               public void Select ()
+               {
+                       currentBlock.Add (new CodeSelect ());
+                       PushNewBlock ();
+               }
+               
+               public void Case (CodeExpression condition)
+               {
+                       PopBlock ();
+                       CodeSelect select = currentBlock.GetLastItem () as CodeSelect;
+                       if (select == null)
+                               throw new InvalidOperationException ("'Case' not allowed here");
+
+                       PushNewBlock ();
+                       select.AddCase (condition, currentBlock);
+               }
+               
+               public void EndSelect ()
+               {
+                       PopBlock ();
+                       CodeSelect select = currentBlock.GetLastItem () as CodeSelect;
+                       if (select == null)
+                               throw new InvalidOperationException ("'EndSelect' not allowed here");
+               }
+               
+               
+               public void While (CodeExpression condition)
+               {
+                       currentBlock.Add (new CodeWhile (condition));
+                       PushNewBlock ();
+               }
+               
+               public void EndWhile ()
+               {
+                       CodeBlock block = PopBlock ();
+                       CodeWhile cif = currentBlock.GetLastItem () as CodeWhile;
+                       
+                       if (cif == null || cif.WhileBlock != null)
+                               throw new InvalidOperationException ("'EndWhile' not allowed here");
+                       
+                       cif.WhileBlock = block;
+               }
+               
+               public void Foreach (Type type, out CodeExpression item, CodeExpression array)
+               {
+                       CodeForeach cfe = new CodeForeach (array, type);
+                       item = cfe.ItemExpression;
+                       currentBlock.Add (cfe);
+                       PushNewBlock ();
+               }
+               
+               public void EndForeach ()
+               {
+                       CodeBlock block = PopBlock ();
+                       CodeForeach cif = currentBlock.GetLastItem () as CodeForeach;
+                       
+                       if (cif == null || cif.ForBlock != null)
+                               throw new InvalidOperationException ("'EndForeach' not allowed here");
+                       
+                       cif.ForBlock = block;
+               }
+               
+               public void For (CodeExpression initExp, CodeExpression conditionExp, CodeExpression nextExp)
+               {
+                       currentBlock.Add (new CodeFor (initExp, conditionExp, nextExp));
+                       PushNewBlock ();
+               }
+               
+               public void EndFor ()
+               {
+                       CodeBlock block = PopBlock ();
+                       CodeFor cif = currentBlock.GetLastItem () as CodeFor;
+                       
+                       if (cif == null || cif.ForBlock != null)
+                               throw new InvalidOperationException ("'EndFor' not allowed here");
+                       
+                       cif.ForBlock = block;
+               }
+               
+               
+               public void Call (CodeExpression target, string name, params CodeExpression[] parameters)
+               {
+                       if ((object) target == null)
+                               throw new ArgumentNullException ("target");
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+                       currentBlock.Add (new CodeMethodCall (target, name, parameters));
+               }
+               
+               public void Call (CodeExpression target, MethodBase method, params CodeExpression[] parameters)
+               {
+                       if ((object) target == null)
+                               throw new ArgumentNullException ("target");
+                       if (method == null)
+                               throw new ArgumentNullException ("method");
+                       currentBlock.Add (new CodeMethodCall (target, method, parameters));
+               }
+               
+               public void Call (CodeExpression target, CodeMethod method, params CodeExpression[] parameters)
+               {
+                       if ((object) target == null)
+                               throw new ArgumentNullException ("target");
+                       if (method == null)
+                               throw new ArgumentNullException ("method");
+                       currentBlock.Add (new CodeMethodCall (target, method, parameters));
+               }
+               
+               public void Call (Type type, string name, params CodeExpression[] parameters)
+               {
+                       if (type == null)
+                               throw new ArgumentNullException ("type");
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+                       currentBlock.Add (new CodeMethodCall (type, name, parameters));
+               }
+               
+               public void Call (MethodInfo method, params CodeExpression[] parameters)
+               {
+                       if (method == null)
+                               throw new ArgumentNullException ("method");
+                       currentBlock.Add (new CodeMethodCall (method, parameters));
+               }
+               
+               public void Call (CodeMethod method, params CodeExpression[] parameters)
+               {
+                       if ((object) method == null)
+                               throw new ArgumentNullException ("method");
+                       currentBlock.Add (new CodeMethodCall (method, parameters));
+               }
+               
+               public CodeExpression CallFunc (CodeExpression target, string name, params CodeExpression[] parameters)
+               {
+                       if ((object) target == null)
+                               throw new ArgumentNullException ("target");
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+                       return new CodeMethodCall (target, name, parameters);
+               }
+               
+               public CodeExpression CallFunc (CodeExpression target, MethodInfo method, params CodeExpression[] parameters)
+               {
+                       if ((object) target == null)
+                               throw new ArgumentNullException ("target");
+                       if (method == null)
+                               throw new ArgumentNullException ("method");
+                       return new CodeMethodCall (target, method, parameters);
+               }
+               
+               public CodeExpression CallFunc (CodeExpression target, CodeMethod method, params CodeExpression[] parameters)
+               {
+                       if ((object) target == null)
+                               throw new ArgumentNullException ("target");
+                       if (method == null)
+                               throw new ArgumentNullException ("method");
+                       return new CodeMethodCall (target, method, parameters);
+               }
+               
+               public CodeExpression CallFunc (Type type, string name, params CodeExpression[] parameters)
+               {
+                       if (type == null)
+                               throw new ArgumentNullException ("type");
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+                       return new CodeMethodCall (type, name, parameters);
+               }
+               
+               public CodeExpression CallFunc (MethodInfo method, params CodeExpression[] parameters)
+               {
+                       if (method == null)
+                               throw new ArgumentNullException ("method");
+                       return new CodeMethodCall (method, parameters);
+               }
+               
+               public CodeExpression CallFunc (CodeMethod method, params CodeExpression[] parameters)
+               {
+                       if ((object) method == null)
+                               throw new ArgumentNullException ("method");
+                       return new CodeMethodCall (method, parameters);
+               }
+               
+               public void Inc (CodeValueReference val)
+               {
+                       Assign (val, new CodeIncrement (val));
+               }
+               
+               public void Dec (CodeValueReference val)
+               {
+                       Assign (val, new CodeDecrement (val));
+               }
+               
+               public CodeExpression When (CodeExpression condition, CodeExpression trueResult, CodeExpression falseResult)
+               {
+                       return new CodeWhen (condition, trueResult, falseResult);
+               }
+               
+               public void ConsoleWriteLine (params CodeExpression[] parameters)
+               {
+                       Call (typeof(Console), "WriteLine", parameters);
+               }
+               
+               public void ConsoleWriteLine (params object[] parameters)
+               {
+                       CodeExpression[] exps = new CodeExpression [parameters.Length];
+                       for (int n=0; n<exps.Length; n++)
+                               exps[n] = Exp.Literal (parameters[n]);
+                               
+                       ConsoleWriteLine (exps);
+               }
+               
+               public void Return (CodeExpression exp)
+               {
+                       currentBlock.Add (new CodeReturn (this, exp));
+               }
+               
+               public void Return ()
+               {
+                       currentBlock.Add (new CodeReturn (this));
+               }
+               
+               public static CodeBuilder operator+(CodeBuilder cb, CodeItem e)
+               {
+                       cb.currentBlock.Add (e);
+                       return cb;
+               }
+               
+               internal Label ReturnLabel
+               {
+                       get { return returnLabel; }
+                       set { returnLabel = value; }
+               }
+               
+               void PushNewBlock ()
+               {
+                       blockStack.Push (currentBlock);
+                       currentBlock = new CodeBlock ();
+               }
+               
+               CodeBlock PopBlock ()
+               {
+                       CodeBlock block = currentBlock;
+                       currentBlock = (CodeBlock) blockStack.Pop ();
+                       return block;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeCast.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeCast.cs
new file mode 100644 (file)
index 0000000..a907264
--- /dev/null
@@ -0,0 +1,131 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using Mono.CodeGeneration;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeCast: CodeExpression
+       {
+               Type type; 
+               CodeExpression exp;
+               
+               public CodeCast (Type type, CodeExpression exp)
+               {
+                       this.type = type;               
+                       this.exp = exp;
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp.Generate (gen);
+                       
+                       Type typeObj = exp.GetResultType ();
+
+                       if (type.IsAssignableFrom (typeObj)) {
+                               if (typeObj.IsValueType)
+                                       gen.Emit (OpCodes.Box, typeObj);
+                               return;
+                       }
+                       else if (type.IsValueType && typeObj == typeof(object)) {
+                               // Unbox
+                               gen.Emit (OpCodes.Unbox, type);
+                               CodeGenerationHelper.LoadFromPtr (gen, type);
+                               return;
+                       }
+                       else if (typeObj.IsAssignableFrom (type)) {
+                               // Sub s = (Sub)base
+                               gen.Emit (OpCodes.Castclass, type);
+                               return;
+                       }
+                       else if (CodeGenerationHelper.IsNumber (type) && CodeGenerationHelper.IsNumber (typeObj)) {
+                               switch (Type.GetTypeCode (type))
+                               {
+                                       case TypeCode.Byte:
+                                               gen.Emit (OpCodes.Conv_U1);
+                                               return;
+                                       case TypeCode.Double:
+                                               gen.Emit (OpCodes.Conv_R8);
+                                               return;
+                                       case TypeCode.Int16:
+                                               gen.Emit (OpCodes.Conv_I2);
+                                               return;
+                                       case TypeCode.Int32:
+                                               gen.Emit (OpCodes.Conv_I4);
+                                               return;
+                                       case TypeCode.Int64:
+                                               gen.Emit (OpCodes.Conv_I8);
+                                               return;
+                                       case TypeCode.SByte:
+                                               gen.Emit (OpCodes.Conv_I1);
+                                               return;
+                                       case TypeCode.Single:
+                                               gen.Emit (OpCodes.Conv_R4);
+                                               return;
+                                       case TypeCode.UInt16:
+                                               gen.Emit (OpCodes.Conv_U2);
+                                               return;
+                                       case TypeCode.UInt32:
+                                               gen.Emit (OpCodes.Conv_U4);
+                                               return;
+                                       case TypeCode.UInt64:
+                                               gen.Emit (OpCodes.Conv_U8);
+                                               return;
+                               }
+                       }
+                       
+                       MethodInfo imp = type.GetMethod ("op_Implicit", new Type[] { typeObj });
+                       if (imp != null) {
+                               gen.Emit (OpCodes.Call, imp);
+                               return;
+                       }
+                       
+                       foreach (MethodInfo m in typeObj.GetMember ("op_Explicit"))
+                               if (m.ReturnType == type) {
+                                       gen.Emit (OpCodes.Call, m);
+                                       return;
+                               }
+
+                       throw new InvalidOperationException ("Can't cast from " + typeObj + " to " + type);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       Type typeObj = exp.GetResultType ();
+                       if (type.IsAssignableFrom (typeObj)) 
+                               return;
+                       
+                       cp.Write ("((" + type.FullName + ")");
+                       exp.PrintCode (cp);
+                       cp.Write (")");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return type;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeClass.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeClass.cs
new file mode 100644 (file)
index 0000000..211d882
--- /dev/null
@@ -0,0 +1,348 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeClass
+       {
+               TypeBuilder typeBuilder;
+               ArrayList customAttributes = new ArrayList ();
+               ArrayList methods = new ArrayList ();
+               ArrayList properties = new ArrayList ();
+               ArrayList fields = new ArrayList ();
+               Hashtable fieldAttributes = new Hashtable ();
+               Type baseType;
+               Type[] interfaces;
+               CodeMethod ctor;
+               CodeMethod cctor;
+               CodeBuilder instanceInit;
+               CodeBuilder classInit;
+               int varId;
+               
+               public CodeClass (ModuleBuilder mb, string name)
+               : this (mb, name, TypeAttributes.Public, typeof(object))
+               {
+               }
+               
+               public CodeClass (ModuleBuilder mb, string name, Type baseType, params Type[] interfaces)
+               : this (mb, name, TypeAttributes.Public, baseType, interfaces)
+               {
+               }
+               
+               public CodeClass (ModuleBuilder mb, string name, TypeAttributes attr, Type baseType, params Type[] interfaces)
+               {
+                       typeBuilder = mb.DefineType (name, attr, baseType, interfaces);
+                       this.baseType = baseType;
+                       this.interfaces = interfaces;
+               }
+
+               public CodeCustomAttribute CreateCustomAttribute (Type attributeType)
+               {
+                       return CreateCustomAttribute (attributeType,
+                               Type.EmptyTypes, new object [0], new string [0], new object [0]);
+               }
+
+               public CodeCustomAttribute CreateCustomAttribute (Type attributeType, Type [] ctorArgTypes, object [] ctorArgs, string [] namedArgFieldNames, object [] namedArgValues)
+               {
+                       CodeCustomAttribute cca = CodeCustomAttribute.Create (
+                               attributeType, ctorArgTypes, ctorArgs, namedArgFieldNames, namedArgValues);
+
+                       typeBuilder.SetCustomAttribute (cca.Builder);
+                       customAttributes.Add (cca);
+                       return cca;
+               }
+
+               public CodeCustomAttribute CreateCustomAttribute (Type attributeType, Type [] ctorArgTypes, CodeLiteral [] ctorArgs, FieldInfo [] fields, CodeLiteral [] fieldValues)
+               {
+                       CodeCustomAttribute cca = CodeCustomAttribute.Create (
+                               attributeType, ctorArgTypes, ctorArgs, fields, fieldValues);
+
+                       typeBuilder.SetCustomAttribute (cca.Builder);
+                       customAttributes.Add (cca);
+                       return cca;
+               }
+
+               public CodeProperty CreateProperty (string name, Type returnType, params Type [] parameterTypes)
+               {
+                       return CreateProperty (name, returnType, MethodAttributes.Private, parameterTypes);
+               }
+
+               public CodeProperty CreateProperty (string name, Type returnType, MethodAttributes methodAttributes, params Type [] parameterTypes)
+               {
+                       CodeProperty prop = new CodeProperty (this, GetPropertyName (name), PropertyAttributes.None, methodAttributes, returnType, parameterTypes);
+                       properties.Add (prop);
+                       return prop;
+               }
+
+               public CodeMethod CreateMethod (string name, Type returnType, params Type[] parameterTypes)
+               {
+                       CodeMethod met = new CodeMethod (this, GetMethodName (name), MethodAttributes.Public, returnType, parameterTypes);
+                       methods.Add (met);
+                       return met;
+               }
+               
+               public CodeMethod CreateVirtualMethod (string name, Type returnType, params Type[] parameterTypes)
+               {
+                       CodeMethod met = new CodeMethod (this, GetMethodName (name), MethodAttributes.Public | MethodAttributes.Virtual, returnType, parameterTypes);
+                       methods.Add (met);
+                       return met;
+               }
+               
+               public CodeMethod CreateStaticMethod (string name, Type returnType, params Type[] parameterTypes)
+               {
+                       CodeMethod met = new CodeMethod (this, GetMethodName (name), MethodAttributes.Public | MethodAttributes.Static, returnType, parameterTypes);
+                       methods.Add (met);
+                       return met;
+               }
+               
+               public CodeMethod CreateMethod (string name, MethodAttributes attributes, Type returnType, params Type[] parameterTypes)
+               {
+                       CodeMethod met = new CodeMethod (this, GetMethodName (name), attributes, returnType, parameterTypes);
+                       methods.Add (met);
+                       return met;
+               }
+               
+               public CodeMethod GetDefaultConstructor ()
+               {
+                       if (ctor != null) return ctor;
+                       ctor = CreateConstructor (MethodAttributes.Public, Type.EmptyTypes);
+                       return ctor;
+               }
+               
+               public CodeMethod CreateConstructor (params Type[] parameters)
+               {
+                       return CreateConstructor (MethodAttributes.Private, parameters);
+               }
+
+               public CodeMethod CreateConstructor (MethodAttributes attributes, params Type[] parameters)
+               {
+                       if (ctor != null) return ctor;
+                       ctor = CodeMethod.DefineConstructor (this, attributes, parameters);
+                       methods.Add (ctor);
+                       CodeBuilder cb = GetInstanceInitBuilder ();
+                       ctor.CodeBuilder.CurrentBlock.Add (cb.CurrentBlock);
+                       return ctor;
+               }
+               
+               public CodeMethod GetStaticConstructor ()
+               {
+                       if (cctor != null) return cctor;
+                       cctor = CodeMethod.DefineConstructor (this, MethodAttributes.Public | MethodAttributes.Static, Type.EmptyTypes);
+                       methods.Add (cctor);
+                       CodeBuilder cb = GetClassInitBuilder ();
+                       cctor.CodeBuilder.CurrentBlock.Add (cb.CurrentBlock);
+                       return cctor;
+               }
+               
+               public CodeMethod ImplementMethod (Type baseType, string methodName)
+               {
+                       MethodInfo basem = baseType.GetMethod (methodName);
+                       return ImplementMethod (baseType, basem);
+               }
+               
+               public CodeMethod ImplementMethod (MethodInfo basem)
+               {
+                       return ImplementMethod (basem.DeclaringType, basem);
+               }
+               
+               public CodeMethod ImplementMethod (Type baseType, MethodInfo basem)
+               {
+                       ParameterInfo[] pinfos = basem.GetParameters ();
+                       Type[] pars = new Type[pinfos.Length];
+                       for (int n=0; n<pinfos.Length; n++)
+                               pars[n] = pinfos[n].ParameterType;
+
+                       CodeMethod met = CodeMethod.DefineMethod (this, basem.Name, MethodAttributes.Public | MethodAttributes.Virtual, basem.ReturnType, pars);
+                       typeBuilder.DefineMethodOverride (met.MethodInfo, basem);
+                       methods.Add (met);
+                       return met;
+               }
+               
+               public CodeFieldReference DefineField (string name, Type type, params CodeCustomAttribute [] customAttributes)
+               {
+                       return DefineField (GetFieldName (name), type, FieldAttributes.Public, null, customAttributes);
+               }
+               
+               public CodeFieldReference DefineStaticField (CodeExpression initialValue, params CodeCustomAttribute [] customAttributes)
+               {
+                       return DefineField (GetFieldName (null), initialValue.GetResultType(), FieldAttributes.Public | FieldAttributes.Static, initialValue, customAttributes);
+               }
+               
+               public CodeFieldReference DefineStaticField (string name, Type type, CodeExpression initialValue, params CodeCustomAttribute [] customAttributes)
+               {
+                       return DefineField (GetFieldName (name), type, FieldAttributes.Public | FieldAttributes.Static, initialValue, customAttributes);
+               }
+               
+               public CodeFieldReference DefineField (string name, Type type, FieldAttributes attrs, CodeExpression initialValue, params CodeCustomAttribute [] customAttributes)
+               {
+                       FieldBuilder fb = typeBuilder.DefineField (GetFieldName (name), type, attrs);
+                       foreach (CodeCustomAttribute a in customAttributes)
+                               fb.SetCustomAttribute (a.Builder);
+                       fieldAttributes [fb] = new ArrayList (customAttributes);
+                       fields.Add (fb);
+                       CodeFieldReference fr;
+                       if ((attrs & FieldAttributes.Static) != 0)
+                               fr = new CodeFieldReference (fb);
+                       else
+                               fr = new CodeFieldReference (new CodeArgumentReference (TypeBuilder, 0, "this"), fb);
+                       
+                       if (null != (object) initialValue) {
+                               CodeBuilder cb = (attrs & FieldAttributes.Static) == 0 ? GetInstanceInitBuilder () : GetClassInitBuilder (); 
+                               cb.Assign (fr, initialValue);
+                       }
+                       return fr;
+               }
+               
+               public TypeBuilder TypeBuilder
+               {
+                       get { return typeBuilder; }
+               } 
+               
+               private CodeBuilder GetInstanceInitBuilder ()
+               {
+                       if (instanceInit != null) return instanceInit;
+                       instanceInit = new CodeBuilder (this);
+                       return instanceInit;
+               }
+               
+               private CodeBuilder GetClassInitBuilder ()
+               {
+                       if (classInit != null) return classInit;
+                       classInit = new CodeBuilder (this);
+                       return classInit;
+               }
+               
+               private string GetFieldName (string name)
+               {
+                       if (name == null) return "__field_" + (varId++);
+                       else return name;
+               }
+               
+               private string GetMethodName (string name)
+               {
+                       if (name == null) return "__Method_" + (varId++);
+                       else return name;
+               }
+               
+               private string GetPropertyName (string name)
+               {
+                       if (name == null) return "__Property_" + (varId++);
+                       else return name;
+               }
+               
+               public string PrintCode ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       CodeWriter cw = new CodeWriter (sw);
+                       PrintCode (cw);
+                       return sw.ToString ();
+               }
+               
+               public void PrintCode (CodeWriter cw)
+               {
+                       for (int n=0; n<customAttributes.Count; n++) {
+                               CodeCustomAttribute cca = customAttributes [n] as CodeCustomAttribute;
+                               if (n > 0) cw.WriteLine ("");
+                               cca.PrintCode (cw);
+                       }
+
+/*                     if ((typeBuilder.Attributes & TypeAttributes.Abstract) != 0) cw.Write ("abstract ");
+                       if ((typeBuilder.Attributes & TypeAttributes.NestedAssembly) != 0) cw.Write ("internal ");
+                       if ((typeBuilder.Attributes & TypeAttributes.NestedPrivate) != 0) cw.Write ("private ");
+*/                     if ((typeBuilder.Attributes & TypeAttributes.Public) != 0) cw.Write ("public ");
+                       cw.Write ("class ").Write (typeBuilder.Name);
+                       
+                       bool dots = false;
+                       if (baseType != null && baseType != typeof(object)) {
+                               cw.Write (" : " + baseType);
+                               dots = true;
+                       }
+                       
+                       if (interfaces != null && interfaces.Length > 0) {
+                               if (!dots) cw.Write (" : ");
+                               else cw.Write (", ");
+                               for (int n=0; n<interfaces.Length; n++) {
+                                       if (n > 0) cw.Write (", ");
+                                       cw.Write (interfaces[n].ToString ());
+                               }
+                       }
+                       
+                       cw.EndLine ().WriteLineInd ("{");
+                       
+                       foreach (FieldInfo f in fields) {
+                               cw.BeginLine ();
+                               ArrayList atts = (ArrayList) fieldAttributes [f];
+                               foreach (CodeCustomAttribute a in atts)
+                                       a.PrintCode (cw);
+                               if ((f.Attributes & FieldAttributes.Static) != 0)
+                                       cw.Write ("static ");
+                               cw.Write (f.FieldType.Name + " ");
+                               cw.Write (f.Name + ";");
+                               cw.EndLine ();
+                               cw.WriteLine (""); 
+                       }
+                       
+                       for (int n=0; n<properties.Count; n++) {
+                               CodeProperty prop = properties [n] as CodeProperty;
+                               if (n > 0) cw.WriteLine ("");
+                               prop.PrintCode (cw);
+                       }
+
+                       for (int n=0; n<methods.Count; n++) {
+                               CodeMethod met = methods[n] as CodeMethod;
+                               if (n > 0) cw.WriteLine ("");
+                               met.PrintCode (cw);
+                       }
+                       cw.WriteLineUnind ("}");
+               }
+               
+               public Type CreateType ()
+               {
+                       if (ctor == null)
+                               ctor = GetDefaultConstructor ();
+                               
+                       foreach (CodeProperty prop in properties)
+                               prop.Generate ();
+
+                       foreach (CodeMethod met in methods)
+                               met.Generate ();
+                               
+                       Type t = typeBuilder.CreateType ();
+                       
+                       foreach (CodeMethod met in methods)
+                               met.UpdateMethodBase (t);
+                               
+                       foreach (CodeProperty prop in properties)
+                               prop.UpdatePropertyInfo (t);
+
+                       return t;
+               }
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeCustomAttribute.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeCustomAttribute.cs
new file mode 100644 (file)
index 0000000..83f4384
--- /dev/null
@@ -0,0 +1,147 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeCustomAttribute
+       {
+               public static CodeCustomAttribute Create (Type attributeType)
+               {
+                       return Create (attributeType, Type.EmptyTypes, new object [0], new string [0], new object [0]);
+               }
+
+               public static CodeCustomAttribute Create (Type attributeType, Type [] ctorArgTypes, object [] ctorArgs, string [] namedArgNames, object [] namedArgValues)
+               {
+                       MemberInfo [] members = new MemberInfo [namedArgNames.Length];
+                       for (int i = 0; i < namedArgNames.Length; i++) {
+                               members [i] = attributeType.GetField (namedArgNames [i]);
+                               if (members [i] == null)
+                                       members [i] = attributeType.GetProperty (namedArgNames [i]);
+                               if (members [i] == null)
+                                       throw new ArgumentException (String.Format ("Named argument {0} was not found in attribute type {1}", namedArgNames [i], attributeType));
+                       }
+
+                       CodeLiteral [] args = new CodeLiteral [ctorArgs.Length];
+                       for (int i = 0; i < args.Length; i++)
+                               args [i] = new CodeLiteral (ctorArgs [i]);
+
+                       CodeLiteral [] nargs = new CodeLiteral [namedArgValues.Length];
+                       for (int i = 0; i < nargs.Length; i++)
+                               nargs [i] = new CodeLiteral (namedArgValues [i]);
+
+                       return Create (attributeType, ctorArgTypes, args, members, nargs);
+               }
+
+               public static CodeCustomAttribute Create (Type attributeType, Type [] ctorArgTypes, CodeLiteral [] ctorArgs, MemberInfo [] members, CodeLiteral [] values)
+               {
+                       ArrayList props = new ArrayList ();
+                       ArrayList pvalues  = new ArrayList ();
+                       ArrayList fields = new ArrayList ();
+                       ArrayList fvalues = new ArrayList ();
+                       for (int i = 0; i < members.Length; i++) {
+                               if (members [i] == null)
+                                       throw new ArgumentException (String.Format ("MemberInfo at {0} was null for type {1}.", i, attributeType));
+                               if (members [i] is PropertyInfo) {
+                                       props.Add ((PropertyInfo) members [i]);
+                                       pvalues.Add (values [i].Value);
+                               } else {
+                                       fields.Add ((FieldInfo) members [i]);
+                                       fvalues.Add (values [i].Value);
+                               }
+                       }
+
+                       ConstructorInfo ci = attributeType.GetConstructor (ctorArgTypes);
+                       CustomAttributeBuilder cab = new CustomAttributeBuilder (
+                               ci, ctorArgs,
+                               (PropertyInfo []) props.ToArray (typeof (PropertyInfo)), pvalues.ToArray (),
+                               (FieldInfo []) fields.ToArray (typeof (FieldInfo)), fvalues.ToArray ());
+
+                       CodeCustomAttribute attr = new CodeCustomAttribute (
+                               cab, attributeType, ci, ctorArgs, members, values);
+
+                       return attr;
+               }
+
+               CustomAttributeBuilder customAttributeBuilder;
+               Type type;
+               ConstructorInfo constructor;
+               CodeLiteral [] ctorArgs;
+               MemberInfo [] members;
+               CodeLiteral [] namedArgValues;
+
+               public CodeCustomAttribute (
+                       CustomAttributeBuilder attributeBuilder,
+                       Type type,
+                       ConstructorInfo constructor,
+                       CodeLiteral [] ctorArgs,
+                       MemberInfo [] namedArgMembers,
+                       CodeLiteral [] namedArgValues)
+               {
+                       this.type = type;
+                       this.constructor = constructor;
+                       this.customAttributeBuilder = attributeBuilder;
+                       this.ctorArgs = ctorArgs;
+                       this.members = namedArgMembers;
+                       this.namedArgValues = namedArgValues;
+               }
+
+               public CustomAttributeBuilder Builder {
+                       get { return customAttributeBuilder; }
+               }
+
+               public string PrintCode ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       CodeWriter cw = new CodeWriter (sw);
+                       PrintCode (cw);
+                       return sw.ToString ();
+               }
+               
+               public void PrintCode (CodeWriter cw)
+               {
+                       cw.Write ("[").Write (type.Name).Write ("(");
+                       if (ctorArgs.Length > 0) {
+                               for (int i = 0; i < ctorArgs.Length - 1; i++) {
+                                       ctorArgs [i].PrintCode (cw);
+                                       cw.Write (", ");
+                               }
+                               ctorArgs [ctorArgs.Length - 1].PrintCode (cw);
+                       }
+                       if (members.Length > 0) {
+                               if (ctorArgs.Length > 0)
+                                       cw.Write (", ");
+                               for (int i = 0; i < members.Length; i++) {
+                                       cw.Write (members [i].Name).Write (" = ");
+                                       namedArgValues [i].PrintCode (cw);
+                                       if (i < members.Length - 1)
+                                               cw.Write (", ");
+                               }
+                       }
+                       cw.Write (" )]");
+                       cw.EndLine ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeDecrement.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeDecrement.cs
new file mode 100644 (file)
index 0000000..9345241
--- /dev/null
@@ -0,0 +1,148 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+namespace Mono.CodeGeneration
+{
+       public class CodeDecrement: CodeValueReference
+       {
+               CodeValueReference exp;
+               
+               public CodeDecrement (CodeValueReference exp)
+               {
+                       this.exp = exp;
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp.GenerateSet (gen, new CodeSubstractOne (exp));
+                       exp.Generate (gen);
+               }
+               
+               public override void GenerateSet (ILGenerator gen, CodeExpression value)
+               {
+                       exp.GenerateSet (gen, value);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       exp.PrintCode (cp);
+                       cp.Write ("--");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return exp.GetResultType();
+               }
+       }
+       
+       public class CodeSubstractOne: CodeExpression
+       {
+               CodeExpression exp;
+               MethodInfo decMet;
+               
+               public CodeSubstractOne (CodeExpression exp)
+               {
+                       this.exp = exp;
+                       if (!exp.IsNumber) {
+                               decMet = exp.GetResultType ().GetMethod ("op_Decrement");
+                               if (decMet == null)
+                                       throw new InvalidOperationException ("Operator '--' cannot be applied to operand of type '" + exp.GetResultType().FullName + "'");
+                       }
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       if (decMet != null) {
+                               CodeGenerationHelper.GenerateMethodCall (gen, null, decMet, exp);
+                               return;
+                       }
+                       
+                       exp.Generate (gen);
+                       Type t = exp.GetResultType ();
+                       switch (Type.GetTypeCode (t))
+                       {
+                               case TypeCode.Byte:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Sub);
+                                       gen.Emit (OpCodes.Conv_U1);
+                                       break;
+
+                               case TypeCode.Double:
+                                       gen.Emit (OpCodes.Ldc_R8, 1);
+                                       gen.Emit (OpCodes.Sub);
+                                       break;
+                                       
+                               case TypeCode.Int16:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Sub);
+                                       gen.Emit (OpCodes.Conv_I2);
+                                       break;
+                                       
+                               case TypeCode.UInt32:
+                               case TypeCode.Int32:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Sub);
+                                       break;
+                                       
+                               case TypeCode.UInt64:
+                               case TypeCode.Int64:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Conv_U8);
+                                       gen.Emit (OpCodes.Sub);
+                                       break;
+                                       
+                               case TypeCode.SByte:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Sub);
+                                       gen.Emit (OpCodes.Conv_I1);
+                                       break;
+                                       
+                               case TypeCode.Single:
+                                       gen.Emit (OpCodes.Ldc_R4, 1);
+                                       gen.Emit (OpCodes.Sub);
+                                       break;
+                                       
+                               case TypeCode.UInt16:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Sub);
+                                       gen.Emit (OpCodes.Conv_U2);
+                                       break;
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       exp.PrintCode (cp);
+                       cp.Write ("--");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return exp.GetResultType();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeEquals.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeEquals.cs
new file mode 100644 (file)
index 0000000..4b977c3
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeEquals: CodeConditionExpression
+       {
+               CodeExpression exp1;
+               CodeExpression exp2;
+               Type t1;
+               Type t2;
+               
+               public CodeEquals (CodeExpression exp1, CodeExpression exp2)
+               {
+                       this.exp1 = exp1;
+                       this.exp2 = exp2;
+                       
+                       t1 = exp1.GetResultType ();
+                       t2 = exp2.GetResultType ();
+                       
+                       if (t1.IsValueType && t2.IsValueType) {
+                               if (t1 != t2)
+                                       throw new InvalidOperationException ("Can't compare values of different primitive types");
+                       }
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       if (t1.IsPrimitive)
+                       {
+                               exp1.Generate (gen);
+                               exp2.Generate (gen);
+                               gen.Emit (OpCodes.Ceq);
+                       }
+                       else
+                       {
+                               exp1.Generate (gen);
+                               exp2.Generate (gen);
+//                             gen.Emit (OpCodes.Ceq);
+                               gen.EmitCall (OpCodes.Callvirt, t1.GetMethod ("Equals", new Type[] {t2}), null);
+                       }
+               }
+               
+               public override void GenerateForBranch (ILGenerator gen, Label label, bool branchCase)
+               {
+                       if (t1.IsPrimitive)
+                       {
+                               exp1.Generate (gen);
+                               exp2.Generate (gen);
+                               if (branchCase)
+                                       gen.Emit (OpCodes.Beq, label);
+                               else
+                                       gen.Emit (OpCodes.Bne_Un, label);
+                       }
+                       else {
+                               Generate (gen);
+                               if (branchCase)
+                                       gen.Emit (OpCodes.Brtrue, label);
+                               else
+                                       gen.Emit (OpCodes.Brfalse, label);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       exp1.PrintCode (cp);
+                       cp.Write (" == ");
+                       exp2.PrintCode (cp);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return typeof (bool);
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeExpression.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeExpression.cs
new file mode 100644 (file)
index 0000000..8691161
--- /dev/null
@@ -0,0 +1,198 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public abstract class CodeExpression: CodeItem
+       {
+               internal CodeVariableReference var;
+
+               public abstract Type GetResultType ();
+               
+               public virtual void GenerateAsStatement (ILGenerator gen)
+               {
+                       Generate (gen);
+                       gen.Emit (OpCodes.Pop);
+               }
+               
+               public CodeExpression CallToString ()
+               {
+                       return new CodeMethodCall (this, "ToString");
+               }
+               
+               public static CodeExpression AreEqual (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeEquals (e1, e2);
+               }
+               
+               public static CodeExpression AreNotEqual (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeNotEquals (e1, e2);
+               }
+               
+               public static CodeExpression IsGreaterThan (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeGreaterThan (e1, e2);
+               }
+               
+               public static CodeExpression IsSmallerThan (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeLessThan (e1, e2);
+               }
+               
+               public static CodeExpression IsGreaterEqualThan (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeGreaterEqualThan (e1, e2);
+               }
+               
+               public static CodeExpression IsSmallerEqualThan (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeLessEqualThan (e1, e2);
+               }
+               
+               public static CodeExpression Not (CodeExpression e)
+               {
+                       return new CodeNot (e);
+               }
+               
+               public static CodeExpression Add (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeAdd (e1, e2);
+               }
+               
+               public static CodeExpression Subtract (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeSub (e1, e2);
+               }
+               
+               public static CodeExpression Multiply (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeMul (e1, e2);
+               }
+               
+               public static CodeExpression Divide (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeDiv (e1, e2);
+               }
+               
+               public CodeExpression CastTo (Type type)
+               {
+                       return new CodeCast (type, this);
+               }
+               
+               public CodeExpression And (CodeExpression other)
+               {
+                       return new CodeAnd (this, other);
+               }
+               
+               public CodeExpression Is (Type type)
+               {
+                       return new CodeIs (type, this);
+               }
+               
+               public CodeExpression Call (string name, params CodeExpression[] parameters)
+               {
+                       return new CodeMethodCall (this, name, parameters);
+               }
+               
+               public CodeExpression Call (MethodInfo method, params CodeExpression[] parameters)
+               {
+                       return new CodeMethodCall (this, method, parameters);
+               }
+               
+               public CodeValueReference MemGet (string name)
+               {
+                       MemberInfo[] mems = GetResultType().GetMember (name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
+                       if (mems.Length == 0) throw new InvalidOperationException ("Field '" + name + "' not found in " + GetResultType()); 
+                       return MemGet (mems[0]);
+               }
+               
+               public CodeValueReference MemGet (MemberInfo member)
+               {
+                       if (member is FieldInfo) 
+                               return new CodeFieldReference (this, (FieldInfo)member);
+                       else if (member is PropertyInfo)
+                               return new CodePropertyReference (this, (PropertyInfo)member);
+                       else
+                               throw new InvalidOperationException (member.Name + " is not either a field or a property");
+               }
+               
+               public CodeValueReference this [CodeExpression index]
+               {
+                       get { return new CodeArrayItem (this, index); }
+               }
+               
+               public CodeValueReference this [string name]
+               {
+                       get { return MemGet (name); }
+               }
+               
+               public CodeValueReference this [FieldInfo field]
+               {
+                       get { return new CodeFieldReference (this, field); }
+               }
+               
+               public CodeValueReference this [PropertyInfo prop]
+               {
+                       get { return new CodePropertyReference (this, prop); }
+               }
+               
+               public CodeExpression ArrayLength
+               {
+                       get { return new CodeArrayLength (this); }
+               }
+               
+               public CodeExpression IsNull
+               {
+                       get { return new CodeEquals (this, new CodeLiteral (null, this.GetResultType())); }
+               }
+               
+               public static CodeExpression NullValue (Type type)
+               {
+                       return new CodeLiteral (null, type);
+               }
+               
+               public bool IsNumber
+               {
+                       get {
+                               return CodeGenerationHelper.IsNumber (GetResultType ());
+                       }
+               }
+       }
+       
+       public abstract class CodeConditionExpression: CodeExpression
+       {
+               public virtual void GenerateForBranch (ILGenerator gen, Label label, bool jumpCase)
+               {
+                       Generate (gen);
+                       if (jumpCase)
+                               gen.Emit (OpCodes.Brtrue, label);
+                       else
+                               gen.Emit (OpCodes.Brfalse, label);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeFieldReference.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeFieldReference.cs
new file mode 100644 (file)
index 0000000..6492d98
--- /dev/null
@@ -0,0 +1,92 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeFieldReference: CodeValueReference
+       {
+               CodeExpression target;
+               FieldInfo field;
+               
+               public CodeFieldReference (CodeExpression target, FieldInfo field)
+               {
+                       if (field.IsStatic)
+                               throw new InvalidOperationException ("Static member '" + field.Name + "' cannot be accessed with an instance reference.");
+                       this.target = target;
+                       this.field = field;             
+               }
+               
+               public CodeFieldReference (FieldInfo field)
+               {
+                       if (!field.IsStatic)
+                               throw new InvalidOperationException ("An object reference is required for the non-static field '" + field.Name + "'.");
+                               
+                       this.field = field;             
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       if (field.IsStatic) {
+                               gen.Emit (OpCodes.Ldsfld, field);
+                       }
+                       else {
+                               target.Generate (gen);
+                               gen.Emit (OpCodes.Ldfld, field);
+                       }
+               }
+               
+               public override void GenerateSet (ILGenerator gen, CodeExpression value)
+               {
+                       if (field.IsStatic) {
+                               value.Generate (gen);
+                               CodeGenerationHelper.GenerateSafeConversion (gen, field.FieldType, value.GetResultType ());
+                               gen.Emit (OpCodes.Stsfld, field);
+                       }
+                       else {
+                               target.Generate (gen);
+                               value.Generate (gen);
+                               CodeGenerationHelper.GenerateSafeConversion (gen, field.FieldType, value.GetResultType ());
+                               gen.Emit (OpCodes.Stfld, field);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       if (!field.IsStatic)
+                               target.PrintCode (cp);
+                       else
+                               cp.Write (field.DeclaringType.Name);
+                       cp.Write (".");
+                       cp.Write (field.Name);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return field.FieldType;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeFor.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeFor.cs
new file mode 100644 (file)
index 0000000..895bd32
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeFor: CodeStatement
+       {
+               CodeExpression initExp;
+               CodeExpression conditionExp;
+               CodeExpression nextExp;
+               CodeBlock forBlock;
+               
+               public CodeFor (CodeExpression initExp, CodeExpression conditionExp, CodeExpression nextExp)
+               {
+                       this.initExp = initExp; 
+                       this.conditionExp = conditionExp;
+                       this.nextExp = nextExp;
+                       
+                       if (conditionExp.GetResultType () != typeof(bool))
+                               throw new InvalidOperationException ("Condition expression is not boolean"); 
+               }
+               
+               public CodeBlock ForBlock
+               {
+                       get { return forBlock; }
+                       set { forBlock = value; }
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       CodeBlock block = new CodeBlock();
+                       CodeWhile cw;
+                       
+                       block.Add (initExp);
+                       block.Add (cw = new CodeWhile (conditionExp));
+                       CodeBlock loopBlock = new CodeBlock ();
+                       loopBlock.Add (forBlock);
+                       loopBlock.Add (nextExp);
+                       cw.WhileBlock = loopBlock;
+                       
+                       block.Generate (gen);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write ("for (");
+                       initExp.PrintCode (cp);
+                       cp.Write (";");
+                       conditionExp.PrintCode (cp);
+                       cp.Write (";");
+                       nextExp.PrintCode (cp);
+                       cp.Write (") {");
+                       cp.EndLine ();
+                       cp.Indent ();
+                       forBlock.PrintCode (cp);
+                       cp.Unindent ();
+                       cp.BeginLine ().Write ("}");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeForeach.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeForeach.cs
new file mode 100644 (file)
index 0000000..0241614
--- /dev/null
@@ -0,0 +1,124 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeForeach: CodeStatement
+       {
+               Type itemType;
+               CodeExpression array;
+               CodeBlock forBlock;
+               
+               CodeVariableDeclaration itemDec;
+               
+               public CodeForeach (CodeExpression array, Type itemType)
+               {
+                       this.array = array;
+                       this.itemType = itemType;
+                       
+                       Type t = array.GetResultType ();
+                       if (!t.IsArray && t.GetMethod ("GetEnumerator", Type.EmptyTypes) == null)
+                               throw new InvalidOperationException ("foreach statement cannot operate on variables of type `" + t + "' because that class does not provide a GetEnumerator method or it is inaccessible");
+                       
+                       itemDec = new CodeVariableDeclaration (itemType, "item");
+               }
+               
+               public CodeValueReference ItemExpression
+               {
+                       get { return itemDec.Variable; }
+               }
+               
+               public CodeBlock ForBlock
+               {
+                       get { return forBlock; }
+                       set { forBlock = value; }
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       Type t = array.GetResultType ();
+                       if (t.IsArray)
+                       {
+                               CodeBlock block = new CodeBlock();
+                               CodeVariableDeclaration indexDec;
+                               CodeWhile cw;
+                               CodeValueReference index;
+                               CodeValueReference item;
+                               
+                               block.Add (itemDec);
+                               item = itemDec.Variable;
+                               block.Add (indexDec = new CodeVariableDeclaration (typeof(int), "n"));
+                               index = indexDec.Variable;
+                               block.Add (new CodeAssignment (index, new CodeLiteral (0)));
+                               
+                               block.Add (cw = new CodeWhile (CodeExpression.IsSmallerThan (index, array.ArrayLength)));
+                               CodeBlock loopBlock = new CodeBlock ();
+                               loopBlock.Add (new CodeAssignment (item, array[index]));
+                               loopBlock.Add (new CodeIncrement(index));
+                               loopBlock.Add (forBlock);
+                               cw.WhileBlock = loopBlock;
+                               
+                               block.Generate (gen);
+                       }
+                       else
+                       {
+                               CodeBlock block = new CodeBlock();
+                               CodeVariableDeclaration dec;
+                               CodeWhile cw;
+                               CodeValueReference enumerator;
+                               CodeValueReference item;
+                               
+                               block.Add (itemDec);
+                               item = itemDec.Variable;
+                               block.Add (dec = new CodeVariableDeclaration (typeof(IEnumerator), "e"));
+                               enumerator = dec.Variable;
+                               block.Add (new CodeAssignment (enumerator, array.Call("GetEnumerator")));
+                               
+                               block.Add (cw = new CodeWhile (enumerator.Call ("MoveNext")));
+                               CodeBlock loopBlock = new CodeBlock ();
+                               loopBlock.Add (new CodeAssignment (item, enumerator["Current"]));
+                               loopBlock.Add (forBlock);
+                               cw.WhileBlock = loopBlock;
+                               
+                               block.Generate (gen);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write ("foreach (" + itemType + " item in ");
+                       array.PrintCode (cp);
+                       cp.Write (") {");
+                       cp.EndLine ();
+                       cp.Indent ();
+                       forBlock.PrintCode (cp);
+                       cp.Unindent ();
+                       cp.BeginLine ().Write ("}");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeGenerationHelper.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeGenerationHelper.cs
new file mode 100644 (file)
index 0000000..7383752
--- /dev/null
@@ -0,0 +1,209 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Collections;
+using System.Reflection.Emit;
+using System.Reflection;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeGenerationHelper
+       {
+               public static void GenerateMethodCall (ILGenerator gen, CodeExpression target, MethodBase method, params CodeExpression[] parameters)
+               {
+                       Type[] ptypes = Type.EmptyTypes;
+                       // It could raise an error since GetParameters() on MethodBuilder is not supported.
+                       if (parameters.Length > 0) {
+                               ParameterInfo[] pars = method.GetParameters ();
+                               ptypes = new Type[pars.Length];
+                               for (int n=0; n<ptypes.Length; n++) ptypes[n] = pars[n].ParameterType;
+                       }
+                       GenerateMethodCall (gen, target, method, ptypes, parameters);
+               }
+               
+               public static void GenerateMethodCall (ILGenerator gen, CodeExpression target, CodeMethod method, params CodeExpression[] parameters)
+               {
+                       GenerateMethodCall (gen, target, method.MethodBase, method.ParameterTypes, parameters);
+               }
+               
+               static void GenerateMethodCall (ILGenerator gen, CodeExpression target, MethodBase method, Type[] parameterTypes, params CodeExpression[] parameters)
+               {
+                       OpCode callOp;
+                       
+                       if (parameterTypes.Length != parameters.Length)
+                               throw GetMethodException (method, "Invalid number of parameters, expected " + parameterTypes.Length + ", found " + parameters.Length + ".");  
+                       
+                       if (!object.ReferenceEquals (target, null)) 
+                       {
+                               target.Generate (gen);
+                               
+                               Type targetType = target.GetResultType();
+                               if (targetType.IsValueType) {
+                                       LocalBuilder lb = gen.DeclareLocal (targetType);
+                                       gen.Emit (OpCodes.Stloc, lb);
+                                       gen.Emit (OpCodes.Ldloca, lb);
+                                       callOp = OpCodes.Call;
+                               }
+                               else
+                                       callOp = OpCodes.Callvirt;
+                       }
+                       else
+                               callOp = OpCodes.Call;
+
+                       for (int n=0; n<parameterTypes.Length; n++) {
+                               try {
+                                       CodeExpression par = parameters[n];
+                                       par.Generate (gen);
+                                       GenerateSafeConversion (gen, parameterTypes[n], par.GetResultType());
+                               }
+                               catch (InvalidOperationException ex) {
+                                       throw GetMethodException (method, "Parameter " + n + ". " + ex.Message);  
+                               }
+                       }
+                       
+                       if (method is MethodInfo)
+                               gen.Emit (callOp, (MethodInfo)method);
+                       else if (method is ConstructorInfo)
+                               gen.Emit (callOp, (ConstructorInfo)method);
+               }
+               
+               public static Exception GetMethodException (MethodBase method, string msg)
+               {
+                       return new InvalidOperationException ("Call to method " + method.DeclaringType + "." + method.Name + ": " + msg);  
+               }
+               
+               public static void GenerateSafeConversion (ILGenerator gen, Type targetType, Type sourceType)
+               {
+                       if (!targetType.IsAssignableFrom (sourceType)) {
+                               throw new InvalidOperationException ("Invalid type conversion. Found '" + sourceType + "', expected '" + targetType + "'.");
+                       }
+                       
+                       if (targetType == typeof(object) && sourceType.IsValueType) {
+                               gen.Emit (OpCodes.Box, sourceType);
+                       }
+               }
+
+               public static void LoadFromPtr (ILGenerator ig, Type t)
+               {
+                       if (t == typeof(int))
+                               ig.Emit (OpCodes.Ldind_I4);
+                       else if (t == typeof(uint))
+                               ig.Emit (OpCodes.Ldind_U4);
+                       else if (t == typeof(short))
+                               ig.Emit (OpCodes.Ldind_I2);
+                       else if (t == typeof(ushort))
+                               ig.Emit (OpCodes.Ldind_U2);
+                       else if (t == typeof(char))
+                               ig.Emit (OpCodes.Ldind_U2);
+                       else if (t == typeof(byte))
+                               ig.Emit (OpCodes.Ldind_U1);
+                       else if (t == typeof(sbyte))
+                               ig.Emit (OpCodes.Ldind_I1);
+                       else if (t == typeof(ulong))
+                               ig.Emit (OpCodes.Ldind_I8);
+                       else if (t == typeof(long))
+                               ig.Emit (OpCodes.Ldind_I8);
+                       else if (t == typeof(float))
+                               ig.Emit (OpCodes.Ldind_R4);
+                       else if (t == typeof(double))
+                               ig.Emit (OpCodes.Ldind_R8);
+                       else if (t == typeof(bool))
+                               ig.Emit (OpCodes.Ldind_I1);
+                       else if (t == typeof(IntPtr))
+                               ig.Emit (OpCodes.Ldind_I);
+                       else if (t.IsEnum) {
+                               if (t == typeof(Enum))
+                                       ig.Emit (OpCodes.Ldind_Ref);
+                               else
+                                       LoadFromPtr (ig, System.Enum.GetUnderlyingType (t));
+                       } else if (t.IsValueType)
+                               ig.Emit (OpCodes.Ldobj, t);
+                       else
+                               ig.Emit (OpCodes.Ldind_Ref);
+               }
+
+               public static void SaveToPtr (ILGenerator ig, Type t)
+               {
+                       if (t == typeof(int))
+                               ig.Emit (OpCodes.Stind_I4);
+                       else if (t == typeof(uint))
+                               ig.Emit (OpCodes.Stind_I4);
+                       else if (t == typeof(short))
+                               ig.Emit (OpCodes.Stind_I2);
+                       else if (t == typeof(ushort))
+                               ig.Emit (OpCodes.Stind_I2);
+                       else if (t == typeof(char))
+                               ig.Emit (OpCodes.Stind_I2);
+                       else if (t == typeof(byte))
+                               ig.Emit (OpCodes.Stind_I1);
+                       else if (t == typeof(sbyte))
+                               ig.Emit (OpCodes.Stind_I1);
+                       else if (t == typeof(ulong))
+                               ig.Emit (OpCodes.Stind_I8);
+                       else if (t == typeof(long))
+                               ig.Emit (OpCodes.Stind_I8);
+                       else if (t == typeof(float))
+                               ig.Emit (OpCodes.Stind_R4);
+                       else if (t == typeof(double))
+                               ig.Emit (OpCodes.Stind_R8);
+                       else if (t == typeof(bool))
+                               ig.Emit (OpCodes.Stind_I1);
+                       else if (t == typeof(IntPtr))
+                               ig.Emit (OpCodes.Stind_I);
+                       else if (t.IsEnum) {
+                               if (t == typeof(Enum))
+                                       ig.Emit (OpCodes.Stind_Ref);
+                               else
+                                       SaveToPtr (ig, System.Enum.GetUnderlyingType (t));
+                       } else if (t.IsValueType)
+                               ig.Emit (OpCodes.Stobj, t);
+                       else
+                               ig.Emit (OpCodes.Stind_Ref);
+               }
+
+               public static bool IsNumber (Type t)
+               {
+                       switch (Type.GetTypeCode (t))
+                       {
+                               case TypeCode.Byte:
+                               case TypeCode.Double:
+                               case TypeCode.Int16:
+                               case TypeCode.Int32:
+                               case TypeCode.Int64:
+                               case TypeCode.SByte:
+                               case TypeCode.Single:
+                               case TypeCode.UInt16:
+                               case TypeCode.UInt32:
+                               case TypeCode.UInt64:
+                                       return true;
+                               default:
+                                       return false;
+                       }
+               }
+               
+               public static void GeneratePrimitiveValue ()
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeIf.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeIf.cs
new file mode 100644 (file)
index 0000000..95fe2a0
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeIf: CodeStatement
+       {
+               CodeExpression condition;
+               CodeBlock trueBlock;
+               CodeBlock falseBlock;
+               
+               public CodeIf (CodeExpression condition)
+               {
+                       this.condition = condition;
+                       if (condition.GetResultType () != typeof(bool))
+                               throw new InvalidOperationException ("Condition expression is not boolean"); 
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       if (trueBlock == null)
+                               throw new InvalidOperationException ("Incomplete If statement");
+                       
+                       Label falseLabel = gen.DefineLabel ();
+                       Label endLabel = gen.DefineLabel ();
+                       
+                       if (falseBlock == null)
+                       {
+                               GenerateCondition (gen, endLabel);
+                               trueBlock.Generate (gen);
+                       }
+                       else
+                       {
+                               GenerateCondition (gen, falseLabel);
+                               trueBlock.Generate (gen);
+                               gen.Emit (OpCodes.Br, endLabel);
+                               gen.MarkLabel(falseLabel);
+                               falseBlock.Generate (gen);
+                       }
+                       gen.MarkLabel(endLabel);
+               }
+               
+               void GenerateCondition (ILGenerator gen, Label falseLabel)
+               {
+                       if (condition is CodeConditionExpression)
+                               ((CodeConditionExpression)condition).GenerateForBranch (gen, falseLabel, false);
+                       else {
+                               condition.Generate (gen);
+                               gen.Emit (OpCodes.Brfalse, falseLabel);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       if (trueBlock == null) return;
+                       
+                       cp.Write ("if (");
+                       condition.PrintCode (cp);
+                       cp.Write (") {");
+                       cp.EndLine ();
+                       cp.Indent ();
+                       trueBlock.PrintCode (cp);
+                       cp.Unindent ();
+                       cp.BeginLine ().Write ("}");
+                       if (falseBlock != null) {
+                               cp.EndLine ();
+                               cp.WriteLineInd ("else {");
+                               falseBlock.PrintCode (cp);
+                               cp.Unindent ();
+                               cp.BeginLine ().Write ("}");
+                       }
+               }
+               
+               public CodeBlock TrueBlock
+               {
+                       get { return trueBlock; }
+                       set { trueBlock = value; }
+               }
+               
+               public CodeBlock FalseBlock
+               {
+                       get { return falseBlock; }
+                       set { falseBlock = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeIncrement.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeIncrement.cs
new file mode 100644 (file)
index 0000000..6cbf570
--- /dev/null
@@ -0,0 +1,153 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeIncrement: CodeValueReference
+       {
+               CodeValueReference exp;
+               
+               public CodeIncrement (CodeValueReference exp)
+               {
+                       this.exp = exp;
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp.GenerateSet (gen, new CodeAddOne (exp));
+                       exp.Generate (gen);
+               }
+               
+               public override void GenerateAsStatement (ILGenerator gen)
+               {
+                       exp.GenerateSet (gen, new CodeAddOne (exp));
+               }
+               
+               public override void GenerateSet (ILGenerator gen, CodeExpression value)
+               {
+                       exp.GenerateSet (gen, value);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       exp.PrintCode (cp);
+                       cp.Write ("++");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return exp.GetResultType();
+               }
+       }
+
+       public class CodeAddOne: CodeExpression
+       {
+               CodeValueReference exp;
+               MethodInfo incMet;
+               
+               public CodeAddOne (CodeValueReference exp)
+               {
+                       this.exp = exp;
+                       if (!exp.IsNumber) {
+                               incMet = exp.GetResultType ().GetMethod ("op_Increment");
+                               if (incMet == null)
+                                       throw new InvalidOperationException ("Operator '++' cannot be applied to operand of type '" + exp.GetResultType().FullName + "'");
+                       }
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       if (incMet != null) {
+                               CodeGenerationHelper.GenerateMethodCall (gen, null, incMet, exp);
+                               return;
+                       }
+                       
+                       exp.Generate (gen);
+                       Type t = exp.GetResultType ();
+                       switch (Type.GetTypeCode (t))
+                       {
+                               case TypeCode.Byte:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       gen.Emit (OpCodes.Conv_U1);
+                                       break;
+
+                               case TypeCode.Double:
+                                       gen.Emit (OpCodes.Ldc_R8, 1);
+                                       gen.Emit (OpCodes.Add);
+                                       break;
+                                       
+                               case TypeCode.Int16:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       gen.Emit (OpCodes.Conv_I2);
+                                       break;
+                                       
+                               case TypeCode.UInt32:
+                               case TypeCode.Int32:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       break;
+                                       
+                               case TypeCode.UInt64:
+                               case TypeCode.Int64:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       gen.Emit (OpCodes.Conv_U8);
+                                       break;
+                                       
+                               case TypeCode.SByte:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       gen.Emit (OpCodes.Conv_I1);
+                                       break;
+                                       
+                               case TypeCode.Single:
+                                       gen.Emit (OpCodes.Ldc_R4, 1);
+                                       gen.Emit (OpCodes.Add);
+                                       break;
+                                       
+                               case TypeCode.UInt16:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       gen.Emit (OpCodes.Conv_U2);
+                                       break;
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       exp.PrintCode (cp);
+                       cp.Write (" + 1");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return exp.GetResultType();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeIs.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeIs.cs
new file mode 100644 (file)
index 0000000..6e4eafd
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using Mono.CodeGeneration;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeIs: CodeConditionExpression
+       {
+               Type type; 
+               CodeExpression exp;
+               
+               public CodeIs (Type type, CodeExpression exp)
+               {
+                       this.type = type;               
+                       this.exp = exp;
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       Type typeObj = exp.GetResultType ();
+
+                       if (type.IsAssignableFrom (typeObj)) { 
+                               gen.Emit (OpCodes.Ldc_I4_1);
+                               return;
+                       }
+                       else if (!typeObj.IsAssignableFrom (type)) { 
+                               gen.Emit (OpCodes.Ldc_I4_0);
+                               return;
+                       }
+                       
+                       exp.Generate (gen);
+                       gen.Emit (OpCodes.Isinst, type);
+                       gen.Emit (OpCodes.Ldnull);
+                       gen.Emit (OpCodes.Cgt_Un);
+               }
+               
+               public override void GenerateForBranch (ILGenerator gen, Label label, bool branchCase)
+               {
+                       Type typeObj = exp.GetResultType ();
+
+                       if (type.IsAssignableFrom (typeObj)) {
+                               if (branchCase)
+                                       gen.Emit (OpCodes.Br, label);
+                               return;
+                       }
+                       else if (!typeObj.IsAssignableFrom (type)) { 
+                               if (!branchCase)
+                                       gen.Emit (OpCodes.Br, label);
+                               return;
+                       }
+                       
+                       exp.Generate (gen);
+                       gen.Emit (OpCodes.Isinst, type);
+                       if (branchCase)
+                               gen.Emit (OpCodes.Brtrue, label);
+                       else
+                               gen.Emit (OpCodes.Brfalse, label);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       exp.PrintCode (cp);
+                       cp.Write (" is ");
+                       cp.Write (type.FullName);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return typeof(bool);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeItem.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeItem.cs
new file mode 100644 (file)
index 0000000..442ee05
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public abstract class CodeItem
+       {
+               public abstract void Generate (ILGenerator gen);
+               public abstract void PrintCode (CodeWriter cp);
+       }
+
+       public abstract class CodeStatement: CodeItem
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeLiteral.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeLiteral.cs
new file mode 100644 (file)
index 0000000..9b25641
--- /dev/null
@@ -0,0 +1,144 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeLiteral: CodeExpression
+       {
+               object value;
+               Type type;
+               
+               public CodeLiteral (object value)
+               {
+                       this.value = value;
+                       if (value != null) type = value.GetType ();
+                       else type = typeof(object);
+               }
+                       
+               public CodeLiteral (object value, Type type)
+               {
+                       this.value = value;
+                       this.type = type;
+               }
+
+               public object Value {
+                       get { return value; }
+               }
+
+               public override void Generate (ILGenerator gen)
+               {
+                       object value = this.value;
+                       
+                       if (value == null)
+                       {
+                               gen.Emit (OpCodes.Ldnull);
+                               return;
+                       }
+                       
+                       if (value is Enum)
+                               value = Convert.ChangeType (value, (value.GetType().UnderlyingSystemType));
+                       
+                       if (value is Type) {
+                               gen.Emit (OpCodes.Ldtoken, (Type)value);
+                               gen.Emit (OpCodes.Call, typeof(Type).GetMethod ("GetTypeFromHandle"));
+                               return;
+                       }
+                       
+                       switch (Type.GetTypeCode (type))
+                       {
+                               case TypeCode.String:
+                                       gen.Emit (OpCodes.Ldstr, (string)value);
+                                       break;
+                                       
+                               case TypeCode.Byte:
+                               case TypeCode.SByte:
+                               case TypeCode.Int16:
+                               case TypeCode.UInt16:
+                               case TypeCode.Int32:
+                               case TypeCode.UInt32:
+                                       int i = (int)value;
+                                       switch (i)
+                                       {
+                                               case 0: gen.Emit (OpCodes.Ldc_I4_0); break;
+                                               case 1: gen.Emit (OpCodes.Ldc_I4_1); break;
+                                               case 2: gen.Emit (OpCodes.Ldc_I4_2); break;
+                                               case 3: gen.Emit (OpCodes.Ldc_I4_3); break;
+                                               case 4: gen.Emit (OpCodes.Ldc_I4_4); break;
+                                               case 5: gen.Emit (OpCodes.Ldc_I4_5); break;
+                                               case 6: gen.Emit (OpCodes.Ldc_I4_6); break;
+                                               case 7: gen.Emit (OpCodes.Ldc_I4_7); break;
+                                               case 8: gen.Emit (OpCodes.Ldc_I4_8); break;
+                                               case -1: gen.Emit (OpCodes.Ldc_I4_M1); break;
+                                               default: gen.Emit (OpCodes.Ldc_I4, i); break;
+                                       }
+                                       break;
+                                       
+                               case TypeCode.Int64:
+                               case TypeCode.UInt64:
+                                       gen.Emit (OpCodes.Ldc_I8, (long)value);
+                                       break;
+                                       
+                               case TypeCode.Single:
+                                       gen.Emit (OpCodes.Ldc_R4, (float)value);
+                                       break;
+                                       
+                               case TypeCode.Double:
+                                       gen.Emit (OpCodes.Ldc_R8, (double)value);
+                                       break;
+                                       
+                               case TypeCode.Boolean:
+                                       if ((bool)value)
+                                               gen.Emit (OpCodes.Ldc_I4_1);
+                                       else
+                                               gen.Emit (OpCodes.Ldc_I4_0);
+                                       break;
+                                       
+                               default:
+                                       throw new InvalidOperationException ("Literal type " + value.GetType() + " not supported");
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       if (value is string)
+                               cp.Write ("\"").Write (value.ToString ()).Write ("\"");
+                       else if (value == null)
+                               cp.Write ("null");
+                       else if (value is Type)
+                               cp.Write ("typeof(" + ((Type)value).Name + ")");
+                       else if (value is Enum)
+                               cp.Write (value.GetType().Name + "." + value);
+                       else
+                               cp.Write (value.ToString ());
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return type;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeMethod.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeMethod.cs
new file mode 100644 (file)
index 0000000..915271a
--- /dev/null
@@ -0,0 +1,228 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeMethod
+       {
+               MethodBase methodBase;
+               CodeBuilder builder;
+               string name;
+               MethodAttributes attributes;
+               Type returnType;
+               TypeBuilder typeBuilder;
+               Type[] parameterTypes;
+               ArrayList customAttributes = new ArrayList ();
+               CodeClass cls;
+               
+               internal static CodeMethod DefineMethod (CodeClass cls, string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes)
+               {
+                       return new CodeMethod (cls, name, attributes, returnType, parameterTypes);
+               }
+               
+               public static CodeMethod DefineConstructor (CodeClass cls, MethodAttributes attributes, Type[] parameterTypes)
+               {
+                       return new CodeMethod (cls, attributes, parameterTypes);
+               }
+               
+               internal CodeMethod (CodeClass cls, string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) 
+               {
+                       this.cls = cls;
+                       this.typeBuilder = cls.TypeBuilder;
+                       this.name = name;
+                       this.attributes = attributes;
+                       this.returnType = returnType;
+                       this.parameterTypes = parameterTypes;
+               
+                       methodBase = typeBuilder.DefineMethod (name, attributes, returnType, parameterTypes);
+                       builder = new CodeBuilder (cls);
+               }
+               
+               CodeMethod (CodeClass cls, MethodAttributes attributes, Type[] parameterTypes) 
+               {
+                       this.cls = cls;
+                       this.typeBuilder = cls.TypeBuilder;
+                       this.attributes = attributes;
+                       this.parameterTypes = parameterTypes;
+                       this.name = typeBuilder.Name;
+               
+                       methodBase = typeBuilder.DefineConstructor (attributes, CallingConventions.Standard, parameterTypes);
+                       builder = new CodeBuilder (cls);
+               }
+               
+               public TypeBuilder DeclaringType
+               {
+                       get { return typeBuilder; }
+               }
+               
+               public MethodInfo MethodInfo
+               {
+                       get { return methodBase as MethodInfo; }
+               }
+               
+               public MethodBase MethodBase
+               {
+                       get { return methodBase; }
+               }
+               
+               public string Name
+               {
+                       get { return name; }
+               }
+               
+               public MethodAttributes Attributes
+               {
+                       get { return attributes; }
+               }
+               
+               public Type ReturnType
+               {
+                       get { return returnType; }
+               }
+               
+               public Type[] ParameterTypes
+               {
+                       get { return parameterTypes; }
+               }
+               
+               public CodeBuilder CodeBuilder
+               {
+                       get { return builder; }
+               }
+               
+               public bool IsStatic
+               {
+                       get { return (attributes & MethodAttributes.Static) != 0; }
+               }
+
+               public CodeCustomAttribute CreateCustomAttribute (Type attributeType)
+               {
+                       return CreateCustomAttribute (attributeType,
+                               Type.EmptyTypes, new object [0]);
+               }
+
+               public CodeCustomAttribute CreateCustomAttribute (Type attributeType, Type [] ctorArgTypes, object [] ctorArgs)
+               {
+                       return CreateCustomAttribute (attributeType,
+                               ctorArgTypes, ctorArgs, new string [0], new object [0]);
+               }
+
+               public CodeCustomAttribute CreateCustomAttribute (Type attributeType, Type [] ctorArgTypes, object [] ctorArgs, string [] namedArgFieldNames, object [] namedArgValues)
+               {
+                       CodeCustomAttribute cca = CodeCustomAttribute.Create (
+                               attributeType, ctorArgTypes, ctorArgs, namedArgFieldNames, namedArgValues);
+                       SetCustomAttribute (cca);
+                       return cca;
+               }
+
+               public CodeCustomAttribute CreateCustomAttribute (Type attributeType, Type [] ctorArgTypes, CodeLiteral [] ctorArgs, FieldInfo [] fields, CodeLiteral [] fieldValues)
+               {
+                       CodeCustomAttribute cca = CodeCustomAttribute.Create (
+                               attributeType, ctorArgTypes, ctorArgs, fields, fieldValues);
+                       SetCustomAttribute (cca);
+                       return cca;
+               }
+
+               void SetCustomAttribute (CodeCustomAttribute cca)
+               {
+                       if (methodBase is MethodBuilder)
+                               ((MethodBuilder) methodBase).SetCustomAttribute (cca.Builder);
+                       else if (methodBase is ConstructorBuilder)
+                               ((ConstructorBuilder) methodBase).SetCustomAttribute (cca.Builder);
+                       customAttributes.Add (cca);
+               }
+
+               public string PrintCode ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       CodeWriter cw = new CodeWriter (sw);
+                       PrintCode (cw);
+                       return sw.ToString ();
+               }
+               
+               public virtual void PrintCode (CodeWriter cp)
+               {
+                       cp.BeginLine ();
+                       foreach (CodeCustomAttribute a in customAttributes)
+                               a.PrintCode (cp);
+                       if ((methodBase.Attributes & MethodAttributes.Static) != 0)
+                               cp.Write ("static ");
+                       if ((methodBase.Attributes & MethodAttributes.Public) != 0)
+                               cp.Write ("public ");
+                       if (returnType != null) cp.Write (returnType + " ");
+                       cp.Write (name + " (");
+                       for (int n=0; n<parameterTypes.Length; n++) {
+                               if (n > 0) cp.Write (", ");
+                               cp.Write (parameterTypes[n] + " arg" + n);
+                       }
+                       cp.Write (")");
+                       cp.EndLine ();
+                       cp.WriteLineInd ("{");
+                       
+                       builder.PrintCode (cp);
+                       
+                       cp.WriteLineUnind ("}");
+               }
+               
+               public CodeArgumentReference GetArg (int n)
+               {
+                       if (n < 0 || n >= parameterTypes.Length)
+                               throw new InvalidOperationException ("Invalid argument number");
+
+                       int narg = IsStatic ? n : n + 1;
+                       return new CodeArgumentReference (parameterTypes[n], narg, "arg" + n);
+               }
+               
+               public CodeArgumentReference GetThis ()
+               {
+                       if (IsStatic)
+                               throw new InvalidOperationException ("'this' not available in static methods");
+                               
+                       return new CodeArgumentReference (DeclaringType, 0, "this");
+               }
+               
+               public void Generate ()
+               {
+                       ILGenerator gen = methodBase is MethodInfo ? ((MethodBuilder)methodBase).GetILGenerator() : ((ConstructorBuilder)methodBase).GetILGenerator();
+                       Label returnLabel = gen.DefineLabel ();
+                       builder.ReturnLabel = returnLabel;
+                       builder.Generate (gen);
+                       gen.MarkLabel(returnLabel);
+                       gen.Emit(OpCodes.Ret);
+               }
+               
+               public void UpdateMethodBase (Type type)
+               {
+                       if (methodBase is MethodInfo)
+                               methodBase = type.GetMethod (methodBase.Name, parameterTypes);
+                       else
+                               methodBase = type.GetConstructor (parameterTypes);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeMethodCall.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeMethodCall.cs
new file mode 100644 (file)
index 0000000..d834753
--- /dev/null
@@ -0,0 +1,144 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeMethodCall: CodeExpression
+       {
+               CodeExpression target;
+               CodeExpression[] parameters;
+               MethodBase method;
+               CodeMethod codeMethod;
+               
+               public CodeMethodCall (CodeExpression target, string name, params CodeExpression[] parameters)
+               {
+                       this.target = target;
+                       this.parameters = parameters;
+                       Type[] types = GetParameterTypes (parameters);
+                       method = target.GetResultType().GetMethod (name, types);
+                       if (method == null) {
+                               throw new InvalidOperationException ("Method " + GetSignature(target.GetResultType(), name, parameters) + " not found");
+                       }
+               }
+               
+               public CodeMethodCall (CodeExpression target, MethodBase method, params CodeExpression[] parameters)
+               {
+                       this.target = target;
+                       this.parameters = parameters;
+                       this.method = method;
+               }
+               
+               public CodeMethodCall (CodeExpression target, CodeMethod method, params CodeExpression[] parameters)
+               {
+                       this.target = target;
+                       this.parameters = parameters;
+                       this.codeMethod = method;
+               }
+               
+               public CodeMethodCall (Type type, string name, params CodeExpression[] parameters)
+               {
+                       this.parameters = parameters;
+                       method = type.GetMethod (name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static, null, GetParameterTypes (parameters), null);
+                       if (method == null) throw new InvalidOperationException ("Method " + GetSignature(type, name, parameters) + " not found");
+               }
+               
+               public CodeMethodCall (MethodInfo method, params CodeExpression[] parameters)
+               {
+                       this.parameters = parameters;
+                       this.method = method;
+               }
+               
+               public CodeMethodCall (CodeMethod method, params CodeExpression[] parameters)
+               {
+                       this.parameters = parameters;
+                       this.codeMethod = method;
+               }
+               
+               Type[] GetParameterTypes (CodeExpression[] parameters)
+               {
+                       Type[] ts = new Type [parameters.Length];
+                       for (int n=0; n<ts.Length; n++)
+                               ts [n] = parameters[n].GetResultType ();
+                       return ts;
+               }
+               
+               string GetSignature (Type type, string name, params CodeExpression[] parameters)
+               {
+                       System.Text.StringBuilder sb = new System.Text.StringBuilder ();
+                       sb.Append (type.FullName).Append(".").Append(name);
+                       
+                       Type[] types = GetParameterTypes (parameters);
+                       sb.Append ("(");
+                       for (int n=0; n<types.Length; n++)
+                       {
+                               if (n > 0) sb.Append (", ");
+                               sb.Append (types[n].FullName);
+                       }
+                       sb.Append (")");
+                       return sb.ToString ();
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       if (codeMethod != null)
+                               CodeGenerationHelper.GenerateMethodCall (gen, target, codeMethod, parameters);
+                       else
+                               CodeGenerationHelper.GenerateMethodCall (gen, target, method, parameters);
+               }
+               
+               public override void GenerateAsStatement (ILGenerator gen)
+               {
+                       Generate (gen);
+                       if (GetResultType () != typeof(void)) gen.Emit (OpCodes.Pop);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       MethodBase met = method != null ? method : codeMethod.MethodInfo;
+                       if (!object.ReferenceEquals (target, null))
+                               target.PrintCode (cp);
+                       else
+                               cp.Write (met.DeclaringType.FullName);
+                       
+                       cp.Write (".");
+                       cp.Write (met.Name).Write (" (");
+                       for (int n=0; n<parameters.Length; n++) {
+                               if (n > 0) cp.Write (", ");
+                               parameters[n].PrintCode (cp);
+                       }
+                       cp.Write (")");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       if (codeMethod != null) return codeMethod.ReturnType;
+                       else if (method is MethodInfo) return ((MethodInfo) method).ReturnType;
+                       else return typeof (void);
+               }
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeModule.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeModule.cs
new file mode 100644 (file)
index 0000000..e9c2914
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeModule
+       {
+               ModuleBuilder module;
+               static CodeModule sharedModule;
+               
+               public CodeModule (string name)
+               {
+                       AppDomain myDomain = System.Threading.Thread.GetDomain();
+                       AssemblyName myAsmName = new AssemblyName();
+                       myAsmName.Name = name;
+                       AssemblyBuilder myAsmBuilder = myDomain.DefineDynamicAssembly (myAsmName, AssemblyBuilderAccess.RunAndSave);
+                       module = myAsmBuilder.DefineDynamicModule (name, name + ".dll");
+               }
+               
+               public static CodeModule Shared
+               {
+                       get {
+                               if (sharedModule == null)
+                                       sharedModule = new CodeModule ("SharedModule");
+                               return sharedModule;
+                       }
+               }
+               
+               public CodeClass CreateClass (string name)
+               {
+                       return CreateClass (name, TypeAttributes.Public, typeof(object));
+               }
+               
+               public CodeClass CreateClass (string name, Type baseType, params Type[] interfaces)
+               {
+                       return CreateClass (name, TypeAttributes.Public, baseType, interfaces);
+               }
+               
+               public CodeClass CreateClass (string name, TypeAttributes attr, Type baseType, params Type[] interfaces)
+               {
+                       return new CodeClass (module, name, attr, baseType, interfaces);
+               }
+               
+               public ModuleBuilder ModuleBuilder
+               {
+                       get { return module; }
+               }
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeNew.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeNew.cs
new file mode 100644 (file)
index 0000000..addefc9
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeNew: CodeExpression
+       {
+               object value;
+               Type type;
+               ConstructorInfo ctor;
+               CodeExpression[] parameters;
+               
+               public CodeNew (Type type, params CodeExpression[] parameters)
+               {
+                       this.type = type;
+                       Type[] ptypes = new Type [parameters.Length];
+                       for (int n=0; n<parameters.Length; n++)
+                               ptypes [n] = parameters[n].GetResultType ();
+                       ctor = type.GetConstructor (ptypes);
+                       if (ctor == null)
+                               throw new InvalidOperationException ("Constructor not found");
+                       this.parameters = parameters;
+               }
+
+               public override void Generate (ILGenerator gen)
+               {
+                       foreach (CodeExpression exp in parameters)
+                               exp.Generate (gen);
+                       gen.Emit (OpCodes.Newobj, ctor);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write ("new " + type.Name + " (");
+                       for (int n=0; n<parameters.Length; n++) {
+                               if (n > 0) cp.Write (", ");
+                               parameters[n].PrintCode (cp);
+                       }
+                       cp.Write (")");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return type;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeNewArray.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeNewArray.cs
new file mode 100644 (file)
index 0000000..68b83a0
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeNewArray: CodeExpression
+       {
+               Type elemType;
+               CodeExpression size;
+               
+               public CodeNewArray (Type type, CodeExpression size)
+               {
+                       this.elemType = type;
+                       this.size = size;
+                       if (size.GetResultType () != typeof(int))
+                               throw new InvalidOperationException ("Array size must be an Int32");
+               }
+
+               public override void Generate (ILGenerator gen)
+               {
+                       size.Generate (gen);
+                       gen.Emit (OpCodes.Newarr, elemType);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write ("new " + elemType.Name + " [");
+                       size.PrintCode (cp);
+                       cp.Write ("]");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return Type.GetType (elemType.FullName + "[]");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeNotEquals.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeNotEquals.cs
new file mode 100644 (file)
index 0000000..5470674
--- /dev/null
@@ -0,0 +1,117 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeNotEquals: CodeConditionExpression
+       {
+               CodeExpression exp1;
+               CodeExpression exp2;
+               Type t1;
+               Type t2;
+               
+               public CodeNotEquals (CodeExpression exp1, CodeExpression exp2)
+               {
+                       this.exp1 = exp1;
+                       this.exp2 = exp2;
+                       
+                       t1 = exp1.GetResultType ();
+                       t2 = exp2.GetResultType ();
+                       
+                       if (t1.IsValueType && t2.IsValueType) {
+                               if (t1 != t2)
+                                       throw new InvalidOperationException ("Can't compare values of different primitive types");
+                       }
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       if (t1.IsPrimitive)
+                       {
+                               exp1.Generate (gen);
+                               exp2.Generate (gen);
+                               gen.Emit (OpCodes.Ceq);
+                               gen.Emit (OpCodes.Ldc_I4_0);
+                               gen.Emit (OpCodes.Ceq);
+                       }
+                       else
+                       {
+                               exp1.Generate (gen);
+                               exp2.Generate (gen);
+                               gen.Emit (OpCodes.Ceq);
+//                             gen.EmitCall (OpCodes.Callvirt, t1.GetMethod ("Equals", new Type[] {t2}), null);
+                               gen.Emit (OpCodes.Ldc_I4_0);
+                               gen.Emit (OpCodes.Ceq);
+                       }
+               }
+               
+               public override void GenerateForBranch (ILGenerator gen, Label label, bool branchCase)
+               {
+                       if (t1.IsPrimitive)
+                       {
+                               exp1.Generate (gen);
+                               exp2.Generate (gen);
+                               if (branchCase)
+                                       gen.Emit (OpCodes.Bne_Un, label);
+                               else
+                                       gen.Emit (OpCodes.Beq, label);
+                       }
+                       else {
+                               exp1.Generate (gen);
+                               exp2.Generate (gen);
+//                             gen.EmitCall (OpCodes.Callvirt, t1.GetMethod ("Equals", new Type[] {t2}), null);
+                               gen.Emit (OpCodes.Ceq);
+                               gen.Emit (OpCodes.Ldc_I4_0);
+                               if (branchCase)
+                                       gen.Emit (OpCodes.Beq, label);
+                               else
+                                       gen.Emit (OpCodes.Bne_Un, label);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       if (t1.IsPrimitive) {
+                               exp1.PrintCode (cp);
+                               cp.Write (" != ");
+                               exp2.PrintCode (cp);
+                       }
+                       else {
+                               cp.Write ("!(");
+                               exp1.PrintCode (cp);
+                               cp.Write (".Equals (");
+                               exp2.PrintCode (cp);
+                               cp.Write ("))");
+                       }
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return typeof (bool);
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeOr.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeOr.cs
new file mode 100644 (file)
index 0000000..1a0c5be
--- /dev/null
@@ -0,0 +1,117 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeOr: CodeConditionExpression
+       {
+               CodeExpression exp1;
+               CodeExpression exp2;
+               Type t1;
+               Type t2;
+               
+               public CodeOr (CodeExpression exp1, CodeExpression exp2)
+               {
+                       this.exp1 = exp1;
+                       this.exp2 = exp2;
+                       
+                       if (exp1.GetResultType () != typeof(bool) || exp1.GetResultType () != typeof(bool)) {
+                               if (t1 != t2)
+                                       throw new InvalidOperationException ("Can't compare values of different primitive types");
+                       }
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       Label trueLabel = gen.DefineLabel ();
+                       Label endLabel = gen.DefineLabel ();
+                       
+                       if (exp1 is CodeConditionExpression)
+                               ((CodeConditionExpression)exp1).GenerateForBranch (gen, trueLabel, true);
+                       else {
+                               exp1.Generate (gen);
+                               gen.Emit (OpCodes.Brtrue, trueLabel);
+                       }
+                               
+                       exp2.Generate (gen);
+                       gen.Emit (OpCodes.Br, endLabel);
+                       gen.MarkLabel(trueLabel);
+                       gen.Emit (OpCodes.Ldc_I4_1);
+                       gen.MarkLabel(endLabel);
+               }
+               
+               public override void GenerateForBranch (ILGenerator gen, Label label, bool branchCase)
+               {
+                       Label endLabel = gen.DefineLabel ();
+                       exp1.Generate (gen);
+                       
+                       if (exp1 is CodeConditionExpression) {
+                               if (branchCase)
+                                       ((CodeConditionExpression)exp1).GenerateForBranch (gen, label, true);
+                               else
+                                       ((CodeConditionExpression)exp1).GenerateForBranch (gen, endLabel, true);
+                       }
+                       else {
+                               exp1.Generate (gen);
+                               if (branchCase)
+                                       gen.Emit (OpCodes.Brtrue, label);
+                               else
+                                       gen.Emit (OpCodes.Brtrue, endLabel);
+                       }
+
+                       if (exp2 is CodeConditionExpression) {
+                               if (branchCase)
+                                       ((CodeConditionExpression)exp2).GenerateForBranch (gen, label, true);
+                               else
+                                       ((CodeConditionExpression)exp2).GenerateForBranch (gen, label, false);
+                       }
+                       else {
+                               exp2.Generate (gen);
+                               if (branchCase)
+                                       gen.Emit (OpCodes.Brtrue, label);
+                               else
+                                       gen.Emit (OpCodes.Brfalse, label);
+                       }
+                       
+                       gen.MarkLabel(endLabel);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write ("(");
+                       exp1.PrintCode (cp);
+                       cp.Write (" || ");
+                       exp2.PrintCode (cp);
+                       cp.Write (")");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return typeof (bool);
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeProperty.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeProperty.cs
new file mode 100644 (file)
index 0000000..8ec6d62
--- /dev/null
@@ -0,0 +1,244 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeProperty
+       {
+               PropertyInfo propertyInfo;
+               CodeBuilder get_builder;
+               CodeBuilder set_builder;
+               string name;
+               PropertyAttributes attributes;
+               MethodAttributes methodAttributes;
+               Type returnType;
+               TypeBuilder typeBuilder;
+               Type[] parameterTypes;
+               ArrayList customAttributes = new ArrayList ();
+               CodeClass cls;
+               
+               internal static CodeProperty DefineProperty (CodeClass cls, string name, PropertyAttributes attributes, MethodAttributes methodAttributes, Type returnType, Type[] parameterTypes)
+               {
+                       return new CodeProperty (cls, name, attributes, methodAttributes, returnType, parameterTypes);
+               }
+               
+               internal CodeProperty (CodeClass cls, string name, PropertyAttributes attributes, MethodAttributes methodAttributes, Type returnType, Type[] parameterTypes) 
+               {
+                       this.cls = cls;
+                       this.typeBuilder = cls.TypeBuilder;
+                       this.name = name;
+                       this.attributes = attributes;
+                       this.methodAttributes = methodAttributes;
+                       this.returnType = returnType;
+                       this.parameterTypes = parameterTypes;
+               
+                       PropertyBuilder pb = typeBuilder.DefineProperty (name, attributes, returnType, parameterTypes);
+                       pb.SetGetMethod (typeBuilder.DefineMethod ("get_" + name, methodAttributes, CallingConventions.Standard, returnType, Type.EmptyTypes));
+                       pb.SetSetMethod (typeBuilder.DefineMethod ("set_" + name, methodAttributes, CallingConventions.Standard, typeof (void), new Type [] {returnType}));
+                       get_builder = new CodeBuilder (cls);
+                       set_builder = new CodeBuilder (cls);
+                       propertyInfo = pb;
+               }
+               
+               public TypeBuilder DeclaringType
+               {
+                       get { return typeBuilder; }
+               }
+               
+               public PropertyBuilder PropertyBuilder
+               {
+                       get { return propertyInfo as PropertyBuilder; }
+               }
+               
+               public string Name
+               {
+                       get { return name; }
+               }
+               
+               public PropertyAttributes Attributes
+               {
+                       get { return attributes; }
+               }
+               
+               public Type ReturnType
+               {
+                       get { return returnType; }
+               }
+               
+               public Type[] ParameterTypes
+               {
+                       get { return parameterTypes; }
+               }
+               
+               public CodeBuilder CodeBuilderGet
+               {
+                       get { return get_builder; }
+               }
+
+               public CodeBuilder CodeBuilderSet
+               {
+                       get { return set_builder; }
+               }
+
+               public bool IsStatic
+               {
+                       get { return (methodAttributes & MethodAttributes.Static) != 0; }
+               }
+
+               public bool IsPublic
+               {
+                       get { return (methodAttributes & MethodAttributes.Public) != 0; }
+               }
+
+               public CodeCustomAttribute CreateCustomAttribute (Type attributeType)
+               {
+                       return CreateCustomAttribute (attributeType,
+                               Type.EmptyTypes, new object [0]);
+               }
+
+               public CodeCustomAttribute CreateCustomAttribute (Type attributeType, Type [] ctorArgTypes, object [] ctorArgs)
+               {
+                       return CreateCustomAttribute (attributeType,
+                               ctorArgTypes, ctorArgs, new string [0], new object [0]);
+               }
+
+               public CodeCustomAttribute CreateCustomAttribute (Type attributeType, Type [] ctorArgTypes, object [] ctorArgs, string [] namedArgFieldNames, object [] namedArgValues)
+               {
+                       CodeCustomAttribute cca = CodeCustomAttribute.Create (
+                               attributeType, ctorArgTypes, ctorArgs, namedArgFieldNames, namedArgValues);
+                       SetCustomAttribute (cca);
+                       return cca;
+               }
+
+               public CodeCustomAttribute CreateCustomAttribute (Type attributeType, Type [] ctorArgTypes, CodeLiteral [] ctorArgs, FieldInfo [] fields, CodeLiteral [] fieldValues)
+               {
+                       CodeCustomAttribute cca = CodeCustomAttribute.Create (
+                               attributeType, ctorArgTypes, ctorArgs, fields, fieldValues);
+                       SetCustomAttribute (cca);
+                       return cca;
+               }
+
+               void SetCustomAttribute (CodeCustomAttribute cca)
+               {
+                       PropertyBuilder.SetCustomAttribute (cca.Builder);
+                       customAttributes.Add (cca);
+               }
+
+               public string PrintCode ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       CodeWriter cw = new CodeWriter (sw);
+                       PrintCode (cw);
+                       return sw.ToString ();
+               }
+               
+               public void PrintCode (CodeWriter cp)
+               {
+                       cp.BeginLine ();
+                       foreach (CodeCustomAttribute a in customAttributes)
+                               a.PrintCode (cp);
+                       cp.BeginLine ();
+                       if (IsStatic)
+                               cp.Write ("static ");
+                       if (IsPublic)
+                               cp.Write ("public ");
+                       if (returnType != null) cp.Write (returnType + " ");
+                       cp.Write (name);
+                       if (parameterTypes.Length > 0) {
+                               cp.Write (name + " [");
+                               for (int n=0; n<parameterTypes.Length; n++) {
+                                       if (n > 0) cp.Write (", ");
+                                       cp.Write (parameterTypes[n] + " arg" + n);
+                               }
+                               cp.Write ("]");
+                       }
+                       cp.Write (" {");
+                       cp.EndLine ();
+                       cp.Indent ();
+                       cp.WriteLineInd ("get {");
+                       get_builder.PrintCode (cp);
+                       cp.WriteLineUnind ("}");
+                       cp.WriteLine ("set {");
+                       set_builder.PrintCode (cp);
+                       cp.WriteLine ("}");
+                       cp.WriteLineUnind ("}");
+               }
+               
+               public CodeArgumentReference GetArg (int n)
+               {
+                       if (n < 0 || n >= parameterTypes.Length)
+                               throw new InvalidOperationException ("Invalid argument number");
+
+                       int narg = IsStatic ? n : n + 1;
+                       return new CodeArgumentReference (parameterTypes[n], narg, "arg" + n);
+               }
+               
+               public CodeArgumentReference GetThis ()
+               {
+                       if (IsStatic)
+                               throw new InvalidOperationException ("'this' not available in static methods");
+                               
+                       return new CodeArgumentReference (DeclaringType, 0, "this");
+               }
+               
+               public void Generate ()
+               {
+                       ILGenerator gen;
+                       Label returnLabel;
+                       MethodBuilder mb;
+
+                       // getter
+                       mb = (MethodBuilder) propertyInfo.GetGetMethod ();
+                       if (mb != null) {
+                               gen = mb.GetILGenerator();
+                               returnLabel = gen.DefineLabel ();
+                               get_builder.ReturnLabel = returnLabel;
+                               get_builder.Generate (gen);
+                               gen.MarkLabel (returnLabel);
+                               gen.Emit (OpCodes.Ret);
+                       }
+
+                       // setter
+                       mb = (MethodBuilder) propertyInfo.GetSetMethod ();
+                       if (mb != null) {
+                               gen = mb.GetILGenerator();
+                               returnLabel = gen.DefineLabel ();
+                               set_builder.ReturnLabel = returnLabel;
+                               set_builder.Generate (gen);
+                               gen.MarkLabel (returnLabel);
+                               gen.Emit (OpCodes.Ret);
+                       }
+               }
+               
+               public void UpdatePropertyInfo (Type type)
+               {
+                       propertyInfo = type.GetProperty (propertyInfo.Name, parameterTypes);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodePropertyReference.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodePropertyReference.cs
new file mode 100644 (file)
index 0000000..e8c9e19
--- /dev/null
@@ -0,0 +1,63 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodePropertyReference: CodeValueReference
+       {
+               CodeExpression target;
+               PropertyInfo property;
+               
+               public CodePropertyReference (CodeExpression target, PropertyInfo property)
+               {
+                       this.target = target;
+                       this.property = property;               
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       CodeGenerationHelper.GenerateMethodCall (gen, target, property.GetGetMethod());
+               }
+               
+               public override void GenerateSet (ILGenerator gen, CodeExpression value)
+               {
+                       CodeGenerationHelper.GenerateMethodCall (gen, target, property.GetSetMethod(), value);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       target.PrintCode (cp);
+                       cp.Write (".");
+                       cp.Write (property.Name);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return property.PropertyType;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeReturn.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeReturn.cs
new file mode 100644 (file)
index 0000000..d29f1d0
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeReturn: CodeStatement
+       {
+               CodeExpression retValue;
+               CodeBuilder codeBuilder;
+               
+               internal CodeReturn (CodeBuilder codeBuilder, CodeExpression retValue)
+               {
+                       this.codeBuilder = codeBuilder;
+                       this.retValue = retValue;
+               }
+               
+               internal CodeReturn (CodeBuilder codeBuilder)
+               {
+                       this.codeBuilder = codeBuilder;
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       if (!object.ReferenceEquals (retValue, null))
+                               retValue.Generate (gen);
+
+                       gen.Emit (OpCodes.Br, codeBuilder.ReturnLabel);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       if (object.ReferenceEquals (retValue, null))
+                               cp.Write ("return");
+                       else {
+                               cp.Write ("return ");
+                               retValue.PrintCode (cp);
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeSelect.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeSelect.cs
new file mode 100644 (file)
index 0000000..c38d167
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeSelect: CodeStatement
+       {
+               ArrayList conditions = new ArrayList ();
+               ArrayList blocks = new ArrayList ();
+               
+               public CodeSelect ()
+               {
+               }
+               
+               public void AddCase (CodeExpression condition, CodeBlock block)
+               {
+                       conditions.Add (condition);
+                       blocks.Add (block);
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       if (blocks.Count == 0) return;
+                       
+                       CodeIf initialIf = new CodeIf ((CodeExpression)conditions[0]);
+                       initialIf.TrueBlock = (CodeBlock) blocks[0];
+                       CodeIf prevCif = initialIf;
+                       
+                       for (int n=1; n<blocks.Count; n++) {
+                               CodeIf cif = new CodeIf ((CodeExpression)conditions[n]);
+                               cif.TrueBlock = (CodeBlock) blocks[n];
+                               CodeBlock cb = new CodeBlock ();
+                               cb.Add (cif);
+                               prevCif.FalseBlock = cb;
+                               prevCif = cif;
+                       }
+
+                       initialIf.Generate (gen);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       for (int n=0; n<blocks.Count; n++) {
+                               if (n == 0)
+                                       cp.Write ("if (");
+                               else
+                                       cp.Write ("else if (");
+                               
+                               ((CodeExpression)conditions[n]).PrintCode (cp);
+                               cp.Write (") {");
+                               cp.EndLine ();
+                               cp.Indent ();
+                               ((CodeBlock) blocks[n]).PrintCode (cp);
+                               cp.Unindent ();
+                               cp.BeginLine ().Write ("}");
+                               if (n < blocks.Count - 1) {
+                                       cp.EndLine ();
+                                       cp.BeginLine ();
+                               }
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeSelfIncrement.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeSelfIncrement.cs
new file mode 100644 (file)
index 0000000..3ebd292
--- /dev/null
@@ -0,0 +1,92 @@
+// created on 28/08/2004 at 17:30
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeSelfIncrement: CodeExpression
+       {
+               CodeValueReference exp;
+               
+               public CodeSelfIncrement (CodeValueReference exp)
+               {
+                       this.exp = exp;
+                       if (!exp.IsNumber)
+                               throw new InvalidOperationException ("Operator '++' cannot be applied to operand of type '" + exp.GetResultType().FullName + "'");
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp.Generate (gen);
+                       Type t = exp.GetResultType ();
+                       switch (Type.GetTypeCode (t))
+                       {
+                               case TypeCode.Byte:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       gen.Emit (OpCodes.Conv_U1);
+                                       break;
+
+                               case TypeCode.Decimal:
+                                       MethodInfo met = typeof(Decimal).GetMethod ("op_Increment");
+                                       CodeGenerationHelper.GenerateMethodCall (gen, null, met, exp);
+                                       break;
+                                       
+                               case TypeCode.Double:
+                                       gen.Emit (OpCodes.Ldc_R8, 1);
+                                       gen.Emit (OpCodes.Add);
+                                       break;
+                                       
+                               case TypeCode.Int16:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       gen.Emit (OpCodes.Conv_I2);
+                                       break;
+                                       
+                               case TypeCode.UInt32:
+                               case TypeCode.Int32:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       break;
+                                       
+                               case TypeCode.UInt64:
+                               case TypeCode.Int64:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       gen.Emit (OpCodes.Conv_U8);
+                                       break;
+                                       
+                               case TypeCode.SByte:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       gen.Emit (OpCodes.Conv_I1);
+                                       break;
+                                       
+                               case TypeCode.Single:
+                                       gen.Emit (OpCodes.Ldc_R4, 1);
+                                       gen.Emit (OpCodes.Add);
+                                       break;
+                                       
+                               case TypeCode.UInt16:
+                                       gen.Emit (OpCodes.Ldc_I4_1);
+                                       gen.Emit (OpCodes.Add);
+                                       gen.Emit (OpCodes.Conv_U2);
+                                       break;
+                       }
+                       exp.GenerateSet (gen, exp);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       exp.PrintCode (cp);
+                       cp.Write ("++");
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return exp.GetResultType();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeUnaryOperation.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeUnaryOperation.cs
new file mode 100644 (file)
index 0000000..10f5cde
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeNeg: CodeExpression
+       {
+               CodeExpression exp;
+               
+               public CodeNeg (CodeExpression exp)
+               {
+                       this.exp = exp;
+                       if (!exp.IsNumber)
+                               throw new InvalidOperationException ("Operator '-' cannot be applied to operand of type '" + exp.GetResultType().FullName + "'");
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp.Generate (gen);
+                       gen.Emit (OpCodes.Neg);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write ("-");
+                       exp.PrintCode (cp);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return exp.GetResultType();
+               }
+       }
+       
+       public class CodeNot: CodeConditionExpression
+       {
+               CodeExpression exp;
+               
+               public CodeNot (CodeExpression exp)
+               {
+                       this.exp = exp;
+                       if (exp.GetResultType() != typeof(bool))
+                               throw new InvalidOperationException ("Operator '!' cannot be applied to operand of type '" + exp.GetResultType().FullName + "'");
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       exp.Generate (gen);
+                       gen.Emit (OpCodes.Ldc_I4_0);
+                       gen.Emit (OpCodes.Ceq);
+               }
+               
+               public override void GenerateForBranch (ILGenerator gen, Label label, bool branchCase)
+               {
+                       if (exp is CodeConditionExpression) {
+                               ((CodeConditionExpression)exp).GenerateForBranch (gen, label, !branchCase);
+                       }
+                       else {
+                               exp.Generate (gen);
+                               if (branchCase)
+                                       gen.Emit (OpCodes.Brfalse, label);
+                               else
+                                       gen.Emit (OpCodes.Brtrue, label);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write ("!");
+                       exp.PrintCode (cp);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return typeof(bool);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeValueReference.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeValueReference.cs
new file mode 100644 (file)
index 0000000..712d55c
--- /dev/null
@@ -0,0 +1,34 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public abstract class CodeValueReference: CodeExpression
+       {
+               public abstract void GenerateSet (ILGenerator gen, CodeExpression value);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeVariableDeclaration.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeVariableDeclaration.cs
new file mode 100644 (file)
index 0000000..a96a077
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeVariableDeclaration: CodeStatement
+       {
+               CodeVariableReference var;
+               
+               public CodeVariableDeclaration (Type type, string name)
+               {
+                       var = new CodeVariableReference (type, name);
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       var.LocalBuilder = gen.DeclareLocal (var.Type);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write (var.Type.FullName + " " + var.Name);
+               }
+               
+               public CodeVariableReference Variable
+               {
+                       get { return var; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeVariableReference.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeVariableReference.cs
new file mode 100644 (file)
index 0000000..01fc93f
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeVariableReference: CodeValueReference
+       {
+               LocalBuilder localBuilder;
+               Type type;
+               string name;
+               
+               public CodeVariableReference (Type type, string name)
+               {
+                       this.type = type;
+                       this.name = name;               
+               }
+               
+               public Type Type
+               {
+                       get { return type; }
+               }
+               
+               public string Name
+               {
+                       get { return name; }
+               }
+               
+               internal LocalBuilder LocalBuilder
+               {
+                       get { return localBuilder; }
+                       set { localBuilder = value; }
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       gen.Emit (OpCodes.Ldloc, localBuilder);
+               }
+               
+               public override void GenerateSet (ILGenerator gen, CodeExpression value)
+               {
+                       value.Generate (gen);
+                       CodeGenerationHelper.GenerateSafeConversion (gen, type, value.GetResultType ());
+                       gen.Emit (OpCodes.Stloc, localBuilder);
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write (name);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return type;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeWhen.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeWhen.cs
new file mode 100644 (file)
index 0000000..b5d1eb9
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeWhen: CodeExpression
+       {
+               CodeExpression condition;
+               CodeExpression trueBlock;
+               CodeExpression falseBlock;
+               
+               public CodeWhen (CodeExpression condition, CodeExpression trueResult, CodeExpression falseResult)
+               {
+                       this.condition = condition;
+                       if (condition.GetResultType () != typeof(bool))
+                               throw new InvalidOperationException ("Condition expression is not boolean");
+                       if (trueResult.GetResultType() != falseResult.GetResultType())
+                               throw new InvalidOperationException ("The types of the true and false expressions must be the same");
+                       trueBlock = trueResult;
+                       falseBlock = falseResult;
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       Label falseLabel = gen.DefineLabel ();
+                       Label endLabel = gen.DefineLabel ();
+                       
+                       GenerateCondition (gen, falseLabel);
+                       trueBlock.Generate (gen);
+                       gen.Emit (OpCodes.Br, endLabel);
+                       gen.MarkLabel(falseLabel);
+                       falseBlock.Generate (gen);
+                       
+                       gen.MarkLabel(endLabel);
+               }
+               
+               void GenerateCondition (ILGenerator gen, Label falseLabel)
+               {
+                       if (condition is CodeConditionExpression)
+                               ((CodeConditionExpression)condition).GenerateForBranch (gen, falseLabel, false);
+                       else {
+                               condition.Generate (gen);
+                               gen.Emit (OpCodes.Brfalse, falseLabel);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write ("(");
+                       condition.PrintCode (cp);
+                       cp.Write (") ? ");
+                       trueBlock.PrintCode (cp);
+                       cp.Write (" : ");
+                       falseBlock.PrintCode (cp);
+               }
+               
+               public override Type GetResultType ()
+               {
+                       return trueBlock.GetResultType();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeWhile.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeWhile.cs
new file mode 100644 (file)
index 0000000..0814a4c
--- /dev/null
@@ -0,0 +1,78 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class CodeWhile: CodeStatement
+       {
+               CodeExpression condition;
+               CodeBlock whileBlock;
+               
+               public CodeWhile (CodeExpression condition)
+               {
+                       this.condition = condition;
+                       if (condition.GetResultType () != typeof(bool))
+                               throw new InvalidOperationException ("Condition expression is not boolean"); 
+               }
+               
+               public override void Generate (ILGenerator gen)
+               {
+                       Label startLabel = gen.DefineLabel ();
+                       Label checkLabel = gen.DefineLabel ();
+                       
+                       gen.Emit (OpCodes.Br, checkLabel);
+                       gen.MarkLabel(startLabel);
+                       whileBlock.Generate (gen);
+                       gen.MarkLabel(checkLabel);
+                       
+                       if (condition is CodeConditionExpression)
+                               ((CodeConditionExpression)condition).GenerateForBranch (gen, startLabel, true);
+                       else {
+                               condition.Generate (gen);
+                               gen.Emit (OpCodes.Brtrue, startLabel);
+                       }
+               }
+               
+               public override void PrintCode (CodeWriter cp)
+               {
+                       cp.Write ("while (");
+                       condition.PrintCode (cp);
+                       cp.Write (") {");
+                       cp.EndLine ();
+                       cp.Indent ();
+                       whileBlock.PrintCode (cp);
+                       cp.Unindent ();
+                       cp.BeginLine ().Write ("}");
+               }
+               
+               public CodeBlock WhileBlock
+               {
+                       get { return whileBlock; }
+                       set { whileBlock = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeWriter.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/CodeWriter.cs
new file mode 100644 (file)
index 0000000..cdcdb17
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.IO;
+
+public class CodeWriter
+{
+       TextWriter writer;
+       int indent;
+       
+       public CodeWriter (TextWriter tw)
+       {
+               writer = tw;
+       }
+       
+       public CodeWriter BeginLine ()
+       {
+               writer.Write (new String (' ', indent*4));
+               return this;
+       }
+       
+       public CodeWriter Write (string s)
+       {
+               writer.Write (s);
+               return this;
+       }
+       
+       public CodeWriter EndLine ()
+       {
+               writer.WriteLine ();
+               return this;
+       }
+       
+       public CodeWriter WriteLine (string s)
+       {
+               BeginLine ();
+               Write (s);
+               EndLine ();
+               return this;
+       }
+       
+       public CodeWriter WriteLineInd (string s)
+       {
+               WriteLine (s);
+               indent++;
+               return this;
+       }
+       
+       public CodeWriter WriteLineUnind (string s)
+       {
+               indent--;
+               WriteLine (s);
+               return this;
+       }
+       
+       public void Indent ()
+       {
+               indent++;
+       }
+       
+       public void Unindent ()
+       {
+               indent--;
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.CodeGeneration/Exp.cs b/mcs/class/System.ServiceModel/Mono.CodeGeneration/Exp.cs
new file mode 100644 (file)
index 0000000..f1fe56c
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (C) Lluis Sanchez Gual, 2004
+//
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+
+namespace Mono.CodeGeneration
+{
+       public class Exp
+       {
+               Exp () {}
+               
+               public static CodeExpression Literal (object ob) { return new CodeLiteral (ob); }
+               public static CodeExpression Literal (string ob) { return new CodeLiteral (ob, typeof(string)); }
+               
+               public static CodeExpression New (Type type, params CodeExpression[] pars)
+               {
+                       return new CodeNew (type, pars);
+               }
+               
+               public static CodeExpression NewArray (Type type, CodeExpression size)
+               {
+                       return new CodeNewArray (type, size);
+               }
+               
+               public static CodeExpression And (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeAnd (e1, e2);
+               } 
+               
+               public static CodeExpression And (CodeExpression e1, CodeExpression e2, CodeExpression e3)
+               {
+                       return new CodeAnd (new CodeAnd (e1, e2), e3);
+               } 
+               
+               public static CodeExpression Or (CodeExpression e1, CodeExpression e2)
+               {
+                       return new CodeOr (e1, e2);
+               }
+                
+               public static CodeValueReference Inc (CodeValueReference e)
+               {
+                       return new CodeIncrement (e);
+               } 
+               
+               public static CodeExpression Call (CodeExpression target, string name, params CodeExpression[] parameters)
+               {
+                       return new CodeMethodCall (target, name, parameters);
+               }
+               
+               public static CodeExpression Call (CodeExpression target, MethodInfo method, params CodeExpression[] parameters)
+               {
+                       return new CodeMethodCall (target, method, parameters);
+               }
+               
+               public static CodeExpression Call (CodeExpression target, CodeMethod method, params CodeExpression[] parameters)
+               {
+                       return new CodeMethodCall (target, method, parameters);
+               }
+               
+               public static CodeExpression Call (Type type, string name, params CodeExpression[] parameters)
+               {
+                       return new CodeMethodCall (type, name, parameters);
+               }
+               
+               public static CodeExpression Call (MethodInfo method, params CodeExpression[] parameters)
+               {
+                       return new CodeMethodCall (method, parameters);
+               }
+               
+               public static CodeExpression Call (CodeMethod method, params CodeExpression[] parameters)
+               {
+                       return new CodeMethodCall (method, parameters);
+               }
+               
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Cryptography/MD5SHA1.cs b/mcs/class/System.ServiceModel/Mono.Security.Cryptography/MD5SHA1.cs
new file mode 100644 (file)
index 0000000..f22400a
--- /dev/null
@@ -0,0 +1,148 @@
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003-2004 Carlos Guzman Alvarez
+ * 
+ * Permission is hereby granted, free of charge, to any person 
+ * obtaining a copy of this software and associated documentation 
+ * files (the "Software"), to deal in the Software without restriction, 
+ * including without limitation the rights to use, copy, modify, merge, 
+ * publish, distribute, sublicense, and/or sell copies of the Software, 
+ * and to permit persons to whom the Software is furnished to do so, 
+ * subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Protocol.Tls;
+
+namespace Mono.Security.Cryptography
+{
+       internal class MD5SHA1 : HashAlgorithm
+       {
+               #region Fields
+
+               private HashAlgorithm   md5;
+               private HashAlgorithm   sha;
+               private bool                    hashing;
+
+               #endregion
+
+               #region Constructors
+
+               public MD5SHA1() : base()
+               {
+                       this.md5 = MD5.Create();
+                       this.sha = SHA1.Create();
+
+                       // Set HashSizeValue
+                       this.HashSizeValue = this.md5.HashSize + this.sha.HashSize;
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Initialize()
+               {
+                       this.md5.Initialize();
+                       this.sha.Initialize();
+                       this.hashing = false;
+               }
+
+               protected override byte[] HashFinal()
+               {
+                       if (!hashing)
+                       {
+                               this.hashing = true;
+                       }
+                       // Finalize the original hash
+                       this.md5.TransformFinalBlock(new byte[0], 0, 0);
+                       this.sha.TransformFinalBlock(new byte[0], 0, 0);
+
+                       byte[] hash = new byte[36];
+
+                       Buffer.BlockCopy(this.md5.Hash, 0, hash, 0, 16);
+                       Buffer.BlockCopy(this.sha.Hash, 0, hash, 16, 20);
+
+                       return hash;
+               }
+
+               protected override void HashCore(
+                       byte[] array,
+                       int ibStart,
+                       int cbSize)
+               {
+                       if (!hashing)
+                       {
+                               hashing = true;
+                       }
+                       this.md5.TransformBlock(array, ibStart, cbSize, array, ibStart);
+                       this.sha.TransformBlock(array, ibStart, cbSize, array, ibStart);
+               }
+
+               public byte[] CreateSignature(RSA rsa) 
+               {
+                       if (rsa == null)
+                       {
+                               throw new CryptographicUnexpectedOperationException ("missing key");
+                       }
+
+                       RSASslSignatureFormatter f = new RSASslSignatureFormatter(rsa);
+                       f.SetHashAlgorithm("MD5SHA1");
+
+                       return f.CreateSignature(this.Hash);
+               }
+
+               public bool VerifySignature(RSA rsa, byte[] rgbSignature) 
+               {
+                       if (rsa == null)
+                       {
+                               throw new CryptographicUnexpectedOperationException ("missing key");
+                       }
+                       if (rgbSignature == null)
+                       {
+                               throw new ArgumentNullException ("rgbSignature");
+                       }
+
+                       RSASslSignatureDeformatter d = new RSASslSignatureDeformatter(rsa);
+                       d.SetHashAlgorithm("MD5SHA1");
+
+                       return d.VerifySignature(this.Hash, rgbSignature);
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Cryptography/README.olive b/mcs/class/System.ServiceModel/Mono.Security.Cryptography/README.olive
new file mode 100644 (file)
index 0000000..522f3fc
--- /dev/null
@@ -0,0 +1 @@
+Imported from Mono.Security.dll
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Cryptography/TlsHMAC.cs b/mcs/class/System.ServiceModel/Mono.Security.Cryptography/TlsHMAC.cs
new file mode 100644 (file)
index 0000000..722d2e5
--- /dev/null
@@ -0,0 +1,212 @@
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+/* Transport Security Layer (TLS)
+ * Copyright (c) 2003-2004 Carlos Guzman Alvarez
+ * 
+ * Permission is hereby granted, free of charge, to any person 
+ * obtaining a copy of this software and associated documentation 
+ * files (the "Software"), to deal in the Software without restriction, 
+ * including without limitation the rights to use, copy, modify, merge, 
+ * publish, distribute, sublicense, and/or sell copies of the Software, 
+ * and to permit persons to whom the Software is furnished to do so, 
+ * subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included 
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+using System.Security.Cryptography;
+
+namespace Mono.Security.Cryptography
+{
+   /*
+       * References:
+       *               RFC 2104 (http://www.ietf.org/rfc/rfc2104.txt)
+       *               RFC 2202 (http://www.ietf.org/rfc/rfc2202.txt)
+       * MSDN:
+       * 
+       *               Extending the KeyedHashAlgorithm Class (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconextendingkeyedhashalgorithmclass.asp)
+       */
+       internal class HMAC : System.Security.Cryptography.KeyedHashAlgorithm
+       {
+               #region Fields
+
+               private HashAlgorithm   hash;
+               private bool                    hashing;
+
+               private byte[]                  innerPad;
+               private byte[]                  outerPad;
+
+               #endregion
+
+               #region Properties
+        
+               public override byte[] Key
+               {
+                       get { return (byte[])KeyValue.Clone(); }
+                       set
+                       {
+                               if (hashing)
+                               {
+                                       throw new Exception("Cannot change key during hash operation.");
+                               }
+
+                               /* if key is longer than 64 bytes reset it to rgbKey = Hash(rgbKey) */
+                               if (value.Length > 64)
+                               {
+                                       KeyValue = hash.ComputeHash(value);
+                               }
+                               else
+                               {
+                                       KeyValue = (byte[])value.Clone();
+                               }
+
+                               initializePad();
+                       }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public HMAC()
+               {
+                       // Create the hash
+                       hash = MD5.Create();
+                       // Set HashSizeValue
+                       HashSizeValue = hash.HashSize;
+
+                       // Generate a radom key
+                       byte[] rgbKey = new byte[64];
+                       RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
+                       rng.GetNonZeroBytes(rgbKey);
+
+                       KeyValue = (byte[])rgbKey.Clone();
+
+                       this.Initialize();
+               }
+
+               public HMAC(string hashName, byte[] rgbKey)
+               {
+                       // Create the hash
+                       if (hashName == null || hashName.Length == 0)
+                       {
+                               hashName = "MD5";
+                       }
+                       hash = HashAlgorithm.Create(hashName);
+                       // Set HashSizeValue
+                       HashSizeValue = hash.HashSize;
+
+                       /* if key is longer than 64 bytes reset it to rgbKey = Hash(rgbKey) */
+                       if (rgbKey.Length > 64)
+                       {
+                               KeyValue = hash.ComputeHash(rgbKey);
+                       }
+                       else
+                       {
+                               KeyValue = (byte[])rgbKey.Clone();
+                       }
+
+                       this.Initialize();
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Initialize()
+               {
+                       hash.Initialize();
+                       initializePad();
+                       hashing = false;
+               }
+
+               protected override byte[] HashFinal()
+               {
+                       if (!hashing)
+                       {
+                               hash.TransformBlock(innerPad, 0, innerPad.Length, innerPad, 0);
+                               hashing = true;
+                       }
+                       // Finalize the original hash
+                       hash.TransformFinalBlock(new byte[0], 0, 0);
+
+                       byte[] firstResult = hash.Hash;
+
+                       hash.Initialize();
+                       hash.TransformBlock(outerPad, 0, outerPad.Length, outerPad, 0);
+                       hash.TransformFinalBlock(firstResult, 0, firstResult.Length);
+                       
+                       Initialize();
+
+                       return hash.Hash;
+               }
+
+               protected override void HashCore(
+                       byte[] array,
+                       int ibStart,
+                       int cbSize)
+               {
+                       if (!hashing)
+                       {
+                               hash.TransformBlock(innerPad, 0, innerPad.Length, innerPad, 0);
+                               hashing = true;
+                       }
+                       hash.TransformBlock(array, ibStart, cbSize, array, ibStart);
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void initializePad()
+               {
+                       // Fill pad arrays
+                       innerPad = new byte[64];
+                       outerPad = new byte[64];
+
+                       /* Pad the key for inner and outer digest */
+                       for (int i = 0 ; i < KeyValue.Length; ++i)
+                       {
+                               innerPad[i] = (byte)(KeyValue[i] ^ 0x36);
+                               outerPad[i] = (byte)(KeyValue[i] ^ 0x5C);
+                       }
+                       for (int i = KeyValue.Length; i < 64; ++i) 
+                       {
+                               innerPad[i] = 0x36;
+                               outerPad[i] = 0x5C;
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/BitConverterLE.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/BitConverterLE.cs
new file mode 100755 (executable)
index 0000000..a787f50
--- /dev/null
@@ -0,0 +1,239 @@
+//
+// Mono.Security.BitConverterLE.cs
+//  Like System.BitConverter but always little endian
+//
+// Author:
+//   Bernie Solomon
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security
+{
+       internal sealed class BitConverterLE
+       {
+               private BitConverterLE ()
+               {
+               }
+
+               unsafe private static byte[] GetUShortBytes (byte *bytes)
+               {
+                       if (BitConverter.IsLittleEndian)
+                               return new byte [] { bytes [0], bytes [1] };
+                       else
+                               return new byte [] { bytes [1], bytes [0] };
+               }
+
+               unsafe private static byte[] GetUIntBytes (byte *bytes)
+               {
+                       if (BitConverter.IsLittleEndian)
+                               return new byte [] { bytes [0], bytes [1], bytes [2], bytes [3] };
+                       else
+                               return new byte [] { bytes [3], bytes [2], bytes [1], bytes [0] };
+               }
+
+               unsafe private static byte[] GetULongBytes (byte *bytes)
+               {
+                       if (BitConverter.IsLittleEndian)
+                               return new byte [] { bytes [0], bytes [1], bytes [2], bytes [3],
+                                                    bytes [4], bytes [5], bytes [6], bytes [7] };
+                       else
+                               return new byte [] { bytes [7], bytes [6], bytes [5], bytes [4],
+                                                    bytes [3], bytes [2], bytes [1], bytes [0] };
+               }
+
+               unsafe internal static byte[] GetBytes (bool value)
+               {
+                       return new byte [] { value ? (byte)1 : (byte)0 };
+               }
+
+               unsafe internal static byte[] GetBytes (char value)
+               {
+                       return GetUShortBytes ((byte *) &value);
+               }
+
+               unsafe internal static byte[] GetBytes (short value)
+               {
+                       return GetUShortBytes ((byte *) &value);
+               }
+
+               unsafe internal static byte[] GetBytes (int value)
+               {
+                       return GetUIntBytes ((byte *) &value);
+               }
+
+               unsafe internal static byte[] GetBytes (long value)
+               {
+                       return GetULongBytes ((byte *) &value);
+               }
+
+               unsafe internal static byte[] GetBytes (ushort value)
+               {
+                       return GetUShortBytes ((byte *) &value);
+               }
+
+               unsafe internal static byte[] GetBytes (uint value)
+               {
+                       return GetUIntBytes ((byte *) &value);
+               }
+
+               unsafe internal static byte[] GetBytes (ulong value)
+               {
+                       return GetULongBytes ((byte *) &value);
+               }
+
+               unsafe internal static byte[] GetBytes (float value)
+               {
+                       return GetUIntBytes ((byte *) &value);
+               }
+
+               unsafe internal static byte[] GetBytes (double value)
+               {
+                       return GetULongBytes ((byte *) &value);
+               }
+
+               unsafe private static void UShortFromBytes (byte *dst, byte[] src, int startIndex)
+               {
+                       if (BitConverter.IsLittleEndian) {
+                               dst [0] = src [startIndex];
+                               dst [1] = src [startIndex + 1];
+                       } else {
+                               dst [0] = src [startIndex + 1];
+                               dst [1] = src [startIndex];
+                       }
+               }
+
+               unsafe private static void UIntFromBytes (byte *dst, byte[] src, int startIndex)
+               {
+                       if (BitConverter.IsLittleEndian) {
+                               dst [0] = src [startIndex];
+                               dst [1] = src [startIndex + 1];
+                               dst [2] = src [startIndex + 2];
+                               dst [3] = src [startIndex + 3];
+                       } else {
+                               dst [0] = src [startIndex + 3];
+                               dst [1] = src [startIndex + 2];
+                               dst [2] = src [startIndex + 1];
+                               dst [3] = src [startIndex];
+                       }
+               }
+
+               unsafe private static void ULongFromBytes (byte *dst, byte[] src, int startIndex)
+               {
+                       if (BitConverter.IsLittleEndian) {
+                               for (int i = 0; i < 8; ++i)
+                                       dst [i] = src [startIndex + i];
+                       } else {
+                               for (int i = 0; i < 8; ++i)
+                                       dst [i] = src [startIndex + (7 - i)];
+                       }
+               }
+
+               unsafe internal static bool ToBoolean (byte[] value, int startIndex)
+               {
+                       return value [startIndex] != 0;
+               }
+
+               unsafe internal static char ToChar (byte[] value, int startIndex)
+               {
+                       char ret;
+
+                       UShortFromBytes ((byte *) &ret, value, startIndex);
+
+                       return ret;
+               }
+
+               unsafe internal static short ToInt16 (byte[] value, int startIndex)
+               {
+                       short ret;
+
+                       UShortFromBytes ((byte *) &ret, value, startIndex);
+
+                       return ret;
+               }
+
+               unsafe internal static int ToInt32 (byte[] value, int startIndex)
+               {
+                       int ret;
+
+                       UIntFromBytes ((byte *) &ret, value, startIndex);
+
+                       return ret;
+               }
+
+               unsafe internal static long ToInt64 (byte[] value, int startIndex)
+               {
+                       long ret;
+
+                       ULongFromBytes ((byte *) &ret, value, startIndex);
+
+                       return ret;
+               }
+
+               unsafe internal static ushort ToUInt16 (byte[] value, int startIndex)
+               {
+                       ushort ret;
+
+                       UShortFromBytes ((byte *) &ret, value, startIndex);
+
+                       return ret;
+               }
+
+               unsafe internal static uint ToUInt32 (byte[] value, int startIndex)
+               {
+                       uint ret;
+
+                       UIntFromBytes ((byte *) &ret, value, startIndex);
+
+                       return ret;
+               }
+
+               unsafe internal static ulong ToUInt64 (byte[] value, int startIndex)
+               {
+                       ulong ret;
+
+                       ULongFromBytes ((byte *) &ret, value, startIndex);
+
+                       return ret;
+               }
+
+               unsafe internal static float ToSingle (byte[] value, int startIndex)
+               {
+                       float ret;
+
+                       UIntFromBytes ((byte *) &ret, value, startIndex);
+
+                       return ret;
+               }
+
+               unsafe internal static double ToDouble (byte[] value, int startIndex)
+               {
+                       double ret;
+
+                       ULongFromBytes ((byte *) &ret, value, startIndex);
+
+                       return ret;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs
new file mode 100755 (executable)
index 0000000..2aabc94
--- /dev/null
@@ -0,0 +1,248 @@
+//
+// Mono.Security.Protocol.Ntlm.ChallengeResponse
+//     Implements Challenge Response for NTLM v1
+//
+// Author:
+//     Sebastien Pouliot <sebastien@ximian.com>
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+// (C) 2004, 2007 Novell (http://www.novell.com)
+//
+// References
+// a.  NTLM Authentication Scheme for HTTP, Ronald Tschalär
+//     http://www.innovation.ch/java/ntlm.html
+// b.  The NTLM Authentication Protocol, Copyright © 2003 Eric Glass
+//     http://davenport.sourceforge.net/ntlm.html
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Globalization;
+using System.Security.Cryptography;
+using System.Text;
+
+using Mono.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Ntlm {
+
+       public class ChallengeResponse : IDisposable {
+
+               static private byte[] magic = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 };
+
+               // This is the pre-encrypted magic value with a null DES key (0xAAD3B435B51404EE)
+               // Ref: http://packetstormsecurity.nl/Crackers/NT/l0phtcrack/l0phtcrack2.5-readme.html
+               static private byte[] nullEncMagic = { 0xAA, 0xD3, 0xB4, 0x35, 0xB5, 0x14, 0x04, 0xEE };
+
+               private bool _disposed;
+               private byte[] _challenge;
+               private byte[] _lmpwd;
+               private byte[] _ntpwd;
+
+               // constructors
+
+               public ChallengeResponse () 
+               {
+                       _disposed = false;
+                       _lmpwd = new byte [21];
+                       _ntpwd = new byte [21];
+               }
+               
+               public ChallengeResponse (string password, byte[] challenge) : this ()
+               {
+                       Password = password;
+                       Challenge = challenge;
+               }
+
+               ~ChallengeResponse () 
+               {
+                       if (!_disposed)
+                               Dispose ();
+               }
+
+               // properties
+
+               public string Password {
+                       get { return null; }
+                       set { 
+                               if (_disposed)
+                                       throw new ObjectDisposedException ("too late");
+
+                               // create Lan Manager password
+                               DES des = DES.Create ();
+                               des.Mode = CipherMode.ECB;
+                               ICryptoTransform ct = null;
+                               
+                               // Note: In .NET DES cannot accept a weak key
+                               // this can happen for a null password
+                               if ((value == null) || (value.Length < 1)) {
+                                       Buffer.BlockCopy (nullEncMagic, 0, _lmpwd, 0, 8);
+                               }
+                               else {
+                                       des.Key = PasswordToKey (value, 0);
+                                       ct = des.CreateEncryptor ();
+                                       ct.TransformBlock (magic, 0, 8, _lmpwd, 0);
+                               }
+
+                               // and if a password has less than 8 characters
+                               if ((value == null) || (value.Length < 8)) {
+                                       Buffer.BlockCopy (nullEncMagic, 0, _lmpwd, 8, 8);
+                               }
+                               else {
+                                       des.Key = PasswordToKey (value, 7);
+                                       ct = des.CreateEncryptor ();
+                                       ct.TransformBlock (magic, 0, 8, _lmpwd, 8);
+                               }
+
+                               // create NT password
+                               MD4 md4 = MD4.Create ();
+                               byte[] data = ((value == null) ? (new byte [0]) : (Encoding.Unicode.GetBytes (value)));
+                               byte[] hash = md4.ComputeHash (data);
+                               Buffer.BlockCopy (hash, 0, _ntpwd, 0, 16);
+
+                               // clean up
+                               Array.Clear (data, 0, data.Length);
+                               Array.Clear (hash, 0, hash.Length);
+                               des.Clear ();
+                       }
+               }
+
+               public byte[] Challenge {
+                       get { return null; }
+                       set {
+                               if (value == null)
+                                       throw new ArgumentNullException ("Challenge");
+                               if (_disposed)
+                                       throw new ObjectDisposedException ("too late");
+                               // we don't want the caller to modify the value afterward
+                               _challenge = (byte[]) value.Clone ();
+                       }
+               }
+
+               public byte[] LM {
+                       get { 
+                               if (_disposed)
+                                       throw new ObjectDisposedException ("too late");
+
+                               return GetResponse (_lmpwd);
+                       }
+               }
+
+               public byte[] NT {
+                       get { 
+                               if (_disposed)
+                                       throw new ObjectDisposedException ("too late");
+
+                               return GetResponse (_ntpwd);
+                       }
+               }
+
+               public byte [] LMSessionKey {
+                       get {
+                               if (_disposed)
+                                       throw new ObjectDisposedException ("too late");
+
+                               byte[] lm = LM;
+                               byte[] pwd = new byte [14];
+                               Buffer.BlockCopy (lm, 0, pwd, 0, 8);
+                               for (int i = 8; i < 14; i++)
+                                       pwd [i] = 0xBD;
+                               byte[] response = new byte [16];
+                               DES des = DES.Create ();
+                               des.Mode = CipherMode.ECB;
+                               des.Key = PrepareDESKey (pwd, 0);
+                               ICryptoTransform ct = des.CreateEncryptor ();
+                               ct.TransformBlock (lm, 0, 8, response, 0);
+                               des.Key = PrepareDESKey (pwd, 7);
+                               ct = des.CreateEncryptor ();
+                               ct.TransformBlock (lm, 0, 8, response, 8);
+                               return response;
+                       }
+               }
+
+               // IDisposable method
+
+               public void Dispose () 
+               {
+                       Dispose (true);
+                       GC.SuppressFinalize (this);
+               }
+
+               private void Dispose (bool disposing) 
+               {
+                       if (!_disposed) {
+                               // cleanup our stuff
+                               Array.Clear (_lmpwd, 0, _lmpwd.Length);
+                               Array.Clear (_ntpwd, 0, _ntpwd.Length);
+                               if (_challenge != null)
+                                       Array.Clear (_challenge, 0, _challenge.Length);
+                               _disposed = true;
+                       }
+               }
+
+               // private methods
+
+               private byte[] GetResponse (byte[] pwd) 
+               {
+                       byte[] response = new byte [24];
+                       DES des = DES.Create ();
+                       des.Mode = CipherMode.ECB;
+                       des.Key = PrepareDESKey (pwd, 0);
+                       ICryptoTransform ct = des.CreateEncryptor ();
+                       ct.TransformBlock (_challenge, 0, 8, response, 0);
+                       des.Key = PrepareDESKey (pwd, 7);
+                       ct = des.CreateEncryptor ();
+                       ct.TransformBlock (_challenge, 0, 8, response, 8);
+                       des.Key = PrepareDESKey (pwd, 14);
+                       ct = des.CreateEncryptor ();
+                       ct.TransformBlock (_challenge, 0, 8, response, 16);
+                       return response;
+               }
+
+               private byte[] PrepareDESKey (byte[] key56bits, int position) 
+               {
+                       // convert to 8 bytes
+                       byte[] key = new byte [8];
+                       key [0] = key56bits [position];
+                       key [1] = (byte) ((key56bits [position] << 7)     | (key56bits [position + 1] >> 1));
+                       key [2] = (byte) ((key56bits [position + 1] << 6) | (key56bits [position + 2] >> 2));
+                       key [3] = (byte) ((key56bits [position + 2] << 5) | (key56bits [position + 3] >> 3));
+                       key [4] = (byte) ((key56bits [position + 3] << 4) | (key56bits [position + 4] >> 4));
+                       key [5] = (byte) ((key56bits [position + 4] << 3) | (key56bits [position + 5] >> 5));
+                       key [6] = (byte) ((key56bits [position + 5] << 2) | (key56bits [position + 6] >> 6));
+                       key [7] = (byte)  (key56bits [position + 6] << 1);
+                       return key;
+               }
+
+               private byte[] PasswordToKey (string password, int position) 
+               {
+                       byte[] key7 = new byte [7];
+                       int len = System.Math.Min (password.Length - position, 7);
+                       Encoding.ASCII.GetBytes (password.ToUpper (CultureInfo.CurrentCulture), position, len, key7, 0);
+                       byte[] key8 = PrepareDESKey (key7, 0);
+                       // cleanup intermediate key material
+                       Array.Clear (key7, 0, key7.Length);
+                       return key8;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/ChangeLog b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/ChangeLog
new file mode 100755 (executable)
index 0000000..9fb92fe
--- /dev/null
@@ -0,0 +1,64 @@
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Type2Message.cs Type3Message.cs : let's just commit my updates to
+         ntlm stuff here as I have done before ahead of sys.security.dll.
+
+2007-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Type1Message.cs : handle offsets per (assumed) document.
+
+         (It should be re-examined in Mono.Security with SqlClient btw...)
+
+2007-03-27  Atsushi Enomoto
+
+       This is temporary addition so do not expect further change here
+       unless these changes are not merged into mcs/class/Mono.Security.
+
+2004-11-05  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * MessageBase.cs: Fixed endian issue. Added globalization support.
+       * Type1Message.cs: Fixed endian issue. Added globalization support.
+       * Type2Message.cs: Fixed endian issue.
+       * Type3Message.cs: Fixed endian issue. Added globalization support.
+
+2004-04-22  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * ChallengeResponse.cs: FxCop-ized. 
+       * NtlmFlags.cs: FxCop-ized. CLS compliance.
+       * Type1Message.cs: FxCop-ized.
+       * Type3Message.cs: FxCop-ized.
+
+2004-04-20  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * NtlmFlags.cs: Changed enum to int for CLS compliance.
+
+2003-12-17  Sebastien Pouliot  <spouliot@videotron.ca>
+
+       * ChallengeResponse.cs: Sorry I must have a profesionnal problem with
+       weak passwords ;-). Anyway I corrected the CR for null passwords (which
+       would produce a weak key for the first DES key) and added clean up :).
+       However it (null password) doesn't work for SQL Server authentication ?
+
+2003-12-15  Sebastien Pouliot  <spouliot@videotron.ca>
+
+       * ChallengeResponse.cs: Pre-calculated second part of the LM hash for 
+       small password. Otherwise we get a  DES weak key - which isn't 
+       supported (exception) by the framework.
+
+2003-12-02  Sebastien Pouliot  <spouliot@videotron.ca>
+
+       * ChallengeResponse.cs: Fixed compilation error with mcs (System.Math.Min)
+       * Type2Message.cs: Fixed compilation warning for override. Flags are now
+       32 bits.
+       * Type3Message.cs: Fixed compilation warning for override. Removed (old)
+       header code to use base class. Changed 16 bits Options for 32 bits Flags 
+       (NtlmFlags).
+
+2003-12-01  Sebastien Pouliot  <spouliot@videotron.ca>
+
+       * ChallengeResponse.cs: New. Implements the NTLM (v1) Challenge Response.
+       * MessageBase.cs: New. Abstract base class for NTLM messages.
+       * NtlmFlags.cs: New. All known flags for NTLM.
+       * Type1Message.cs: New. Negotiation message.
+       * Type2Message.cs: New. Challenge message.
+       * Type3Message.cs: New. Authentication message.
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/MessageBase.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/MessageBase.cs
new file mode 100755 (executable)
index 0000000..b1d0dc6
--- /dev/null
@@ -0,0 +1,140 @@
+//
+// Mono.Security.Protocol.Ntlm.MessageBase
+//     abstract class for all NTLM messages
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2004, 2007 Novell, Inc (http://www.novell.com)
+//
+// References
+// a.  NTLM Authentication Scheme for HTTP, Ronald Tschalär
+//     http://www.innovation.ch/java/ntlm.html
+// b.  The NTLM Authentication Protocol, Copyright © 2003 Eric Glass
+//     http://davenport.sourceforge.net/ntlm.html
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Globalization;
+
+namespace Mono.Security.Protocol.Ntlm {
+
+       public abstract class MessageBase {
+               static byte [] _current_os_version = GetOSVersion ();
+
+               static byte [] GetOSVersion ()
+               {
+                       Version v = Environment.OSVersion.Version;
+                       byte [] bytes = new byte [8];
+                       bytes [0] = (byte) v.Major;
+                       bytes [1] = (byte) v.Minor;
+                       bytes [2] = (byte) v.Build;
+                       bytes [3] = (byte) (v.Build >> 8);
+                       bytes [7] = 0xF;
+                       return bytes;
+               }
+
+               static private byte[] header = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00 };
+               
+               private int _type;
+               private NtlmFlags _flags;
+               private NtlmVersion _version;
+               private byte [] _osversion = _current_os_version;
+
+               protected MessageBase (int messageType) : this (messageType, NtlmVersion.Version1)
+               {
+               }
+               protected MessageBase (int messageType, NtlmVersion version) 
+               {
+                       _type = messageType;
+                       _version = version;
+               }
+               
+               public NtlmFlags Flags {
+                       get { return _flags; }
+                       set { _flags = value; }
+               }
+
+               public byte [] OSVersion {
+                       get { return (byte []) _osversion.Clone (); }
+                       set { _osversion = (byte []) value.Clone (); }
+               }
+
+               public int Type { 
+                       get { return _type; }
+               }
+
+               public NtlmVersion Version {
+                       get { return _version; }
+               }
+
+               protected byte[] PrepareMessage (int messageSize) 
+               {
+                       byte[] message = new byte [messageSize];
+                       Buffer.BlockCopy (header, 0, message, 0, 8);
+                       
+                       message [ 8] = (byte) _type;
+                       message [ 9] = (byte)(_type >> 8);
+                       message [10] = (byte)(_type >> 16);
+                       message [11] = (byte)(_type >> 24);
+
+                       return message;
+               }
+
+               protected virtual void Decode (byte[] message) 
+               {
+                       if (message == null)
+                               throw new ArgumentNullException ("message");
+
+                       if (message.Length < 12) {
+                               string msg = Locale.GetText ("Minimum message length is 12 bytes.");
+                               throw new ArgumentOutOfRangeException ("message", message.Length, msg);
+                       }
+
+                       if (!CheckHeader (message)) {
+                               string msg = String.Format (Locale.GetText ("Invalid Type{0} message."), _type);
+                               throw new ArgumentException (msg, "message");
+                       }
+               }
+
+
+               protected bool CheckHeader (byte[] message) 
+               {
+                       for (int i=0; i < header.Length; i++) {
+                               if (message [i] != header [i])
+                                       return false;
+                       }
+                       return (BitConverterLE.ToUInt32 (message, 8) == _type);
+               }
+
+               public abstract byte[] GetBytes ();
+
+               internal byte [] CreateSubArray (byte [] source, int offset, int length)
+               {
+                       byte [] ret = new byte [length];
+                       Array.Copy (source, offset, ret, 0, length);
+                       return ret;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/NtlmFlags.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/NtlmFlags.cs
new file mode 100755 (executable)
index 0000000..7151c79
--- /dev/null
@@ -0,0 +1,78 @@
+//
+// Mono.Security.Protocol.Ntlm.NtlmFlags
+//
+// Author:
+//     Sebastien Pouliot <sebastien@ximian.com>
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+// (C) 2004, 2007 Novell (http://www.novell.com)
+//
+// References
+// a.  NTLM Authentication Scheme for HTTP, Ronald Tschalär
+//     http://www.innovation.ch/java/ntlm.html
+// b.  The NTLM Authentication Protocol, Copyright © 2003 Eric Glass
+//     http://davenport.sourceforge.net/ntlm.html
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Ntlm {
+
+       [Flags]
+       public enum NtlmFlags : int {
+               // The client sets this flag to indicate that it supports Unicode strings.
+               NegotiateUnicode = 0x00000001,
+               // This is set to indicate that the client supports OEM strings.
+               NegotiateOem = 0x00000002,
+               // This requests that the server send the authentication target with the Type 2 reply.
+               RequestTarget = 0x00000004,
+               // Negotiate Sign
+               NegotiateSign = 0x00000010,
+               // Negotiate Seal
+               NegotiateSeal = 0x00000020,
+               // Negotiate DatagramStyle
+               NegotiateDatagramStyle = 0x00000040,
+               // Negotiate Lan Manager Key
+               NegotiateLm = 0x00000080,
+               // Indicates that NTLM authentication is supported.
+               NegotiateNtlm = 0x00000200,
+               // Indicates that NTLM authentication is supported.
+               NegotiateAnonymous = 0x00000800,
+               // When set, the client will send with the message the name of the domain in which the workstation has membership.
+               NegotiateDomainSupplied = 0x00001000,
+               // Indicates that the client is sending its workstation name with the message.  
+               NegotiateWorkstationSupplied = 0x00002000,
+               // Indicates that communication between the client and server after authentication should carry a "dummy" signature.
+               NegotiateAlwaysSign = 0x00008000,
+               // Indicates that this client supports the NTLM2 signing and sealing scheme; if negotiated, this can also affect the response calculations.
+               NegotiateNtlm2Key = 0x00080000,
+               // Indicates that this client supports strong (128-bit) encryption.
+               Negotiate128 = 0x20000000,
+               // Negotiate Key Exchange
+               NegotiateKeyExchange = 0x40000000,
+               // Indicates that this client supports medium (56-bit) encryption.
+               Negotiate56 = (unchecked ((int) 0x80000000))
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/NtlmTargetInformation.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/NtlmTargetInformation.cs
new file mode 100755 (executable)
index 0000000..ecca459
--- /dev/null
@@ -0,0 +1,103 @@
+//
+// Mono.Security.Protocol.Ntlm.NtlmTargetInformation
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// (C) 2007 Novell, Inc. (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Text;
+
+namespace Mono.Security.Protocol.Ntlm {
+       public class NtlmTargetInformation {
+               string _server, _domain, _dns_host, _dns_domain;
+
+               public string ServerName {
+                       get { return _server; }
+                       set { _server = value; }
+               }
+
+               public string DomainName {
+                       get { return _domain; }
+                       set { _domain = value; }
+               }
+
+               public string DnsHostName {
+                       get { return _dns_host; }
+                       set { _dns_host = value; }
+               }
+
+               public string DnsDomainName {
+                       get { return _dns_domain; }
+                       set { _dns_domain = value; }
+               }
+
+               public void Decode (byte [] bytes, int length, int offset)
+               {
+                       int end = offset + length;
+                       for (int pos = offset; pos < end;) {
+                               short type = BitConverterLE.ToInt16 (bytes, pos); // reader.ReadInt16 ();
+                               short blen = BitConverterLE.ToInt16 (bytes, pos + 2); // reader.ReadInt16 ();
+                               string s = Encoding.Unicode.GetString (bytes, pos + 4, blen);
+                               pos += blen + 4;
+                               switch (type) {
+                               case 0: break; // terminator
+                               case 1: ServerName = s; break;
+                               case 2: DomainName = s; break;
+                               case 3: DnsHostName = s; break;
+                               case 4: DnsDomainName = s; break;
+                               default:
+                                       throw new ArgumentException (String.Format ("Invalid SSPI message type 2 subblock type: {0}", type));
+                               }
+                               if (type == 0)
+                                       break; // terminator subblock
+                       }
+               }
+
+               public byte [] ToBytes ()
+               {
+                       MemoryStream ms = new MemoryStream ();
+                       BinaryWriter bw = new BinaryWriter (ms);
+
+                       WriteName (bw, 1, ServerName);
+                       WriteName (bw, 2, DomainName);
+                       WriteName (bw, 3, DnsHostName);
+                       WriteName (bw, 4, DnsDomainName);
+                       bw.Close ();
+                       return ms.ToArray ();
+               }
+
+               private void WriteName (BinaryWriter bw, short type, string value)
+               {
+                       if (value == null)
+                               return;
+                       byte [] bytes = Encoding.Unicode.GetBytes (value);
+                       bw.Write (type);
+                       bw.Write ((short) bytes.Length);
+                       bw.Write (bytes);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/NtlmVersion.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/NtlmVersion.cs
new file mode 100755 (executable)
index 0000000..c96054e
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// Mono.Security.Protocol.Ntlm.NtlmVersion
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// (C) 2007 Novell, Inc. (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Ntlm 
+{
+       public enum NtlmVersion
+       {
+               Version1,
+               Version2,
+               Version3
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/Type1Message.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/Type1Message.cs
new file mode 100755 (executable)
index 0000000..a2dc077
--- /dev/null
@@ -0,0 +1,158 @@
+//
+// Mono.Security.Protocol.Ntlm.Type1Message - Negotiation
+//
+// Author:
+//     Sebastien Pouliot <sebastien@ximian.com>
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2004, 2007 Novell, Inc (http://www.novell.com)
+//
+// References
+// a.  NTLM Authentication Scheme for HTTP, Ronald Tschalär
+//     http://www.innovation.ch/java/ntlm.html
+// b.  The NTLM Authentication Protocol, Copyright © 2003 Eric Glass
+//     http://davenport.sourceforge.net/ntlm.html
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Globalization;
+using System.Text;
+
+namespace Mono.Security.Protocol.Ntlm {
+
+       public class Type1Message : MessageBase {
+
+               private string _host;
+               private string _domain;
+
+               public Type1Message () : this (NtlmVersion.Version2)
+               {
+               }
+
+               public Type1Message (NtlmVersion version) : base (1, version)
+               {
+                       // default values
+                       _domain = Environment.UserDomainName;
+                       _host = Environment.MachineName;
+                       Flags = (NtlmFlags) 0xb203;
+               }
+
+               public Type1Message (byte[] message) : this (message, NtlmVersion.Version2)
+               {
+               }
+
+               public Type1Message (byte[] message, NtlmVersion version) : base (1, version)
+               {
+                       Decode (message);
+               }
+
+               // properties
+
+               public string Domain {
+                       get { return _domain; }
+                       set { _domain = value; }
+               }
+
+               public string Host {
+                       get { return _host; }
+                       set { _host = value; }
+               }
+
+               // methods
+
+               protected override void Decode (byte[] message) 
+               {
+                       base.Decode (message);
+
+                       Flags = (NtlmFlags) BitConverterLE.ToUInt32 (message, 12);
+                       if (Version == NtlmVersion.Version1)
+                               return;
+
+                       int dom_len = BitConverterLE.ToUInt16 (message, 16);
+                       int dom_off = BitConverterLE.ToUInt16 (message, 20);
+                       _domain = Encoding.ASCII.GetString (message, dom_off, dom_len);
+
+                       int host_len = BitConverterLE.ToUInt16 (message, 24);
+                       int host_off = BitConverterLE.ToUInt16 (message, 28);
+                       _host = Encoding.ASCII.GetString (message, host_off, host_len);
+
+                       if (Version != NtlmVersion.Version3)
+                               return;
+                       OSVersion = CreateSubArray (message, 32, 8);
+               }
+
+               public override byte[] GetBytes () 
+               {
+                       short dom_len = 0, host_len = 0;
+                       if (Version != NtlmVersion.Version1) {
+                               dom_len = (short) _domain.Length;
+                               host_len = (short) _host.Length;
+                       }
+
+                       int headSize = (Version == NtlmVersion.Version3 ? 40 : 32);
+
+                       byte[] data = PrepareMessage (headSize + dom_len + host_len);
+
+                       // v1 contains only the flags.
+                       if (Version == NtlmVersion.Version1)
+                               return data;
+
+                       data [12] = (byte) Flags;
+                       data [13] = (byte)((uint)Flags >> 8);
+                       data [14] = (byte)((uint)Flags >> 16);
+                       data [15] = (byte)((uint)Flags >> 24);
+
+                       int dom_off = (headSize + host_len);
+
+                       data [16] = (byte) dom_len;
+                       data [17] = (byte)(dom_len >> 8);
+                       data [18] = data [16];
+                       data [19] = data [17];
+                       data [20] = (byte) dom_off;
+                       data [21] = (byte)(dom_off >> 8);
+                       data [22] = (byte)(dom_off >> 16);
+                       data [23] = (byte)(dom_off >> 24);
+
+                       int host_off = headSize;
+                       data [24] = (byte) host_len;
+                       data [25] = (byte)(host_len >> 8);
+                       data [26] = data [24];
+                       data [27] = data [25];
+                       data [28] = (byte) host_off;
+                       data [29] = (byte)(host_off >> 8);
+                       data [30] = (byte)(host_off >> 16);
+                       data [31] = (byte)(host_off >> 24);
+
+                       if (Version == NtlmVersion.Version3)
+                               Buffer.BlockCopy (OSVersion, 0, data, 32, OSVersion.Length);
+
+                       byte[] host = Encoding.ASCII.GetBytes (_host.ToUpper (CultureInfo.InvariantCulture));
+                       Buffer.BlockCopy (host, 0, data, host_off, host.Length);
+
+                       byte[] domain = Encoding.ASCII.GetBytes (_domain.ToUpper (CultureInfo.InvariantCulture));
+                       Buffer.BlockCopy (domain, 0, data, dom_off, domain.Length);
+
+                       return data;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/Type2Message.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/Type2Message.cs
new file mode 100755 (executable)
index 0000000..76c9022
--- /dev/null
@@ -0,0 +1,215 @@
+//
+// Mono.Security.Protocol.Ntlm.Type2Message - Challenge
+//
+// Author:
+//     Sebastien Pouliot <sebastien@ximian.com>
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2004, 2007 Novell, Inc (http://www.novell.com)
+//
+// References
+// a.  NTLM Authentication Scheme for HTTP, Ronald Tschalär
+//     http://www.innovation.ch/java/ntlm.html
+// b.  The NTLM Authentication Protocol, Copyright © 2003 Eric Glass
+//     http://davenport.sourceforge.net/ntlm.html
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Mono.Security.Protocol.Ntlm {
+
+       public class Type2Message : MessageBase {
+
+               private byte[] _nonce;
+               private byte[] _context;
+               private NtlmTargetInformation _target;
+               private string _target_name;
+
+               public Type2Message () : this (NtlmVersion.Version1)
+               {
+               }
+
+               public Type2Message (NtlmVersion version) : base (2, version)
+               {
+                       _nonce = new byte [8];
+                       RandomNumberGenerator rng = RandomNumberGenerator.Create ();
+                       rng.GetBytes (_nonce);
+                       // default values
+                       Flags = (NtlmFlags) 0x8201;
+                       if (Version != NtlmVersion.Version1) {
+                               _context = new byte [8];
+                               _target = new NtlmTargetInformation ();
+                       }
+               }
+
+               public Type2Message (byte[] message) : this (message, NtlmVersion.Version1)
+               {
+               }
+
+               public Type2Message (byte[] message, NtlmVersion version) : base (2, version)
+               {
+                       _nonce = new byte [8];
+                       Decode (message);
+               }
+
+               ~Type2Message () 
+               {
+                       if (_nonce != null)
+                               Array.Clear (_nonce, 0, _nonce.Length);
+               }
+
+               // properties
+
+               public byte[] Context {
+                       get { return (byte[]) _context.Clone (); }
+                       set { 
+                               if (value == null)
+                                       throw new ArgumentNullException ("Nonce");
+                               if (value.Length != 8) {
+                                       string msg = Locale.GetText ("Invalid Nonce Length (should be 8 bytes).");
+                                       throw new ArgumentException (msg, "Nonce");
+                               }
+                               _context = (byte[]) value.Clone (); 
+                       }
+               }
+
+               public byte[] Nonce {
+                       get { return (byte[]) _nonce.Clone (); }
+                       set { 
+                               if (value == null)
+                                       throw new ArgumentNullException ("Nonce");
+                               if (value.Length != 8) {
+                                       string msg = Locale.GetText ("Invalid Nonce Length (should be 8 bytes).");
+                                       throw new ArgumentException (msg, "Nonce");
+                               }
+                               _nonce = (byte[]) value.Clone (); 
+                       }
+               }
+
+               public NtlmTargetInformation Target {
+                       get { return _target; }
+               }
+
+               public string TargetName {
+                       get { return _target_name; }
+                       set { _target_name = value; }
+               }
+
+               // methods
+
+               protected override void Decode (byte[] message) 
+               {
+                       base.Decode (message);
+
+                       short targetNameSize = BitConverterLE.ToInt16 (message, 12);
+                       int targetNameOffset = BitConverterLE.ToInt32 (message, 16);
+
+                       Flags = (NtlmFlags) BitConverterLE.ToUInt32 (message, 20);
+
+                       Buffer.BlockCopy (message, 24, _nonce, 0, 8);
+
+                       if (Version == NtlmVersion.Version1)
+                               return;
+
+                       Buffer.BlockCopy (message, 32, _context, 0, 8);
+                       short targetInfoSize = BitConverterLE.ToInt16 (message, 40);
+                       int targetInfoOffset = BitConverterLE.ToInt32 (message, 44);
+
+                       if (Version == NtlmVersion.Version3)
+                               Buffer.BlockCopy (OSVersion, 0, message, 48, OSVersion.Length);
+
+                       Encoding enc = (Flags & NtlmFlags.NegotiateUnicode) != 0 ? Encoding.Unicode : Encoding.UTF8;
+                       if (targetNameSize > 0)
+                               TargetName = enc.GetString (message, targetNameOffset, targetNameSize);
+
+                       _target.Decode (message, targetInfoOffset, targetInfoSize);
+               }
+
+               public override byte[] GetBytes ()
+               {
+                       byte [] name_bytes = null, target = null;
+                       short name_len = 0, target_len = 0;
+                       if (TargetName != null) {
+                               Encoding enc = (Flags & NtlmFlags.NegotiateUnicode) != 0 ? Encoding.Unicode : Encoding.UTF8;
+                               name_bytes = enc.GetBytes (TargetName);
+                               name_len = (short) name_bytes.Length;
+                       }
+                       if (Version != NtlmVersion.Version1) {
+                               target = _target.ToBytes ();
+                               target_len = (short) target.Length;
+                       }
+
+                       uint name_offset = (uint) (Version == NtlmVersion.Version3 ? 56 : 40);
+
+                       int size = (int) name_offset +
+                                  (name_len > 0 ? name_len + 8 : 0) +
+                                  (target_len > 0 ? target_len + 8 : 0);
+                       byte[] data = PrepareMessage (size);
+
+                       // target name
+                       data [12] = (byte) name_len;
+                       data [13] = (byte) (name_len >> 8);
+                       data [14] = data [12];
+                       data [15] = data [13];
+                       data [16] = (byte) name_offset;
+                       data [17] = (byte) (name_offset >> 8);
+                       data [18] = (byte) (name_offset >> 16);
+                       data [19] = (byte) (name_offset >> 24);
+
+                       // flags
+                       data [20] = (byte) Flags;
+                       data [21] = (byte)((uint)Flags >> 8);
+                       data [22] = (byte)((uint)Flags >> 16);
+                       data [23] = (byte)((uint)Flags >> 24);
+
+                       Buffer.BlockCopy (_nonce, 0, data, 24, _nonce.Length);
+
+                       if (Version == NtlmVersion.Version1)
+                               return data;
+
+                       // context
+                       Buffer.BlockCopy (_context, 0, data, 32, 8);
+
+                       // target information
+                       data [40] = (byte) target_len;
+                       data [41] = (byte) (target_len >> 8);
+                       data [42] = data [40];
+                       data [43] = data [41];
+                       uint info_offset = (uint) (name_offset + name_bytes.Length);
+                       data [44] = (byte) info_offset;
+                       data [45] = (byte) (info_offset >> 8);
+                       data [46] = (byte) (info_offset >> 16);
+                       data [47] = (byte) (info_offset >> 24);
+
+                       if (Version == NtlmVersion.Version3)
+                               Buffer.BlockCopy (OSVersion, 0, data, 48, OSVersion.Length);
+
+                       Buffer.BlockCopy (name_bytes, 0, data, (int) name_offset, name_len);
+                       Buffer.BlockCopy (target, 0, data, (int) info_offset, target.Length);
+
+                       return data;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/Type3Message.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Ntlm/Type3Message.cs
new file mode 100755 (executable)
index 0000000..4effaf9
--- /dev/null
@@ -0,0 +1,294 @@
+//
+// Mono.Security.Protocol.Ntlm.Type3Message - Authentication
+//
+// Author:
+//     Sebastien Pouliot <sebastien@ximian.com>
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
+// Copyright (C) 2004, 2007 Novell, Inc (http://www.novell.com)
+//
+// References
+// a.  NTLM Authentication Scheme for HTTP, Ronald Tschalär
+//     http://www.innovation.ch/java/ntlm.html
+// b.  The NTLM Authentication Protocol, Copyright © 2003 Eric Glass
+//     http://davenport.sourceforge.net/ntlm.html
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Globalization;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Mono.Security.Protocol.Ntlm {
+
+       public class Type3Message : MessageBase {
+
+               private byte[] _challenge;
+               private string _host;
+               private string _domain;
+               private string _username;
+               private string _password;
+               private byte[] _lm;
+               private byte[] _nt;
+               private byte[] _nonce;
+
+               public Type3Message () : this (NtlmVersion.Version1)
+               {
+               }
+
+               public Type3Message (NtlmVersion version) : base (3, version)
+               {
+                       // default values
+                       _domain = Environment.UserDomainName;
+                       _host = Environment.MachineName;
+                       _username = Environment.UserName;
+                       Flags = (NtlmFlags) 0x8201;
+                       _nonce = new byte [8];
+                       RandomNumberGenerator rng = RandomNumberGenerator.Create ();
+                       rng.GetBytes (_nonce);
+               }
+
+               public Type3Message (byte[] message) : this (message, NtlmVersion.Version1)
+               {
+               }
+
+               public Type3Message (byte[] message, NtlmVersion version) : base (3, version)
+               {
+                       Decode (message);
+               }
+
+               ~Type3Message () 
+               {
+                       if (_challenge != null)
+                               Array.Clear (_challenge, 0, _challenge.Length);
+                       if (_lm != null)
+                               Array.Clear (_lm, 0, _lm.Length);
+                       if (_nt != null)
+                               Array.Clear (_nt, 0, _nt.Length);
+               }
+
+               // properties
+
+               public byte[] Challenge {
+                       get { 
+                               if (_challenge == null)
+                                       return null;
+                               return (byte[]) _challenge.Clone (); }
+                       set { 
+                               if (value == null)
+                                       throw new ArgumentNullException ("Challenge");
+                               if (value.Length != 8) {
+                                       string msg = Locale.GetText ("Invalid Challenge Length (should be 8 bytes).");
+                                       throw new ArgumentException (msg, "Challenge");
+                               }
+                               _challenge = (byte[]) value.Clone (); 
+                       }
+               }
+
+               public string Domain {
+                       get { return _domain; }
+                       set { _domain = value; }
+               }
+
+               public string Host {
+                       get { return _host; }
+                       set { _host = value; }
+               }
+
+               public string Password {
+                       get { return _password; }
+                       set { _password = value; }
+               }
+
+               public string Username {
+                       get { return _username; }
+                       set { _username = value; }
+               }
+
+               public byte[] LM {
+                       get { return _lm; }
+               }
+
+               public byte[] NT {
+                       get { return _nt; }
+               }
+
+               // methods
+
+               protected override void Decode (byte[] message) 
+               {
+                       base.Decode (message);
+
+                       // FIXME: This Version condition is introduced to make
+                       // nunit tests pass, and hence not based on the NTLM 
+                       // analysis docs. Find out the reason why it is needed.
+                       if (Version == NtlmVersion.Version1 &&
+                           BitConverterLE.ToUInt16 (message, 56) != message.Length) {
+                               string msg = Locale.GetText ("Invalid Type3 message length.");
+                               throw new ArgumentException (msg, "message");
+                       }
+
+                       _password = null;
+
+                       int dom_len = BitConverterLE.ToUInt16 (message, 28);
+                       int dom_off = BitConverterLE.ToUInt16 (message, 32);
+                       _domain = Encoding.Unicode.GetString (message, dom_off, dom_len);
+
+                       int host_len = BitConverterLE.ToUInt16 (message, 44);
+                       int host_off = BitConverterLE.ToUInt16 (message, 48);
+                       _host = Encoding.Unicode.GetString (message, host_off, host_len);
+
+                       int user_len = BitConverterLE.ToUInt16 (message, 36);
+                       int user_off = BitConverterLE.ToUInt16 (message, 40);
+                       _username = Encoding.Unicode.GetString (message, user_off, user_len);
+
+                       _lm = new byte [24];
+                       int lm_off = BitConverterLE.ToUInt16 (message, 16);
+                       Buffer.BlockCopy (message, lm_off, _lm, 0, 24);
+                       
+                       _nt = new byte [24];
+                       int nt_off = BitConverterLE.ToUInt16 (message, 24);
+                       Buffer.BlockCopy (message, nt_off, _nt, 0, 24);
+
+                       if (message.Length >= 64)
+                               Flags = (NtlmFlags) BitConverterLE.ToUInt32 (message, 60);
+               }
+
+               public override byte[] GetBytes () 
+               {
+                       byte[] domain = Encoding.Unicode.GetBytes (_domain.ToUpper (CultureInfo.InvariantCulture));
+                       byte[] user = Encoding.Unicode.GetBytes (_username);
+                       byte[] host = Encoding.Unicode.GetBytes (_host.ToUpper (CultureInfo.InvariantCulture));
+
+                       int fixed_size = Version == NtlmVersion.Version3 ? 72 : 64;
+                       short skey_len = (short) (Version != NtlmVersion.Version1 ? 16 : 0);
+                       int skey_off = 0;
+
+                       byte[] data = PrepareMessage (fixed_size + domain.Length + user.Length + host.Length + 24 + 24 + skey_len);
+
+                       // LM response
+                       int lmresp_off = fixed_size + domain.Length + user.Length + host.Length;
+                       data [12] = (byte) 0x18;
+                       data [13] = (byte) 0x00;
+                       data [14] = (byte) 0x18;
+                       data [15] = (byte) 0x00;
+                       data [16] = (byte) lmresp_off;
+                       data [17] = (byte)(lmresp_off >> 8);
+                       data [18] = (byte)(lmresp_off >> 16);
+                       data [19] = (byte)(lmresp_off >> 24);
+
+                       // NT response
+                       int ntresp_off = lmresp_off + 24;
+                       data [20] = (byte) 0x18;
+                       data [21] = (byte) 0x00;
+                       data [22] = (byte) 0x18;
+                       data [23] = (byte) 0x00;
+                       data [24] = (byte) ntresp_off;
+                       data [25] = (byte)(ntresp_off >> 8);
+                       data [26] = (byte)(ntresp_off >> 16);
+                       data [27] = (byte)(ntresp_off >> 24);
+
+                       // domain
+                       short dom_len = (short)domain.Length;
+                       int dom_off = (short)fixed_size;
+                       data [28] = (byte) dom_len;
+                       data [29] = (byte)(dom_len >> 8);
+                       data [30] = data [28];
+                       data [31] = data [29];
+                       data [32] = (byte) dom_off;
+                       data [33] = (byte)(dom_off >> 8);
+                       data [34] = (byte)(dom_off >> 16);
+                       data [35] = (byte)(dom_off >> 24);
+
+                       // username
+                       short uname_len = (short)user.Length;
+                       int uname_off = dom_off + dom_len;
+                       data [36] = (byte) uname_len;
+                       data [37] = (byte)(uname_len >> 8);
+                       data [38] = data [36];
+                       data [39] = data [37];
+                       data [40] = (byte) uname_off;
+                       data [41] = (byte)(uname_off >> 8);
+                       data [42] = (byte)(uname_off >> 16);
+                       data [43] = (byte)(uname_off >> 24);
+
+                       // host
+                       short host_len = (short)host.Length;
+                       int host_off = uname_off + uname_len;
+                       data [44] = (byte) host_len;
+                       data [45] = (byte)(host_len >> 8);
+                       data [46] = data [44];
+                       data [47] = data [45];
+                       data [48] = (byte) host_off;
+                       data [49] = (byte)(host_off >> 8);
+                       data [50] = (byte)(host_off >> 16);
+                       data [51] = (byte)(host_off >> 24);
+
+                       // session key
+                       // FIXME: This Version condition is introduced to make
+                       // nunit tests pass, and hence not based on the NTLM 
+                       // analysis docs. Find out the reason why it is needed.
+                       if (Version != NtlmVersion.Version1) {
+                               skey_off = (short)(data.Length - skey_len);
+                               data [52] = (byte) skey_len;
+                               data [53] = (byte)(skey_len >> 8);
+                               data [54] = data [52];
+                               data [55] = data [53];
+                               data [56] = (byte) skey_off;
+                               data [57] = (byte)(skey_off >> 8);
+                               data [58] = (byte)(skey_off >> 16);
+                               data [59] = (byte)(skey_off >> 24);
+                       } else {
+                               // message length
+                               short msg_len = (short)data.Length;
+                               data [56] = (byte) msg_len;
+                               data [57] = (byte)(msg_len >> 8);
+                       }
+
+                       // options flags
+                       data [60] = (byte) Flags;
+                       data [61] = (byte)((uint)Flags >> 8);
+                       data [62] = (byte)((uint)Flags >> 16);
+                       data [63] = (byte)((uint)Flags >> 24);
+
+                       // osversion
+                       if (Version == NtlmVersion.Version3)
+                               Buffer.BlockCopy (OSVersion, 0, data, 64, OSVersion.Length);
+
+                       Buffer.BlockCopy (domain, 0, data, dom_off, domain.Length);
+                       Buffer.BlockCopy (user, 0, data, uname_off, user.Length);
+                       Buffer.BlockCopy (host, 0, data, host_off, host.Length);
+
+                       using (ChallengeResponse ntlm = new ChallengeResponse (_password, _challenge)) {
+                               Buffer.BlockCopy (ntlm.LM, 0, data, lmresp_off, 24);
+                               Buffer.BlockCopy (ntlm.NT, 0, data, ntresp_off, 24);
+
+                               if (Version != NtlmVersion.Version1)
+                                       // session key
+                                       Buffer.BlockCopy (ntlm.LMSessionKey, 0, data, skey_off, 16);
+                       }
+
+                       return data;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/ChangeLog b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/ChangeLog
new file mode 100644 (file)
index 0000000..bcc3ece
--- /dev/null
@@ -0,0 +1,316 @@
+2007-12-15  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsServerCertificate.cs: Add support for wilcard (*) when matching
+       the target host with the certificate. Fix bug #346812
+
+2007-05-22  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientCertificate.cs: If possible avoid to export the private key
+       (it could be non-exportable in a different RSA class implementation).
+       Patch from Roy Versteeg to fix #81592.
+       * TlsClientCertificateVerify.cs: Add chain support for x.509 client 
+       certificates. Based on Roy Versteeg patch to fix #80557.
+
+2006-12-23 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * TlsServerCertificate.cs: typo.
+
+2006-09-11  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientFinished.cs: Use Write.Cipher instead of Cipher. Remove 
+       usage of TlsStream in ProcessAsSsl3.
+       * TlsClientKeyExchange.cs: Use Negotiating.Cipher instead of Cipher.
+       Refactor to avoid code duplication between SSL3 and TLS.
+       * TlsServerCertificate.cs: Use Negotiating.Cipher instead of Cipher.
+       * TlsServerFinished.cs: Use Current.Cipher instead of Cipher. Use 
+       Compare to test client and server digests equality. Remove usage of 
+       TlsStream in ProcessAsSsl3.
+       * TlsServerHello.cs: Use Negotiating.Cipher instead of Cipher. Remove
+       usage of TlsStream to reduce memory allocations. Remove method 
+       CompareSessionId and use the new base class Compare method instead.
+
+2006-03-16  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientHello.cs: Check to see if we already have a known session
+       (past or concurrent) with the same target host. If so the use this
+       session id to try to resume (i.e. abbreviated handshake).
+       * TlsServerFinished.cs: Don't reset the hasndshake stream here. The 
+       stream must be resetted once BOTH the client and the server are done.
+       The order of message can be different if we use an abbreviated 
+       handshake sequence which leads to an invalid handshake.
+       * TlsServerHello.cs: Add this session info to the client cache. If the
+       server sends the same session id (as we supplied) then we MUST do an 
+       abbreviated handshake.
+
+2005-11-23  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsServerCertificate.cs: Add support for Netscape Server Gated 
+       Crypto (2.16.840.1.113730.4) as a valid server-side EKU OID. Fix bug
+       #76804.
+
+2005-06-14  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientCertificate.cs: Add support for _optional_ mutual 
+       authentication. SSL3 and TLS1 deals differently with this. SSL3 tested
+       with OpenSSL, TSL1 tested with OpenSSL and LDAPS/AD.
+
+2005-04-12  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientCertificateVerify.cs: Add missing data length (16 bits - 
+       not to be confused with the record 24 bits length) before the RSA
+       signature of the MD5SHA1 hash. Fix #71696.
+
+2004-05-11 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs:
+
+               - Added fix for better handling of exceptions when
+               building the X509 Certificate chain.
+
+2004-04-22  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientCertificateVerify.cs: Use Buffer.BlockCopy instead of 
+       Array.Copy.
+       * TlsServerCertificate.cs: Changed KeyUsage to KeyUsages and CertType 
+       to CertTypes.
+
+2004-03-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientKeyExchange.cs: Fixed key pair used to encrypt pre-master
+       secret for exportable ciphers - must use the public key received in 
+       ServerKeyExchange.
+
+2004-03-10 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs:
+
+               - Fixed meesage type definition.
+
+2004-03-04 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs:
+
+        - Fixed message type.
+
+2004-02-26  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsServerCertificate.cs: Certificate validation has been activated.
+
+2004-02-26 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs:
+
+               - Added changes for better handling of ClientHelloRequest messages.
+
+2004-02-21  Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+    * TlsServerHello: Fix for handle SecurityProtocolType.Default.
+
+2004-02-20  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsServerCertificate.cs: Added code to validate the server X.509
+       certificate (identity, usage) and it's chain to a trusted root.
+       Note that the verification is commented for the time being.
+
+2004-02-14 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+    * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs:
+
+        - Removed test code.
+
+2003-11-17 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/SslClientStream.cs:
+
+               Removed ReadByte method, use innerStream.ReadByte() method instead.
+
+2003-11-13 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Added implementation of an SslClientStream class similar to the MS .NET Framework 1.2 documentation.
+
+               The next files are no more needed:
+
+                       - TlsSession.cs
+
+                       - TlsNetworkStream.cs
+
+                       - TlsSocket.cs
+
+                       - TlsSessionState.cs
+
+               The next files are renamed:
+
+                       - TlsSessionSettings.cs -> TlsClientSettings.cs
+
+                       - TlsSessionContext.cs -> TlsContext.cs
+
+               The next files are new:
+
+                       - SslClientStream.cs ( the name is non definitive yet )
+
+               The next files where changed to reflect the new canges:
+
+                       - TlsHandshakeMessage.cs
+
+                       - TlsClientCertificate.cs
+
+                       - TlsClientCertificateVerify.cs
+
+                       - TlsClientFinished.cs
+
+                       - TlsClientHello.cs
+
+                       - TlsClientKeyExchange.cs
+
+                       - TlsServerCertificate.cs
+
+                       - TlsServerCertificateRequest.cs
+
+                       - TlsServerFinished.cs
+
+                       - TlsServerHello.cs
+
+                       - TlsServerHelloDone.cs
+
+                       - TlsServerKeyExchange.cs
+
+                       - TlsAlert.cs
+
+                       - TlsCloseNotifyAlert.cs
+
+               
+2003-11-12 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+       
+               - Changes for give full error message only in debug mode ( Thanks to Sebastién Pouliot. )
+               
+       * Mono.Security.Protocol.Tls/TlsProtocol.cs:
+       
+               - Renamed to SecurityProtocolType.cs ( for match .NET 1.2 )
+       
+       * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+       
+               - Renamed to MD5SHA1.cs ( Thanks to Sebastién Pouliot. )
+               
+       * Mono.Security.Cryptography/TlsCompressionMethod.cs:
+       
+               - Renamed to SecurityCompressionType.
+               
+       * Mono.Security.Protocol.Tls/CipherAlgorithmType.cs:
+       * Mono.Security.Protocol.Tls/HashAlgorithmType.cs:
+       * Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs:
+       
+               - New enumerations that matches .NET 1.2 definitions with some minor differences.
+       
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsCipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+       
+               - Added changes for make use of new enumerations.
+       
+       * Mono.Security.Protocol.Tls/TlsClientStream.cs:
+       
+               - Added new informative properties that matches .NET 1.2 SslClientStream
+               ( Not all the properties are implemented yet ).
+
+
+2003-11-10 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+
+               - Fixed invalid alert message.
+
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+       * Mono.Security.Cryptography/HMAC.cs:
+       * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+
+               - Changed ( Thanks to Sebastién Pouliot for his feedback )
+
+                       SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
+                       MD5CryptoServiceProvider sha = new MD5CryptoServiceProvider();
+
+                       to
+
+                       HashAlgorithm sha = SHA1.Create();
+                       HashAlgorithm md5 = MD5.Create(); 
+
+2003-11-04 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+
+               - Added custom padding for record encryption.
+
+
+2003-11-03 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Handshake/TlsHandshakeMessages.cs:
+       
+               - Removed file.
+
+       * Mono.Security.Protocol.Tls/TlsSslHandshakeHash.cs:
+       
+               - New class for handshake hashes calculation on SSL3 protocol.
+
+       * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+       
+               - Fixed mac keys clearing for SSL3 protocol.
+
+       * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs:
+       
+               - Added changes for make use of new TlsSslHandshakeHash class.
+       
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs:
+       
+               - Added initial implementation for SSL3 protocol.
+       
+       * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+       
+               - New class for md5-sha hash calculation.
+                                                       
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsHandshakeMessage.cs:
+       
+               - Make use of new MD5SHA1CryptoServiceProvider class.
+               
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+       
+               - Added initial implementation (not finished).
+                       
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
+       
+               - Minor change to message processing.
+
+               - Changed verify method name to verifySignature.
+                       
+       * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+       
+               - Changed handshakeHashes member to be an TlsStream.
+
+2003-10-28 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSessionSettings.cs:
+       * Mono.Security.Protocol.Tls/TlsServerSettings.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
+
+               - Added changes for make use of X509 classes from mono.
+
+2003-10-23 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Added partial implementation of SSL3 protocol ( not finished yet ).
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/README.olive b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/README.olive
new file mode 100644 (file)
index 0000000..522f3fc
--- /dev/null
@@ -0,0 +1 @@
+Imported from Mono.Security.dll
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs
new file mode 100644 (file)
index 0000000..d59769b
--- /dev/null
@@ -0,0 +1,147 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography.X509Certificates;
+
+using Mono.Security.Protocol.Tls;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Client
+{
+       internal class TlsClientCertificate : HandshakeMessage
+       {
+               private bool clientCertSelected;
+               private X509Certificate clientCert;
+
+               #region Constructors
+
+               public TlsClientCertificate(Context context) 
+                       : base(context, HandshakeType.Certificate)
+               {
+               }
+
+               #endregion
+
+               #region Properties
+
+               public X509Certificate ClientCertificate {
+                       get {
+                               if (!clientCertSelected)
+                               {
+                                       GetClientCertificate ();
+                                       clientCertSelected = true;
+                               }
+                               return clientCert;
+                       }
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       base.Update();
+                       this.Reset();
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               private void GetClientCertificate ()
+               {
+#warning "Client certificate selection is unfinished"
+                       ClientContext context = (ClientContext)this.Context;
+
+                       // note: the server may ask for mutual authentication 
+                       // but may not require it (i.e. it can be optional).
+                       if (context.ClientSettings.Certificates != null &&
+                               context.ClientSettings.Certificates.Count > 0)
+                       {
+                               clientCert = context.SslStream.RaiseClientCertificateSelection(
+                                       this.Context.ClientSettings.Certificates,
+                                       new X509Certificate(this.Context.ServerSettings.Certificates[0].RawData),
+                                       this.Context.ClientSettings.TargetHost,
+                                       null);
+                               // Note: the application code can raise it's 
+                               // own exception to stop the connection too.
+                       }
+
+                       // Update the selected client certificate
+                       context.ClientSettings.ClientCertificate = clientCert;
+               }
+
+               private void SendCertificates ()
+               {
+                       TlsStream chain = new TlsStream ();
+
+                       X509Certificate currentCert = this.ClientCertificate;
+                       while (currentCert != null) {
+                               byte[] rawCert = currentCert.GetRawCertData ();
+                               chain.WriteInt24 (rawCert.Length);
+                               chain.Write(rawCert);
+                               currentCert = FindParentCertificate (currentCert);
+                       }
+                       this.WriteInt24 ((int)chain.Length);
+                       this.Write (chain.ToArray ());
+               }
+
+               protected override void ProcessAsSsl3()
+               {
+                       if (this.ClientCertificate != null) {
+                               SendCertificates ();
+                       } else {
+                               // an Alert warning for NoCertificate (41) 
+                               // should be sent from here - but that would
+                               // break the current message handling
+                       }
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       if (this.ClientCertificate != null) {
+                               SendCertificates ();
+                       } else {
+                               // return message with empty certificate (see 7.4.6 in RFC2246)
+                               this.WriteInt24 (0);
+                       }
+               }
+
+               private X509Certificate FindParentCertificate (X509Certificate cert)
+               {
+                       // This certificate is the root certificate
+                       if (cert.GetName () == cert.GetIssuerName ())
+                               return null;
+
+                       foreach (X509Certificate certificate in this.Context.ClientSettings.Certificates) {
+                               if (cert.GetName () == cert.GetIssuerName ())
+                                       return certificate;
+                       }
+                       return null;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs
new file mode 100644 (file)
index 0000000..bfa689d
--- /dev/null
@@ -0,0 +1,220 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography.X509Certificates;
+
+using System.Security.Cryptography;
+using Mono.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Client
+{
+       internal class TlsClientCertificateVerify : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsClientCertificateVerify(Context context) 
+                       : base(context, HandshakeType.CertificateVerify)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       base.Update();
+                       this.Reset();
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       AsymmetricAlgorithm privKey = null;
+                       ClientContext           context = (ClientContext)this.Context;
+                       
+                       privKey = context.SslStream.RaisePrivateKeySelection(
+                               context.ClientSettings.ClientCertificate,
+                               context.ClientSettings.TargetHost);
+
+                       if (privKey == null)
+                       {
+                               throw new TlsException(AlertDescription.UserCancelled, "Client certificate Private Key unavailable.");
+                       }
+                       else
+                       {
+                               SslHandshakeHash hash = new SslHandshakeHash(context.MasterSecret);                     
+                               hash.TransformFinalBlock(
+                                       context.HandshakeMessages.ToArray(), 
+                                       0, 
+                                       (int)context.HandshakeMessages.Length);
+
+                               // CreateSignature uses ((RSA)privKey).DecryptValue which is not implemented
+                               // in RSACryptoServiceProvider. Other implementations likely implement DecryptValue
+                               // so we will try the CreateSignature method.
+                               byte[] signature = null;
+                               if (!(privKey is RSACryptoServiceProvider))
+                               {
+                                       try
+                                       {
+                                               signature = hash.CreateSignature((RSA)privKey);
+                                       }
+                                       catch (NotImplementedException)
+                                       { }
+                               }
+                               // If DecryptValue is not implemented, then try to export the private
+                               // key and let the RSAManaged class do the DecryptValue
+                               if (signature == null)
+                               {
+                                       // RSAManaged of the selected ClientCertificate 
+                                       // (at this moment the first one)
+                                       RSA rsa = this.getClientCertRSA((RSA)privKey);
+
+                                       // Write message
+                                       signature = hash.CreateSignature(rsa);
+                               }
+                               this.Write((short)signature.Length);
+                               this.Write(signature, 0, signature.Length);
+                       }
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       AsymmetricAlgorithm privKey = null;
+                       ClientContext           context = (ClientContext)this.Context;
+                       
+                       privKey = context.SslStream.RaisePrivateKeySelection(
+                               context.ClientSettings.ClientCertificate,
+                               context.ClientSettings.TargetHost);
+
+                       if (privKey == null)
+                       {
+                               throw new TlsException(AlertDescription.UserCancelled, "Client certificate Private Key unavailable.");
+                       }
+                       else
+                       {
+                               // Compute handshake messages hash
+                               MD5SHA1 hash = new MD5SHA1();
+                               hash.ComputeHash(
+                                       context.HandshakeMessages.ToArray(),
+                                       0,
+                                       (int)context.HandshakeMessages.Length);
+
+                               // CreateSignature uses ((RSA)privKey).DecryptValue which is not implemented
+                               // in RSACryptoServiceProvider. Other implementations likely implement DecryptValue
+                               // so we will try the CreateSignature method.
+                               byte[] signature = null;
+                               if (!(privKey is RSACryptoServiceProvider))
+                               {
+                                       try
+                                       {
+                                               signature = hash.CreateSignature((RSA)privKey);
+                                       }
+                                       catch (NotImplementedException)
+                                       { }
+                               }
+                               // If DecryptValue is not implemented, then try to export the private
+                               // key and let the RSAManaged class do the DecryptValue
+                               if (signature == null)
+                               {
+                                       // RSAManaged of the selected ClientCertificate 
+                                       // (at this moment the first one)
+                                       RSA rsa = this.getClientCertRSA((RSA)privKey);
+
+                                       // Write message
+                                       signature = hash.CreateSignature(rsa);
+                               }
+                               this.Write((short)signature.Length);
+                               this.Write(signature, 0, signature.Length);
+                       }
+               }
+
+               #endregion
+
+               #region Private methods
+
+               private RSA getClientCertRSA(RSA privKey)
+               {
+                       RSAParameters rsaParams         = new RSAParameters();
+                       RSAParameters privateParams = privKey.ExportParameters(true);
+
+                       // for RSA m_publickey contains 2 ASN.1 integers
+                       // the modulus and the public exponent
+                       ASN1 pubkey = new ASN1 (this.Context.ClientSettings.Certificates[0].GetPublicKey());
+                       ASN1 modulus = pubkey [0];
+                       if ((modulus == null) || (modulus.Tag != 0x02))
+                       {
+                               return null;
+                       }
+                       ASN1 exponent = pubkey [1];
+                       if (exponent.Tag != 0x02)
+                       {
+                               return null;
+                       }
+
+                       rsaParams.Modulus = this.getUnsignedBigInteger(modulus.Value);
+                       rsaParams.Exponent = exponent.Value;
+
+                       // Set private key parameters
+                       rsaParams.D                     = privateParams.D;
+                       rsaParams.DP            = privateParams.DP;
+                       rsaParams.DQ            = privateParams.DQ;
+                       rsaParams.InverseQ      = privateParams.InverseQ;
+                       rsaParams.P                     = privateParams.P;
+                       rsaParams.Q                     = privateParams.Q;                      
+
+                       // BUG: MS BCL 1.0 can't import a key which 
+                       // isn't the same size as the one present in
+                       // the container.
+                       int keySize = (rsaParams.Modulus.Length << 3);
+                       RSAManaged rsa = new RSAManaged(keySize);
+                       rsa.ImportParameters (rsaParams);
+
+                       return (RSA)rsa;
+               }
+
+               private byte[] getUnsignedBigInteger(byte[] integer) 
+               {
+                       if (integer [0] == 0x00) 
+                       {
+                               // this first byte is added so we're sure it's an unsigned integer
+                               // however we can't feed it into RSAParameters or DSAParameters
+                               int length = integer.Length - 1;
+                               byte[] uinteger = new byte [length];
+                               Buffer.BlockCopy (integer, 1, uinteger, 0, length);
+                               return uinteger;
+                       }
+                       else
+                       {
+                               return integer;
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs
new file mode 100644 (file)
index 0000000..9f2e1ae
--- /dev/null
@@ -0,0 +1,87 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Client
+{
+       internal class TlsClientFinished : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsClientFinished(Context context) 
+                       : base(context, HandshakeType.Finished)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       base.Update();
+                       this.Reset();
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               static private byte[] Ssl3Marker = new byte [4] { 0x43, 0x4c, 0x4e, 0x54 };
+
+               protected override void ProcessAsSsl3()
+               {
+                       // Compute handshake messages hashes
+                       HashAlgorithm hash = new SslHandshakeHash(this.Context.MasterSecret);
+
+                       byte[] data = this.Context.HandshakeMessages.ToArray ();
+                       hash.TransformBlock (data, 0, data.Length, data, 0);
+                       hash.TransformBlock (Ssl3Marker, 0, Ssl3Marker.Length, Ssl3Marker, 0);
+                       // hack to avoid memory allocation
+                       hash.TransformFinalBlock (CipherSuite.EmptyArray, 0, 0);
+
+                       this.Write (hash.Hash);
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       // Compute handshake messages hash
+                       HashAlgorithm hash = new MD5SHA1();
+
+                       // note: we could call HashAlgorithm.ComputeHash(Stream) but that would allocate (on Mono)
+                       // a 4096 bytes buffer to process the hash - which is bigger than HandshakeMessages
+                       byte[] data = this.Context.HandshakeMessages.ToArray ();
+                       byte[] digest = hash.ComputeHash (data, 0, data.Length);
+
+                       // Write message
+                       Write(this.Context.Write.Cipher.PRF(this.Context.MasterSecret, "client finished", digest, 12));
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs
new file mode 100644 (file)
index 0000000..9800ce0
--- /dev/null
@@ -0,0 +1,118 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Client
+{
+       internal class TlsClientHello : HandshakeMessage
+       {
+               #region Fields
+
+               private byte[] random;
+
+               #endregion
+
+               #region Constructors
+
+               public TlsClientHello(Context context) 
+                       : base(context, HandshakeType.ClientHello)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       ClientContext context = (ClientContext)this.Context;
+
+                       base.Update();
+
+                       context.ClientRandom            = random;
+                       context.ClientHelloProtocol     = this.Context.Protocol;
+
+                       random = null;
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       this.ProcessAsTls1();
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       // Client Version
+                       this.Write(this.Context.Protocol);
+                                                               
+                       // Random bytes - Unix time + Radom bytes [28]
+                       TlsStream clientRandom = new TlsStream();
+                       clientRandom.Write(this.Context.GetUnixTime());
+                       clientRandom.Write(this.Context.GetSecureRandomBytes(28));
+                       this.random = clientRandom.ToArray();
+                       clientRandom.Reset();
+
+                       this.Write(this.random);
+
+                       // Session id
+                       // Check if we have a cache session we could reuse
+                       this.Context.SessionId = ClientSessionCache.FromHost (this.Context.ClientSettings.TargetHost);
+                       if (this.Context.SessionId != null)
+                       {
+                               this.Write((byte)this.Context.SessionId.Length);
+                               if (this.Context.SessionId.Length > 0)
+                               {
+                                       this.Write(this.Context.SessionId);
+                               }
+                       }
+                       else
+                       {
+                               this.Write((byte)0);
+                       }
+                       
+                       // Write length of Cipher suites                        
+                       this.Write((short)(this.Context.SupportedCiphers.Count*2));
+
+                       // Write Supported Cipher suites
+                       for (int i = 0; i < this.Context.SupportedCiphers.Count; i++)
+                       {
+                               this.Write((short)this.Context.SupportedCiphers[i].Code);
+                       }
+
+                       // Compression methods length
+                       this.Write((byte)1);
+                       
+                       // Compression methods ( 0 = none )
+                       this.Write((byte)this.Context.CompressionMethod);
+               }
+
+               #endregion
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs
new file mode 100644 (file)
index 0000000..3534d83
--- /dev/null
@@ -0,0 +1,98 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Client
+{
+       internal class TlsClientKeyExchange : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsClientKeyExchange (Context context) : 
+                       base(context, HandshakeType.ClientKeyExchange)
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       // a large chunk of code is common to both SSL3 and TLS1
+                       // SSL3 doesn't send the length of the buffer
+                       ProcessCommon (false);
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       // a large chunk of code is common to both SSL3 and TLS1
+                       // TLS1 does send the length of the buffer
+                       ProcessCommon (true);
+               }
+
+               public void ProcessCommon (bool sendLength)
+               {
+                       // Compute pre master secret
+                       byte[] preMasterSecret = this.Context.Negotiating.Cipher.CreatePremasterSecret ();
+
+                       // Create a new RSA key
+                       RSA rsa = null;
+                       if (this.Context.ServerSettings.ServerKeyExchange) 
+                       {
+                               // this is the case for "exportable" ciphers
+                               rsa = new RSAManaged ();
+                               rsa.ImportParameters (this.Context.ServerSettings.RsaParameters);
+                       }
+                       else
+                       {
+                               rsa = this.Context.ServerSettings.CertificateRSA;
+                       }
+
+                       // Encrypt premaster_sercret
+                       RSAPKCS1KeyExchangeFormatter formatter = new RSAPKCS1KeyExchangeFormatter (rsa);
+
+                       // Write the preMasterSecret encrypted
+                       byte[] buffer = formatter.CreateKeyExchange (preMasterSecret);
+                       if (sendLength)
+                               this.Write ((short) buffer.Length);
+                       this.Write (buffer);
+
+                       // Create master secret
+                       this.Context.Negotiating.Cipher.ComputeMasterSecret (preMasterSecret);
+
+                       // Create keys
+                       this.Context.Negotiating.Cipher.ComputeKeys ();
+
+                       // Clear resources
+                       rsa.Clear ();
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs
new file mode 100644 (file)
index 0000000..ef12ed1
--- /dev/null
@@ -0,0 +1,408 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2004, 2006-2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Net;
+using System.Collections;
+using System.Globalization;
+using System.Text.RegularExpressions;
+using System.Security.Cryptography;
+using X509Cert = System.Security.Cryptography.X509Certificates;
+
+using Mono.Security.X509;
+using Mono.Security.X509.Extensions;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Client
+{
+       internal class TlsServerCertificate : HandshakeMessage
+       {
+               #region Fields
+
+               private X509CertificateCollection certificates;
+               
+               #endregion
+
+               #region Constructors
+
+               public TlsServerCertificate(Context context, byte[] buffer) 
+                       : base(context, HandshakeType.Certificate, buffer)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       base.Update();
+                       this.Context.ServerSettings.Certificates = this.certificates;
+                       this.Context.ServerSettings.UpdateCertificateRSA();
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       this.ProcessAsTls1();
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       this.certificates = new X509CertificateCollection();
+                       
+                       int readed      = 0;
+                       int length      = this.ReadInt24();
+
+                       while (readed < length)
+                       {
+                               // Read certificate length
+                               int certLength = ReadInt24();
+
+                               // Increment readed
+                               readed += 3;
+
+                               if (certLength > 0)
+                               {
+                                       // Read certificate data
+                                       byte[] buffer = this.ReadBytes(certLength);
+
+                                       // Create a new X509 Certificate
+                                       X509Certificate certificate = new X509Certificate(buffer);
+                                       certificates.Add(certificate);
+
+                                       readed += certLength;
+
+                                       DebugHelper.WriteLine(
+                                               String.Format("Server Certificate {0}", certificates.Count),
+                                               buffer);
+                               }
+                       }
+
+                       this.validateCertificates(certificates);
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               // Note: this method only works for RSA certificates
+               // DH certificates requires some changes - does anyone use one ?
+               private bool checkCertificateUsage (X509Certificate cert) 
+               {
+                       ClientContext context = (ClientContext)this.Context;
+
+                       // certificate extensions are required for this
+                       // we "must" accept older certificates without proofs
+                       if (cert.Version < 3)
+                               return true;
+
+                       KeyUsages ku = KeyUsages.none;
+                       switch (context.Negotiating.Cipher.ExchangeAlgorithmType) 
+                       {
+                               case ExchangeAlgorithmType.RsaSign:
+                                       ku = KeyUsages.digitalSignature;
+                                       break;
+                               case ExchangeAlgorithmType.RsaKeyX:
+                                       ku = KeyUsages.keyEncipherment;
+                                       break;
+                               case ExchangeAlgorithmType.DiffieHellman:
+                                       ku = KeyUsages.keyAgreement;
+                                       break;
+                               case ExchangeAlgorithmType.Fortezza:
+                                       return false; // unsupported certificate type
+                       }
+
+                       KeyUsageExtension kux = null;
+                       ExtendedKeyUsageExtension eku = null;
+
+                       X509Extension xtn = cert.Extensions ["2.5.29.15"];
+                       if (xtn != null)
+                               kux = new KeyUsageExtension (xtn);
+
+                       xtn = cert.Extensions ["2.5.29.37"];
+                       if (xtn != null)
+                               eku = new ExtendedKeyUsageExtension (xtn);
+
+                       if ((kux != null) && (eku != null)) 
+                       {
+                               // RFC3280 states that when both KeyUsageExtension and 
+                               // ExtendedKeyUsageExtension are present then BOTH should
+                               // be valid
+                               if (!kux.Support (ku))
+                                       return false;
+                               return (eku.KeyPurpose.Contains ("1.3.6.1.5.5.7.3.1") ||
+                                       eku.KeyPurpose.Contains ("2.16.840.1.113730.4.1"));
+                       }
+                       else if (kux != null) 
+                       {
+                               return kux.Support (ku);
+                       }
+                       else if (eku != null) 
+                       {
+                               // Server Authentication (1.3.6.1.5.5.7.3.1) or
+                               // Netscape Server Gated Crypto (2.16.840.1.113730.4)
+                               return (eku.KeyPurpose.Contains ("1.3.6.1.5.5.7.3.1") ||
+                                       eku.KeyPurpose.Contains ("2.16.840.1.113730.4.1"));
+                       }
+
+                       // last chance - try with older (deprecated) Netscape extensions
+                       xtn = cert.Extensions ["2.16.840.1.113730.1.1"];
+                       if (xtn != null) 
+                       {
+                               NetscapeCertTypeExtension ct = new NetscapeCertTypeExtension (xtn);
+                               return ct.Support (NetscapeCertTypeExtension.CertTypes.SslServer);
+                       }
+
+                       // certificate isn't valid for SSL server usage
+                       return false;
+               }
+
+               private void validateCertificates(X509CertificateCollection certificates)
+               {
+                       ClientContext           context                 = (ClientContext)this.Context;
+                       AlertDescription        description             = AlertDescription.BadCertificate;
+
+                       // the leaf is the web server certificate
+                       X509Certificate leaf = certificates [0];
+                       X509Cert.X509Certificate cert = new X509Cert.X509Certificate (leaf.RawData);
+
+                       ArrayList errors = new ArrayList();
+
+                       // SSL specific check - not all certificates can be 
+                       // used to server-side SSL some rules applies after 
+                       // all ;-)
+                       if (!checkCertificateUsage (leaf)) 
+                       {
+                               // WinError.h CERT_E_PURPOSE 0x800B0106
+                               errors.Add ((int)-2146762490);
+                       }
+
+                       // SSL specific check - does the certificate match 
+                       // the host ?
+                       if (!checkServerIdentity (leaf))
+                       {
+                               // WinError.h CERT_E_CN_NO_MATCH 0x800B010F
+                               errors.Add ((int)-2146762481);
+                       }
+
+                       // Note: building and verifying a chain can take much time
+                       // so we do it last (letting simple things fails first)
+
+                       // Note: In TLS the certificates MUST be in order (and
+                       // optionally include the root certificate) so we're not
+                       // building the chain using LoadCertificate (it's faster)
+
+                       // Note: IIS doesn't seem to send the whole certificate chain
+                       // but only the server certificate :-( it's assuming that you
+                       // already have this chain installed on your computer. duh!
+                       // http://groups.google.ca/groups?q=IIS+server+certificate+chain&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=85058s%24avd%241%40nnrp1.deja.com&rnum=3
+
+                       // we must remove the leaf certificate from the chain
+                       X509CertificateCollection chain = new X509CertificateCollection (certificates);
+                       chain.Remove (leaf);
+                       X509Chain verify = new X509Chain (chain);
+
+                       bool result = false;
+
+                       try
+                       {
+                               result = verify.Build (leaf);
+                       }
+                       catch (Exception)
+                       {
+                               result = false;
+                       }
+
+                       if (!result) 
+                       {
+                               switch (verify.Status) 
+                               {
+                                       case X509ChainStatusFlags.InvalidBasicConstraints:
+                                               // WinError.h TRUST_E_BASIC_CONSTRAINTS 0x80096019
+                                               errors.Add ((int)-2146869223);
+                                               break;
+                                       
+                                       case X509ChainStatusFlags.NotSignatureValid:
+                                               // WinError.h TRUST_E_BAD_DIGEST 0x80096010
+                                               errors.Add ((int)-2146869232);
+                                               break;
+                                       
+                                       case X509ChainStatusFlags.NotTimeNested:
+                                               // WinError.h CERT_E_VALIDITYPERIODNESTING 0x800B0102
+                                               errors.Add ((int)-2146762494);
+                                               break;
+                                       
+                                       case X509ChainStatusFlags.NotTimeValid:
+                                               // WinError.h CERT_E_EXPIRED 0x800B0101
+                                               description = AlertDescription.CertificateExpired;
+                                               errors.Add ((int)-2146762495);
+                                               break;
+                                       
+                                       case X509ChainStatusFlags.PartialChain:
+                                               // WinError.h CERT_E_CHAINING 0x800B010A
+                                               description = AlertDescription.UnknownCA;
+                                               errors.Add ((int)-2146762486);
+                                               break;
+                                       
+                                       case X509ChainStatusFlags.UntrustedRoot:
+                                               // WinError.h CERT_E_UNTRUSTEDROOT 0x800B0109
+                                               description = AlertDescription.UnknownCA;
+                                               errors.Add ((int)-2146762487);
+                                               break;
+                                       
+                                       default:
+                                               // unknown error
+                                               description = AlertDescription.CertificateUnknown;
+                                               errors.Add ((int)verify.Status);
+                                               break;
+                               }
+                       }
+
+                       int[] certificateErrors = (int[])errors.ToArray(typeof(int));
+
+                       if (!context.SslStream.RaiseServerCertificateValidation(
+                               cert, 
+                               certificateErrors))
+                       {
+                               throw new TlsException(
+                                       description,
+                                       "Invalid certificate received from server.");
+                       }
+               }
+
+               // RFC2818 - HTTP Over TLS, Section 3.1
+               // http://www.ietf.org/rfc/rfc2818.txt
+               // 
+               // 1.   if present MUST use subjectAltName dNSName as identity
+               // 1.1.         if multiples entries a match of any one is acceptable
+               // 1.2.         wildcard * is acceptable
+               // 2.   URI may be an IP address -> subjectAltName.iPAddress
+               // 2.1.         exact match is required
+               // 3.   Use of the most specific Common Name (CN=) in the Subject
+               // 3.1          Existing practice but DEPRECATED
+               private bool checkServerIdentity (X509Certificate cert) 
+               {
+                       ClientContext context = (ClientContext)this.Context;
+
+                       string targetHost = context.ClientSettings.TargetHost;
+
+                       X509Extension ext = cert.Extensions ["2.5.29.17"];
+                       // 1. subjectAltName
+                       if (ext != null) 
+                       {
+                               SubjectAltNameExtension subjectAltName = new SubjectAltNameExtension (ext);
+                               // 1.1 - multiple dNSName
+                               foreach (string dns in subjectAltName.DNSNames) 
+                               {
+                                       // 1.2 TODO - wildcard support
+                                       if (Match (targetHost, dns))
+                                               return true;
+                               }
+                               // 2. ipAddress
+                               foreach (string ip in subjectAltName.IPAddresses) 
+                               {
+                                       // 2.1. Exact match required
+                                       if (ip == targetHost)
+                                               return true;
+                               }
+                       }
+                       // 3. Common Name (CN=)
+                       return checkDomainName (cert.SubjectName);
+               }
+
+               private bool checkDomainName(string subjectName)
+               {
+                       ClientContext context = (ClientContext)this.Context;
+
+                       string  domainName = String.Empty;
+                       Regex search = new Regex(@"CN\s*=\s*([^,]*)");
+
+                       MatchCollection elements = search.Matches(subjectName);
+
+                       if (elements.Count == 1)
+                       {
+                               if (elements[0].Success)
+                               {
+                                       domainName = elements[0].Groups[1].Value.ToString();
+                               }
+                       }
+
+                       return Match (context.ClientSettings.TargetHost, domainName);
+               }
+
+               // ensure the pattern is valid wrt to RFC2595 and RFC2818
+               // http://www.ietf.org/rfc/rfc2595.txt
+               // http://www.ietf.org/rfc/rfc2818.txt
+               static bool Match (string hostname, string pattern)
+               {
+                       // check if this is a pattern
+                       int index = pattern.IndexOf ('*');
+                       if (index == -1) {
+                               // not a pattern, do a direct case-insensitive comparison
+                               return (String.Compare (hostname, pattern, true, CultureInfo.InvariantCulture) == 0);
+                       }
+
+                       // check pattern validity
+                       // A "*" wildcard character MAY be used as the left-most name component in the certificate.
+
+                       // unless this is the last char (valid)
+                       if (index != pattern.Length - 1) {
+                               // then the next char must be a dot .'.
+                               if (pattern [index + 1] != '.')
+                                       return false;
+                       }
+
+                       // only one (A) wildcard is supported
+                       int i2 = pattern.IndexOf ('*', index + 1);
+                       if (i2 != -1)
+                               return false;
+
+                       // match the end of the pattern
+                       string end = pattern.Substring (index + 1);
+                       int length = hostname.Length - end.Length;
+                       // no point to check a pattern that is longer than the hostname
+                       if (length <= 0)
+                               return false;
+
+                       if (String.Compare (hostname, length, end, 0, end.Length, true, CultureInfo.InvariantCulture) != 0)
+                               return false;
+
+                       // special case, we start with the wildcard
+                       if (index == 0) {
+                               // ensure we hostname non-matched part (start) doesn't contain a dot
+                               int i3 = hostname.IndexOf ('.');
+                               return ((i3 == -1) || (i3 >= (hostname.Length - end.Length)));
+                       }
+
+                       // match the start of the pattern
+                       string start = pattern.Substring (0, index);
+                       return (String.Compare (hostname, 0, start, 0, start.Length, true, CultureInfo.InvariantCulture) == 0);
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs
new file mode 100644 (file)
index 0000000..cedb565
--- /dev/null
@@ -0,0 +1,111 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+using Mono.Security;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Client
+{
+       internal class TlsServerCertificateRequest : HandshakeMessage
+       {
+               #region Fields
+
+               private ClientCertificateType[] certificateTypes;
+               private string[]                                distinguisedNames;
+
+               #endregion
+
+               #region Constructors
+
+               public TlsServerCertificateRequest(Context context, byte[] buffer) 
+                       : base(context, HandshakeType.CertificateRequest, buffer)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       base.Update();
+
+                       this.Context.ServerSettings.CertificateTypes    = this.certificateTypes;
+                       this.Context.ServerSettings.DistinguisedNames   = this.distinguisedNames;
+                       this.Context.ServerSettings.CertificateRequest  = true;
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       this.ProcessAsTls1();
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       // Read requested certificate types
+                       int typesCount = this.ReadByte();
+                                               
+                       this.certificateTypes = new ClientCertificateType[typesCount];
+
+                       for (int i = 0; i < typesCount; i++)
+                       {
+                               this.certificateTypes[i] = (ClientCertificateType)this.ReadByte();
+                       }
+
+                       /*
+                        * Read requested certificate authorities (Distinguised Names)
+                        * 
+                        * Name ::= SEQUENCE OF RelativeDistinguishedName
+                        * 
+                        * RelativeDistinguishedName ::= SET OF AttributeValueAssertion
+                        * 
+                        * AttributeValueAssertion ::= SEQUENCE {
+                        * attributeType OBJECT IDENTIFIER
+                        * attributeValue ANY }
+                        */
+                       if (this.ReadInt16() != 0)
+                       {
+                               ASN1 rdn = new ASN1(this.ReadBytes(this.ReadInt16()));
+
+                               distinguisedNames = new string[rdn.Count];
+
+                               for (int i = 0; i < rdn.Count; i++)
+                               {
+                                       // element[0] = attributeType
+                                       // element[1] = attributeValue
+                                       ASN1 element = new ASN1(rdn[i].Value);
+
+                                       distinguisedNames[i] = Encoding.UTF8.GetString(element[1].Value);
+                               }
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs
new file mode 100644 (file)
index 0000000..b383124
--- /dev/null
@@ -0,0 +1,102 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Client
+{
+       internal class TlsServerFinished : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsServerFinished(Context context, byte[] buffer) 
+                       : base(context, HandshakeType.Finished, buffer)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       base.Update();
+
+                       // Hahdshake is finished
+                       this.Context.HandshakeState = HandshakeState.Finished;
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               static private byte[] Ssl3Marker = new byte [4] { 0x53, 0x52, 0x56, 0x52 };
+
+               protected override void ProcessAsSsl3()
+               {
+                       // Compute handshake messages hashes
+                       HashAlgorithm hash = new SslHandshakeHash(this.Context.MasterSecret);
+
+                       byte[] data = this.Context.HandshakeMessages.ToArray ();
+                       hash.TransformBlock (data, 0, data.Length, data, 0);
+                       hash.TransformBlock (Ssl3Marker, 0, Ssl3Marker.Length, Ssl3Marker, 0);
+                       // hack to avoid memory allocation
+                       hash.TransformFinalBlock (CipherSuite.EmptyArray, 0, 0);
+
+                       byte[] serverHash       = this.ReadBytes((int)Length);                  
+                       byte[] clientHash       = hash.Hash;
+                       
+                       // Check server prf against client prf
+                       if (!Compare (clientHash, serverHash))
+                       {
+#warning Review that selected alert is correct
+                               throw new TlsException(AlertDescription.InsuficientSecurity, "Invalid ServerFinished message received.");
+                       }
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       byte[]                  serverPRF       = this.ReadBytes((int)Length);
+                       HashAlgorithm   hash            = new MD5SHA1();
+
+                       // note: we could call HashAlgorithm.ComputeHash(Stream) but that would allocate (on Mono)
+                       // a 4096 bytes buffer to process the hash - which is bigger than HandshakeMessages
+                       byte[] data = this.Context.HandshakeMessages.ToArray ();
+                       byte[] digest = hash.ComputeHash (data, 0, data.Length);
+
+                       byte[] clientPRF = this.Context.Current.Cipher.PRF(this.Context.MasterSecret, "server finished", digest, 12);
+
+                       // Check server prf against client prf
+                       if (!Compare (clientPRF, serverPRF))
+                       {
+                               throw new TlsException("Invalid ServerFinished message received.");
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs
new file mode 100644 (file)
index 0000000..bb662a0
--- /dev/null
@@ -0,0 +1,152 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Client
+{
+       internal class TlsServerHello : HandshakeMessage
+       {
+               #region Fields
+
+               private SecurityCompressionType compressionMethod;
+               private byte[]                                  random;
+               private byte[]                                  sessionId;
+               private CipherSuite     cipherSuite;
+               
+               #endregion
+
+               #region Constructors
+
+               public TlsServerHello(Context context, byte[] buffer) 
+                       : base(context, HandshakeType.ServerHello, buffer)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       base.Update();
+
+                       this.Context.SessionId                  = this.sessionId;
+                       this.Context.ServerRandom               = this.random;
+                       this.Context.Negotiating.Cipher = this.cipherSuite;
+                       this.Context.CompressionMethod  = this.compressionMethod;
+                       this.Context.ProtocolNegotiated = true;
+
+                       DebugHelper.WriteLine("Selected Cipher Suite {0}", this.cipherSuite.Name);
+                       DebugHelper.WriteLine("Client random", this.Context.ClientRandom);
+                       DebugHelper.WriteLine("Server random", this.Context.ServerRandom);
+                       
+                       // Compute ClientRandom + ServerRandom
+                       int clen = this.Context.ClientRandom.Length;
+                       int slen = this.Context.ServerRandom.Length;
+                       int rlen = clen + slen;
+                       byte[] cs = new byte[rlen];
+                       Buffer.BlockCopy (this.Context.ClientRandom, 0, cs, 0, clen);
+                       Buffer.BlockCopy (this.Context.ServerRandom, 0, cs, clen, slen);
+                       this.Context.RandomCS = cs;
+                       
+                       // Server Random + Client Random
+                       byte[] sc = new byte[rlen];
+                       Buffer.BlockCopy (this.Context.ServerRandom, 0, sc, 0, slen);
+                       Buffer.BlockCopy (this.Context.ClientRandom, 0, sc, slen, clen);
+                       this.Context.RandomSC = sc;
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       this.ProcessAsTls1();
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       // Read protocol version
+                       this.processProtocol(this.ReadInt16());
+                       
+                       // Read random  - Unix time + Random bytes
+                       this.random     = this.ReadBytes(32);
+
+                       // Read Session id
+                       int length = (int) ReadByte ();
+                       if (length > 0)
+                       {
+                               this.sessionId = this.ReadBytes(length);
+                               ClientSessionCache.Add (this.Context.ClientSettings.TargetHost, this.sessionId);
+                               this.Context.AbbreviatedHandshake = Compare (this.sessionId, this.Context.SessionId);
+                       } 
+                       else
+                       {
+                               this.Context.AbbreviatedHandshake = false;
+                       }
+
+                       // Read cipher suite
+                       short cipherCode = this.ReadInt16();
+                       if (this.Context.SupportedCiphers.IndexOf(cipherCode) == -1)
+                       {
+                               // The server has sent an invalid ciphersuite
+                               throw new TlsException(AlertDescription.InsuficientSecurity, "Invalid cipher suite received from server");
+                       }
+                       this.cipherSuite = this.Context.SupportedCiphers[cipherCode];
+                       
+                       // Read compression methods ( always 0 )
+                       this.compressionMethod = (SecurityCompressionType)this.ReadByte();
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void processProtocol(short protocol)
+               {
+                       SecurityProtocolType serverProtocol = this.Context.DecodeProtocolCode(protocol);
+
+                       if ((serverProtocol & this.Context.SecurityProtocolFlags) == serverProtocol ||
+                               (this.Context.SecurityProtocolFlags & SecurityProtocolType.Default) == SecurityProtocolType.Default)
+                       {
+                               this.Context.SecurityProtocol = serverProtocol;
+                               this.Context.SupportedCiphers.Clear();
+                               this.Context.SupportedCiphers = null;
+                               this.Context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(serverProtocol);
+
+                               DebugHelper.WriteLine("Selected protocol {0}", serverProtocol);
+                       }
+                       else
+                       {
+                               throw new TlsException(
+                                       AlertDescription.ProtocolVersion,
+                                       "Incorrect protocol version received from server");
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs
new file mode 100644 (file)
index 0000000..7a0e61f
--- /dev/null
@@ -0,0 +1,52 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Client
+{
+       internal class TlsServerHelloDone : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsServerHelloDone(Context context, byte[] buffer) 
+                       : base(context, HandshakeType.ServerHelloDone, buffer)
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+               }
+
+               protected override void ProcessAsTls1()
+               {
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs
new file mode 100644 (file)
index 0000000..d6c8e51
--- /dev/null
@@ -0,0 +1,121 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Cryptography;
+using Mono.Security.X509;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Client
+{
+       internal class TlsServerKeyExchange : HandshakeMessage
+       {
+               #region Fields
+
+               private RSAParameters   rsaParams;
+               private byte[]                  signedParams;
+
+               #endregion
+
+               #region Constructors
+
+               public TlsServerKeyExchange(Context context, byte[] buffer)
+                       : base(context, HandshakeType.ServerKeyExchange, buffer)
+               {
+                       this.verifySignature();
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       base.Update();
+
+                       this.Context.ServerSettings.ServerKeyExchange   = true;
+                       this.Context.ServerSettings.RsaParameters               = this.rsaParams;
+                       this.Context.ServerSettings.SignedParams                = this.signedParams;
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       this.ProcessAsTls1();
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       this.rsaParams = new RSAParameters();
+                       
+                       // Read modulus
+                       this.rsaParams.Modulus  = this.ReadBytes(this.ReadInt16());
+
+                       // Read exponent
+                       this.rsaParams.Exponent = this.ReadBytes(this.ReadInt16());
+
+                       // Read signed params
+                       this.signedParams               = this.ReadBytes(this.ReadInt16());
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void verifySignature()
+               {
+                       MD5SHA1 hash = new MD5SHA1();
+
+                       // Calculate size of server params
+                       int size = rsaParams.Modulus.Length + rsaParams.Exponent.Length + 4;
+
+                       // Create server params array
+                       TlsStream stream = new TlsStream();
+
+                       stream.Write(this.Context.RandomCS);
+                       stream.Write(this.ToArray(), 0, size);
+
+                       hash.ComputeHash(stream.ToArray());
+
+                       stream.Reset();
+                       
+                       bool isValidSignature = hash.VerifySignature(
+                               this.Context.ServerSettings.CertificateRSA,
+                               this.signedParams);
+
+                       if (!isValidSignature)
+                       {
+                               throw new TlsException(
+                                       AlertDescription.DecodeError,
+                                       "Data was not signed with the server certificate.");
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/ChangeLog b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/ChangeLog
new file mode 100644 (file)
index 0000000..1799522
--- /dev/null
@@ -0,0 +1,43 @@
+2007-05-22  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientCertificate.cs: Add chain support for x.509 client 
+       certificates. Based on Roy Versteeg patch to fix #80557.
+
+2007-05-07  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientCertificate.cs: A client certficate with a RSA public key
+       can only be used, protocol wise, to sign. Which means we should always
+       be checking it's keyUsage for digitalSignature. Fix for bug #81511
+
+2006-09-11  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientCertificate.cs: Use Negotiating.Cipher instead of Cipher.
+       Fix reading the message length if it's zero (in that case it's not 
+       present two times).
+       * TlsClientFinished.cs: Use Current.Cipher instead of Cipher. Use 
+       Compare to test client and server digests equality.
+       * TlsClientHello.cs: Use Negotiating.Cipher instead of Cipher.
+       * TlsClientKeyExchange.cs: Use Negotiating.Cipher instead of Cipher.
+       * TlsServerFinished.cs: Use Current.Cipher instead of Cipher.
+       * TlsServerHello.cs: Use Negotiating.Cipher instead of Cipher.
+
+2005-07-01  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientCertificate.cs: Fix decoding (extra length) and for null
+        (no certificates). Add basic client certificate validations before
+       calling the callback (which can override the default decision).
+       * TlsClientCertificateVerify.cs: Fix signature verification (the first
+       two bytes are the length of the signature).
+       * TlsServerCertificateRequest.cs: Sent the list of trusted root DNs.
+
+2004-11-10  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientFinished.cs: ProcessAsTls1 - get out of the loop if PRF are
+       different.
+
+2004-09-23  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * TlsClientKeyExchange.cs: Removed .Clear call on private key as itn't
+       ours (but only a reference). It also requires the callback to recreate
+       a new key object each time (which is worse). This also implies that 
+       the caller (implementing the callback) is responsible to clear it.
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/README.olive b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/README.olive
new file mode 100644 (file)
index 0000000..522f3fc
--- /dev/null
@@ -0,0 +1 @@
+Imported from Mono.Security.dll
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs
new file mode 100644 (file)
index 0000000..15d8dd6
--- /dev/null
@@ -0,0 +1,272 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using SSCX = System.Security.Cryptography.X509Certificates;
+using Mono.Security.X509;
+using Mono.Security.X509.Extensions;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Server
+{
+       internal class TlsClientCertificate : HandshakeMessage
+       {
+               #region Fields
+
+               private X509CertificateCollection clientCertificates;
+
+               #endregion
+
+               #region Constructors
+
+               public TlsClientCertificate(Context context, byte[] buffer)
+                       : base(context, HandshakeType.Certificate, buffer)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       foreach (X509Certificate certificate in clientCertificates) {
+                               this.Context.ClientSettings.Certificates.Add (new SSCX.X509Certificate (certificate.RawData));
+                       }
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       this.ProcessAsTls1();
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       int bytesRead = 0;
+                       int length = this.ReadInt24 ();
+                       this.clientCertificates = new X509CertificateCollection ();
+                       while (length > bytesRead) {
+                               int certLength = this.ReadInt24 ();
+                               bytesRead += certLength + 3;
+                               byte[] cert = this.ReadBytes (certLength);
+                               this.clientCertificates.Add (new X509Certificate (cert));
+                       }
+
+                       if (this.clientCertificates.Count > 0) 
+                       {
+                               this.validateCertificates (this.clientCertificates);
+                       } 
+                       else if ((this.Context as ServerContext).ClientCertificateRequired) 
+                       {
+                               throw new TlsException (AlertDescription.NoCertificate);
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private bool checkCertificateUsage (X509Certificate cert)
+               {
+                       ServerContext context = (ServerContext)this.Context;
+
+                       // certificate extensions are required for this
+                       // we "must" accept older certificates without proofs
+                       if (cert.Version < 3)
+                               return true;
+
+                       KeyUsages ku = KeyUsages.none;
+                       switch (context.Negotiating.Cipher.ExchangeAlgorithmType)
+                       {
+                               case ExchangeAlgorithmType.RsaSign:
+                               case ExchangeAlgorithmType.RsaKeyX:
+                                       ku = KeyUsages.digitalSignature;
+                                       break;
+                               case ExchangeAlgorithmType.DiffieHellman:
+                                       ku = KeyUsages.keyAgreement;
+                                       break;
+                               case ExchangeAlgorithmType.Fortezza:
+                                       return false; // unsupported certificate type
+                       }
+
+                       KeyUsageExtension kux = null;
+                       ExtendedKeyUsageExtension eku = null;
+
+                       X509Extension xtn = cert.Extensions["2.5.29.15"];
+                       if (xtn != null)
+                               kux = new KeyUsageExtension (xtn);
+
+                       xtn = cert.Extensions["2.5.29.37"];
+                       if (xtn != null)
+                               eku = new ExtendedKeyUsageExtension (xtn);
+
+                       if ((kux != null) && (eku != null))
+                       {
+                               // RFC3280 states that when both KeyUsageExtension and 
+                               // ExtendedKeyUsageExtension are present then BOTH should
+                               // be valid
+                               return (kux.Support (ku) &&
+                                       eku.KeyPurpose.Contains ("1.3.6.1.5.5.7.3.2"));
+                       }
+                       else if (kux != null)
+                       {
+                               return kux.Support (ku);
+                       }
+                       else if (eku != null)
+                       {
+                               // Client Authentication (1.3.6.1.5.5.7.3.2)
+                               return eku.KeyPurpose.Contains ("1.3.6.1.5.5.7.3.2");
+                       }
+
+                       // last chance - try with older (deprecated) Netscape extensions
+                       xtn = cert.Extensions["2.16.840.1.113730.1.1"];
+                       if (xtn != null)
+                       {
+                               NetscapeCertTypeExtension ct = new NetscapeCertTypeExtension (xtn);
+                               return ct.Support (NetscapeCertTypeExtension.CertTypes.SslClient);
+                       }
+
+                       // certificate isn't valid for SSL server usage
+                       return false;
+               }
+
+               private void validateCertificates (X509CertificateCollection certificates)
+               {
+                       ServerContext context = (ServerContext)this.Context;
+                       AlertDescription description = AlertDescription.BadCertificate;
+                       SSCX.X509Certificate client = null;
+                       int[] certificateErrors = null;
+
+                       // note: certificate may be null is no certificate is sent
+                       // (e.g. optional mutual authentication)
+                       if (certificates.Count > 0) {
+                               X509Certificate leaf = certificates[0];
+                       
+                               ArrayList errors = new ArrayList ();
+
+                               // SSL specific check - not all certificates can be 
+                               // used to server-side SSL some rules applies after 
+                               // all ;-)
+                               if (!checkCertificateUsage (leaf))
+                               {
+                                       // WinError.h CERT_E_PURPOSE 0x800B0106
+                                       errors.Add ((int)-2146762490);
+                               }
+
+                               X509Chain verify;
+                               // was a chain supplied ? if so use it, if not
+                               if (certificates.Count > 1) {
+                                       // if so use it (and don't build our own)
+                                       X509CertificateCollection chain = new X509CertificateCollection (certificates);
+                                       chain.Remove (leaf);
+                                       verify = new X509Chain (chain);
+                               } else {
+                                       // if not, then let's build our own (based on what's available in the stores)
+                                       verify = new X509Chain ();
+                               }
+
+                               bool result = false;
+
+                               try
+                               {
+                                       result = verify.Build (leaf);
+                               }
+                               catch (Exception)
+                               {
+                                       result = false;
+                               }
+
+                               if (!result)
+                               {
+                                       switch (verify.Status)
+                                       {
+                                               case X509ChainStatusFlags.InvalidBasicConstraints:
+                                                       // WinError.h TRUST_E_BASIC_CONSTRAINTS 0x80096019
+                                                       errors.Add ((int)-2146869223);
+                                                       break;
+
+                                               case X509ChainStatusFlags.NotSignatureValid:
+                                                       // WinError.h TRUST_E_BAD_DIGEST 0x80096010
+                                                       errors.Add ((int)-2146869232);
+                                                       break;
+
+                                               case X509ChainStatusFlags.NotTimeNested:
+                                                       // WinError.h CERT_E_VALIDITYPERIODNESTING 0x800B0102
+                                                       errors.Add ((int)-2146762494);
+                                                       break;
+
+                                               case X509ChainStatusFlags.NotTimeValid:
+                                                       // WinError.h CERT_E_EXPIRED 0x800B0101
+                                                       description = AlertDescription.CertificateExpired;
+                                                       errors.Add ((int)-2146762495);
+                                                       break;
+
+                                               case X509ChainStatusFlags.PartialChain:
+                                                       // WinError.h CERT_E_CHAINING 0x800B010A
+                                                       description = AlertDescription.UnknownCA;
+                                                       errors.Add ((int)-2146762486);
+                                                       break;
+
+                                               case X509ChainStatusFlags.UntrustedRoot:
+                                                       // WinError.h CERT_E_UNTRUSTEDROOT 0x800B0109
+                                                       description = AlertDescription.UnknownCA;
+                                                       errors.Add ((int)-2146762487);
+                                                       break;
+
+                                               default:
+                                                       // unknown error
+                                                       description = AlertDescription.CertificateUnknown;
+                                                       errors.Add ((int)verify.Status);
+                                                       break;
+                                       }
+                               }
+                               client = new SSCX.X509Certificate (leaf.RawData);
+                               certificateErrors = (int[])errors.ToArray (typeof (int));
+                       }
+                       else
+                       {
+                               certificateErrors = new int[0];
+                       }
+
+                       SSCX.X509CertificateCollection certCollection = new SSCX.X509CertificateCollection ();
+                       foreach (X509Certificate certificate in certificates) {
+                               certCollection.Add (new SSCX.X509Certificate (certificate.RawData));
+                       }
+                       if (!context.SslStream.RaiseClientCertificateValidation(client, certificateErrors))
+                       {
+                               throw new TlsException (
+                                       description,
+                                       "Invalid certificate received from client.");
+                       }
+
+                       this.Context.ClientSettings.ClientCertificate = client;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs
new file mode 100644 (file)
index 0000000..20a69ed
--- /dev/null
@@ -0,0 +1,86 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography.X509Certificates;
+
+using System.Security.Cryptography;
+using Mono.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Server
+{
+       internal class TlsClientCertificateVerify : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsClientCertificateVerify(Context context, byte[] buffer)
+                       : base(context, HandshakeType.CertificateVerify, buffer)
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       ServerContext context = (ServerContext)this.Context;
+                       int length = this.ReadInt16 ();
+                       byte[] signature = this.ReadBytes (length);
+
+                       // Verify signature
+                       SslHandshakeHash hash = new SslHandshakeHash(context.MasterSecret);                     
+                       hash.TransformFinalBlock(
+                               context.HandshakeMessages.ToArray(), 
+                               0, 
+                               (int)context.HandshakeMessages.Length);
+
+                       if (!hash.VerifySignature(context.ClientSettings.CertificateRSA, signature))
+                       {
+                               throw new TlsException(AlertDescription.HandshakeFailiure, "Handshake Failure.");
+                       }
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       ServerContext context = (ServerContext)this.Context;
+                       int length = this.ReadInt16 ();
+                       byte[] signature = this.ReadBytes (length);
+
+                       // Verify signature
+                       MD5SHA1 hash = new MD5SHA1();
+                       hash.ComputeHash(
+                               context.HandshakeMessages.ToArray(),
+                               0,
+                               (int)context.HandshakeMessages.Length);
+
+                       if (!hash.VerifySignature(context.ClientSettings.CertificateRSA, signature))
+                       {
+                               throw new TlsException (AlertDescription.HandshakeFailiure, "Handshake Failure.");
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs
new file mode 100644 (file)
index 0000000..26eaad9
--- /dev/null
@@ -0,0 +1,88 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Server
+{
+       internal class TlsClientFinished : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsClientFinished(Context context, byte[] buffer)
+                       : base(context, HandshakeType.Finished,  buffer)
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       // Compute handshake messages hashes
+                       HashAlgorithm hash = new SslHandshakeHash(this.Context.MasterSecret);
+
+                       TlsStream data = new TlsStream();
+                       data.Write(this.Context.HandshakeMessages.ToArray());
+                       data.Write((int)0x434C4E54);
+                       
+                       hash.TransformFinalBlock(data.ToArray(), 0, (int)data.Length);
+
+                       data.Reset();
+
+                       byte[] clientHash       = this.ReadBytes((int)Length);                  
+                       byte[] serverHash       = hash.Hash;
+                       
+                       // Check client prf against server prf
+                       if (!Compare (clientHash, serverHash))
+                       {
+                               throw new TlsException(AlertDescription.DecryptError, "Decrypt error.");
+                       }
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       byte[]                  clientPRF               = this.ReadBytes((int)this.Length);
+                       HashAlgorithm   hash                    = new MD5SHA1();
+
+                       byte[] data = this.Context.HandshakeMessages.ToArray ();
+                       byte[] digest = hash.ComputeHash (data, 0, data.Length);
+
+                       byte[] serverPRF = this.Context.Current.Cipher.PRF(
+                               this.Context.MasterSecret, "client finished", digest, 12);
+
+                       // Check client prf against server prf
+                       if (!Compare (clientPRF, serverPRF))
+                       {
+                               throw new TlsException(AlertDescription.DecryptError, "Decrypt error.");
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs
new file mode 100644 (file)
index 0000000..e328e2a
--- /dev/null
@@ -0,0 +1,151 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Server
+{
+       internal class TlsClientHello : HandshakeMessage
+       {
+               #region Private Fields
+
+               private byte[]  random;
+               private byte[]  sessionId;
+               private short[] cipherSuites;
+               private byte[]  compressionMethods;
+
+               #endregion
+
+               #region Constructors
+
+               public TlsClientHello(Context context, byte[] buffer)
+                       : base(context, HandshakeType.ClientHello, buffer)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       base.Update();
+
+                       this.selectCipherSuite();
+                       this.selectCompressionMethod();
+
+                       this.Context.SessionId                  = this.sessionId;
+                       this.Context.ClientRandom               = this.random;
+                       this.Context.ProtocolNegotiated = true;
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       this.ProcessAsTls1();
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       // Client Version
+                       this.processProtocol(this.ReadInt16());
+                                                               
+                       // Random bytes - Unix time + Radom bytes [28]
+                       this.random = this.ReadBytes(32);
+                       
+                       // Session id
+                       // Send the session ID empty
+                       this.sessionId = this.ReadBytes(this.ReadByte());
+                       
+                       // Read Supported Cipher Suites count
+                       this.cipherSuites = new short[this.ReadInt16()/2];
+
+                       // Read Cipher Suites
+                       for (int i = 0; i < this.cipherSuites.Length; i++)
+                       {
+                               this.cipherSuites[i] = this.ReadInt16();
+                       }
+
+                       // Compression methods length
+                       this.compressionMethods = new byte[this.ReadByte()];
+                       
+                       for (int i = 0; i < this.compressionMethods.Length; i++)
+                       {
+                               this.compressionMethods[i] = this.ReadByte();
+                       }
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void processProtocol(short protocol)
+               {
+                       SecurityProtocolType clientProtocol = this.Context.DecodeProtocolCode(protocol);
+
+                       if ((clientProtocol & this.Context.SecurityProtocolFlags) == clientProtocol ||
+                               (this.Context.SecurityProtocolFlags & SecurityProtocolType.Default) == SecurityProtocolType.Default)
+                       {
+                               this.Context.SecurityProtocol = clientProtocol;
+                               this.Context.SupportedCiphers.Clear();
+                               this.Context.SupportedCiphers = null;
+                               this.Context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(clientProtocol);
+                       }
+                       else
+                       {
+                               throw new TlsException(AlertDescription.ProtocolVersion, "Incorrect protocol version received from server");
+                       }
+               }
+
+               private void selectCipherSuite()
+               {
+                       int index = 0;
+
+                       for (int i = 0; i < this.cipherSuites.Length; i++)
+                       {
+                               if ((index = this.Context.SupportedCiphers.IndexOf(this.cipherSuites[i])) != -1)        
+                               {
+                                       this.Context.Negotiating.Cipher = this.Context.SupportedCiphers[index];
+                                       break;
+                               }
+                       }
+
+                       if (this.Context.Negotiating.Cipher == null)
+                       {
+                               throw new TlsException(AlertDescription.InsuficientSecurity, "Insuficient Security");
+                       }
+               }
+
+               private void selectCompressionMethod()
+               {
+                       this.Context.CompressionMethod = SecurityCompressionType.None;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs
new file mode 100644 (file)
index 0000000..ceeb39a
--- /dev/null
@@ -0,0 +1,116 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Server
+{
+    internal class TlsClientKeyExchange : HandshakeMessage
+    {
+        #region Constructors
+
+        public TlsClientKeyExchange(Context context, byte[] buffer) : 
+                       base(context,
+                               HandshakeType.ClientKeyExchange, 
+                               buffer)
+        {
+        }
+
+        #endregion
+
+        #region Protected Methods
+
+        protected override void ProcessAsSsl3()
+        {
+            AsymmetricAlgorithm privKey = null;
+            ServerContext context = (ServerContext)this.Context;
+
+            // Select the private key information
+            privKey = context.SslStream.RaisePrivateKeySelection(
+                new X509Certificate(context.ServerSettings.Certificates[0].RawData),
+                null);
+
+            if (privKey == null)
+            {
+                throw new TlsException(AlertDescription.UserCancelled, "Server certificate Private Key unavailable.");
+            }
+
+            // Read client premaster secret
+            byte[] clientSecret = this.ReadBytes((int)this.Length);
+
+            // Decrypt premaster secret
+            RSAPKCS1KeyExchangeDeformatter deformatter = new RSAPKCS1KeyExchangeDeformatter(privKey);
+
+            byte[] preMasterSecret = deformatter.DecryptKeyExchange(clientSecret);
+
+            // Create master secret
+            this.Context.Negotiating.Cipher.ComputeMasterSecret(preMasterSecret);
+
+            // Create keys
+           this.Context.Negotiating.Cipher.ComputeKeys ();
+
+            // Initialize Cipher Suite
+           this.Context.Negotiating.Cipher.InitializeCipher ();
+        }
+
+        protected override void ProcessAsTls1()
+        {
+            AsymmetricAlgorithm privKey = null;
+            ServerContext context = (ServerContext)this.Context;
+
+            // Select the private key information
+            // Select the private key information
+            privKey = context.SslStream.RaisePrivateKeySelection(
+                new X509Certificate(context.ServerSettings.Certificates[0].RawData),
+                null);
+
+            if (privKey == null)
+            {
+                throw new TlsException(AlertDescription.UserCancelled, "Server certificate Private Key unavailable.");
+            }
+
+            // Read client premaster secret
+            byte[] clientSecret = this.ReadBytes(this.ReadInt16());
+
+            // Decrypt premaster secret
+            RSAPKCS1KeyExchangeDeformatter deformatter = new RSAPKCS1KeyExchangeDeformatter(privKey);
+
+            byte[] preMasterSecret = deformatter.DecryptKeyExchange(clientSecret);
+
+            // Create master secret
+            this.Context.Negotiating.Cipher.ComputeMasterSecret(preMasterSecret);
+
+            // Create keys
+            this.Context.Negotiating.Cipher.ComputeKeys();
+
+            // Initialize Cipher Suite
+            this.Context.Negotiating.Cipher.InitializeCipher();
+        }
+
+        #endregion
+    }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs
new file mode 100644 (file)
index 0000000..7475d2d
--- /dev/null
@@ -0,0 +1,74 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Text.RegularExpressions;
+using System.Security.Cryptography;
+using X509Cert = System.Security.Cryptography.X509Certificates;
+
+using Mono.Security.X509;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Server
+{
+       internal class TlsServerCertificate : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsServerCertificate(Context context) 
+                       : base(context, HandshakeType.Certificate)
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       this.ProcessAsTls1();
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       TlsStream certs = new TlsStream();
+
+                       foreach (X509Certificate certificate in this.Context.ServerSettings.Certificates)
+                       {
+                               // Write certificate length
+                               certs.WriteInt24(certificate.RawData.Length);
+
+                               // Write certificate data
+                               certs.Write(certificate.RawData);
+                       }
+
+                       this.WriteInt24(Convert.ToInt32(certs.Length));
+                       this.Write(certs.ToArray());
+
+                       certs.Close();
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs
new file mode 100644 (file)
index 0000000..a86e421
--- /dev/null
@@ -0,0 +1,97 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+using Mono.Security;
+using Mono.Security.X509;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Server
+{
+       internal class TlsServerCertificateRequest : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsServerCertificateRequest(Context context) 
+                       : base(context, HandshakeType.CertificateRequest)
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       this.ProcessAsTls1();
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       ServerContext context = (ServerContext)this.Context;
+                       
+                       int count = context.ServerSettings.CertificateTypes.Length;
+
+                       this.WriteByte(Convert.ToByte(count));
+
+                       // Write requested certificate types
+                       for (int i = 0; i < count; i++)
+                       {
+                               this.WriteByte((byte)context.ServerSettings.CertificateTypes[i]);
+                       }
+
+                       /*
+                        * Write requested certificate authorities (Distinguised Names)
+                        * 
+                        * Name ::= SEQUENCE OF RelativeDistinguishedName
+                        * 
+                        * RelativeDistinguishedName ::= SET OF AttributeValueAssertion
+                        * 
+                        * AttributeValueAssertion ::= SEQUENCE {
+                        * attributeType OBJECT IDENTIFIER
+                        * attributeValue ANY }
+                        */
+
+                       if (context.ServerSettings.DistinguisedNames.Length > 0)
+                       {
+                               TlsStream list = new TlsStream ();
+                               // this is the worst formating ever :-|
+                               foreach (string dn in context.ServerSettings.DistinguisedNames)
+                               {
+                                       byte[] name = X501.FromString (dn).GetBytes ();
+                                       list.Write ((short)name.Length);
+                                       list.Write (name);
+                               }
+                               this.Write ((short)list.Length);
+                               this.Write (list.ToArray ());
+                       }
+                       else
+                       {
+                               this.Write ((short)0);
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs
new file mode 100644 (file)
index 0000000..9131150
--- /dev/null
@@ -0,0 +1,75 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Server
+{
+       internal class TlsServerFinished : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsServerFinished(Context context) 
+                       : base(context, HandshakeType.Finished)
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               static private byte[] Ssl3Marker = new byte [4] { 0x53, 0x52, 0x56, 0x52 };
+
+               protected override void ProcessAsSsl3()
+               {
+                       // Compute handshake messages hashes
+                       HashAlgorithm hash = new SslHandshakeHash(this.Context.MasterSecret);
+
+                       byte[] data = this.Context.HandshakeMessages.ToArray ();
+                       hash.TransformBlock (data, 0, data.Length, data, 0);
+                       hash.TransformBlock (Ssl3Marker, 0, Ssl3Marker.Length, Ssl3Marker, 0);
+                       // hack to avoid memory allocation
+                       hash.TransformFinalBlock (CipherSuite.EmptyArray, 0, 0);
+
+                       this.Write(hash.Hash);
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       // Compute handshake messages hash
+                       HashAlgorithm hash = new MD5SHA1();
+                       byte[] data = this.Context.HandshakeMessages.ToArray ();
+                       byte[] digest = hash.ComputeHash (data, 0, data.Length);
+
+                       // Write message
+                       this.Write(this.Context.Current.Cipher.PRF(
+                               this.Context.MasterSecret, "server finished", digest, 12));
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs
new file mode 100644 (file)
index 0000000..c02c24c
--- /dev/null
@@ -0,0 +1,122 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Server
+{
+       internal class TlsServerHello : HandshakeMessage
+       {
+               #region Private Fields
+
+               private int             unixTime;
+               private byte[]  random;
+
+               #endregion
+
+               #region Constructors
+
+               public TlsServerHello(Context context) 
+                       : base(context, HandshakeType.ServerHello)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       base.Update();
+
+                       TlsStream random = new TlsStream();
+
+                       // Compute Server Random
+                       random.Write(this.unixTime);
+                       random.Write(this.random);
+
+                       this.Context.ServerRandom = random.ToArray();
+
+                       // Compute ClientRandom + ServerRandom
+                       random.Reset();
+                       random.Write(this.Context.ClientRandom);
+                       random.Write(this.Context.ServerRandom);
+
+                       this.Context.RandomCS = random.ToArray();
+
+                       // Server Random + Client Random
+                       random.Reset();
+                       random.Write(this.Context.ServerRandom);
+                       random.Write(this.Context.ClientRandom);
+
+                       this.Context.RandomSC = random.ToArray();
+
+                       random.Reset();
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       this.ProcessAsTls1();
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       // Write protocol version
+                       this.Write(this.Context.Protocol);
+                       
+                       // Write Unix time
+                       this.unixTime = this.Context.GetUnixTime();
+                       this.Write(this.unixTime);
+
+                       // Write Random bytes
+                       random = this.Context.GetSecureRandomBytes(28);
+                       this.Write(this.random);
+                                               
+                       if (this.Context.SessionId == null)
+                       {
+                               this.WriteByte(0);
+                       }
+                       else
+                       {
+                               // Write Session ID length
+                               this.WriteByte((byte)this.Context.SessionId.Length);
+
+                               // Write Session ID
+                               this.Write(this.Context.SessionId);
+                       }
+
+                       // Write selected cipher suite
+                       this.Write(this.Context.Negotiating.Cipher.Code);
+                       
+                       // Write selected compression method
+                       this.WriteByte((byte)this.Context.CompressionMethod);
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs
new file mode 100644 (file)
index 0000000..1ce467c
--- /dev/null
@@ -0,0 +1,52 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Server
+{
+       internal class TlsServerHelloDone : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsServerHelloDone(Context context) 
+                       : base(context, HandshakeType.ServerHelloDone)
+               {
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+               }
+
+               protected override void ProcessAsTls1()
+               {
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs
new file mode 100644 (file)
index 0000000..8a2d033
--- /dev/null
@@ -0,0 +1,110 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+using SX509 = System.Security.Cryptography.X509Certificates;
+
+using Mono.Security.Cryptography;
+using Mono.Security.X509;
+
+namespace Mono.Security.Protocol.Tls.Handshake.Server
+{
+       internal class TlsServerKeyExchange : HandshakeMessage
+       {
+               #region Constructors
+
+               public TlsServerKeyExchange(Context context)
+                       : base(context, HandshakeType.ServerKeyExchange)
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Update()
+               {
+                       throw new NotSupportedException();
+               }
+
+               #endregion
+
+               #region Protected Methods
+
+               protected override void ProcessAsSsl3()
+               {
+                       this.ProcessAsTls1();
+               }
+
+               protected override void ProcessAsTls1()
+               {
+                       ServerContext context = (ServerContext)this.Context;
+
+                       // Select the private key information
+                       RSA rsa = (RSA)context.SslStream.PrivateKeyCertSelectionDelegate(
+                               new SX509.X509Certificate(context.ServerSettings.Certificates[0].RawData),
+                               null);
+
+                       RSAParameters rsaParams = rsa.ExportParameters(false);
+
+                       // Write Modulus
+                       this.WriteInt24(rsaParams.Modulus.Length);
+                       this.Write(rsaParams.Modulus, 0, rsaParams.Modulus.Length);
+                       
+                       // Write exponent
+                       this.WriteInt24(rsaParams.Exponent.Length);
+                       this.Write(rsaParams.Exponent, 0, rsaParams.Exponent.Length);
+
+                       // Write signed params
+                       byte[] signature = this.createSignature(rsa, this.ToArray());
+                       this.WriteInt24(signature.Length);
+                       this.Write(signature);
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private byte[] createSignature(RSA rsa, byte[] buffer)
+               {
+                       MD5SHA1 hash = new MD5SHA1();
+
+                       // Create server params array
+                       TlsStream stream = new TlsStream();
+
+                       stream.Write(this.Context.RandomCS);
+                       stream.Write(buffer, 0, buffer.Length);
+
+                       hash.ComputeHash(stream.ToArray());
+
+                       stream.Reset();
+
+                       return hash.CreateSignature(rsa);                       
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/ChangeLog b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/ChangeLog
new file mode 100644 (file)
index 0000000..be1099e
--- /dev/null
@@ -0,0 +1,205 @@
+2006-09-11  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * HandshakeMessage.cs: EncodeMessage is called very often so we avoid
+       many allocations by not creating a TlsStream and by not calling 
+       WriteInt24 (IPAddress.HostToNetworkOrder and BitConverter.GetBytes).
+       We also cache the encoded result to avoid computing/allocating the 
+       encoded message twice (in most cases) for the handshake. Added a
+       Compare static method to compare byte arrays (easier to step out when
+       debugging).
+
+2004-07-14  Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Updated license head in c# source files for use
+       always the same format.
+
+2003-11-17 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/SslClientStream.cs:
+
+               Removed ReadByte method, use innerStream.ReadByte() method instead.
+
+2003-11-13 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Added implementation of an SslClientStream class similar to the MS .NET Framework 1.2 documentation.
+
+               The next files are no more needed:
+
+                       - TlsSession.cs
+
+                       - TlsNetworkStream.cs
+
+                       - TlsSocket.cs
+
+                       - TlsSessionState.cs
+
+               The next files are renamed:
+
+                       - TlsSessionSettings.cs -> TlsClientSettings.cs
+
+                       - TlsSessionContext.cs -> TlsContext.cs
+
+               The next files are new:
+
+                       - SslClientStream.cs ( the name is non definitive yet )
+
+               The next files where changed to reflect the new canges:
+
+                       - TlsHandshakeMessage.cs
+
+                       - TlsClientCertificate.cs
+
+                       - TlsClientCertificateVerify.cs
+
+                       - TlsClientFinished.cs
+
+                       - TlsClientHello.cs
+
+                       - TlsClientKeyExchange.cs
+
+                       - TlsServerCertificate.cs
+
+                       - TlsServerCertificateRequest.cs
+
+                       - TlsServerFinished.cs
+
+                       - TlsServerHello.cs
+
+                       - TlsServerHelloDone.cs
+
+                       - TlsServerKeyExchange.cs
+
+                       - TlsAlert.cs
+
+                       - TlsCloseNotifyAlert.cs
+
+               
+2003-11-12 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+       
+               - Changes for give full error message only in debug mode ( Thanks to Sebastién Pouliot. )
+               
+       * Mono.Security.Protocol.Tls/TlsProtocol.cs:
+       
+               - Renamed to SecurityProtocolType.cs ( for match .NET 1.2 )
+       
+       * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+       
+               - Renamed to MD5SHA1.cs ( Thanks to Sebastién Pouliot. )
+               
+       * Mono.Security.Cryptography/TlsCompressionMethod.cs:
+       
+               - Renamed to SecurityCompressionType.
+               
+       * Mono.Security.Protocol.Tls/CipherAlgorithmType.cs:
+       * Mono.Security.Protocol.Tls/HashAlgorithmType.cs:
+       * Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs:
+       
+               - New enumerations that matches .NET 1.2 definitions with some minor differences.
+       
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsCipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+       
+               - Added changes for make use of new enumerations.
+       
+       * Mono.Security.Protocol.Tls/TlsClientStream.cs:
+       
+               - Added new informative properties that matches .NET 1.2 SslClientStream
+               ( Not all the properties are implemented yet ).
+
+
+2003-11-10 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+
+               - Fixed invalid alert message.
+
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+       * Mono.Security.Cryptography/HMAC.cs:
+       * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+
+               - Changed ( Thanks to Sebastién Pouliot for his feedback )
+
+                       SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
+                       MD5CryptoServiceProvider sha = new MD5CryptoServiceProvider();
+
+                       to
+
+                       HashAlgorithm sha = SHA1.Create();
+                       HashAlgorithm md5 = MD5.Create(); 
+
+2003-11-04 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+
+               - Added custom padding for record encryption.
+
+
+2003-11-03 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Handshake/TlsHandshakeMessages.cs:
+       
+               - Removed file.
+
+       * Mono.Security.Protocol.Tls/TlsSslHandshakeHash.cs:
+       
+               - New class for handshake hashes calculation on SSL3 protocol.
+
+       * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+       
+               - Fixed mac keys clearing for SSL3 protocol.
+
+       * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs:
+       
+               - Added changes for make use of new TlsSslHandshakeHash class.
+       
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs:
+       
+               - Added initial implementation for SSL3 protocol.
+       
+       * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+       
+               - New class for md5-sha hash calculation.
+                                                       
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsHandshakeMessage.cs:
+       
+               - Make use of new MD5SHA1CryptoServiceProvider class.
+               
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+       
+               - Added initial implementation (not finished).
+                       
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
+       
+               - Minor change to message processing.
+
+               - Changed verify method name to verifySignature.
+                       
+       * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+       
+               - Changed handshakeHashes member to be an TlsStream.
+
+2003-10-28 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSessionSettings.cs:
+       * Mono.Security.Protocol.Tls/TlsServerSettings.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
+
+               - Added changes for make use of X509 classes from mono.
+
+2003-10-23 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Added partial implementation of SSL3 protocol ( not finished yet ).
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs
new file mode 100644 (file)
index 0000000..8bff712
--- /dev/null
@@ -0,0 +1,38 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls.Handshake
+{
+       [Serializable]
+       internal enum ClientCertificateType
+       {
+               RSA                     = 1,
+               DSS                     = 2,
+               RSAFixed        = 3,
+               DSSFixed        = 4,
+               Unknown         = 255
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs
new file mode 100644 (file)
index 0000000..5407127
--- /dev/null
@@ -0,0 +1,170 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls.Handshake
+{
+       internal abstract class HandshakeMessage : TlsStream
+       {
+               #region Fields
+
+               private Context                 context;
+               private HandshakeType   handshakeType;
+               private ContentType     contentType;
+               private byte[]          cache;
+
+               #endregion
+
+               #region Properties
+
+               public Context Context
+               {
+                       get { return this.context; }
+               }
+
+               public HandshakeType HandshakeType
+               {
+                       get { return this.handshakeType; }
+               }
+
+               public ContentType ContentType
+               {
+                       get { return this.contentType; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public HandshakeMessage(
+                       Context                 context,
+                       HandshakeType   handshakeType) 
+                       : this(context, handshakeType, ContentType.Handshake)
+               {
+               }
+
+               public HandshakeMessage(
+                       Context                 context,
+                       HandshakeType   handshakeType,
+                       ContentType             contentType) : base()
+               {
+                       this.context            = context;
+                       this.handshakeType      = handshakeType;
+                       this.contentType        = contentType;
+               }
+
+               public HandshakeMessage(
+                       Context                 context, 
+                       HandshakeType   handshakeType, 
+                       byte[]                  data) : base(data)
+               {
+                       this.context            = context;
+                       this.handshakeType      = handshakeType;                                                
+               }
+
+               #endregion
+
+               #region Abstract Methods
+
+               protected abstract void ProcessAsTls1();
+
+               protected abstract void ProcessAsSsl3();
+
+               #endregion
+
+               #region Methods
+
+               public void Process()
+               {
+                       switch (this.Context.SecurityProtocol)
+                       {
+                               case SecurityProtocolType.Tls:
+                               case SecurityProtocolType.Default:
+                                       this.ProcessAsTls1();
+                                       break;
+
+                               case SecurityProtocolType.Ssl3:
+                                       this.ProcessAsSsl3();
+                                       break;
+
+                               case SecurityProtocolType.Ssl2:
+                               default:
+                                       throw new NotSupportedException("Unsupported security protocol type");
+                       }
+               }
+
+               public virtual void Update()
+               {
+                       if (this.CanWrite)
+                       {
+                               // result may (should) be available from a previous call to EncodeMessage
+                               if (cache == null)
+                                       cache = this.EncodeMessage ();
+                               this.context.HandshakeMessages.Write (cache);
+                               this.Reset();
+                               cache = null;
+                       }
+               }
+
+               public virtual byte[] EncodeMessage()
+               {
+                       cache = null;
+
+                       if (CanWrite)
+                       {
+                               byte[] hs = this.ToArray ();
+                               int len = hs.Length;
+                               cache = new byte[4 + len];
+
+                               cache[0] = (byte) HandshakeType;
+                               // Length as an Int24 in Network Order
+                               cache[1] = (byte) (len >> 16);
+                               cache[2] = (byte) (len >> 8);
+                               cache[3] = (byte) len;
+                               Buffer.BlockCopy (hs, 0, cache, 4, len);
+                       }
+
+                       return cache;
+               }
+
+               static public bool Compare (byte[] buffer1, byte[] buffer2)
+               {
+                       // in our case both null can't exist (or be valid)
+                       if ((buffer1 == null) || (buffer2 == null))
+                               return false;
+
+                       if (buffer1.Length != buffer2.Length)
+                               return false;
+
+                       for (int i = 0; i < buffer1.Length; i++) {
+                               if (buffer1[i] != buffer2[i])
+                                       return false;
+                       }
+                       return true;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs
new file mode 100644 (file)
index 0000000..a0165a3
--- /dev/null
@@ -0,0 +1,44 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls.Handshake
+{
+       [Serializable]
+       internal enum HandshakeType : byte
+       {
+               HelloRequest            = 0,
+               ClientHello                     = 1,
+               ServerHello                     = 2,
+               Certificate                     = 11,
+               ServerKeyExchange       = 12,
+               CertificateRequest      = 13,
+               ServerHelloDone         = 14,
+               CertificateVerify       = 15,
+               ClientKeyExchange       = 16,
+               Finished                        = 20,
+               None                            = 255
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/README.olive b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls.Handshake/README.olive
new file mode 100644 (file)
index 0000000..522f3fc
--- /dev/null
@@ -0,0 +1 @@
+Imported from Mono.Security.dll
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/Alert.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/Alert.cs
new file mode 100644 (file)
index 0000000..b40292c
--- /dev/null
@@ -0,0 +1,267 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+       #region Enumerations
+
+       [Serializable]
+       internal enum AlertLevel : byte
+       {
+               Warning = 1,
+               Fatal   = 2
+       }
+
+       [Serializable]
+       internal enum AlertDescription : byte
+       {
+               CloseNotify                             = 0,
+               UnexpectedMessage               = 10,
+               BadRecordMAC                    = 20,
+               DecryptionFailed                = 21,
+               RecordOverflow                  = 22,
+               DecompressionFailiure   = 30,
+               HandshakeFailiure               = 40,
+               NoCertificate                   = 41,   // should be used in SSL3
+               BadCertificate                  = 42,
+               UnsupportedCertificate  = 43,
+               CertificateRevoked              = 44,
+               CertificateExpired              = 45,
+               CertificateUnknown              = 46,
+               IlegalParameter                 = 47,
+               UnknownCA                               = 48,
+               AccessDenied                    = 49,
+               DecodeError                             = 50,
+               DecryptError                    = 51,
+               ExportRestriction               = 60,
+               ProtocolVersion                 = 70,
+               InsuficientSecurity             = 71,
+               InternalError                   = 80,
+               UserCancelled                   = 90,
+               NoRenegotiation                 = 100
+       }
+
+       #endregion
+       
+       internal class Alert
+       {
+               #region Fields
+
+               private AlertLevel                      level;
+               private AlertDescription        description;
+
+               #endregion
+
+               #region Properties
+
+               public AlertLevel Level
+               {
+                       get { return this.level; }
+               }
+
+               public AlertDescription Description
+               {
+                       get { return this.description; }
+               }
+
+               public string Message
+               {
+                       get { return Alert.GetAlertMessage(this.description); }
+               }
+
+               public bool IsWarning
+               {
+                       get { return this.level == AlertLevel.Warning ? true : false; }
+               }
+
+               /*
+               public bool IsFatal
+               {
+                       get { return this.level == AlertLevel.Fatal ? true : false; }
+               }
+               */
+
+               public bool IsCloseNotify
+               {
+                       get
+                       {
+                               if (this.IsWarning &&
+                                       this.description == AlertDescription.CloseNotify)
+                               {
+                                       return true;
+                               }
+
+                               return false;
+                       }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public Alert(AlertDescription description)
+               {
+                       this.inferAlertLevel();
+                       this.description = description;
+               }
+
+               public Alert(
+                       AlertLevel                      level,
+                       AlertDescription        description)
+               {
+                       this.level                      = level;
+                       this.description        = description;
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void inferAlertLevel()
+               {
+                       switch (description)
+                       {
+                               case AlertDescription.CloseNotify:
+                               case AlertDescription.NoRenegotiation:
+                               case AlertDescription.UserCancelled:
+                                       this.level = AlertLevel.Warning;
+                                       break;
+
+                               case AlertDescription.AccessDenied:
+                               case AlertDescription.BadCertificate:
+                               case AlertDescription.BadRecordMAC:
+                               case AlertDescription.CertificateExpired:
+                               case AlertDescription.CertificateRevoked:
+                               case AlertDescription.CertificateUnknown:
+                               case AlertDescription.DecodeError:
+                               case AlertDescription.DecompressionFailiure:
+                               case AlertDescription.DecryptError:
+                               case AlertDescription.DecryptionFailed:
+                               case AlertDescription.ExportRestriction:
+                               case AlertDescription.HandshakeFailiure:
+                               case AlertDescription.IlegalParameter:
+                               case AlertDescription.InsuficientSecurity:
+                               case AlertDescription.InternalError:
+                               case AlertDescription.ProtocolVersion:
+                               case AlertDescription.RecordOverflow:
+                               case AlertDescription.UnexpectedMessage:
+                               case AlertDescription.UnknownCA:
+                               case AlertDescription.UnsupportedCertificate:
+                               default:
+                                       this.level = AlertLevel.Fatal;
+                                       break;
+                       }
+               }
+               
+               #endregion
+
+               #region Static Methods
+
+               public static string GetAlertMessage(AlertDescription description)
+               {
+                       #if (DEBUG)
+                       switch (description)
+                       {
+                               case AlertDescription.AccessDenied:
+                                       return "An inappropriate message was received.";
+
+                               case AlertDescription.BadCertificate:
+                                       return "TLSCiphertext decrypted in an invalid way.";
+
+                               case AlertDescription.BadRecordMAC:
+                                       return "Record with an incorrect MAC.";
+
+                               case AlertDescription.CertificateExpired:
+                                       return "Certificate has expired or is not currently valid";
+
+                               case AlertDescription.CertificateRevoked:
+                                       return "Certificate was revoked by its signer.";
+                                       
+                               case AlertDescription.CertificateUnknown:
+                                       return "Certificate Unknown.";
+
+                               case AlertDescription.CloseNotify:
+                                       return "Connection closed";
+
+                               case AlertDescription.DecodeError:
+                                       return "A message could not be decoded because some field was out of the specified range or the length of the message was incorrect.";
+
+                               case AlertDescription.DecompressionFailiure:
+                                       return "The decompression function received improper input (e.g. data that would expand to excessive length).";
+
+                               case AlertDescription.DecryptError:
+                                       return "TLSCiphertext decrypted in an invalid way: either it wasn`t an even multiple of the block length or its padding values, when checked, weren`t correct.";
+
+                               case AlertDescription.DecryptionFailed:
+                                       return "Handshake cryptographic operation failed, including being unable to correctly verify a signature, decrypt a key exchange, or validate finished message.";
+
+                               case AlertDescription.ExportRestriction:
+                                       return "Negotiation not in compliance with export restrictions was detected.";
+
+                               case AlertDescription.HandshakeFailiure:
+                                       return "Unable to negotiate an acceptable set of security parameters given the options available.";
+
+                               case AlertDescription.IlegalParameter:
+                                       return "A field in the handshake was out of range or inconsistent with other fields.";
+                                       
+                               case AlertDescription.InsuficientSecurity:
+                                       return "Negotiation has failed specifically because the server requires ciphers more secure than those supported by the client.";
+                                       
+                               case AlertDescription.InternalError:
+                                       return "Internal error unrelated to the peer or the correctness of the protocol makes it impossible to continue.";
+
+                               case AlertDescription.NoRenegotiation:
+                                       return "Invalid renegotiation.";
+
+                               case AlertDescription.ProtocolVersion:
+                                       return "Unsupported protocol version.";
+
+                               case AlertDescription.RecordOverflow:
+                                       return "Invalid length on TLSCiphertext record or TLSCompressed record.";
+
+                               case AlertDescription.UnexpectedMessage:
+                                       return "Invalid message received.";
+
+                               case AlertDescription.UnknownCA:
+                                       return "CA can't be identified as a trusted CA.";
+
+                               case AlertDescription.UnsupportedCertificate:
+                                       return "Certificate was of an unsupported type.";
+
+                               case AlertDescription.UserCancelled:
+                                       return "Handshake cancelled by user.";
+
+                               default:
+                                       return "";
+                       }
+                       #else
+                       return "The authentication or decryption has failed.";
+                       #endif
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ChangeLog b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ChangeLog
new file mode 100644 (file)
index 0000000..24429ef
--- /dev/null
@@ -0,0 +1,791 @@
+2007-09-12  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Context.cs: Clear key info memory (not just nullify). Fix bug #82819
+
+2007-08-16  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * RecordProtocol.cs, SslStreamBase.cs: Ensure nothing (even the same
+       thread) can confuse the record decoding code. Fix bug #82145 (LDAP) 
+       which uses several thread over a single SslClientStream instance.
+
+2007-05-23 Gonzalo Paniagua Javier <gonzalo.mono@gmail.com>
+
+       * Context.cs: fix the calculation of the unix time.
+
+2007-05-09  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * HttpsClientStream.cs: Add support for client certificates from
+       HttpWebRequest if it uses X509Certificate2 instance (which requires
+       using 2.0 profile) and if the private key is available.
+       * SslStreamBase.cs: Fix warning in 2.0 because Stream now implements
+       Dispose. Rework Close (in 2.0) to avoid infinite recursion.
+
+2006-12-08  Sebastien Pouliot  <sebastien@ximian.com> 
+
+       * ClientSessionCache.cs: Fix cache to be really used. Original patch
+       by Roy Versteeg. Fix bug #80175.
+
+2006-12-08  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * ClientSessionCache.cs: Check for a new environment variable to 
+       control the cache validity period (MONO_TLS_SESSION_CACHE_TIMEOUT).
+       Fix bug #80174.
+
+2006-09-11  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * CipherSuite.cs: Avoid creating a CryptoStream and a MemoryStream in
+       EncryptRecord (removing the need to do a keysetup each time). Add
+       helper methods to write inside byte buffers. Decrypt the data in
+       place (without allocating new memory) as the result will always be
+       smaller than the original. Avoid TlsStream in CreatePremasterSecret 
+       method. All HMAC access are done with the Negotiating parameters.
+       * ClientRecordProtocol.cs: Set HandshakeState to None if we receive
+       a HelloRequest during an existing session. Remove overidden method
+       ProcessChangeCipherSpec. Skip memory allocation if possible.
+       * Context.cs: Add new SecurityParameters for current, negotiating, 
+       read and write (actually only two different instance exists). Change
+       readSequenceNumber and writeSequenceNumber to ulong to match specs.
+       Remove all properties that are moved/replaced with SecurityParameters.
+       Added methods to Start and End a switch of the security parameters.
+       * RecordProtocol.cs: Add code to ProcessChangeCipherSpec (not abstract
+       anymore). Remove ReadShort and it's use. Deal with null alerts in 
+       SendAlert method (internal error). Change code to deal with 
+       SendChangeCipherSpec inside an existing (encrypted) session. Update 
+       Cipher to use the correct one (mostly Read.Cipher or Negotiating.Cipher
+       for ProcessCipherSpecV2Buffer method).
+       * SecurityParameters.cs: New. Deal with all parameters that changes
+       between negotiations.
+       * ServerRecordProtocol.cs: Remove method ProcessChangeCipherSpec.
+       * SslCipherSuite.cs: Don't use TlsStream when computing MAC. Set the
+       MAC keys to the Negotiating security parameters.
+       * SslClientStream.cs: Change calls from Cipher to Negotiating.Cipher.
+       * SslServerStream.cs: Change calls from Cipher to Negotiating.Cipher.
+       Remove debugging dead code (DateTime).
+       * SslStreamBase.cs: Change calls from Cipher to Current.Cipher. Reuse
+       existing memory buffer.
+       * TlsCipherSuite.cs: Don't use TlsStream when computing MAC. Set the
+       MAC keys to the Negotiating security parameters.
+       * TlsClientSettings.cs: Comment code cause compiler warnings.
+       * TlsStream.cs: Avoid/reduce memory allocations when reading or 
+       writing small integer values to the stream.
+
+2006-09-07  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * HttpsClientStream.cs: Honor ServicePointManager.SecurityProtocol to
+       select between SSL3, TLS1 or, by default, auto. Great for testing :)
+
+2006-06-08  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * ClientRecordProtocol.cs: Avoid a NRE when the server request a
+       re-negotiation of the security parameters. Possible fix for #78597.
+
+2006-04-21  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslCipherSuite.cs: Enable abbreviated handshakes for SSL3 too.
+
+2006-04-12  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * ClientSessionCache.cs: Deal with empty (null) master secret, that 
+       can find their ways into the cache, and treat them as invalid. Fix
+       bug #78085.
+
+2006-04-10  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * ClientSessionCache.cs: The session id can be zero-length (like our 
+       own server class).
+       * SslServerStream.cs: Adapt code to fixes made in cipher suite and
+       message processing changes in client code.
+
+2006-03-16  Sebastien Pouliot  <sebastien@ximian.com>
+       * CipherSuiteFactory.cs: Fix bad key exchange values for non-export
+       cihpers. Most certificates have "too much" usages by default so this
+       was hidden from view.
+       * SslStreamBase.cs: Safety net. Throw an exception if we're waiting 
+       for more than five (5) minutes for an async read or write to complete.
+
+2006-03-16  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * ClientSessionCache.cs: New. Handle a client-side session cache to 
+       enable the use of abbreviated handshake whenever possible. This will
+       reduce the number of negotiation (a very CPU intensive process) done
+       with the same host.
+       * Context.cs: Add a property for AbbreviatedHandshake.
+       * RecordProtocol.cs: Don't send Finished record from ChangeCipherSpec
+       as this won't work if the message flow change.
+       * SslClientStream.cs: Line endings.
+       * SslServerStream.cs: Throw an exception if ReceiveRecord return null
+       or an empty buffer (i.e. communication ended with client). Fix #76254.
+       * SslStreamBase.cs: Re-add synchronous implementations for Read and 
+       Write.
+       * TlsCipherSuite.cs: Update the client-side session cache with the 
+       mastersecret.
+       * TlsStream.cs: Avoid possible buffer underun reading bytes (found by
+       Gonzalo).
+
+2006-03-08  Sebastien Pouliot  <sebastien@ximian.com>
+  
+       * SslStreamBase.cs: Re-implemented the synchronous versions of Read
+       and Write methods so they don't use the async code.
+
+2006-03-07 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * SslStreamBase.cs: avoid creating the ManualResetEvent whenever
+       possible. Don't lock on an instance of an object that the user can get.
+
+2006-03-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * RecordProtocol.cs: avoid creating the ManualResetEvent whenever
+       possible. Don't lock on an instance of an object that the user can get.
+
+2006-03-02  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * RecordProtocol.cs: Fix possible endless loop (#77663). Remove hack
+       for an old, fixed, MCS bug (#67711).
+
+2005-10-06  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * ClientRecordProtocol.cs: Update HandshakeMessages after each 
+       message. Fix bug #76258.
+       * RecordProtocol.cs: Remove writing into the HandshakeMessages stream
+       at this stage. We may need the data before that. Fix bug #76258.
+       * ServerRecordProtocol.cs: Update HandshakeMessages after each 
+       message. Fix bug #76258.
+       * SslServerStream.cs: Changed check for the presence of client 
+       certificates during handshake.
+
+2005-09-02  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslStreamBase.cs, ServerRecordProtocol.cs, SslClientStream.cs,
+       ClientRecordProtocol.cs, RecordProtocol.cs, SslServerStream.cs:
+       Re-written async support for Ssl[Client|Server]Stream from JD Conley
+       <jd.conley@coversant.net> with minor changes. Fix bug #75687 (and a 
+       lot of other known problems).
+
+2005-07-01  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * ServerContext.cs: Build the list of trusted certificates from all
+       the trusted root for the current user and the local machine.
+       * SslServerStream.cs: Add support for client certificate (and the 
+       callback for optional mutual authentication with SSL3).
+
+2005-06-22  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslClientStream.cs: Removed failsafe timeout of 5 minutes as some
+       protocols can go idle for longer than this.
+
+2005-06-14  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslClientStream.cs: Add support for _optional_ mutual authentication.
+       SSL3 and TLS1 deals differently with this. SSL3 tested with OpenSSL,
+       TSL1 tested with OpenSSL and LDAPS/AD.
+
+2005-06-06  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Alert.cs: Add NoCertificate (41) which _should_ be used in SSL3
+       if we don't want to send a certificate when requested by a server
+       (e.g. in the case the mutual authentication is optional).
+       * CipherSuite.cs: Fixed recursive property. Changed type to short so
+       it can hold 256 bits (valid value). Fixed ctor so it doesn't assign
+       the it's own value.
+
+2005-05-13  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslClientStream.cs: Forgot to set the event in the previous fix.
+
+2005-05-10 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * SslClientStream.cs: check for the dispose in NetworkReadCallback.
+       Patch by Sebastien "Cryptoman" Pouliot.
+
+2005-04-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * SslClientStream.cs: gotta call EndInvoke, not EndRead.
+
+2005-04-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * SslClientStream.cs: MemoryStream does not implement proper Begin*
+       methods, so we need this to prevent infinite recursion if we have a
+       callback that calls BeginRead.
+
+2005-04-13  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * RecordProtocol.cs: Some API changes so a record can be decoded from
+       any supplied stream (not just the inner network stream).
+       * SslClientStream.cs: BeginRead is now truly async if the Negotiate is
+       called from BeginWrite (where it should be in most case).
+       * SslServerStream.cs: Adapted to API changes in RecordProtocol.cs.
+
+2005-04-12  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslHandshakeHash.cs: Changed "SslHash" to "MD5SHA1". Fix #71696.
+
+2005-04-10  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * HttpsClientStream.cs: Added a TrustFailure property so a 
+       WebException can now report TrustFailure correctly. Fix bug 74286.
+
+2005-04-07  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslCipherSuite.cs: Fix calculation (sequence number) for the server
+       side stream. Patch by Brian Ritchie.
+
+2005-02-04  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Reverting last changes in SslClientStream and RecordProtocol. This
+       break when sending large files back and forth (echo test).
+
+2005-02-02  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslClientStream.cs: Throw exception when we receive a null record.
+       * RecordProtocol.cs: Added code to avoid blocking and endless loops
+       if the data is incomplete or missing - even in the case the server
+       side doesn't close the connection (see new cutcli tool).
+
+2004-12-15  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * CipherSuite.cs: Removed unused MD5 and SHA1 instances created in 
+       PRF method (fix compilation warnings).
+
+2004-12-13  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslClientStream.cs: New internal property, ServerCertificates, to
+       "easily" retreive the server's certificate chain using reflection.
+
+2004-11-23  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * RecordProtocol.cs: Fixed ClientHelloV2 support.
+
+2004-11-10  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * CipherSuiteFactory.cs: Activated RSA_WITH_AES_256_CBC_SHA as it is
+       supported by some browsers.
+       * ContentType.cs: Removed ClientHelloV2 from the enum as it is not a
+       "true" content type (it just looks so where we're processing it).
+       * Context.cs: Added support to switch protocol (e.g. SSL2->SSL3 or 
+       SSL2->TLS1). Contributed by Carlos Guzman Alvarez.
+       * RecordProtocol.cs: Added support for ClientHelloV2 message 
+       (contributed by Carlos Guzman Alvarez). This is a Handshake message
+       so it must be MACed. Also fixed the challenge length because some
+       browsers implementation don't interpret "This value must be 32." as
+       having 32 bytes.
+
+2004-10-05  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslClientStream.cs: Changed InputBuffer to internal (was protected).
+
+2004-10-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * HttpsClientStream.cs: the .ctor receives a pre-read buffer now.
+       * SslClientStream.cs: added InputBuffer property.
+
+2004-09-23  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * RecordProtocol.cs: Fix alert data that could leak into appplication 
+       data (e.g. when closing the SSL session).
+
+2004-07-14  Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Removed duplicate license header file from
+       all source files.
+
+2004-07-14  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslClientStream.cs: Changed lock to "new object()" and not 
+       String.Empty (as the read/write locks points becomes the same).
+       * SslServerStream.cs: Changed lock to "new object()" and not 
+       String.Empty (as the read/write locks points becomes the same).
+
+2004-07-14 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * HttpsClientStream.cs: get an HttpWebRequest so that we can use the
+       ServicePoint it has. No need to get the host now.
+
+2004-05-09 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/Alert.cs:
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/CipherSuiteCollection.cs:
+       * Mono.Security.Protocol.Tls/ClientRecordProtocol.cs:
+       * Mono.Security.Protocol.Tls/Context.cs:
+       * Mono.Security.Protocol.Tls/RecordProtocol.cs:
+       * Mono.Security.Protocol.Tls/SecurityCompressionType.cs:
+       * Mono.Security.Protocol.Tls/ServerRecordProtocol.cs:
+       * Mono.Security.Protocol.Tls/SslServerStream.cs:
+       * Mono.Security.Protocol.Tls/TlsClientSettings.cs:
+
+               - Changes for fix FxCop Rules.
+
+               - Reworked CipherSuiteCollection class.
+
+
+2004-04-21 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/DebugHelper.cs:
+
+               - New class.
+
+       * Mono.Security.Protocol.Tls/ClientRecordProtocol.cs:
+       * Mono.Security.Protocol.Tls/RecordProtocol.cs:
+       * Mono.Security.Protocol.Tls/Context.cs:
+       * Mono.Security.Protocol.Tls/Context.cs:
+       * Mono.Security.Protocol.Tls/SslCipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsCipherSuite.cs:
+       * Mono.Security.Protocol.Tls/SslClientStream.cs:
+
+               - Added debug capabilities.
+
+       * Mono.Security.Protocol.Tls/ServerContext.cs:
+
+               - Added initialization of requested CertificateTypes and CA's
+
+2004-04-16 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/TlsException.cs:
+
+               - Make it public until npgsql people can fix their sources.
+
+2004-03-19 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/TlsServerSettings.cs:
+
+               - Added new CertificateRSA property.
+
+               - Added new UpdateCertfificateRSA method.
+
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+
+               - Removed CertificateRSA() method.      
+
+2004-03-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * CipherSuite.cs: Fixed PRF generation when secret is an odd number of 
+       bytes (section 5 in RFC2246).
+       * CipherSuiteFactory.cs: Added algorithms RSA_EXPORT_WITH_RC4_40_MD5,
+       RSA_EXPORT_WITH_RC2_CBC_40_MD5, RSA_EXPORT_WITH_DES40_CBC_SHA,
+       RSA_EXPORT_WITH_RC4_56_MD5, RSA_EXPORT_WITH_RC2_CBC_56_MD5,
+       RSA_EXPORT_WITH_DES_CBC_56_SHA and RSA_EXPORT_WITH_RC4_56_SHA to both
+       SSL3 and TLS1 protocols.
+       * SslCipherSuite.cs: Fixed key generation for exportable ciphers.
+       * TlsCipherSuite.cs: Fixed key generation for exportable ciphers.
+
+2004-03-16 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/SslCipherSuite.cs:
+
+               - Added changes for allow it to work as server or client.
+
+2004-03-15 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/TlsStream.cs:
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsCipherSuite.cs:
+       * Mono.Security.Protocol.Tls/SslHandshakeHash.cs:
+       * Mono.Security.Protocol.Tls/RecordProtocol.cs:
+
+               - Use Buffer.BlockCopy instead of System.Array.Copy
+
+2004-03-10 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/Ciphersuite.cs:
+
+               - Added generation of the Server encryption algorithms.
+
+               - Modified encryption/decription methods for work
+               as client or server as needed.
+
+       * Mono.Security.Protocol.Tls/RecordProtocol.cs:
+       * Mono.Security.Protocol.Tls/ClientRecordProtocol.cs:
+       * Mono.Security.Protocol.Tls/ServerRecordProtocol.cs:
+
+               - Added new ProcessChangeCipherSpec method.
+
+       * Mono.Security.Protocol.Tls/Context.cs:
+
+               - Added new PrintBuffer method ( for debug ).
+
+       * Mono.Security.Protocol.Tls/SslClientStream.cs:
+       * Mono.Security.Protocol.Tls/SslServerStream.cs:
+
+               - Callback cleanup.
+
+2004-03-06 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/SslServerStream.cs:
+
+               - Initial implementation of the doHandshake method.
+
+        - Added initial events implementation.
+
+       * Mono.Security.Protocol.Tls/Ciphersuite.cs:
+       * Mono.Security.Protocol.Tls/TlsCiphersuite.cs:
+       * Mono.Security.Protocol.Tls/ClientRecordProtocol.cs:
+       * Mono.Security.Protocol.Tls/ServerRecordProtocol.cs:
+       * Mono.Security.Protocol.Tls/SslClientStream.cs:
+       * Mono.Security.Protocol.Tls/TlsServerSettings.cs:
+       * Mono.Security.Protocol.Tls/TlsClientSettings.cs:
+       * Mono.Security.Protocol.Tls/ClientContext.cs:
+
+               - Changes for make use of the renamed classes and enums.
+
+       * Mono.Security.Protocol.Tls/TlsContentType.cs:
+
+               - Renamed to ContentType.cs ( Enum and file )
+       * Mono.Security.Protocol.Tls/TlsCiphersuiteCollection.cs:
+
+               - Renamed to CiphersuiteCollection.cs ( Class and file )
+
+       * Mono.Security.Protocol.Tls/TlsCiphersuiteFactory.cs:
+
+               - Renamed to CiphersuiteCollection.cs ( Class and file )
+
+       * Mono.Security.Protocol.Tls/TlsSslHandshakeHash.cs:
+
+               - Renamed to SslHandshakeHash.cs ( Class and file )
+
+       * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+
+               - Renamed to SslCipherSuite.cs ( Class and file )
+
+2004-02-26 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/HandshakeState.cs:
+
+               - New file.
+
+       * Mono.Security.Protocol.Tls/SslClientStream.cs:
+       * Mono.Security.Protocol.Tls/SslServerStream.cs:
+       * Mono.Security.Protocol.Tls/Context.cs:
+       * Mono.Security.Protocol.Tls/ClientContext.cs:
+       * Mono.Security.Protocol.Tls/ClientRecordProtocol.cs:
+
+               - Added changes for better handling of ClientHelloRequest messages.
+
+2004-02-25  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * HttpsClientStream.cs: New. Internal glue class between System.dll 
+       WebConnection and SslClientStream to reduce reflection.
+       * SslClientStream.cs: RaiseServerCertificateValidation is now virtual
+       to allow HttpsClientStream to override it.
+
+2004-02-24 Carlos Guzman Alvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/RecordProtocol.cs:
+       * Mono.Security.Protocol.Tls/SslClientStream.cs:
+       * Mono.Security.Protocol.Tls/SslServerStream.cs:
+
+               - Reimplementation of TLS/SSL Alert Protocol.
+
+2004-02-20 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Handshake.Client/SslClientCertificate.cs:
+
+        - Improved exception handling.
+
+2004-02-18 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/CipherAlgorithmType.cs:
+       * Mono.Security.Protocol.Tls/HashAlgorithmType.cs:
+       * Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs:
+
+               - Added Serializable attribute.
+
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsCipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsContext.cs:
+
+               - Added some optimizations proposed by Sebastien Pouliot.
+
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs:
+
+               - Changes on Common Name detection and certificate error handling ( Thanks to Sebastien Pouliot for his feedback ).
+
+2004-02-18  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * SslClientStream.cs: Fixed (inverted) condition for ServerCertificate.
+       * SecurityProtocolType.cs: Added [Serializable] to enum to match MS 
+       implementation.
+
+2004-02-17 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/SslClientStream.cs:
+
+               - Added changes to security properties for check that the handshake is finished.
+
+       * Mono.Security.Protocol.Tls/SslClientStream.cs:
+
+        - Added changes for bring async methods to work ( Thanks to Sebastien Pouliot )
+
+        - Reworked the record fragmentation.
+
+        - Fix for send the close notify alert in the Close method
+        only if the Handshake is fully negotiated.
+
+
+2004-02-16 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs:
+
+        - Changed ciphersuites order of preference ( Thanks to Sebastien Pouliot for his feedback ).
+
+2004-02-15 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+       * Mono.Security.Protocol.Tls/SslClientStream.cs:
+               - Added specific control od available data for Network Streams
+               on Read ( Thanks to Francisco Figueiredo Jr. for his feedback ).
+               - Removed test code.
+
+2004-02-14 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+    * Mono.Security.Protocol.Tls/SslClientStream.cs:
+
+        - Removed test code.
+
+2003-11-17 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/SslClientStream.cs:
+
+               Removed ReadByte method, use innerStream.ReadByte() method instead.
+
+2003-11-13 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Added implementation of an SslClientStream class similar to the MS .NET Framework 1.2 documentation.
+
+               The next files are no more needed:
+
+                       - TlsSession.cs
+
+                       - TlsNetworkStream.cs
+
+                       - TlsSocket.cs
+
+                       - TlsSessionState.cs
+
+               The next files are renamed:
+
+                       - TlsSessionSettings.cs -> TlsClientSettings.cs
+
+                       - TlsSessionContext.cs -> TlsContext.cs
+
+               The next files are new:
+
+                       - SslClientStream.cs ( the name is non definitive yet )
+
+               The next files where changed to reflect the new canges:
+
+                       - TlsHandshakeMessage.cs
+
+                       - TlsClientCertificate.cs
+
+                       - TlsClientCertificateVerify.cs
+
+                       - TlsClientFinished.cs
+
+                       - TlsClientHello.cs
+
+                       - TlsClientKeyExchange.cs
+
+                       - TlsServerCertificate.cs
+
+                       - TlsServerCertificateRequest.cs
+
+                       - TlsServerFinished.cs
+
+                       - TlsServerHello.cs
+
+                       - TlsServerHelloDone.cs
+
+                       - TlsServerKeyExchange.cs
+
+                       - TlsAlert.cs
+
+                       - TlsCloseNotifyAlert.cs
+
+               
+2003-11-12 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+       
+               - Changes for give full error message only in debug mode ( Thanks to Sebastién Pouliot. )
+               
+       * Mono.Security.Protocol.Tls/TlsProtocol.cs:
+       
+               - Renamed to SecurityProtocolType.cs ( for match .NET 1.2 )
+       
+       * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+       
+               - Renamed to MD5SHA1.cs ( Thanks to Sebastién Pouliot. )
+               
+       * Mono.Security.Cryptography/TlsCompressionMethod.cs:
+       
+               - Renamed to SecurityCompressionType.
+               
+       * Mono.Security.Protocol.Tls/CipherAlgorithmType.cs:
+       * Mono.Security.Protocol.Tls/HashAlgorithmType.cs:
+       * Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs:
+       
+               - New enumerations that matches .NET 1.2 definitions with some minor differences.
+       
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsCipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+       
+               - Added changes for make use of new enumerations.
+       
+       * Mono.Security.Protocol.Tls/TlsClientStream.cs:
+       
+               - Added new informative properties that matches .NET 1.2 SslClientStream
+               ( Not all the properties are implemented yet ).
+
+
+2003-11-10 Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
+
+               - Fixed invalid alert message.
+
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+       * Mono.Security.Cryptography/HMAC.cs:
+       * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+
+               - Changed ( Thanks to Sebastién Pouliot for his feedback )
+
+                       SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
+                       MD5CryptoServiceProvider sha = new MD5CryptoServiceProvider();
+
+                       to
+
+                       HashAlgorithm sha = SHA1.Create();
+                       HashAlgorithm md5 = MD5.Create(); 
+
+2003-11-04 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+
+               - Added custom padding for record encryption.
+
+
+2003-11-03 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls.Handshake/TlsHandshakeMessages.cs:
+       
+               - Removed file.
+
+       * Mono.Security.Protocol.Tls/TlsSslHandshakeHash.cs:
+       
+               - New class for handshake hashes calculation on SSL3 protocol.
+
+       * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+       
+               - Fixed mac keys clearing for SSL3 protocol.
+
+       * Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs:
+       
+               - Added changes for make use of new TlsSslHandshakeHash class.
+       
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs:
+       
+               - Added initial implementation for SSL3 protocol.
+       
+       * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
+       
+               - New class for md5-sha hash calculation.
+                                                       
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsHandshakeMessage.cs:
+       
+               - Make use of new MD5SHA1CryptoServiceProvider class.
+               
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+       
+               - Added initial implementation (not finished).
+                       
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
+       
+               - Minor change to message processing.
+
+               - Changed verify method name to verifySignature.
+                       
+       * Mono.Security.Protocol.Tls/TlsSessionContext.cs:
+       
+               - Changed handshakeHashes member to be an TlsStream.
+
+2003-10-28 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Mono.Security.Protocol.Tls/CipherSuite.cs:
+       * Mono.Security.Protocol.Tls/TlsSessionSettings.cs:
+       * Mono.Security.Protocol.Tls/TlsServerSettings.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs:
+       * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
+
+               - Added changes for make use of X509 classes from mono.
+
+2003-10-23 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       * Added partial implementation of SSL3 protocol ( not finished yet ).
+
+       * TlsAbstractCipherSuite.cs: Renamed to CipherSuite.cs.
+
+       * Removed AssemblyInfo.cs file.
+
+2003-10-21 Carlos Guzmán Álvarez <carlosga@telefonica.net>
+
+       TlsCipherSuiteFactory.cs: Changed names of private methods.
+
+       TlsSslCipherSuite.cs: Replaced implementations of key generation methods with a throw new NotSupportedException().
+
+
+2003-10-20  Carlos Guzmán Álvarez  <carlosga@telefonica.net>
+
+       TlsCupherSuite.cs: Fixed padding length calculation on record encryption.
+       
+       TlsSessionContext.cs:   Added new CompressionMethod property.
+                                       Added new MAX_FRAGMENT_SIZE constant.
+
+       TlsSession.cs: Removed MaxFragmentSize property.
+
+       TlsSocket.cs: Replaced use of TlsSesison.MaxFragmentSize by TlsSessionContext.MAX_FAGMENT_SIZE
+       
+       TlsSessionSettings.cs: Added new CompressionMethod property.
+
+       * Abstracted CipherSuite classes for allow work with other protocol versions.
+
+       * Added new files :
+
+               TlsAbstractCipherSuite.cs 
+                       
+               TlsSslCipherSuite.cs
+
+               TlsCipherSuiteFactory.cs
+
+               TlsCompressionMethod.cs
+
+       * Added new cipher suites definitions based on RFC3268 - (http://www.ietf.org/rfc/rfc3268.txt)
+
+       * Added two new supported ciphersuites for TLS protocol:
+
+               TLS_RSA_WITH_AES_256_CBC_SHA
+
+               TLS_RSA_WITH_AES_128_CBC_SHA
+
+       * Moved key generation stuff to specific cipher suite classes.
+
+2003-10-20  Pedro Martínez Juliá  <yoros@wanadoo.es>
+
+       * AssemblyInfo.cs: commented out KeyFile reference.
+
+       * TlsSession.cs: changed Math.Pow for System.Math.Pow because of MCS
+       bug with namespace resolving.
+
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs
new file mode 100644 (file)
index 0000000..e8e6171
--- /dev/null
@@ -0,0 +1,40 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+       [Serializable]
+       public enum CipherAlgorithmType
+       {
+               Des,
+               None,
+               Rc2,
+               Rc4,
+               Rijndael,
+               SkipJack,
+               TripleDes
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherSuite.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherSuite.cs
new file mode 100644 (file)
index 0000000..66f3a65
--- /dev/null
@@ -0,0 +1,580 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Text;
+using System.Security.Cryptography;
+
+using Mono.Security;
+using Mono.Security.Cryptography;
+using M = Mono.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal abstract class CipherSuite
+       {
+               #region Static Fields
+
+               public static byte[] EmptyArray = new byte[0];
+
+               #endregion
+
+               #region Fields
+
+               private short                                   code;
+               private string                                  name;
+               private CipherAlgorithmType             cipherAlgorithmType;
+               private HashAlgorithmType               hashAlgorithmType;
+               private ExchangeAlgorithmType   exchangeAlgorithmType;
+               private bool                                    isExportable;
+               private CipherMode                              cipherMode;
+               private byte                                    keyMaterialSize;
+               private int                                             keyBlockSize;
+               private byte                                    expandedKeyMaterialSize;
+               private short                                   effectiveKeyBits;
+               private byte                                    ivSize;
+               private byte                                    blockSize;
+               private Context                                 context;
+               private SymmetricAlgorithm              encryptionAlgorithm;
+               private ICryptoTransform                encryptionCipher;
+               private SymmetricAlgorithm              decryptionAlgorithm;
+               private ICryptoTransform                decryptionCipher;
+               private KeyedHashAlgorithm              clientHMAC;
+               private KeyedHashAlgorithm              serverHMAC;
+                       
+               #endregion
+
+               #region Protected Properties
+
+               protected ICryptoTransform EncryptionCipher
+               {
+                       get { return this.encryptionCipher; }
+               }
+
+               protected ICryptoTransform DecryptionCipher
+               {
+                       get { return this.decryptionCipher; }
+               }
+
+               protected KeyedHashAlgorithm ClientHMAC
+               {
+                       get { return this.clientHMAC; }
+               }
+               
+               protected KeyedHashAlgorithm ServerHMAC
+               {
+                       get { return this.serverHMAC; }
+               }
+
+               #endregion
+
+               #region Properties
+
+               public CipherAlgorithmType CipherAlgorithmType
+               {
+                       get { return this.cipherAlgorithmType; }
+               }
+
+               public string HashAlgorithmName
+               {
+                       get 
+                       {  
+                               switch (this.hashAlgorithmType)
+                               {
+                                       case HashAlgorithmType.Md5:
+                                               return "MD5";
+
+                                       case HashAlgorithmType.Sha1:
+                                               return "SHA1";
+
+                                       default:
+                                               return "None";
+                               }
+                       }
+               }
+
+               public HashAlgorithmType HashAlgorithmType
+               {
+                       get { return this.hashAlgorithmType; }
+               }
+
+               public int HashSize
+               {
+                       get 
+                       { 
+                               switch (this.hashAlgorithmType)
+                               {
+                                       case HashAlgorithmType.Md5:
+                                               return 16;
+
+                                       case HashAlgorithmType.Sha1:
+                                               return 20;
+
+                                       default:
+                                               return 0;
+                               }
+                       }       
+               }
+               
+               public ExchangeAlgorithmType ExchangeAlgorithmType
+               {
+                       get { return this.exchangeAlgorithmType; }
+               }
+
+               public CipherMode CipherMode
+               {
+                       get { return this.cipherMode; }
+               }
+
+               public short Code
+               {
+                       get { return this.code; }
+               }
+
+               public string Name
+               {
+                       get { return this.name; }
+               }
+
+               public bool IsExportable
+               {
+                       get { return this.isExportable; }
+               }
+
+               public byte     KeyMaterialSize
+               {
+                       get { return this.keyMaterialSize; }
+               }
+
+               public int KeyBlockSize
+               {
+                       get { return this.keyBlockSize; }
+               }
+
+               public byte     ExpandedKeyMaterialSize
+               {
+                       get { return this.expandedKeyMaterialSize; }
+               }
+
+               public short    EffectiveKeyBits
+               {
+                       get { return this.effectiveKeyBits; }
+               }
+               
+               public byte IvSize
+               {
+                       get { return this.ivSize; }
+               }
+
+               /*
+               public byte     BlockSize
+               {
+                       get { return this.blockSize; }
+               }
+               */
+
+               public Context Context
+               {
+                       get { return this.context; }
+                       set 
+                       { 
+                               this.context = value; 
+                       }
+               }
+
+               #endregion
+
+               #region Constructors
+               
+               public CipherSuite(
+                       short code, string name, CipherAlgorithmType cipherAlgorithmType, 
+                       HashAlgorithmType hashAlgorithmType, ExchangeAlgorithmType exchangeAlgorithmType,
+                       bool exportable, bool blockMode, byte keyMaterialSize, 
+                       byte expandedKeyMaterialSize, short effectiveKeyBits, 
+                       byte ivSize, byte blockSize)
+               {
+                       this.code                                       = code;
+                       this.name                                       = name;
+                       this.cipherAlgorithmType        = cipherAlgorithmType;
+                       this.hashAlgorithmType          = hashAlgorithmType;
+                       this.exchangeAlgorithmType      = exchangeAlgorithmType;
+                       this.isExportable                       = exportable;
+                       if (blockMode)
+                       {
+                               this.cipherMode                 = CipherMode.CBC;
+                       }
+                       this.keyMaterialSize            = keyMaterialSize;
+                       this.expandedKeyMaterialSize= expandedKeyMaterialSize;
+                       this.effectiveKeyBits           = effectiveKeyBits;
+                       this.ivSize                                     = ivSize;
+                       this.blockSize                          = blockSize;
+                       this.keyBlockSize                       = (this.keyMaterialSize + this.HashSize + this.ivSize) << 1;
+               }
+
+               #endregion
+
+               #region Methods
+
+               internal void Write (byte[] array, int offset, short value)
+               {
+                       if (offset > array.Length - 2)
+                               throw new ArgumentException ("offset");
+
+                       array [offset    ] = (byte) (value >> 8);
+                       array [offset + 1] = (byte) value;
+               }
+
+               internal void Write (byte[] array, int offset, ulong value)
+               {
+                       if (offset > array.Length - 8)
+                               throw new ArgumentException ("offset");
+
+                       array [offset    ] = (byte) (value >> 56);
+                       array [offset + 1] = (byte) (value >> 48);
+                       array [offset + 2] = (byte) (value >> 40);
+                       array [offset + 3] = (byte) (value >> 32);
+                       array [offset + 4] = (byte) (value >> 24);
+                       array [offset + 5] = (byte) (value >> 16);
+                       array [offset + 6] = (byte) (value >> 8);
+                       array [offset + 7] = (byte) value;
+               }
+
+               public void InitializeCipher()
+               {
+                       this.createEncryptionCipher();
+                       this.createDecryptionCipher();
+               }
+
+               public byte[] EncryptRecord(byte[] fragment, byte[] mac)
+               {
+                       // Encryption ( fragment + mac [+ padding + padding_length] )
+                       int length = fragment.Length + mac.Length;
+                       int padlen = 0;
+                       if (this.CipherMode == CipherMode.CBC) {
+                               // Calculate padding_length
+                               length++; // keep an extra byte
+                               padlen = (this.blockSize - length % this.blockSize);
+                               if (padlen == this.blockSize) {
+                                       padlen = 0;
+                               }
+                               length += padlen;
+                       }
+
+                       byte[] plain = new byte [length];
+                       Buffer.BlockCopy (fragment, 0, plain, 0, fragment.Length);
+                       Buffer.BlockCopy (mac, 0, plain, fragment.Length, mac.Length);
+                       if (padlen > 0) {
+                               int start = fragment.Length + mac.Length;
+                               for (int i = start; i < (start + padlen + 1); i++) {
+                                       plain[i] = (byte)padlen;
+                               }
+                       }
+
+                       this.EncryptionCipher.TransformBlock (plain, 0, plain.Length, plain, 0);
+                       return plain;
+               }
+
+               public void DecryptRecord(byte[] fragment, out byte[] dcrFragment, out byte[] dcrMAC)
+               {
+                       int     fragmentSize    = 0;
+                       int paddingLength       = 0;
+
+                       // Decrypt message fragment ( fragment + mac [+ padding + padding_length] )
+                       this.DecryptionCipher.TransformBlock(fragment, 0, fragment.Length, fragment, 0);
+                       // optimization: decrypt "in place", worst case: padding will reduce the size of the data
+                       // this will cut in half the memory allocations (dcrFragment and dcrMAC remains)
+
+                       // Calculate fragment size
+                       if (this.CipherMode == CipherMode.CBC)
+                       {
+                               // Calculate padding_length
+                               paddingLength   = fragment[fragment.Length - 1];
+                               fragmentSize    = (fragment.Length - (paddingLength + 1)) - this.HashSize;
+                       }
+                       else
+                       {
+                               fragmentSize = fragment.Length - this.HashSize;
+                       }
+
+                       dcrFragment = new byte[fragmentSize];
+                       dcrMAC          = new byte[HashSize];
+
+                       Buffer.BlockCopy(fragment, 0, dcrFragment, 0, dcrFragment.Length);
+                       Buffer.BlockCopy(fragment, dcrFragment.Length, dcrMAC, 0, dcrMAC.Length);
+               }
+
+               #endregion
+
+               #region Abstract Methods
+
+               public abstract byte[] ComputeClientRecordMAC(ContentType contentType, byte[] fragment);
+
+               public abstract byte[] ComputeServerRecordMAC(ContentType contentType, byte[] fragment);
+
+               public abstract void ComputeMasterSecret(byte[] preMasterSecret);
+
+               public abstract void ComputeKeys();
+
+               #endregion
+
+               #region Key Generation Methods
+
+               public byte[] CreatePremasterSecret()
+               {
+                       ClientContext   context = (ClientContext)this.context;
+
+                       // Generate random bytes (total size)
+                       byte[] preMasterSecret = this.context.GetSecureRandomBytes (48);
+                       // and replace the first two bytes with the protocol version
+                       // (maximum support version not actual)
+                       preMasterSecret [0] = (byte)(context.ClientHelloProtocol >> 8);
+                       preMasterSecret [1] = (byte)context.ClientHelloProtocol;
+
+                       return preMasterSecret;
+               }
+
+               public byte[] PRF(byte[] secret, string label, byte[] data, int length)
+               {
+                       /* Secret Length calc exmplain from the RFC2246. Section 5
+                        * 
+                        * S1 and S2 are the two halves of the secret and each is the same
+                        * length. S1 is taken from the first half of the secret, S2 from the
+                        * second half. Their length is created by rounding up the length of the
+                        * overall secret divided by two; thus, if the original secret is an odd
+                        * number of bytes long, the last byte of S1 will be the same as the
+                        * first byte of S2.
+                        */
+
+                       // split secret in 2
+                       int secretLen = secret.Length >> 1;
+                       // rounding up
+                       if ((secret.Length & 0x1) == 0x1)
+                               secretLen++;
+
+                       // Seed
+                       TlsStream seedStream = new TlsStream();
+                       seedStream.Write(Encoding.ASCII.GetBytes(label));
+                       seedStream.Write(data);
+                       byte[] seed = seedStream.ToArray();
+                       seedStream.Reset();
+
+                       // Secret 1
+                       byte[] secret1 = new byte[secretLen];
+                       Buffer.BlockCopy(secret, 0, secret1, 0, secretLen);
+
+                       // Secret2
+                       byte[] secret2 = new byte[secretLen];
+                       Buffer.BlockCopy(secret, (secret.Length - secretLen), secret2, 0, secretLen);
+
+                       // Secret 1 processing
+                       byte[] p_md5 = Expand("MD5", secret1, seed, length);
+
+                       // Secret 2 processing
+                       byte[] p_sha = Expand("SHA1", secret2, seed, length);
+
+                       // Perfor XOR of both results
+                       byte[] masterSecret = new byte[length];
+                       for (int i = 0; i < masterSecret.Length; i++)
+                       {
+                               masterSecret[i] = (byte)(p_md5[i] ^ p_sha[i]);
+                       }
+
+                       return masterSecret;
+               }
+               
+               public byte[] Expand(string hashName, byte[] secret, byte[] seed, int length)
+               {
+                       int hashLength  = hashName == "MD5" ? 16 : 20;
+                       int     iterations      = (int)(length / hashLength);
+                       if ((length % hashLength) > 0)
+                       {
+                               iterations++;
+                       }
+                       
+                       M.HMAC          hmac    = new M.HMAC(hashName, secret);
+                       TlsStream       resMacs = new TlsStream();
+                       
+                       byte[][] hmacs = new byte[iterations + 1][];
+                       hmacs[0] = seed;
+                       for (int i = 1; i <= iterations; i++)
+                       {                               
+                               TlsStream hcseed = new TlsStream();
+                               hmac.TransformFinalBlock(hmacs[i-1], 0, hmacs[i-1].Length);
+                               hmacs[i] = hmac.Hash;
+                               hcseed.Write(hmacs[i]);
+                               hcseed.Write(seed);
+                               hmac.TransformFinalBlock(hcseed.ToArray(), 0, (int)hcseed.Length);
+                               resMacs.Write(hmac.Hash);
+                               hcseed.Reset();
+                       }
+
+                       byte[] res = new byte[length];
+                       
+                       Buffer.BlockCopy(resMacs.ToArray(), 0, res, 0, res.Length);
+
+                       resMacs.Reset();
+
+                       return res;
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void createEncryptionCipher()
+               {
+                       // Create and configure the symmetric algorithm
+                       switch (this.cipherAlgorithmType)
+                       {
+                               case CipherAlgorithmType.Des:
+                                       this.encryptionAlgorithm = DES.Create();
+                                       break;
+
+                               case CipherAlgorithmType.Rc2:
+                                       this.encryptionAlgorithm = RC2.Create();
+                                       break;
+
+                               case CipherAlgorithmType.Rc4:
+                                       this.encryptionAlgorithm = new ARC4Managed();
+                                       break;
+
+                               case CipherAlgorithmType.TripleDes:
+                                       this.encryptionAlgorithm = TripleDES.Create();
+                                       break;
+
+                               case CipherAlgorithmType.Rijndael:
+                                       this.encryptionAlgorithm = Rijndael.Create();
+                                       break;
+                       }
+
+                       // If it's a block cipher
+                       if (this.cipherMode == CipherMode.CBC)
+                       {
+                               // Configure encrypt algorithm
+                               this.encryptionAlgorithm.Mode           = this.cipherMode;
+                               this.encryptionAlgorithm.Padding        = PaddingMode.None;
+                               this.encryptionAlgorithm.KeySize        = this.expandedKeyMaterialSize * 8;
+                               this.encryptionAlgorithm.BlockSize      = this.blockSize * 8;
+                       }
+
+                       // Set the key and IV for the algorithm
+                       if (this.context is ClientContext)
+                       {
+                               this.encryptionAlgorithm.Key    = this.context.ClientWriteKey;
+                               this.encryptionAlgorithm.IV             = this.context.ClientWriteIV;
+                       }
+                       else
+                       {
+                               this.encryptionAlgorithm.Key    = this.context.ServerWriteKey;
+                               this.encryptionAlgorithm.IV             = this.context.ServerWriteIV;
+                       }
+                       
+                       // Create encryption cipher
+                       this.encryptionCipher = this.encryptionAlgorithm.CreateEncryptor();
+
+                       // Create the HMAC algorithm
+                       if (this.context is ClientContext)
+                       {
+                               this.clientHMAC = new M.HMAC(
+                                       this.HashAlgorithmName,
+                                       this.context.Negotiating.ClientWriteMAC);
+                       }
+                       else
+                       {
+                               this.serverHMAC = new M.HMAC(
+                                       this.HashAlgorithmName,
+                                       this.context.Negotiating.ServerWriteMAC);
+                       }
+               }
+
+               private void createDecryptionCipher()
+               {
+                       // Create and configure the symmetric algorithm
+                       switch (this.cipherAlgorithmType)
+                       {
+                               case CipherAlgorithmType.Des:
+                                       this.decryptionAlgorithm = DES.Create();
+                                       break;
+
+                               case CipherAlgorithmType.Rc2:
+                                       this.decryptionAlgorithm = RC2.Create();
+                                       break;
+
+                               case CipherAlgorithmType.Rc4:
+                                       this.decryptionAlgorithm = new ARC4Managed();
+                                       break;
+
+                               case CipherAlgorithmType.TripleDes:
+                                       this.decryptionAlgorithm = TripleDES.Create();
+                                       break;
+
+                               case CipherAlgorithmType.Rijndael:
+                                       this.decryptionAlgorithm = Rijndael.Create();
+                                       break;
+                       }
+
+                       // If it's a block cipher
+                       if (this.cipherMode == CipherMode.CBC)
+                       {
+                               // Configure encrypt algorithm
+                               this.decryptionAlgorithm.Mode           = this.cipherMode;
+                               this.decryptionAlgorithm.Padding        = PaddingMode.None;
+                               this.decryptionAlgorithm.KeySize        = this.expandedKeyMaterialSize * 8;
+                               this.decryptionAlgorithm.BlockSize      = this.blockSize * 8;
+                       }
+
+                       // Set the key and IV for the algorithm
+                       if (this.context is ClientContext)
+                       {
+                               this.decryptionAlgorithm.Key    = this.context.ServerWriteKey;
+                               this.decryptionAlgorithm.IV             = this.context.ServerWriteIV;
+                       }
+                       else
+                       {
+                               this.decryptionAlgorithm.Key    = this.context.ClientWriteKey;
+                               this.decryptionAlgorithm.IV             = this.context.ClientWriteIV;
+                       }
+
+                       // Create decryption cipher                     
+                       this.decryptionCipher = this.decryptionAlgorithm.CreateDecryptor();
+
+                       // Create the HMAC
+                       if (this.context is ClientContext)
+                       {
+                               this.serverHMAC = new M.HMAC(
+                                       this.HashAlgorithmName,
+                                       this.context.Negotiating.ServerWriteMAC);
+                       }
+                       else
+                       {
+                               this.clientHMAC = new M.HMAC(
+                                       this.HashAlgorithmName,
+                                       this.context.Negotiating.ClientWriteMAC);
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherSuiteCollection.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherSuiteCollection.cs
new file mode 100644 (file)
index 0000000..8240e82
--- /dev/null
@@ -0,0 +1,254 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Globalization;
+using System.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal sealed class CipherSuiteCollection : ICollection, IList, IEnumerable
+       {
+               #region Fields
+
+               private ArrayList                               cipherSuites;
+               private SecurityProtocolType    protocol;
+
+               #endregion
+
+               #region Indexers
+
+               public CipherSuite this[string name] 
+               {
+                       get { return (CipherSuite)this.cipherSuites[this.IndexOf(name)]; }
+                       set { this.cipherSuites[this.IndexOf(name)] = (CipherSuite)value; }
+               }
+
+               public CipherSuite this[int index] 
+               {
+                       get { return (CipherSuite)this.cipherSuites[index]; }
+                       set { this.cipherSuites[index] = (CipherSuite)value; }
+               }
+
+               public CipherSuite this[short code] 
+               {
+                       get { return (CipherSuite)this.cipherSuites[this.IndexOf(code)]; }
+                       set { this.cipherSuites[this.IndexOf(code)] = (CipherSuite)value; }
+               }
+
+               object IList.this[int index]
+               {
+                       get { return this[index]; }
+                       set { this[index] = (CipherSuite)value; }
+               }
+
+               #endregion
+
+               #region ICollection Properties
+
+               bool ICollection.IsSynchronized
+               {
+                       get { return this.cipherSuites.IsSynchronized; }
+               }
+
+               object ICollection.SyncRoot 
+               {
+                       get { return this.cipherSuites.SyncRoot; }
+               }
+
+               public int Count 
+               {
+                       get { return this.cipherSuites.Count; }
+               }
+               
+               #endregion
+
+               #region IList Properties
+
+               public bool IsFixedSize 
+               {
+                       get { return this.cipherSuites.IsFixedSize; }
+               }
+
+               public bool IsReadOnly
+               {
+                       get { return this.cipherSuites.IsReadOnly; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public CipherSuiteCollection(SecurityProtocolType protocol) : base()
+               {
+                       this.protocol           = protocol;
+                       this.cipherSuites       = new ArrayList();
+               }
+
+               #endregion
+
+               #region ICollection Methods
+
+               public void CopyTo(Array array, int index)
+               {
+                       this.cipherSuites.CopyTo(array, index);
+               }
+               
+               #endregion
+
+               #region IEnumerable Methods
+
+               IEnumerator IEnumerable.GetEnumerator()
+               {
+                       return this.cipherSuites.GetEnumerator();
+               }
+
+               #endregion
+
+               #region IList Methods
+
+               public void Clear()
+               {
+                       this.cipherSuites.Clear();
+               }
+                       
+               bool IList.Contains(object value)
+               {
+                       return this.cipherSuites.Contains(value as CipherSuite);
+               }
+
+               public int IndexOf(string name)
+               {
+                       int index = 0;
+
+                       foreach (CipherSuite cipherSuite in this.cipherSuites)
+                       {
+                               if (this.cultureAwareCompare(cipherSuite.Name, name))
+                               {
+                                       return index;
+                               }
+                               index++;
+                       }
+
+                       return -1;
+               }
+
+               public int IndexOf(short code)
+               {
+                       int index = 0;
+
+                       foreach (CipherSuite cipherSuite in this.cipherSuites)
+                       {
+                               if (cipherSuite.Code == code)
+                               {
+                                       return index;
+                               }
+                               index++;
+                       }
+
+                       return -1;
+               }
+
+               int IList.IndexOf(object value)
+               {
+                       return this.cipherSuites.IndexOf(value as CipherSuite);
+               }
+
+               void IList.Insert(int index, object value)
+               {
+                       this.cipherSuites.Insert(index, value as CipherSuite);
+               }
+
+               void IList.Remove(object value)
+               {
+                       this.cipherSuites.Remove(value as CipherSuite);
+               }
+
+               void IList.RemoveAt(int index)
+               {
+                       this.cipherSuites.RemoveAt(index);
+               }
+
+               public CipherSuite Add(
+                       short code, string name, CipherAlgorithmType cipherType, 
+                       HashAlgorithmType hashType, ExchangeAlgorithmType exchangeType,
+                       bool exportable, bool blockMode, byte keyMaterialSize, 
+                       byte expandedKeyMaterialSize, short effectiveKeyBytes, 
+                       byte ivSize, byte blockSize)
+               {
+                       switch (this.protocol)
+                       {
+                               case SecurityProtocolType.Default:
+                               case SecurityProtocolType.Tls:
+                                       return this.add(
+                                               new TlsCipherSuite(
+                                               code, name, cipherType, hashType, exchangeType, exportable, 
+                                               blockMode, keyMaterialSize, expandedKeyMaterialSize, 
+                                               effectiveKeyBytes, ivSize, blockSize));
+
+                               case SecurityProtocolType.Ssl3:
+                                       return this.add(
+                                               new SslCipherSuite(
+                                               code, name, cipherType, hashType, exchangeType, exportable, 
+                                               blockMode, keyMaterialSize, expandedKeyMaterialSize, 
+                                               effectiveKeyBytes, ivSize, blockSize));
+
+                               case SecurityProtocolType.Ssl2:
+                               default:
+                                       throw new NotSupportedException("Unsupported security protocol type.");
+                       }
+               }
+
+               private TlsCipherSuite add(TlsCipherSuite cipherSuite)
+               {
+                       this.cipherSuites.Add(cipherSuite);
+
+                       return cipherSuite;
+               }
+
+               private SslCipherSuite add(SslCipherSuite cipherSuite)
+               {
+                       this.cipherSuites.Add(cipherSuite);
+
+                       return cipherSuite;
+               }
+
+               int IList.Add(object value)
+               {
+                       return this.cipherSuites.Add(value as CipherSuite);
+               }
+               
+               private bool cultureAwareCompare(string strA, string strB)
+               {
+                       return CultureInfo.CurrentCulture.CompareInfo.Compare(
+                               strA, 
+                               strB, 
+                               CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | 
+                               CompareOptions.IgnoreCase) == 0 ? true : false;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherSuiteFactory.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/CipherSuiteFactory.cs
new file mode 100644 (file)
index 0000000..3fa618a
--- /dev/null
@@ -0,0 +1,191 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class CipherSuiteFactory
+       {
+               public static CipherSuiteCollection GetSupportedCiphers(SecurityProtocolType protocol)
+               {
+                       switch (protocol)
+                       {
+                               case SecurityProtocolType.Default:
+                               case SecurityProtocolType.Tls:                          
+                                       return CipherSuiteFactory.GetTls1SupportedCiphers();
+
+                               case SecurityProtocolType.Ssl3:
+                                       return CipherSuiteFactory.GetSsl3SupportedCiphers();
+
+                               case SecurityProtocolType.Ssl2:
+                               default:
+                                       throw new NotSupportedException("Unsupported security protocol type");
+                       }
+               }
+
+               #region Private Static Methods
+
+               private static CipherSuiteCollection GetTls1SupportedCiphers()
+               {
+                       CipherSuiteCollection scs = new CipherSuiteCollection(SecurityProtocolType.Tls);
+
+                       // Supported ciphers
+                       scs.Add((0x00 << 0x08) | 0x35, "TLS_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, false, true, 32, 32, 256, 16, 16);
+                       scs.Add((0x00 << 0x08) | 0x2F, "TLS_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, false, true, 16, 16, 128, 16, 16);
+                       scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, false, true, 24, 24, 168, 8, 8);
+                       scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, false, false, 16, 16, 128, 0, 0);
+                       scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, false, false, 16, 16, 128, 0, 0);
+                       scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, false, true, 8, 8, 56, 8, 8);
+                       
+                       // Supported exportable ciphers
+                       scs.Add((0x00 << 0x08) | 0x03, "TLS_RSA_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, false, 5, 16, 40, 0, 0);
+                       scs.Add((0x00 << 0x08) | 0x06, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 16, 40, 8, 8);
+                       scs.Add((0x00 << 0x08) | 0x08, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 8, 40, 8, 8);
+                       scs.Add((0x00 << 0x08) | 0x60, "TLS_RSA_EXPORT_WITH_RC4_56_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, false, 7, 16, 56, 0, 0);
+                       scs.Add((0x00 << 0x08) | 0x61, "TLS_RSA_EXPORT_WITH_RC2_CBC_56_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 7, 16, 56, 8, 8);
+                       // 56 bits but we use 64 bits because of parity (DES is really 56 bits)
+                       scs.Add((0x00 << 0x08) | 0x62, "TLS_RSA_EXPORT_WITH_DES_CBC_56_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, true, true, 8, 8, 64, 8, 8); 
+                       scs.Add((0x00 << 0x08) | 0x64, "TLS_RSA_EXPORT_WITH_RC4_56_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, true, false, 7, 16, 56, 0, 0);
+                       
+                       // Default CipherSuite
+                       // scs.Add(0, "TLS_NULL_WITH_NULL_NULL", CipherAlgorithmType.None, HashAlgorithmType.None, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0);
+                       
+                       // RSA Cipher Suites
+                       // scs.Add((0x00 << 0x08) | 0x01, "TLS_RSA_WITH_NULL_MD5", CipherAlgorithmType.None, HashAlgorithmType.Md5, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x02, "TLS_RSA_WITH_NULL_SHA", CipherAlgorithmType.None, HashAlgorithmType.Sha1, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x03, "TLS_RSA_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, false, 5, 16, 40, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);                  
+                       // scs.Add((0x00 << 0x08) | 0x06, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 16, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x07, "TLS_RSA_WITH_IDEA_CBC_SHA", "IDEA", HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x08, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8);
+
+                       // Diffie-Hellman Cipher Suites
+                       // scs.Add((0x00 << 0x08) | 0x0B, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x0C, "TLS_DH_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, false, ExchangeAlgorithmType.DiffieHellman, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x0D, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x0E, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x0F, "TLS_DH_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, false, ExchangeAlgorithmType.DiffieHellman, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x10, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x11, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x12, "TLS_DHE_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x13, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x14, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x15, "TLS_DHE_RSA_WITH_DES_CBC_SHA", HashAlgorithmType.Sha1, CipherAlgorithmType.Des, false, ExchangeAlgorithmType.DiffieHellman, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x16, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+
+                       // Anonymous Diffie-Hellman Cipher Suites
+                       // scs.Add((0x00 << 0x08) | 0x17, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.DiffieHellman, true, false, 5, 16, 40, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x18, "TLS_DH_anon_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, false, ExchangeAlgorithmType.DiffieHellman, false, 16, 16, 128, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x19, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x1A, "TLS_DH_anon_WITH_DES_CBC_SHA", "DES4", HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x1B, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+
+                       // AES CipherSuites
+                       //
+                       // Ref: RFC3268 - (http://www.ietf.org/rfc/rfc3268.txt)
+               
+                       // scs.Add((0x00 << 0x08) | 0x2F, "TLS_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 16, 16);
+                       // scs.Add((0x00 << 0x08) | 0x30, "TLS_DH_DSS_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x31, "TLS_DH_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x32, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x33, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x34, "TLS_DH_anon_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8);
+
+                       // scs.Add((0x00 << 0x08) | 0x35, "TLS_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 32, 32, 256, 16, 16);
+                       // scs.Add((0x00 << 0x08) | 0x36, "TLS_DH_DSS_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16);
+                       // scs.Add((0x00 << 0x08) | 0x37, "TLS_DH_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16);
+                       // scs.Add((0x00 << 0x08) | 0x38, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16);
+                       // scs.Add((0x00 << 0x08) | 0x39, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16);
+                       // scs.Add((0x00 << 0x08) | 0x3A, "TLS_DH_anon_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16);
+
+                       return scs;
+               }
+
+               private static CipherSuiteCollection GetSsl3SupportedCiphers()
+               {
+                       CipherSuiteCollection scs = new CipherSuiteCollection(SecurityProtocolType.Ssl3);
+
+                       // Supported ciphers
+                       scs.Add((0x00 << 0x08) | 0x35, "SSL_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, false, true, 32, 32, 256, 16, 16);
+                       scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, false, true, 24, 24, 168, 8, 8);
+                       scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, false, false, 16, 16, 128, 0, 0);
+                       scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, false, false, 16, 16, 128, 0, 0);
+                       scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, false, true, 8, 8, 56, 8, 8);
+
+                       // Supported exportable ciphers
+                       scs.Add((0x00 << 0x08) | 0x03, "SSL_RSA_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, false, 5, 16, 40, 0, 0);
+                       scs.Add((0x00 << 0x08) | 0x06, "SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 16, 40, 8, 8);
+                       scs.Add((0x00 << 0x08) | 0x08, "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 8, 40, 8, 8);
+                       scs.Add((0x00 << 0x08) | 0x60, "SSL_RSA_EXPORT_WITH_RC4_56_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, false, 7, 16, 56, 0, 0);
+                       scs.Add((0x00 << 0x08) | 0x61, "SSL_RSA_EXPORT_WITH_RC2_CBC_56_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 7, 16, 56, 8, 8);
+                       // 56 bits but we use 64 bits because of parity (DES is really 56 bits)
+                       scs.Add((0x00 << 0x08) | 0x62, "SSL_RSA_EXPORT_WITH_DES_CBC_56_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, true, true, 8, 8, 64, 8, 8); 
+                       scs.Add((0x00 << 0x08) | 0x64, "SSL_RSA_EXPORT_WITH_RC4_56_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, true, false, 7, 16, 56, 0, 0);
+
+                       // Default CipherSuite
+                       // scs.Add(0, "SSL_NULL_WITH_NULL_NULL", CipherAlgorithmType.None, HashAlgorithmType.None, true, false, 0, 0, 0, 0, 0);
+                       
+                       // RSA Cipher Suites
+                       // scs.Add((0x00 << 0x08) | 0x01, "SSL_RSA_WITH_NULL_MD5", CipherAlgorithmType.None, HashAlgorithmType.Md5, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x02, "SSL_RSA_WITH_NULL_SHA", CipherAlgorithmType.None, HashAlgorithmType.Sha1, true, ExchangeAlgorithmType.None, false, 0, 0, 0, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x03, "SSL_RSA_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, false, 5, 16, 40, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0);                  
+                       // scs.Add((0x00 << 0x08) | 0x06, "SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 16, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x07, "SSL_RSA_WITH_IDEA_CBC_SHA", "IDEA", HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x08, "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyEx, true, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8);
+                                               
+                       // Diffie-Hellman Cipher Suites
+                       // scs.Add((0x00 << 0x08) | 0x0B, "SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x0C, "SSL_DH_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x0D, "SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x0E, "SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x0F, "SSL_DH_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x10, "SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x11, "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x12, "SSL_DHE_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x13, "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x14, "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x15, "SSL_DHE_RSA_WITH_DES_CBC_SHA", HashAlgorithmType.Sha1, CipherAlgorithmType.Des, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x16, "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+
+                       // Anonymous Diffie-Hellman Cipher Suites
+                       // scs.Add((0x00 << 0x08) | 0x17, "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.DiffieHellman, true, false, 5, 16, 40, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x18, "SSL_DH_anon_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, false, ExchangeAlgorithmType.DiffieHellman, false, 16, 16, 128, 0, 0);
+                       // scs.Add((0x00 << 0x08) | 0x19, "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 5, 8, 40, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x1A, "SSL_DH_anon_WITH_DES_CBC_SHA", "DES4", HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8);
+                       // scs.Add((0x00 << 0x08) | 0x1B, "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8);
+
+                       return scs;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ClientContext.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ClientContext.cs
new file mode 100644 (file)
index 0000000..2472f9a
--- /dev/null
@@ -0,0 +1,82 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class ClientContext : Context
+       {
+               #region Fields
+
+               private SslClientStream sslStream;
+               private short                   clientHelloProtocol;
+
+               #endregion
+
+               #region Properties
+
+               public SslClientStream SslStream
+               {
+                       get { return this.sslStream; }
+               }
+
+               public short ClientHelloProtocol
+               {
+                       get { return this.clientHelloProtocol; }
+                       set { this.clientHelloProtocol = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public ClientContext(
+                       SslClientStream                         stream,
+                       SecurityProtocolType            securityProtocolType,
+                       string                                          targetHost,
+                       X509CertificateCollection       clientCertificates) 
+                       : base(securityProtocolType)
+               {
+                       this.sslStream                                          = stream;
+                       this.ClientSettings.Certificates        = clientCertificates;
+                       this.ClientSettings.TargetHost          = targetHost;
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Clear()
+               {
+                       this.clientHelloProtocol = 0;
+                       base.Clear();
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ClientRecordProtocol.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ClientRecordProtocol.cs
new file mode 100644 (file)
index 0000000..7cece50
--- /dev/null
@@ -0,0 +1,179 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Globalization;
+using System.IO;
+
+using Mono.Security.Protocol.Tls.Handshake;
+using Mono.Security.Protocol.Tls.Handshake.Client;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class ClientRecordProtocol : RecordProtocol
+       {
+               #region Constructors
+
+               public ClientRecordProtocol(
+                       Stream                  innerStream, 
+                       ClientContext   context) : base(innerStream, context)
+               {
+               }
+
+               #endregion
+
+               #region Send Messages
+
+               public override HandshakeMessage GetMessage(HandshakeType type)
+               {
+                       HandshakeMessage msg = this.createClientHandshakeMessage(type);
+
+                       return msg;
+               }
+
+               #endregion
+
+               #region Handshake Processing Methods
+
+               protected override void ProcessHandshakeMessage(TlsStream handMsg)
+               {
+                       HandshakeType           handshakeType   = (HandshakeType)handMsg.ReadByte();
+                       HandshakeMessage        message                 = null;
+
+                       DebugHelper.WriteLine(">>>> Processing Handshake record ({0})", handshakeType);
+
+                       // Read message length
+                       int length = handMsg.ReadInt24();
+
+                       // Read message data
+                       byte[] data = null;
+                       if (length > 0)
+                       {
+                               data = new byte[length];
+                               handMsg.Read (data, 0, length);
+                       }
+
+                       // Create and process the server message
+                       message = this.createServerHandshakeMessage(handshakeType, data);
+                       if (message != null)
+                       {
+                               message.Process();
+                       }
+
+                       // Update the last handshake message
+                       this.Context.LastHandshakeMsg = handshakeType;
+
+                       // Update session
+                       if (message != null)
+                       {
+                               message.Update();
+                               this.Context.HandshakeMessages.WriteByte ((byte) handshakeType);
+                               this.Context.HandshakeMessages.WriteInt24 (length);
+                               if (length > 0) 
+                               {
+                                       this.Context.HandshakeMessages.Write (data, 0, data.Length);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Client Handshake Message Factories
+
+               private HandshakeMessage createClientHandshakeMessage(HandshakeType type)
+               {
+                       switch (type)
+                       {
+                               case HandshakeType.ClientHello:
+                                       return new TlsClientHello(this.context);
+
+                               case HandshakeType.Certificate:
+                                       return new TlsClientCertificate(this.context);
+
+                               case HandshakeType.ClientKeyExchange:
+                                       return new TlsClientKeyExchange(this.context);
+
+                               case HandshakeType.CertificateVerify:
+                                       return new TlsClientCertificateVerify(this.context);
+
+                               case HandshakeType.Finished:
+                                       return new TlsClientFinished(this.context);
+
+                               default:
+                                       throw new InvalidOperationException("Unknown client handshake message type: " + type.ToString() );
+                       }
+               }
+
+               private HandshakeMessage createServerHandshakeMessage(
+                       HandshakeType type, byte[] buffer)
+               {
+                       ClientContext context = (ClientContext)this.context;
+
+                       switch (type)
+                       {
+                               case HandshakeType.HelloRequest:
+                                       if (context.HandshakeState != HandshakeState.Started)
+                                       {
+                                               context.HandshakeState = HandshakeState.None;
+                                               // re-negotiation will occur at next read/write
+                                               // (i.e. not during an existing encode/decode op)
+                                       }
+                                       else
+                                       {
+                                               this.SendAlert(
+                                                       AlertLevel.Warning,
+                                                       AlertDescription.NoRenegotiation);
+                                       }
+                                       return null;
+
+                               case HandshakeType.ServerHello:
+                                       return new TlsServerHello(this.context, buffer);
+
+                               case HandshakeType.Certificate:
+                                       return new TlsServerCertificate(this.context, buffer);
+
+                               case HandshakeType.ServerKeyExchange:
+                                       return new TlsServerKeyExchange(this.context, buffer);
+
+                               case HandshakeType.CertificateRequest:
+                                       return new TlsServerCertificateRequest(this.context, buffer);
+
+                               case HandshakeType.ServerHelloDone:
+                                       return new TlsServerHelloDone(this.context, buffer);
+
+                               case HandshakeType.Finished:
+                                       return new TlsServerFinished(this.context, buffer);
+
+                               default:
+                                       throw new TlsException(
+                                               AlertDescription.UnexpectedMessage,
+                                               String.Format(CultureInfo.CurrentUICulture,
+                                                       "Unknown server handshake message received ({0})", 
+                                                       type.ToString()));
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ClientSessionCache.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ClientSessionCache.cs
new file mode 100644 (file)
index 0000000..749a51e
--- /dev/null
@@ -0,0 +1,254 @@
+//
+// ClientSessionCache.cs: Client-side cache for re-using sessions
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 2006 Novell (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+
+namespace Mono.Security.Protocol.Tls {
+
+       internal class ClientSessionInfo : IDisposable {
+
+               // (by default) we keep this item valid for 3 minutes (if unused)
+               private const int DefaultValidityInterval = 3 * 60;
+               private static readonly int ValidityInterval;
+
+               private bool disposed;
+               private DateTime validuntil;
+               private string host;
+
+               // see RFC2246 - Section 7
+               private byte[] sid;
+               private byte[] masterSecret;
+
+               static ClientSessionInfo ()
+               {
+                       string user_cache_timeout = Environment.GetEnvironmentVariable ("MONO_TLS_SESSION_CACHE_TIMEOUT");
+                       if (user_cache_timeout == null) {
+                               ValidityInterval = DefaultValidityInterval;
+                       } else {
+                               try {
+                                       ValidityInterval = Int32.Parse (user_cache_timeout);
+                               }
+                               catch {
+                                       ValidityInterval = DefaultValidityInterval;
+                               }
+                       }
+               }
+
+               public ClientSessionInfo (string hostname, byte[] id)
+               {
+                       host = hostname;
+                       sid = id;
+                       KeepAlive ();
+               }
+
+               ~ClientSessionInfo ()
+               {
+                       Dispose (false);
+               }
+
+
+               public string HostName {
+                       get { return host; }
+               }
+
+               public byte[] Id {
+                       get { return sid; }
+               }
+
+               public bool Valid {
+                       get { return ((masterSecret != null) && (validuntil > DateTime.UtcNow)); }
+               }
+
+
+               public void GetContext (Context context)
+               {
+                       CheckDisposed ();
+                       if (context.MasterSecret != null)
+                               masterSecret = (byte[]) context.MasterSecret.Clone ();
+               }
+
+               public void SetContext (Context context)
+               {
+                       CheckDisposed ();
+                       if (masterSecret != null)
+                               context.MasterSecret = (byte[]) masterSecret.Clone ();
+               }
+
+               public void KeepAlive ()
+               {
+                       CheckDisposed ();
+                       validuntil = DateTime.UtcNow.AddSeconds (ValidityInterval);
+               }
+
+               public void Dispose ()
+               {
+                       Dispose (true);
+                       GC.SuppressFinalize (this);
+               }
+
+               private void Dispose (bool disposing)
+               {
+                       if (!disposed) {
+                               validuntil = DateTime.MinValue;
+                               host = null;
+                               sid = null;
+
+                               if (masterSecret != null) {
+                                       Array.Clear (masterSecret, 0, masterSecret.Length);
+                                       masterSecret = null;
+                               }
+                       }
+                       disposed = true;
+               }
+
+               private void CheckDisposed ()
+               {
+                       if (disposed) {
+                               string msg = Locale.GetText ("Cache session information were disposed.");
+                               throw new ObjectDisposedException (msg);
+                       }
+               }
+       }
+
+       // note: locking is aggressive but isn't used often (and we gain much more :)
+       internal class ClientSessionCache {
+
+               static Hashtable cache;
+               static object locker;
+
+               static ClientSessionCache ()
+               {
+                       cache = new Hashtable ();
+                       locker = new object ();
+               }
+
+               // note: we may have multiple connections with a host, so 
+               // possibly multiple entries per host (each with a different 
+               // id), so we do not use the host as the hashtable key
+               static public void Add (string host, byte[] id)
+               {
+                       lock (locker) {
+                               string uid = BitConverter.ToString (id);
+                               ClientSessionInfo si = (ClientSessionInfo) cache[uid];
+                               if (si == null) {
+                                       cache.Add (uid, new ClientSessionInfo (host, id));
+                               } else if (si.HostName == host) {
+                                       // we already have this and it's still valid
+                                       // on the server, so we'll keep it a little longer
+                                       si.KeepAlive ();
+                               } else {
+                                       // it's very unlikely but the same session id 
+                                       // could be used by more than one host. In this
+                                       // case we replace the older one with the new one
+                                       si.Dispose ();
+                                       cache.Remove (uid);
+                                       cache.Add (uid, new ClientSessionInfo (host, id));
+                               }
+                       }
+               }
+
+               // return the first session us
+               static public byte[] FromHost (string host)
+               {
+                       lock (locker) {
+                               foreach (ClientSessionInfo si in cache.Values) {
+                                       if (si.HostName == host) {
+                                               if (si.Valid) {
+                                                       // ensure it's still valid when we really need it
+                                                       si.KeepAlive ();
+                                                       return si.Id;
+                                               }
+                                       }
+                               }
+                               return null;
+                       }
+               }
+
+               // only called inside the lock
+               static private ClientSessionInfo FromContext (Context context, bool checkValidity)
+               {
+                       if (context == null)
+                               return null;
+
+                       byte[] id = context.SessionId;
+                       if ((id == null) || (id.Length == 0))
+                               return null;
+
+                       // do we have a session cached for this host ?
+                       string uid = BitConverter.ToString (id);
+
+                       ClientSessionInfo si = (ClientSessionInfo) cache[uid];
+                       if (si == null)
+                               return null;
+
+                       // In the unlikely case of multiple hosts using the same 
+                       // session id, we just act like we do not know about it
+                       if (context.ClientSettings.TargetHost != si.HostName)
+                               return null;
+
+                       // yes, so what's its status ?
+                       if (checkValidity && !si.Valid) {
+                               si.Dispose ();
+                               cache.Remove (uid);
+                               return null;
+                       }
+
+                       // ok, it make sense
+                       return si;
+               }
+
+               static public bool SetContextInCache (Context context)
+               {
+                       lock (locker) {
+                               // Don't check the validity because the masterKey of the ClientSessionInfo
+                               // can still be null when this is called the first time
+                               ClientSessionInfo csi = FromContext (context, false);
+                               if (csi == null)
+                                       return false;
+
+                               csi.GetContext (context);
+                               csi.KeepAlive ();
+                               return true;
+                       }
+               }
+
+               static public bool SetContextFromCache (Context context)
+               {
+                       lock (locker) {
+                               ClientSessionInfo csi = FromContext (context, true);
+                               if (csi == null)
+                                       return false;
+
+                               csi.SetContext (context);
+                               csi.KeepAlive ();
+                               return true;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ContentType.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ContentType.cs
new file mode 100644 (file)
index 0000000..e07d64e
--- /dev/null
@@ -0,0 +1,37 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+       [Serializable]
+       internal enum ContentType : byte
+       {
+               ChangeCipherSpec        = 20,
+               Alert                           = 21,
+               Handshake                       = 22,
+               ApplicationData         = 23,
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/Context.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/Context.cs
new file mode 100644 (file)
index 0000000..295eee5
--- /dev/null
@@ -0,0 +1,508 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+using System.Collections;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+
+using Mono.Security.Cryptography;
+using Mono.Security.Protocol.Tls.Handshake;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal abstract class Context
+       {
+               #region Internal Constants
+
+               internal const short MAX_FRAGMENT_SIZE  = 16384; // 2^14
+               internal const short TLS1_PROTOCOL_CODE = (0x03 << 8) | 0x01;
+               internal const short SSL3_PROTOCOL_CODE = (0x03 << 8) | 0x00;
+               internal const long  UNIX_BASE_TICKS    = 621355968000000000;
+
+               #endregion
+
+               #region Fields
+               
+               // Protocol version
+               private SecurityProtocolType securityProtocol;
+               
+               // Sesison ID
+               private byte[] sessionId;
+
+               // Compression method
+               private SecurityCompressionType compressionMethod;
+
+               // Information sent and request by the server in the Handshake protocol
+               private TlsServerSettings serverSettings;
+
+               // Client configuration
+               private TlsClientSettings clientSettings;
+
+               // Cipher suite information
+               private SecurityParameters current;
+               private SecurityParameters negotiating;
+               private SecurityParameters read;
+               private SecurityParameters write;
+               private CipherSuiteCollection supportedCiphers;
+
+               // Last handshake message received
+               private HandshakeType lastHandshakeMsg;
+
+               // Handshake negotiation state
+               private HandshakeState handshakeState;
+
+               // Misc
+               private bool    abbreviatedHandshake;
+               private bool    connectionEnd;
+               private bool    protocolNegotiated;
+               
+               // Sequence numbers
+               private ulong   writeSequenceNumber;
+               private ulong   readSequenceNumber;
+
+               // Random data
+               private byte[]  clientRandom;
+               private byte[]  serverRandom;
+               private byte[]  randomCS;
+               private byte[]  randomSC;
+
+               // Key information
+               private byte[]  masterSecret;
+               private byte[]  clientWriteKey;
+               private byte[]  serverWriteKey;
+               private byte[]  clientWriteIV;
+               private byte[]  serverWriteIV;
+               
+               // Handshake hashes
+               private TlsStream handshakeMessages;
+               
+               // Secure Random generator              
+               private RandomNumberGenerator random;
+
+               // Record protocol
+               private RecordProtocol recordProtocol;
+
+               #endregion
+
+               #region Properties
+
+               public bool AbbreviatedHandshake
+               {
+                       get { return abbreviatedHandshake; }
+                       set { abbreviatedHandshake = value; }
+               }
+
+               public bool     ProtocolNegotiated
+               {
+                       get { return this.protocolNegotiated; }
+                       set { this.protocolNegotiated = value; }
+               }
+
+               public SecurityProtocolType SecurityProtocol
+               {
+                       get 
+                       {
+                               if ((this.securityProtocol & SecurityProtocolType.Tls) == SecurityProtocolType.Tls ||   
+                                       (this.securityProtocol & SecurityProtocolType.Default) == SecurityProtocolType.Default)
+                               {
+                                       return SecurityProtocolType.Tls;
+                               }
+                               else
+                               {
+                                       if ((this.securityProtocol & SecurityProtocolType.Ssl3) == SecurityProtocolType.Ssl3)
+                                       {
+                                               return SecurityProtocolType.Ssl3;
+                                       }
+                               }
+
+                               throw new NotSupportedException("Unsupported security protocol type");
+                       }
+
+                       set { this.securityProtocol = value; }
+               }
+
+               public SecurityProtocolType SecurityProtocolFlags
+               {
+                       get { return this.securityProtocol; }
+               }
+
+               public short Protocol
+               {
+                       get 
+                       { 
+                               switch (this.SecurityProtocol)
+                               {
+                                       case SecurityProtocolType.Tls:
+                                       case SecurityProtocolType.Default:
+                                               return Context.TLS1_PROTOCOL_CODE;
+
+                                       case SecurityProtocolType.Ssl3:
+                                               return Context.SSL3_PROTOCOL_CODE;
+
+                                       case SecurityProtocolType.Ssl2:
+                                       default:
+                                               throw new NotSupportedException("Unsupported security protocol type");
+                               }
+                       }
+               }
+
+               public byte[] SessionId
+               {
+                       get { return this.sessionId; }
+                       set { this.sessionId = value; }
+               }
+
+               public SecurityCompressionType CompressionMethod
+               {
+                       get { return this.compressionMethod; }
+                       set { this.compressionMethod = value; }
+               }
+
+               public TlsServerSettings ServerSettings
+               {
+                       get { return this.serverSettings; }
+               }
+
+               public TlsClientSettings ClientSettings
+               {
+                       get { return this.clientSettings; }
+               }
+
+               public HandshakeType LastHandshakeMsg
+               {
+                       get { return this.lastHandshakeMsg; }
+                       set { this.lastHandshakeMsg = value; }
+               }
+
+               public  HandshakeState HandshakeState
+               {
+                       get { return this.handshakeState; }
+                       set { this.handshakeState = value; }
+               }
+
+               public bool ConnectionEnd
+               {
+                       get { return this.connectionEnd; }
+                       set { this.connectionEnd = value; }
+               }
+
+               public CipherSuiteCollection SupportedCiphers
+               {
+                       get { return supportedCiphers; }
+                       set { supportedCiphers = value; }
+               }
+
+               public TlsStream HandshakeMessages
+               {
+                       get { return this.handshakeMessages; }
+               }
+
+               public ulong WriteSequenceNumber
+               {
+                       get { return this.writeSequenceNumber; }
+                       set { this.writeSequenceNumber = value; }
+               }
+
+               public ulong ReadSequenceNumber
+               {
+                       get { return this.readSequenceNumber; }
+                       set { this.readSequenceNumber = value; }
+               }
+
+               public byte[] ClientRandom
+               {
+                       get { return this.clientRandom; }
+                       set { this.clientRandom = value; }
+               }
+
+               public byte[] ServerRandom
+               {
+                       get { return this.serverRandom; }
+                       set { this.serverRandom = value; }
+               }
+
+               public byte[] RandomCS
+               {
+                       get { return this.randomCS; }
+                       set { this.randomCS = value; }
+               }
+
+               public byte[] RandomSC
+               {
+                       get { return this.randomSC; }
+                       set { this.randomSC = value; }
+               }
+
+               public byte[] MasterSecret
+               {
+                       get { return this.masterSecret; }
+                       set { this.masterSecret = value; }
+               }
+
+               public byte[] ClientWriteKey
+               {
+                       get { return this.clientWriteKey; }
+                       set { this.clientWriteKey = value; }
+               }
+
+               public byte[] ServerWriteKey
+               {
+                       get { return this.serverWriteKey; }
+                       set { this.serverWriteKey = value; }
+               }
+
+               public byte[] ClientWriteIV
+               {
+                       get { return this.clientWriteIV; }
+                       set { this.clientWriteIV = value; }
+               }
+
+               public byte[] ServerWriteIV
+               {
+                       get { return this.serverWriteIV; }
+                       set { this.serverWriteIV = value; }
+               }
+
+               public RecordProtocol RecordProtocol
+               {
+                       get { return this.recordProtocol; }
+                       set { this.recordProtocol = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public Context(SecurityProtocolType securityProtocolType)
+               {
+                       this.SecurityProtocol   = securityProtocolType;
+                       this.compressionMethod  = SecurityCompressionType.None;
+                       this.serverSettings             = new TlsServerSettings();
+                       this.clientSettings             = new TlsClientSettings();
+                       this.handshakeMessages  = new TlsStream();
+                       this.sessionId                  = null;
+                       this.handshakeState             = HandshakeState.None;
+                       this.random                             = RandomNumberGenerator.Create();
+               }
+
+               #endregion
+
+               #region Methods
+               
+               public int GetUnixTime()
+               {
+                       DateTime now = DateTime.UtcNow;
+                                                                                                                                                    
+                       return (int)((now.Ticks - UNIX_BASE_TICKS) / TimeSpan.TicksPerSecond);
+               }
+
+               public byte[] GetSecureRandomBytes(int count)
+               {
+                       byte[] secureBytes = new byte[count];
+
+                       this.random.GetNonZeroBytes(secureBytes);
+                       
+                       return secureBytes;
+               }
+
+               public virtual void Clear()
+               {
+                       this.compressionMethod  = SecurityCompressionType.None;
+                       this.serverSettings             = new TlsServerSettings();
+                       this.clientSettings             = new TlsClientSettings();
+                       this.handshakeMessages  = new TlsStream();
+                       this.sessionId                  = null;
+                       this.handshakeState             = HandshakeState.None;
+
+                       this.ClearKeyInfo();
+               }
+
+               public virtual void ClearKeyInfo()
+               {
+                       // Clear Master Secret
+                       if (masterSecret != null) {
+                               Array.Clear (masterSecret, 0, masterSecret.Length);
+                               masterSecret = null;
+                       }
+
+                       // Clear client and server random
+                       if (clientRandom != null) {
+                               Array.Clear (clientRandom, 0, clientRandom.Length);
+                               clientRandom = null;
+                       }
+                       if (serverRandom != null) {
+                               Array.Clear (serverRandom, 0, serverRandom.Length);
+                               serverRandom = null;
+                       }
+                       if (randomCS != null) {
+                               Array.Clear (randomCS, 0, randomCS.Length);
+                               randomCS = null;
+                       }
+                       if (randomSC != null) {
+                               Array.Clear (randomSC, 0, randomSC.Length);
+                               randomSC = null;
+                       }
+
+                       // Clear client keys
+                       if (clientWriteKey != null) {
+                               Array.Clear (clientWriteKey, 0, clientWriteKey.Length);
+                               clientWriteKey = null;
+                       }
+                       if (clientWriteIV != null) {
+                               Array.Clear (clientWriteIV, 0, clientWriteIV.Length);
+                               clientWriteIV = null;
+                       }
+                       
+                       // Clear server keys
+                       if (serverWriteKey != null) {
+                               Array.Clear (serverWriteKey, 0, serverWriteKey.Length);
+                               serverWriteKey = null;
+                       }
+                       if (serverWriteIV != null) {
+                               Array.Clear (serverWriteIV, 0, serverWriteIV.Length);
+                               serverWriteIV = null;
+                       }
+
+                       // Reset handshake messages
+                       this.handshakeMessages.Reset();
+
+                       // Clear MAC keys if protocol is different than Ssl3
+                       // SSLv3 needs them inside Mono.Security.Protocol.Tls.SslCipherSuite.Compute[Client|Server]RecordMAC
+                       if (this.securityProtocol != SecurityProtocolType.Ssl3)
+                       {
+//                             this.clientWriteMAC = null;
+//                             this.serverWriteMAC = null;
+                       }
+               }
+
+               public SecurityProtocolType DecodeProtocolCode(short code)
+               {
+                       switch (code)
+                       {
+                               case Context.TLS1_PROTOCOL_CODE:
+                                       return SecurityProtocolType.Tls;
+
+                               case Context.SSL3_PROTOCOL_CODE:
+                                       return SecurityProtocolType.Ssl3;
+
+                               default:
+                                       throw new NotSupportedException("Unsupported security protocol type");
+                       }
+               }
+
+               public void ChangeProtocol(short protocol)
+               {
+                       SecurityProtocolType protocolType = this.DecodeProtocolCode(protocol);
+
+                       if ((protocolType & this.SecurityProtocolFlags) == protocolType ||
+                               (this.SecurityProtocolFlags & SecurityProtocolType.Default) == SecurityProtocolType.Default)
+                       {
+                               this.SecurityProtocol = protocolType;
+                               this.SupportedCiphers.Clear();
+                               this.SupportedCiphers = null;
+                               this.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(protocolType);
+                       }
+                       else
+                       {
+                               throw new TlsException(AlertDescription.ProtocolVersion, "Incorrect protocol version received from server");
+                       }
+               }
+
+
+               public SecurityParameters Current
+               {
+                       get
+                       {
+                               if (current == null)
+                                       current = new SecurityParameters ();
+                               if (current.Cipher != null)
+                                       current.Cipher.Context = this;
+                               return current;
+                       }
+               }
+
+               public SecurityParameters Negotiating
+               {
+                       get
+                       {
+                               if (negotiating == null)
+                                       negotiating = new SecurityParameters ();
+                               if (negotiating.Cipher != null)
+                                       negotiating.Cipher.Context = this;
+                               return negotiating;
+                       }
+               }
+
+               public SecurityParameters Read
+               {
+                       get { return read; }
+               }
+
+               public SecurityParameters Write
+               {
+                       get { return write; }
+               }
+
+               public void StartSwitchingSecurityParameters (bool client)
+               {
+                       if (client) {
+                               // everything we write from now on is encrypted
+                               write = negotiating;
+                               // but we still read with the older cipher until we 
+                               // receive the ChangeCipherSpec message
+                               read = current;
+                       } else {
+                               // everything we read from now on is encrypted
+                               read = negotiating;
+                               // but we still write with the older cipher until we 
+                               // receive the ChangeCipherSpec message
+                               write = current;
+                       }
+                       current = negotiating;
+               }
+
+               public void EndSwitchingSecurityParameters (bool client)
+               {
+                       SecurityParameters temp;
+                       if (client) {
+                               temp = read;
+                               // we now read with the new, negotiated, security parameters
+                               read = current;
+                       } else {
+                               temp = write;
+                               // we now write with the new, negotiated, security parameters
+                               write = current;
+                       }
+                       // so we clear the old one (last reference)
+                       if (temp != null)
+                               temp.Clear ();
+                       negotiating = temp;
+                       // and are now ready for a future renegotiation
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/DebugHelper.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/DebugHelper.cs
new file mode 100644 (file)
index 0000000..a4e2937
--- /dev/null
@@ -0,0 +1,92 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Diagnostics;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class DebugHelper
+       {
+               private static bool isInitialized;
+
+               [Conditional("DEBUG")]
+               public static void Initialize()
+               {
+                       if (!isInitialized)
+                       {
+                               Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
+                               // Debug.Listeners.Add(new TextWriterTraceListener(@"c:\ssl.log"));
+                               Debug.AutoFlush = true;
+                               Debug.Indent();
+
+                               isInitialized = true;
+                       }
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteLine(string format, params object[] args)
+               {
+                       Initialize();
+                       Debug.WriteLine(String.Format(format, args));
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteLine(string message)
+               {
+                       Initialize();
+                       Debug.WriteLine(message);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteLine(string message, byte[] buffer)
+               {
+                       Initialize();
+                       DebugHelper.WriteLine(String.Format("{0} ({1} bytes))", message, buffer.Length));
+                       DebugHelper.WriteBuffer(buffer);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteBuffer(byte[] buffer)
+               {
+                       Initialize();
+                       DebugHelper.WriteBuffer(buffer, 0, buffer.Length);
+               }
+
+               [Conditional("DEBUG")]
+               public static void WriteBuffer(byte[] buffer, int index, int length)
+               {
+                       Initialize();
+                       for (int i = index; i < length; i += 16)
+                       {
+                               int count = (length - i) >= 16 ? 16 : (length - i);
+                               for (int j = 0; j < count; j++)
+                               {
+                                       Debug.Write(buffer[i + j].ToString("x2") + " ");
+                               }
+                               Debug.WriteLine("");
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs
new file mode 100644 (file)
index 0000000..a244b2e
--- /dev/null
@@ -0,0 +1,38 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+       [Serializable]
+       public enum ExchangeAlgorithmType
+       {
+               DiffieHellman,
+               Fortezza,
+               None,
+               RsaKeyX,
+               RsaSign
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/HandshakeState.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/HandshakeState.cs
new file mode 100644 (file)
index 0000000..cf15386
--- /dev/null
@@ -0,0 +1,36 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+       [Serializable]
+       internal enum HandshakeState
+       {
+               None,
+               Started,
+               Finished
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/HashAlgorithmType.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/HashAlgorithmType.cs
new file mode 100644 (file)
index 0000000..092d7ad
--- /dev/null
@@ -0,0 +1,36 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+       [Serializable]
+       public enum HashAlgorithmType
+       {
+               Md5,
+               None,
+               Sha1
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/HttpsClientStream.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/HttpsClientStream.cs
new file mode 100644 (file)
index 0000000..aa43523
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// HttpsClientStream.cs: Glue between HttpWebRequest and SslClientStream to
+//      reduce reflection usage.
+//
+// Author:
+//      Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 2004-2007 Novell, Inc. (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Net;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+
+namespace Mono.Security.Protocol.Tls {
+
+        // Note: DO NOT REUSE this class - instead use SslClientStream
+
+        internal class HttpsClientStream : SslClientStream {
+
+                private HttpWebRequest _request;
+               private int _status;
+
+                public HttpsClientStream (Stream stream, X509CertificateCollection clientCertificates,
+                                       HttpWebRequest request, byte [] buffer)
+                        : base (stream, request.RequestUri.Host, false, (Mono.Security.Protocol.Tls.SecurityProtocolType)
+                               ServicePointManager.SecurityProtocol, clientCertificates)
+                {
+                        // this constructor permit access to the WebRequest to call
+                        // ICertificatePolicy.CheckValidationResult
+                        _request = request;
+                       _status = 0;
+                       if (buffer != null)
+                               InputBuffer.Write (buffer, 0, buffer.Length);
+#if !NET_1_0
+                        // also saved from reflection
+                        base.CheckCertRevocationStatus = ServicePointManager.CheckCertificateRevocationList;
+#endif
+#if NET_2_0
+                       ClientCertSelection += delegate (X509CertificateCollection clientCerts, X509Certificate serverCertificate,
+                               string targetHost, X509CertificateCollection serverRequestedCertificates) {
+                               return ((clientCerts == null) || (clientCerts.Count == 0)) ? null : clientCerts [0];
+                       };
+                       PrivateKeySelection += delegate (X509Certificate certificate, string targetHost) {
+                               X509Certificate2 cert = (certificate as X509Certificate2);
+                               return (cert == null) ? null : cert.PrivateKey;
+                       };
+#endif
+               }
+
+               public bool TrustFailure {
+                       get { 
+                               switch (_status) {
+                               case -2146762486: // CERT_E_CHAINING            0x800B010A
+                               case -2146762487: // CERT_E_UNTRUSTEDROOT       0x800B0109
+                                       return true;
+                               default:
+                                       return false;
+                               }
+                       }
+               }
+
+                internal override bool RaiseServerCertificateValidation (X509Certificate certificate, int[] certificateErrors)
+                {
+                       bool failed = (certificateErrors.Length > 0);
+                       // only one problem can be reported by this interface
+                       _status = ((failed) ? certificateErrors [0] : 0);
+
+                       if (ServicePointManager.CertificatePolicy != null) {
+                               ServicePoint sp = _request.ServicePoint;
+                               return ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, _request, _status);
+                       }
+                       return failed;
+               }
+        }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/README.olive b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/README.olive
new file mode 100644 (file)
index 0000000..522f3fc
--- /dev/null
@@ -0,0 +1 @@
+Imported from Mono.Security.dll
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs
new file mode 100644 (file)
index 0000000..1b9f5e4
--- /dev/null
@@ -0,0 +1,104 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class RSASslSignatureDeformatter : AsymmetricSignatureDeformatter
+       {
+               #region Fields
+
+               private RSA                             key;
+               private HashAlgorithm   hash;
+
+               #endregion
+
+               #region Constructors
+
+               public RSASslSignatureDeformatter()
+               {
+               }
+
+               public RSASslSignatureDeformatter(AsymmetricAlgorithm key)
+               {
+                       this.SetKey(key);
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override bool VerifySignature(
+                       byte[] rgbHash,
+                       byte[] rgbSignature)
+               {
+                       if (this.key == null)
+                       {
+                               throw new CryptographicUnexpectedOperationException("The key is a null reference");
+                       }
+                       if (hash == null)
+                       {
+                               throw new CryptographicUnexpectedOperationException("The hash algorithm is a null reference.");
+                       }
+                       if (rgbHash == null)
+                       {
+                               throw new ArgumentNullException("The rgbHash parameter is a null reference.");
+                       }
+
+                       return Mono.Security.Cryptography.PKCS1.Verify_v15(
+                               this.key,
+                               this.hash,
+                               rgbHash,
+                               rgbSignature);
+               }
+
+               public override void SetHashAlgorithm(string strName)
+               {
+                       switch (strName)
+                       {
+                               case "MD5SHA1":
+                                       this.hash = new Mono.Security.Cryptography.MD5SHA1();
+                                       break;
+
+                               default:
+                                       this.hash = HashAlgorithm.Create(strName);
+                                       break;
+                       }
+               }
+
+               public override void SetKey(AsymmetricAlgorithm key)
+               {
+                       if (!(key is RSA))
+                       {
+                               throw new ArgumentException("Specfied key is not an RSA key");
+                       }
+
+                       this.key = key as RSA;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs
new file mode 100644 (file)
index 0000000..f2e168c
--- /dev/null
@@ -0,0 +1,101 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class RSASslSignatureFormatter : AsymmetricSignatureFormatter
+       {
+               #region Fields
+
+               private RSA                             key;
+               private HashAlgorithm   hash;
+
+               #endregion
+
+               #region Constructors
+
+               public RSASslSignatureFormatter()
+               {
+               }
+
+               public RSASslSignatureFormatter(AsymmetricAlgorithm key)
+               {
+                       this.SetKey(key);
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override byte[] CreateSignature(byte[] rgbHash)
+               {
+                       if (this.key == null)
+                       {
+                               throw new CryptographicUnexpectedOperationException("The key is a null reference");
+                       }
+                       if (hash == null)
+                       {
+                               throw new CryptographicUnexpectedOperationException("The hash algorithm is a null reference.");
+                       }
+                       if (rgbHash == null)
+                       {
+                               throw new ArgumentNullException("The rgbHash parameter is a null reference.");
+                       }
+
+                       return Mono.Security.Cryptography.PKCS1.Sign_v15(
+                               this.key,
+                               this.hash,
+                               rgbHash);
+               }
+
+               public override void SetHashAlgorithm(string strName)
+               {
+                       switch (strName)
+                       {
+                               case "MD5SHA1":
+                                       this.hash = new Mono.Security.Cryptography.MD5SHA1();
+                                       break;
+
+                               default:
+                                       this.hash = HashAlgorithm.Create(strName);
+                                       break;
+                       }
+               }
+
+               public override void SetKey(AsymmetricAlgorithm key)
+               {
+                       if (!(key is RSA))
+                       {
+                               throw new ArgumentException("Specfied key is not an RSA key");
+                       }
+
+                       this.key = key as RSA;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/RecordProtocol.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/RecordProtocol.cs
new file mode 100644 (file)
index 0000000..6ccced6
--- /dev/null
@@ -0,0 +1,984 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Threading;
+
+using Mono.Security.Protocol.Tls.Handshake;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal abstract class RecordProtocol
+       {
+               #region Fields
+
+               private static ManualResetEvent record_processing = new ManualResetEvent (true);
+
+               protected Stream        innerStream;
+               protected Context       context;
+
+               #endregion
+
+               #region Properties
+
+               public Context Context
+               {
+                       get { return this.context; }
+                       set { this.context = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public RecordProtocol(Stream innerStream, Context context)
+               {
+                       this.innerStream                        = innerStream;
+                       this.context                            = context;
+                       this.context.RecordProtocol = this;
+               }
+
+               #endregion
+
+               #region Abstract Methods
+
+               public virtual void SendRecord(HandshakeType type)
+               {
+
+                       IAsyncResult ar = this.BeginSendRecord(type, null, null);
+
+                       this.EndSendRecord(ar);
+
+               }
+
+               protected abstract void ProcessHandshakeMessage(TlsStream handMsg);
+
+               protected virtual void ProcessChangeCipherSpec ()
+               {
+                       Context ctx = this.Context;
+
+                       // Reset sequence numbers
+                       ctx.ReadSequenceNumber = 0;
+
+                       if (ctx is ClientContext) {
+                               ctx.EndSwitchingSecurityParameters (true);
+                       } else {
+                               ctx.StartSwitchingSecurityParameters (false);
+                       }
+               }
+
+               public virtual HandshakeMessage GetMessage(HandshakeType type)
+               {
+                       throw new NotSupportedException();
+               }
+
+               #endregion
+
+               #region Receive Record Async Result
+               private class ReceiveRecordAsyncResult : IAsyncResult
+               {
+                       private object locker = new object ();
+                       private AsyncCallback _userCallback;
+                       private object _userState;
+                       private Exception _asyncException;
+                       private ManualResetEvent handle;
+                       private byte[] _resultingBuffer;
+                       private Stream _record;
+                       private bool completed;
+
+                       private byte[] _initialBuffer;
+
+                       public ReceiveRecordAsyncResult(AsyncCallback userCallback, object userState, byte[] initialBuffer, Stream record)
+                       {
+                               _userCallback = userCallback;
+                               _userState = userState;
+                               _initialBuffer = initialBuffer;
+                               _record = record;
+                       }
+
+                       public Stream Record
+                       {
+                               get { return _record; }
+                       }
+
+                       public byte[] ResultingBuffer
+                       {
+                               get { return _resultingBuffer; }
+                       }
+
+                       public byte[] InitialBuffer
+                       {
+                               get { return _initialBuffer; }
+                       }
+
+                       public object AsyncState
+                       {
+                               get { return _userState; }
+                       }
+
+                       public Exception AsyncException
+                       {
+                               get { return _asyncException; }
+                       }
+
+                       public bool CompletedWithError
+                       {
+                               get {
+                                       if (!IsCompleted)
+                                               return false; // Perhaps throw InvalidOperationExcetion?
+
+                                       return null != _asyncException;
+                               }
+                       }
+
+                       public WaitHandle AsyncWaitHandle
+                       {
+                               get {
+                                       lock (locker) {
+                                               if (handle == null)
+                                                       handle = new ManualResetEvent (completed);
+                                       }
+                                       return handle;
+                               }
+                               
+                       }
+
+                       public bool CompletedSynchronously
+                       {
+                               get { return false; }
+                       }
+
+                       public bool IsCompleted
+                       {
+                               get {
+                                       lock (locker) {
+                                               return completed;
+                                       }
+                               }
+                       }
+
+                       private void SetComplete(Exception ex, byte[] resultingBuffer)
+                       {
+                               lock (locker) {
+                                       if (completed)
+                                               return;
+
+                                       completed = true;
+                                       _asyncException = ex;
+                                       _resultingBuffer = resultingBuffer;
+                                       if (handle != null)
+                                               handle.Set ();
+
+                                       if (_userCallback != null)
+                                               _userCallback.BeginInvoke (this, null, null);
+                               }
+                       }
+
+                       public void SetComplete(Exception ex)
+                       {
+                               SetComplete(ex, null);
+                       }
+
+                       public void SetComplete(byte[] resultingBuffer)
+                       {
+                               SetComplete(null, resultingBuffer);
+                       }
+
+                       public void SetComplete()
+                       {
+                               SetComplete(null, null);
+                       }
+               }
+               #endregion
+
+               #region Receive Record Async Result
+               private class SendRecordAsyncResult : IAsyncResult
+               {
+                       private object locker = new object ();
+                       private AsyncCallback _userCallback;
+                       private object _userState;
+                       private Exception _asyncException;
+                       private ManualResetEvent handle;
+                       private HandshakeMessage _message;
+                       private bool completed;
+
+                       public SendRecordAsyncResult(AsyncCallback userCallback, object userState, HandshakeMessage message)
+                       {
+                               _userCallback = userCallback;
+                               _userState = userState;
+                               _message = message;
+                       }
+
+                       public HandshakeMessage Message
+                       {
+                               get { return _message; }
+                       }
+
+                       public object AsyncState
+                       {
+                               get { return _userState; }
+                       }
+
+                       public Exception AsyncException
+                       {
+                               get { return _asyncException; }
+                       }
+
+                       public bool CompletedWithError
+                       {
+                               get {
+                                       if (!IsCompleted)
+                                               return false; // Perhaps throw InvalidOperationExcetion?
+
+                                       return null != _asyncException;
+                               }
+                       }
+
+                       public WaitHandle AsyncWaitHandle
+                       {
+                               get {
+                                       lock (locker) {
+                                               if (handle == null)
+                                                       handle = new ManualResetEvent (completed);
+                                       }
+                                       return handle;
+                               }
+                               
+                       }
+
+                       public bool CompletedSynchronously
+                       {
+                               get { return false; }
+                       }
+
+                       public bool IsCompleted
+                       {
+                               get {
+                                       lock (locker) {
+                                               return completed;
+                                       }
+                               }
+                       }
+
+                       public void SetComplete(Exception ex)
+                       {
+                               lock (locker) {
+                                       if (completed)
+                                               return;
+
+                                       completed = true;
+                                       if (handle != null)
+                                               handle.Set ();
+
+                                       if (_userCallback != null)
+                                               _userCallback.BeginInvoke (this, null, null);
+
+                                       _asyncException = ex;
+                               }
+                       }
+
+                       public void SetComplete()
+                       {
+                               SetComplete(null);
+                       }
+               }
+               #endregion
+
+               #region Reveive Record Methods
+
+               public IAsyncResult BeginReceiveRecord(Stream record, AsyncCallback callback, object state)
+               {
+                       if (this.context.ConnectionEnd)
+                       {
+                               throw new TlsException(
+                                       AlertDescription.InternalError,
+                                       "The session is finished and it's no longer valid.");
+                       }
+
+                       record_processing.Reset ();
+                       byte[] recordTypeBuffer = new byte[1];
+
+                       ReceiveRecordAsyncResult internalResult = new ReceiveRecordAsyncResult(callback, state, recordTypeBuffer, record);
+
+                       record.BeginRead(internalResult.InitialBuffer, 0, internalResult.InitialBuffer.Length, new AsyncCallback(InternalReceiveRecordCallback), internalResult);
+
+                       return internalResult;
+               }
+
+               private void InternalReceiveRecordCallback(IAsyncResult asyncResult)
+               {
+                       ReceiveRecordAsyncResult internalResult = asyncResult.AsyncState as ReceiveRecordAsyncResult;
+                       Stream record = internalResult.Record;
+
+                       try
+                       {
+                               
+                               int bytesRead = internalResult.Record.EndRead(asyncResult);
+
+                               //We're at the end of the stream. Time to bail.
+                               if (bytesRead == 0)
+                               {
+                                       internalResult.SetComplete((byte[])null);
+                                       return;
+                               }
+
+                               // Try to read the Record Content Type
+                               int type = internalResult.InitialBuffer[0];
+
+                               // Set last handshake message received to None
+                               this.context.LastHandshakeMsg = HandshakeType.ClientHello;
+
+                               ContentType     contentType     = (ContentType)type;
+                               byte[] buffer = this.ReadRecordBuffer(type, record);
+                               if (buffer == null)
+                               {
+                                       // record incomplete (at the moment)
+                                       internalResult.SetComplete((byte[])null);
+                                       return;
+                               }
+
+                               // Decrypt message contents if needed
+                               if (contentType == ContentType.Alert && buffer.Length == 2)
+                               {
+                               }
+                               else if ((this.Context.Read != null) && (this.Context.Read.Cipher != null))
+                               {
+                                       buffer = this.decryptRecordFragment (contentType, buffer);
+                                       DebugHelper.WriteLine ("Decrypted record data", buffer);
+                               }
+
+                               // Process record
+                               switch (contentType)
+                               {
+                                       case ContentType.Alert:
+                                               this.ProcessAlert((AlertLevel)buffer [0], (AlertDescription)buffer [1]);
+                                               if (record.CanSeek) 
+                                               {
+                                                       // don't reprocess that memory block
+                                                       record.SetLength (0); 
+                                               }
+                                               buffer = null;
+                                               break;
+
+                                       case ContentType.ChangeCipherSpec:
+                                               this.ProcessChangeCipherSpec();
+                                               break;
+
+                                       case ContentType.ApplicationData:
+                                               break;
+
+                                       case ContentType.Handshake:
+                                               TlsStream message = new TlsStream (buffer);
+                                               while (!message.EOF)
+                                               {
+                                                       this.ProcessHandshakeMessage(message);
+                                               }
+                                               break;
+
+                                       case (ContentType)0x80:
+                                               this.context.HandshakeMessages.Write (buffer);
+                                               break;
+
+                                       default:
+                                               throw new TlsException(
+                                                       AlertDescription.UnexpectedMessage,
+                                                       "Unknown record received from server.");
+                               }
+
+                               internalResult.SetComplete(buffer);
+                       }
+                       catch (Exception ex)
+                       {
+                               internalResult.SetComplete(ex);
+                       }
+
+               }
+
+               public byte[] EndReceiveRecord(IAsyncResult asyncResult)
+               {
+                       ReceiveRecordAsyncResult internalResult = asyncResult as ReceiveRecordAsyncResult;
+
+                       if (null == internalResult)
+                               throw new ArgumentException("Either the provided async result is null or was not created by this RecordProtocol.");
+
+                       if (!internalResult.IsCompleted)
+                               internalResult.AsyncWaitHandle.WaitOne();
+
+                       if (internalResult.CompletedWithError)
+                               throw internalResult.AsyncException;
+
+                       byte[] result = internalResult.ResultingBuffer;
+                       record_processing.Set ();
+                       return result;
+               }
+
+               public byte[] ReceiveRecord(Stream record)
+               {
+
+                       IAsyncResult ar = this.BeginReceiveRecord(record, null, null);
+                       return this.EndReceiveRecord(ar);
+
+               }
+
+               private byte[] ReadRecordBuffer (int contentType, Stream record)
+               {
+                       switch (contentType)
+                       {
+                               case 0x80:
+                                       return this.ReadClientHelloV2(record);
+
+                               default:
+                                       if (!Enum.IsDefined(typeof(ContentType), (ContentType)contentType))
+                                       {
+                                               throw new TlsException(AlertDescription.DecodeError);
+                                       }
+                                       return this.ReadStandardRecordBuffer(record);
+                       }
+               }
+
+               private byte[] ReadClientHelloV2 (Stream record)
+               {
+                       int msgLength = record.ReadByte ();
+                       // process further only if the whole record is available
+                       if (record.CanSeek && (msgLength + 1 > record.Length)) 
+                       {
+                               return null;
+                       }
+
+                       byte[] message = new byte[msgLength];
+                       record.Read (message, 0, msgLength);
+
+                       int msgType             = message [0];
+                       if (msgType != 1)
+                       {
+                               throw new TlsException(AlertDescription.DecodeError);
+                       }
+                       int protocol = (message [1] << 8 | message [2]);
+                       int cipherSpecLength = (message [3] << 8 | message [4]);
+                       int sessionIdLength = (message [5] << 8 | message [6]);
+                       int challengeLength = (message [7] << 8 | message [8]);
+                       int length = (challengeLength > 32) ? 32 : challengeLength;
+
+                       // Read CipherSpecs
+                       byte[] cipherSpecV2 = new byte[cipherSpecLength];
+                       Buffer.BlockCopy (message, 9, cipherSpecV2, 0, cipherSpecLength);
+
+                       // Read session ID
+                       byte[] sessionId = new byte[sessionIdLength];
+                       Buffer.BlockCopy (message, 9 + cipherSpecLength, sessionId, 0, sessionIdLength);
+
+                       // Read challenge ID
+                       byte[] challenge = new byte[challengeLength];
+                       Buffer.BlockCopy (message, 9 + cipherSpecLength + sessionIdLength, challenge, 0, challengeLength);
+               
+                       if (challengeLength < 16 || cipherSpecLength == 0 || (cipherSpecLength % 3) != 0)
+                       {
+                               throw new TlsException(AlertDescription.DecodeError);
+                       }
+
+                       // Updated the Session ID
+                       if (sessionId.Length > 0)
+                       {
+                               this.context.SessionId = sessionId;
+                       }
+
+                       // Update the protocol version
+                       this.Context.ChangeProtocol((short)protocol);
+
+                       // Select the Cipher suite
+                       this.ProcessCipherSpecV2Buffer(this.Context.SecurityProtocol, cipherSpecV2);
+
+                       // Updated the Client Random
+                       this.context.ClientRandom = new byte [32]; // Always 32
+                       // 1. if challenge is bigger than 32 bytes only use the last 32 bytes
+                       // 2. right justify (0) challenge in ClientRandom if less than 32
+                       Buffer.BlockCopy (challenge, challenge.Length - length, this.context.ClientRandom, 32 - length, length);
+
+                       // Set 
+                       this.context.LastHandshakeMsg = HandshakeType.ClientHello;
+                       this.context.ProtocolNegotiated = true;
+
+                       return message;
+               }
+
+               private byte[] ReadStandardRecordBuffer (Stream record)
+               {
+                       byte[] header = new byte[4];
+                       if (record.Read (header, 0, 4) != 4)
+                               throw new TlsException ("buffer underrun");
+                       
+                       short protocol = (short)((header [0] << 8) | header [1]);
+                       short length = (short)((header [2] << 8) | header [3]);
+
+                       // process further only if the whole record is available
+                       // note: the first 5 bytes aren't part of the length
+                       if (record.CanSeek && (length + 5 > record.Length)) 
+                       {
+                               return null;
+                       }
+                       
+                       // Read Record data
+                       int     totalReceived = 0;
+                       byte[]  buffer          = new byte[length];
+                       while (totalReceived != length)
+                       {
+                               int justReceived = record.Read(buffer, totalReceived, buffer.Length - totalReceived);
+
+                               //Make sure we get some data so we don't end up in an infinite loop here before shutdown.
+                               if (0 == justReceived)
+                               {
+                                       throw new TlsException(AlertDescription.CloseNotify, "Received 0 bytes from stream. It must be closed.");
+                               }
+
+                               totalReceived += justReceived;
+                       }
+
+                       // Check that the message has a valid protocol version
+                       if (protocol != this.context.Protocol && this.context.ProtocolNegotiated)
+                       {
+                               throw new TlsException(
+                                       AlertDescription.ProtocolVersion, "Invalid protocol version on message received");
+                       }
+
+                       DebugHelper.WriteLine("Record data", buffer);
+
+                       return buffer;
+               }
+
+               private void ProcessAlert(AlertLevel alertLevel, AlertDescription alertDesc)
+               {
+                       switch (alertLevel)
+                       {
+                               case AlertLevel.Fatal:
+                                       throw new TlsException(alertLevel, alertDesc);
+
+                               case AlertLevel.Warning:
+                               default:
+                               switch (alertDesc)
+                               {
+                                       case AlertDescription.CloseNotify:
+                                               this.context.ConnectionEnd = true;
+                                               break;
+                               }
+                               break;
+                       }
+               }
+
+               #endregion
+
+               #region Send Alert Methods
+
+               public void SendAlert(AlertDescription description)
+               {
+                       this.SendAlert(new Alert(description));
+               }
+
+               public void SendAlert(
+                       AlertLevel                      level, 
+                       AlertDescription        description)
+               {
+                       this.SendAlert(new Alert(level, description));
+               }
+
+               public void SendAlert(Alert alert)
+               {
+                       AlertLevel level;
+                       AlertDescription description;
+                       bool close;
+
+                       if (alert == null) {
+                               DebugHelper.WriteLine(">>>> Write Alert NULL");
+                               level = AlertLevel.Fatal;
+                               description = AlertDescription.InternalError;
+                               close = true;
+                       } else {
+                               DebugHelper.WriteLine(">>>> Write Alert ({0}|{1})", alert.Description, alert.Message);
+                               level = alert.Level;
+                               description = alert.Description;
+                               close = alert.IsCloseNotify;
+                       }
+
+                       // Write record
+                       this.SendRecord (ContentType.Alert, new byte[2] { (byte) level, (byte) description });
+
+                       if (close)
+                       {
+                               this.context.ConnectionEnd = true;
+                       }
+               }
+
+               #endregion
+
+               #region Send Record Methods
+
+               public void SendChangeCipherSpec()
+               {
+                       DebugHelper.WriteLine(">>>> Write Change Cipher Spec");
+
+                       // Send Change Cipher Spec message with the current cipher
+                       // or as plain text if this is the initial negotiation
+                       this.SendRecord(ContentType.ChangeCipherSpec, new byte[] {1});
+
+                       Context ctx = this.context;
+
+                       // Reset sequence numbers
+                       ctx.WriteSequenceNumber = 0;
+
+                       // all further data sent will be encrypted with the negotiated
+                       // security parameters (now the current parameters)
+                       if (ctx is ClientContext) {
+                               ctx.StartSwitchingSecurityParameters (true);
+                       } else {
+                               ctx.EndSwitchingSecurityParameters (false);
+                       }
+               }
+
+               public IAsyncResult BeginSendRecord(HandshakeType handshakeType, AsyncCallback callback, object state)
+               {
+                       HandshakeMessage msg = this.GetMessage(handshakeType);
+
+                       msg.Process();
+
+                       DebugHelper.WriteLine(">>>> Write handshake record ({0}|{1})", context.Protocol, msg.ContentType);
+
+                       SendRecordAsyncResult internalResult = new SendRecordAsyncResult(callback, state, msg);
+
+                       this.BeginSendRecord(msg.ContentType, msg.EncodeMessage(), new AsyncCallback(InternalSendRecordCallback), internalResult);
+
+                       return internalResult;
+               }
+
+               private void InternalSendRecordCallback(IAsyncResult ar)
+               {
+                       SendRecordAsyncResult internalResult = ar.AsyncState as SendRecordAsyncResult;
+                       
+                       try
+                       {
+                               this.EndSendRecord(ar);
+
+                               // Update session
+                               internalResult.Message.Update();
+
+                               // Reset message contents
+                               internalResult.Message.Reset();
+
+                               internalResult.SetComplete();
+                       }
+                       catch (Exception ex)
+                       {
+                               internalResult.SetComplete(ex);
+                       }
+               }
+
+               public IAsyncResult BeginSendRecord(ContentType contentType, byte[] recordData, AsyncCallback callback, object state)
+               {
+                       if (this.context.ConnectionEnd)
+                       {
+                               throw new TlsException(
+                                       AlertDescription.InternalError,
+                                       "The session is finished and it's no longer valid.");
+                       }
+
+                       byte[] record = this.EncodeRecord(contentType, recordData);
+
+                       return this.innerStream.BeginWrite(record, 0, record.Length, callback, state);
+               }
+
+               public void EndSendRecord(IAsyncResult asyncResult)
+               {
+                       if (asyncResult is SendRecordAsyncResult)
+                       {
+                               SendRecordAsyncResult internalResult = asyncResult as SendRecordAsyncResult;
+                               if (!internalResult.IsCompleted)
+                                       internalResult.AsyncWaitHandle.WaitOne();
+                               if (internalResult.CompletedWithError)
+                                       throw internalResult.AsyncException;
+                       }
+                       else
+                       {
+                               this.innerStream.EndWrite(asyncResult);
+                       }
+               }
+
+               public void SendRecord(ContentType contentType, byte[] recordData)
+               {
+                       IAsyncResult ar = this.BeginSendRecord(contentType, recordData, null, null);
+
+                       this.EndSendRecord(ar);
+               }
+
+               public byte[] EncodeRecord(ContentType contentType, byte[] recordData)
+               {
+                       return this.EncodeRecord(
+                               contentType,
+                               recordData,
+                               0,
+                               recordData.Length);
+               }
+
+               public byte[] EncodeRecord(
+                       ContentType     contentType, 
+                       byte[]          recordData,
+                       int                     offset,
+                       int                     count)
+               {
+                       if (this.context.ConnectionEnd)
+                       {
+                               throw new TlsException(
+                                       AlertDescription.InternalError,
+                                       "The session is finished and it's no longer valid.");
+                       }
+
+                       TlsStream record = new TlsStream();
+
+                       int     position = offset;
+
+                       while (position < ( offset + count ))
+                       {
+                               short   fragmentLength = 0;
+                               byte[]  fragment;
+
+                               if ((count + offset - position) > Context.MAX_FRAGMENT_SIZE)
+                               {
+                                       fragmentLength = Context.MAX_FRAGMENT_SIZE;
+                               }
+                               else
+                               {
+                                       fragmentLength = (short)(count + offset - position);
+                               }
+
+                               // Fill the fragment data
+                               fragment = new byte[fragmentLength];
+                               Buffer.BlockCopy(recordData, position, fragment, 0, fragmentLength);
+
+                               if ((this.Context.Write != null) && (this.Context.Write.Cipher != null))
+                               {
+                                       // Encrypt fragment
+                                       fragment = this.encryptRecordFragment (contentType, fragment);
+                               }
+
+                               // Write tls message
+                               record.Write((byte)contentType);
+                               record.Write(this.context.Protocol);
+                               record.Write((short)fragment.Length);
+                               record.Write(fragment);
+
+                               DebugHelper.WriteLine("Record data", fragment);
+
+                               // Update buffer position
+                               position += fragmentLength;
+                       }
+
+                       return record.ToArray();
+               }
+               
+               #endregion
+
+               #region Cryptography Methods
+
+               private byte[] encryptRecordFragment(
+                       ContentType     contentType, 
+                       byte[]          fragment)
+               {
+                       byte[] mac      = null;
+
+                       // Calculate message MAC
+                       if (this.Context is ClientContext)
+                       {
+                               mac = this.context.Write.Cipher.ComputeClientRecordMAC(contentType, fragment);
+                       }       
+                       else
+                       {
+                               mac = this.context.Write.Cipher.ComputeServerRecordMAC (contentType, fragment);
+                       }
+
+                       DebugHelper.WriteLine(">>>> Record MAC", mac);
+
+                       // Encrypt the message
+                       byte[] ecr = this.context.Write.Cipher.EncryptRecord (fragment, mac);
+
+                       // Update sequence number
+                       this.context.WriteSequenceNumber++;
+
+                       return ecr;
+               }
+
+               private byte[] decryptRecordFragment(
+                       ContentType     contentType, 
+                       byte[]          fragment)
+               {
+                       byte[]  dcrFragment             = null;
+                       byte[]  dcrMAC                  = null;
+
+                       try
+                       {
+                               this.context.Read.Cipher.DecryptRecord (fragment, out dcrFragment, out dcrMAC);
+                       }
+                       catch
+                       {
+                               if (this.context is ServerContext)
+                               {
+                                       this.Context.RecordProtocol.SendAlert(AlertDescription.DecryptionFailed);
+                               }
+
+                               throw;
+                       }
+                       
+                       // Generate record MAC
+                       byte[] mac = null;
+
+                       if (this.Context is ClientContext)
+                       {
+                               mac = this.context.Read.Cipher.ComputeServerRecordMAC(contentType, dcrFragment);
+                       }
+                       else
+                       {
+                               mac = this.context.Read.Cipher.ComputeClientRecordMAC (contentType, dcrFragment);
+                       }
+
+                       DebugHelper.WriteLine(">>>> Record MAC", mac);
+
+                       // Check record MAC
+                       if (!Compare (mac, dcrMAC))
+                       {
+                               throw new TlsException(AlertDescription.BadRecordMAC, "Bad record MAC");
+                       }
+
+                       // Update sequence number
+                       this.context.ReadSequenceNumber++;
+
+                       return dcrFragment;
+               }
+
+               private bool Compare (byte[] array1, byte[] array2)
+               {
+                       if (array1 == null)
+                               return (array2 == null);
+                       if (array2 == null)
+                               return false;
+                       if (array1.Length != array2.Length)
+                               return false;
+                       for (int i = 0; i < array1.Length; i++) {
+                               if (array1[i] != array2[i])
+                                       return false;
+                       }
+                       return true;
+               }
+
+               #endregion
+
+               #region CipherSpecV2 processing
+
+               private void ProcessCipherSpecV2Buffer (SecurityProtocolType protocol, byte[] buffer)
+               {
+                       TlsStream codes = new TlsStream(buffer);
+
+                       string prefix = (protocol == SecurityProtocolType.Ssl3) ? "SSL_" : "TLS_";
+
+                       while (codes.Position < codes.Length)
+                       {
+                               byte check = codes.ReadByte();
+
+                               if (check == 0)
+                               {
+                                       // SSL/TLS cipher spec
+                                       short code = codes.ReadInt16(); 
+                                       int index = this.Context.SupportedCiphers.IndexOf(code);
+                                       if (index != -1)
+                                       {
+                                               this.Context.Negotiating.Cipher = this.Context.SupportedCiphers[index];
+                                               break;
+                                       }
+                               }
+                               else
+                               {
+                                       byte[] tmp = new byte[2];
+                                       codes.Read(tmp, 0, tmp.Length);
+
+                                       int tmpCode = ((check & 0xff) << 16) | ((tmp[0] & 0xff) << 8) | (tmp[1] & 0xff);
+                                       CipherSuite cipher = this.MapV2CipherCode(prefix, tmpCode);
+
+                                       if (cipher != null)
+                                       {
+                                               this.Context.Negotiating.Cipher = cipher;
+                                               break;
+                                       }
+                               }
+                       }
+
+                       if (this.Context.Negotiating == null)
+                       {
+                               throw new TlsException(AlertDescription.InsuficientSecurity, "Insuficient Security");
+                       }
+               }
+
+               private CipherSuite MapV2CipherCode(string prefix, int code)
+               {
+                       try
+                       {
+                               switch (code)
+                               {
+                                       case 65664:
+                                               // TLS_RC4_128_WITH_MD5
+                                               return this.Context.SupportedCiphers[prefix + "RSA_WITH_RC4_128_MD5"];
+                                       
+                                       case 131200:
+                                               // TLS_RC4_128_EXPORT40_WITH_MD5
+                                               return this.Context.SupportedCiphers[prefix + "RSA_EXPORT_WITH_RC4_40_MD5"];
+                                       
+                                       case 196736:
+                                               // TLS_RC2_CBC_128_CBC_WITH_MD5
+                                               return this.Context.SupportedCiphers[prefix + "RSA_EXPORT_WITH_RC2_CBC_40_MD5"];
+                                       
+                                       case 262272:
+                                               // TLS_RC2_CBC_128_CBC_EXPORT40_WITH_MD5
+                                               return this.Context.SupportedCiphers[prefix + "RSA_EXPORT_WITH_RC2_CBC_40_MD5"];
+                                       
+                                       case 327808:
+                                               // TLS_IDEA_128_CBC_WITH_MD5
+                                               return null;
+                                       
+                                       case 393280:
+                                               // TLS_DES_64_CBC_WITH_MD5
+                                               return null;
+
+                                       case 458944:
+                                               // TLS_DES_192_EDE3_CBC_WITH_MD5
+                                               return null;
+
+                                       default:
+                                               return null;
+                               }
+                       }
+                       catch
+                       {
+                               return null;
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SecurityCompressionType.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SecurityCompressionType.cs
new file mode 100644 (file)
index 0000000..730a807
--- /dev/null
@@ -0,0 +1,37 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+       // Information about compression methods allowed by TLS
+       // can be found in:
+       //      draft-ietf-tls-compression-05.txt (http://www.ietf.org/internet-drafts/draft-ietf-tls-compression-05.txt)
+       public enum SecurityCompressionType
+       {
+               None = 0,
+               Zlib = 1
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SecurityParameters.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SecurityParameters.cs
new file mode 100644 (file)
index 0000000..3c744ea
--- /dev/null
@@ -0,0 +1,60 @@
+// Transport Security Layer (TLS)
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls {
+
+       // note: other things should be moved here
+       internal class SecurityParameters {
+
+               private CipherSuite cipher;
+               private byte[] clientWriteMAC;
+               private byte[] serverWriteMAC;
+
+               public SecurityParameters ()
+               {
+               }
+
+               public CipherSuite Cipher {
+                       get { return cipher; }
+                       set { cipher = value; }
+               }
+
+               public byte[] ClientWriteMAC {
+                       get { return clientWriteMAC; }
+                       set { clientWriteMAC = value; }
+               }
+
+               public byte[] ServerWriteMAC {
+                       get { return serverWriteMAC; }
+                       set { serverWriteMAC = value; }
+               }
+
+               public void Clear ()
+               {
+                       // FIXME: clear cipher
+                       cipher = null;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SecurityProtocolType.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SecurityProtocolType.cs
new file mode 100644 (file)
index 0000000..a914afc
--- /dev/null
@@ -0,0 +1,38 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Mono.Security.Protocol.Tls
+{
+       [Flags]
+       [Serializable]
+       public enum SecurityProtocolType
+       {
+               Default = -1073741824,
+               Ssl2    = 12,
+               Ssl3    = 48,
+               Tls             = 192
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ServerContext.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ServerContext.cs
new file mode 100644 (file)
index 0000000..8181974
--- /dev/null
@@ -0,0 +1,96 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+
+using Mono.Security.Protocol.Tls.Handshake;
+using MonoX509 = Mono.Security.X509;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class ServerContext : Context
+       {
+               #region Fields
+
+               private SslServerStream sslStream;
+               private bool                    clientCertificateRequired;
+
+               #endregion
+
+               #region Properties
+
+               public SslServerStream SslStream
+               {
+                       get { return this.sslStream; }
+               }
+
+               public bool     ClientCertificateRequired
+               {
+                       get { return this.clientCertificateRequired; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public ServerContext(
+                       SslServerStream                 stream,
+                       SecurityProtocolType    securityProtocolType,
+                       X509Certificate                 serverCertificate,
+                       bool                                    clientCertificateRequired)
+                       : base(securityProtocolType)
+               {
+                       this.sslStream                                  = stream;
+                       this.clientCertificateRequired  = clientCertificateRequired;
+
+                       // Convert the System.Security cert to a Mono Cert
+                       MonoX509.X509Certificate cert = new MonoX509.X509Certificate(serverCertificate.GetRawCertData());
+
+                       // Add server certificate to the certificate collection
+                       this.ServerSettings.Certificates = new MonoX509.X509CertificateCollection();
+                       this.ServerSettings.Certificates.Add(cert);
+
+                       this.ServerSettings.UpdateCertificateRSA();
+
+                       // Add requested certificate types
+                       this.ServerSettings.CertificateTypes = new ClientCertificateType[1];
+                       this.ServerSettings.CertificateTypes[0] = ClientCertificateType.RSA;
+
+                       // Add certificate authorities
+                       MonoX509.X509CertificateCollection trusted = MonoX509.X509StoreManager.TrustedRootCertificates;
+                       string[] list = new string [trusted.Count];
+                       int i = 0;
+                       foreach (MonoX509.X509Certificate root in trusted)
+                       {
+                               list [i++] = root.IssuerName;
+                       }
+                       this.ServerSettings.DistinguisedNames = list;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs
new file mode 100644 (file)
index 0000000..6e316dc
--- /dev/null
@@ -0,0 +1,156 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Globalization;
+using System.IO;
+
+using Mono.Security.Protocol.Tls.Handshake;
+using Mono.Security.Protocol.Tls.Handshake.Server;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class ServerRecordProtocol : RecordProtocol
+       {
+               #region Constructors
+
+               public ServerRecordProtocol(
+                       Stream                  innerStream, 
+                       ServerContext   context) : base(innerStream, context)
+               {
+               }
+
+               #endregion
+
+               #region Send Messages
+
+               public override HandshakeMessage GetMessage(HandshakeType type)
+               {
+                       // Create and process the record message
+                       HandshakeMessage msg = this.createServerHandshakeMessage(type);
+
+                       return msg;
+               }
+
+               #endregion
+
+               #region Handshake Processing Methods
+
+               protected override void ProcessHandshakeMessage(TlsStream handMsg)
+               {
+                       HandshakeType           handshakeType   = (HandshakeType)handMsg.ReadByte();
+                       HandshakeMessage        message                 = null;
+
+                       // Read message length
+                       int length = handMsg.ReadInt24();
+
+                       // Read message data
+                       byte[] data = new byte[length];
+                       handMsg.Read(data, 0, length);
+
+                       // Create and process the server message
+                       message = this.createClientHandshakeMessage(handshakeType, data);
+                       message.Process();
+
+                       // Update the last handshake message
+                       this.Context.LastHandshakeMsg = handshakeType;
+
+                       // Update session
+                       if (message != null)
+                       {
+                               message.Update();
+                               this.Context.HandshakeMessages.WriteByte ((byte) handshakeType);
+                               this.Context.HandshakeMessages.WriteInt24 (length);
+                               this.Context.HandshakeMessages.Write (data, 0, data.Length);
+                       }
+               }
+
+               #endregion
+
+               #region Server Handshake Message Factories
+
+               private HandshakeMessage createClientHandshakeMessage(
+                       HandshakeType type, byte[] buffer)
+               {
+                       switch (type)
+                       {
+                               case HandshakeType.ClientHello:
+                                       return new TlsClientHello(this.context, buffer);
+
+                               case HandshakeType.Certificate:
+                                       return new TlsClientCertificate(this.context, buffer);
+
+                               case HandshakeType.ClientKeyExchange:
+                                       return new TlsClientKeyExchange(this.context, buffer);
+
+                               case HandshakeType.CertificateVerify:
+                                       return new TlsClientCertificateVerify(this.context, buffer);
+
+                               case HandshakeType.Finished:
+                                       return new TlsClientFinished(this.context, buffer);
+
+                               default:
+                                       throw new TlsException(
+                                               AlertDescription.UnexpectedMessage,
+                                               String.Format(CultureInfo.CurrentUICulture,
+                                                       "Unknown server handshake message received ({0})", 
+                                                       type.ToString()));
+                       }
+               }
+
+               private HandshakeMessage createServerHandshakeMessage(
+                       HandshakeType type)
+               {
+                       switch (type)
+                       {
+                               case HandshakeType.HelloRequest:
+                                       this.SendRecord(HandshakeType.ClientHello);
+                                       return null;
+
+                               case HandshakeType.ServerHello:
+                                       return new TlsServerHello(this.context);
+
+                               case HandshakeType.Certificate:
+                                       return new TlsServerCertificate(this.context);
+
+                               case HandshakeType.ServerKeyExchange:
+                                       return new TlsServerKeyExchange(this.context);
+
+                               case HandshakeType.CertificateRequest:
+                                       return new TlsServerCertificateRequest(this.context);
+
+                               case HandshakeType.ServerHelloDone:
+                                       return new TlsServerHelloDone(this.context);
+
+                               case HandshakeType.Finished:
+                                       return new TlsServerFinished(this.context);
+
+                               default:
+                                       throw new InvalidOperationException("Unknown server handshake message type: " + type.ToString() );                                      
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslCipherSuite.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslCipherSuite.cs
new file mode 100644 (file)
index 0000000..1454052
--- /dev/null
@@ -0,0 +1,295 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class SslCipherSuite : CipherSuite
+       {
+               #region Fields
+
+               private byte[] pad1;
+               private byte[] pad2;
+
+               private const int MacHeaderLength = 11;
+               private byte[] header;
+
+               #endregion
+
+               #region Constructors
+               
+               public SslCipherSuite(
+                       short code, string name, CipherAlgorithmType cipherAlgorithmType, 
+                       HashAlgorithmType hashAlgorithmType, ExchangeAlgorithmType exchangeAlgorithmType,
+                       bool exportable, bool blockMode, byte keyMaterialSize, 
+                       byte expandedKeyMaterialSize, short effectiveKeyBytes, 
+                       byte ivSize, byte blockSize) :
+                       base(code, name, cipherAlgorithmType, hashAlgorithmType, 
+                       exchangeAlgorithmType, exportable, blockMode, keyMaterialSize, 
+                       expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize)
+
+               {
+                       int padLength = (hashAlgorithmType == HashAlgorithmType.Md5) ? 48 : 40;
+
+                       // Fill pad arrays
+                       this.pad1 = new byte[padLength];
+                       this.pad2 = new byte[padLength];
+
+                       /* Pad the key for inner and outer digest */
+                       for (int i = 0; i < padLength; ++i) 
+                       {
+                               this.pad1[i] = 0x36;
+                               this.pad2[i] = 0x5C;
+                       }
+               }
+
+               #endregion
+
+               #region MAC Generation Methods
+
+               public override byte[] ComputeServerRecordMAC(ContentType contentType, byte[] fragment)
+               {
+                       HashAlgorithm   hash    = HashAlgorithm.Create(this.HashAlgorithmName);
+
+                       byte[] smac = this.Context.Read.ServerWriteMAC;
+                       hash.TransformBlock (smac, 0, smac.Length, smac, 0);
+                       hash.TransformBlock (pad1, 0, pad1.Length, pad1, 0);
+
+                       if (header == null)
+                               header = new byte [MacHeaderLength];
+
+                       ulong seqnum = (Context is ClientContext) ? Context.ReadSequenceNumber : Context.WriteSequenceNumber;
+                       Write (header, 0, seqnum);
+                       header [8] = (byte) contentType;
+                       Write (header, 9, (short)fragment.Length);
+                       hash.TransformBlock (header, 0, header.Length, header, 0);
+                       hash.TransformBlock (fragment, 0, fragment.Length, fragment, 0);
+                       // hack, else the method will allocate a new buffer of the same length (negative half the optimization)
+                       hash.TransformFinalBlock (CipherSuite.EmptyArray, 0, 0);
+
+                       byte[] blockHash = hash.Hash;
+
+                       hash.Initialize ();
+
+                       hash.TransformBlock (smac, 0, smac.Length, smac, 0);
+                       hash.TransformBlock (pad2, 0, pad2.Length, pad2, 0);
+                       hash.TransformBlock (blockHash, 0, blockHash.Length, blockHash, 0);
+                       // hack again
+                       hash.TransformFinalBlock (CipherSuite.EmptyArray, 0, 0);
+
+                       return hash.Hash;
+               }
+
+               public override byte[] ComputeClientRecordMAC(ContentType contentType, byte[] fragment)
+               {
+                       HashAlgorithm   hash    = HashAlgorithm.Create(this.HashAlgorithmName);
+
+                       byte[] cmac = this.Context.Current.ClientWriteMAC;
+                       hash.TransformBlock (cmac, 0, cmac.Length, cmac, 0);
+                       hash.TransformBlock (pad1, 0, pad1.Length, pad1, 0);
+
+                       if (header == null)
+                               header = new byte [MacHeaderLength];
+
+                       ulong seqnum = (Context is ClientContext) ? Context.WriteSequenceNumber : Context.ReadSequenceNumber;
+                       Write (header, 0, seqnum);
+                       header [8] = (byte) contentType;
+                       Write (header, 9, (short)fragment.Length);
+                       hash.TransformBlock (header, 0, header.Length, header, 0);
+                       hash.TransformBlock (fragment, 0, fragment.Length, fragment, 0);
+                       // hack, else the method will allocate a new buffer of the same length (negative half the optimization)
+                       hash.TransformFinalBlock (CipherSuite.EmptyArray, 0, 0);
+
+                       byte[] blockHash = hash.Hash;
+
+                       hash.Initialize ();
+
+                       hash.TransformBlock (cmac, 0, cmac.Length, cmac, 0);
+                       hash.TransformBlock (pad2, 0, pad2.Length, pad2, 0);
+                       hash.TransformBlock (blockHash, 0, blockHash.Length, blockHash, 0);
+                       // hack again
+                       hash.TransformFinalBlock (CipherSuite.EmptyArray, 0, 0);
+
+                       return hash.Hash;
+               }
+
+               #endregion
+
+               #region Key Generation Methods
+
+               public override void ComputeMasterSecret(byte[] preMasterSecret)
+               {
+                       TlsStream masterSecret = new TlsStream();
+
+                       masterSecret.Write(this.prf(preMasterSecret, "A", this.Context.RandomCS));
+                       masterSecret.Write(this.prf(preMasterSecret, "BB", this.Context.RandomCS));
+                       masterSecret.Write(this.prf(preMasterSecret, "CCC", this.Context.RandomCS));
+
+                       this.Context.MasterSecret = masterSecret.ToArray();
+
+                       DebugHelper.WriteLine(">>>> MasterSecret", this.Context.MasterSecret);
+               }
+
+               public override void ComputeKeys()
+               {
+                       // Compute KeyBlock
+                       TlsStream tmp = new TlsStream();
+                       
+                       char    labelChar       = 'A';
+                       int             count           = 1;
+
+                       while (tmp.Length < this.KeyBlockSize)
+                       {
+                               string label = String.Empty;
+
+                               for (int i = 0; i < count; i++)
+                               {
+                                       label += labelChar.ToString();
+                               }
+                                               
+                               byte[] block = this.prf(this.Context.MasterSecret, label.ToString(), this.Context.RandomSC);
+
+                               int size = (tmp.Length + block.Length) > this.KeyBlockSize ? (this.KeyBlockSize - (int)tmp.Length) : block.Length;
+                               
+                               tmp.Write(block, 0, size);
+
+                               labelChar++;
+                               count++;
+                       }
+                       
+                       // Create keyblock
+                       TlsStream keyBlock = new TlsStream(tmp.ToArray());                      
+                       
+                       this.Context.Negotiating.ClientWriteMAC = keyBlock.ReadBytes(this.HashSize);
+                       this.Context.Negotiating.ServerWriteMAC = keyBlock.ReadBytes(this.HashSize);
+                       this.Context.ClientWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize);
+                       this.Context.ServerWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize);
+
+                       if (!this.IsExportable)
+                       {
+                               if (this.IvSize != 0)
+                               {
+                                       this.Context.ClientWriteIV = keyBlock.ReadBytes(this.IvSize);
+                                       this.Context.ServerWriteIV = keyBlock.ReadBytes(this.IvSize);
+                               }
+                               else
+                               {
+                                       this.Context.ClientWriteIV = CipherSuite.EmptyArray;
+                                       this.Context.ServerWriteIV = CipherSuite.EmptyArray;
+                               }
+                       }
+                       else
+                       {
+                               HashAlgorithm md5 = MD5.Create();
+
+                               int keySize = (md5.HashSize >> 3); //in bytes not bits
+                               byte[] temp = new byte [keySize];
+
+                               // Generate final write keys
+                               md5.TransformBlock(this.Context.ClientWriteKey, 0, this.Context.ClientWriteKey.Length, temp, 0);
+                               md5.TransformFinalBlock(this.Context.RandomCS, 0, this.Context.RandomCS.Length);
+                               byte[] finalClientWriteKey = new byte[this.ExpandedKeyMaterialSize];
+                               Buffer.BlockCopy(md5.Hash, 0, finalClientWriteKey, 0, this.ExpandedKeyMaterialSize);
+
+                               md5.Initialize();
+                               md5.TransformBlock(this.Context.ServerWriteKey, 0, this.Context.ServerWriteKey.Length, temp, 0);
+                               md5.TransformFinalBlock(this.Context.RandomSC, 0, this.Context.RandomSC.Length);
+                               byte[] finalServerWriteKey = new byte[this.ExpandedKeyMaterialSize];
+                               Buffer.BlockCopy(md5.Hash, 0, finalServerWriteKey, 0, this.ExpandedKeyMaterialSize);
+                               
+                               this.Context.ClientWriteKey = finalClientWriteKey;
+                               this.Context.ServerWriteKey = finalServerWriteKey;
+
+                               // Generate IV keys
+                               if (this.IvSize > 0) 
+                               {
+                                       md5.Initialize();
+                                       temp = md5.ComputeHash(this.Context.RandomCS, 0, this.Context.RandomCS.Length);
+                                       this.Context.ClientWriteIV = new byte[this.IvSize];
+                                       Buffer.BlockCopy(temp, 0, this.Context.ClientWriteIV, 0, this.IvSize);
+
+                                       md5.Initialize();
+                                       temp = md5.ComputeHash(this.Context.RandomSC, 0, this.Context.RandomSC.Length);
+                                       this.Context.ServerWriteIV = new byte[this.IvSize];
+                                       Buffer.BlockCopy(temp, 0, this.Context.ServerWriteIV, 0, this.IvSize);
+                               }
+                               else 
+                               {
+                                       this.Context.ClientWriteIV = CipherSuite.EmptyArray;
+                                       this.Context.ServerWriteIV = CipherSuite.EmptyArray;
+                               }
+                       }
+
+                       DebugHelper.WriteLine(">>>> KeyBlock", keyBlock.ToArray());
+                       DebugHelper.WriteLine(">>>> ClientWriteKey", this.Context.ClientWriteKey);
+                       DebugHelper.WriteLine(">>>> ClientWriteIV", this.Context.ClientWriteIV);
+                       DebugHelper.WriteLine(">>>> ClientWriteMAC", this.Context.Negotiating.ClientWriteMAC);
+                       DebugHelper.WriteLine(">>>> ServerWriteKey", this.Context.ServerWriteKey);
+                       DebugHelper.WriteLine(">>>> ServerWriteIV", this.Context.ServerWriteIV);
+                       DebugHelper.WriteLine(">>>> ServerWriteMAC", this.Context.Negotiating.ServerWriteMAC);
+
+                       ClientSessionCache.SetContextInCache (this.Context);
+                       // Clear no more needed data
+                       keyBlock.Reset();
+                       tmp.Reset();
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private byte[] prf(byte[] secret, string label, byte[] random)
+               {
+                       HashAlgorithm md5 = MD5.Create();
+                       HashAlgorithm sha = SHA1.Create();
+
+                       // Compute SHA hash
+                       TlsStream block = new TlsStream();
+                       block.Write(Encoding.ASCII.GetBytes(label));
+                       block.Write(secret);
+                       block.Write(random);
+                                               
+                       byte[] shaHash = sha.ComputeHash(block.ToArray(), 0, (int)block.Length);
+
+                       block.Reset();
+
+                       // Compute MD5 hash
+                       block.Write(secret);
+                       block.Write(shaHash);
+
+                       byte[] result = md5.ComputeHash(block.ToArray(), 0, (int)block.Length);
+
+                       // Free resources
+                       block.Reset();
+
+                       return result;
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslClientStream.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslClientStream.cs
new file mode 100644 (file)
index 0000000..03d37d7
--- /dev/null
@@ -0,0 +1,421 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Threading;
+
+using Mono.Security.Protocol.Tls.Handshake;
+
+namespace Mono.Security.Protocol.Tls
+{
+       #region Delegates
+
+       public delegate bool CertificateValidationCallback(
+               X509Certificate certificate, 
+               int[]                   certificateErrors);
+
+       public delegate X509Certificate CertificateSelectionCallback(
+               X509CertificateCollection       clientCertificates, 
+               X509Certificate                         serverCertificate, 
+               string                                          targetHost, 
+               X509CertificateCollection       serverRequestedCertificates);
+
+       public delegate AsymmetricAlgorithm PrivateKeySelectionCallback(
+               X509Certificate certificate, 
+               string                  targetHost);
+
+       #endregion
+
+       public class SslClientStream : SslStreamBase
+       {
+               #region Internal Events
+               
+               internal event CertificateValidationCallback    ServerCertValidation;
+               internal event CertificateSelectionCallback             ClientCertSelection;
+               internal event PrivateKeySelectionCallback              PrivateKeySelection;
+               
+               #endregion
+
+               #region Properties
+
+               // required by HttpsClientStream for proxy support
+               internal Stream InputBuffer 
+               {
+                       get { return base.inputBuffer; }
+               }
+
+               public X509CertificateCollection ClientCertificates
+               {
+                       get { return this.context.ClientSettings.Certificates; }
+               }
+
+               public X509Certificate SelectedClientCertificate
+               {
+                       get { return this.context.ClientSettings.ClientCertificate; }
+               }
+
+               #endregion
+
+               #region Callback Properties
+
+               public CertificateValidationCallback ServerCertValidationDelegate
+               {
+                       get { return this.ServerCertValidation; }
+                       set { this.ServerCertValidation = value; }                      
+               }
+
+               public CertificateSelectionCallback ClientCertSelectionDelegate 
+               {
+                       get { return this.ClientCertSelection; }
+                       set { this.ClientCertSelection = value; }
+               }
+
+               public PrivateKeySelectionCallback PrivateKeyCertSelectionDelegate
+               {
+                       get { return this.PrivateKeySelection; }
+                       set { this.PrivateKeySelection = value; }
+               }
+               
+               #endregion
+
+               #region Constructors
+               
+               public SslClientStream(
+                       Stream  stream, 
+                       string  targetHost, 
+                       bool    ownsStream) 
+                       : this(
+                               stream, targetHost, ownsStream, 
+                               SecurityProtocolType.Default, null)
+               {
+               }
+               
+               public SslClientStream(
+                       Stream                          stream, 
+                       string                          targetHost, 
+                       X509Certificate         clientCertificate) 
+                       : this(
+                               stream, targetHost, false, SecurityProtocolType.Default, 
+                               new X509CertificateCollection(new X509Certificate[]{clientCertificate}))
+               {
+               }
+
+               public SslClientStream(
+                       Stream                                          stream,
+                       string                                          targetHost, 
+                       X509CertificateCollection clientCertificates) : 
+                       this(
+                               stream, targetHost, false, SecurityProtocolType.Default, 
+                               clientCertificates)
+               {
+               }
+
+               public SslClientStream(
+                       Stream                                  stream,
+                       string                                  targetHost,
+                       bool                                    ownsStream,
+                       SecurityProtocolType    securityProtocolType) 
+                       : this(
+                               stream, targetHost, ownsStream, securityProtocolType,
+                               new X509CertificateCollection())
+               {
+               }
+
+               public SslClientStream(
+                       Stream                                          stream,
+                       string                                          targetHost,
+                       bool                                            ownsStream,
+                       SecurityProtocolType            securityProtocolType,
+                       X509CertificateCollection       clientCertificates):
+                       base(stream, ownsStream)
+               {
+                       if (targetHost == null || targetHost.Length == 0)
+                       {
+                               throw new ArgumentNullException("targetHost is null or an empty string.");
+                       }
+
+                       this.context = new ClientContext(
+                               this,
+                               securityProtocolType, 
+                               targetHost, 
+                               clientCertificates);
+
+                       this.protocol = new ClientRecordProtocol(innerStream, (ClientContext)this.context);
+               }
+
+               #endregion
+
+               #region Finalizer
+
+               ~SslClientStream()
+               {
+                       base.Dispose(false);
+               }
+
+               #endregion
+
+               #region IDisposable Methods
+
+               protected override void Dispose(bool disposing)
+               {
+                       base.Dispose(disposing);
+
+                       if (disposing)
+                       {
+                               this.ServerCertValidation = null;
+                               this.ClientCertSelection = null;
+                               this.PrivateKeySelection = null;
+                       }
+               }
+
+               #endregion
+
+               #region Handshake Methods
+
+               /*
+                       Client                                                                                  Server
+
+                       ClientHello                 -------->
+                                                                                                                       ServerHello
+                                                                                                                       Certificate*
+                                                                                                                       ServerKeyExchange*
+                                                                                                                       CertificateRequest*
+                                                                               <--------                       ServerHelloDone
+                       Certificate*
+                       ClientKeyExchange
+                       CertificateVerify*
+                       [ChangeCipherSpec]
+                       Finished                    -------->
+                                                                                                                       [ChangeCipherSpec]
+                                                                               <--------           Finished
+                       Application Data            <------->                   Application Data
+
+                                       Fig. 1 - Message flow for a full handshake              
+               */
+
+               internal override IAsyncResult OnBeginNegotiateHandshake(AsyncCallback callback, object state)
+               {
+                       try
+                       {
+                               if (this.context.HandshakeState != HandshakeState.None)
+                               {
+                                       this.context.Clear();
+                               }
+
+                               // Obtain supported cipher suites
+                               this.context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(this.context.SecurityProtocol);
+
+                               // Set handshake state
+                               this.context.HandshakeState = HandshakeState.Started;
+
+                               // Send client hello
+                               return this.protocol.BeginSendRecord(HandshakeType.ClientHello, callback, state);
+                       }
+                       catch (TlsException ex)
+                       {
+                               this.protocol.SendAlert(ex.Alert);
+
+                               throw new IOException("The authentication or decryption has failed.", ex);
+                       }
+                       catch (Exception ex)
+                       {
+                               this.protocol.SendAlert(AlertDescription.InternalError);
+
+                               throw new IOException("The authentication or decryption has failed.", ex);
+                       }
+               }
+
+               private void SafeReceiveRecord (Stream s)
+               {
+                       byte[] record = this.protocol.ReceiveRecord (s);
+                       if ((record == null) || (record.Length == 0)) {
+                               throw new TlsException (
+                                       AlertDescription.HandshakeFailiure,
+                                       "The server stopped the handshake.");
+                       }
+               }
+
+               internal override void OnNegotiateHandshakeCallback(IAsyncResult asyncResult)
+               {
+                       this.protocol.EndSendRecord(asyncResult);
+
+                       // Read server response
+                       while (this.context.LastHandshakeMsg != HandshakeType.ServerHelloDone) 
+                       {
+                               // Read next record
+                               SafeReceiveRecord (this.innerStream);
+
+                               // special case for abbreviated handshake where no ServerHelloDone is sent from the server
+                               if (this.context.AbbreviatedHandshake && (this.context.LastHandshakeMsg == HandshakeType.ServerHello))
+                                       break;
+                       }
+
+                       // the handshake is much easier if we can reuse a previous session settings
+                       if (this.context.AbbreviatedHandshake) 
+                       {
+                               ClientSessionCache.SetContextFromCache (this.context);
+                               this.context.Negotiating.Cipher.ComputeKeys ();
+                               this.context.Negotiating.Cipher.InitializeCipher ();
+
+                               // Send Cipher Spec protocol
+                               this.protocol.SendChangeCipherSpec ();
+
+                               // Read record until server finished is received
+                               while (this.context.HandshakeState != HandshakeState.Finished) 
+                               {
+                                       // If all goes well this will process messages:
+                                       //              Change Cipher Spec
+                                       //              Server finished
+                                       SafeReceiveRecord (this.innerStream);
+                               }
+
+                               // Send Finished message
+                               this.protocol.SendRecord (HandshakeType.Finished);
+                       }
+                       else
+                       {
+                               // Send client certificate if requested
+                               // even if the server ask for it it _may_ still be optional
+                               bool clientCertificate = this.context.ServerSettings.CertificateRequest;
+
+                               // NOTE: sadly SSL3 and TLS1 differs in how they handle this and
+                               // the current design doesn't allow a very cute way to handle 
+                               // SSL3 alert warning for NoCertificate (41).
+                               if (this.context.SecurityProtocol == SecurityProtocolType.Ssl3)
+                               {
+                                       clientCertificate = ((this.context.ClientSettings.Certificates != null) &&
+                                               (this.context.ClientSettings.Certificates.Count > 0));
+                                       // this works well with OpenSSL (but only for SSL3)
+                               }
+
+                               if (clientCertificate)
+                               {
+                                       this.protocol.SendRecord(HandshakeType.Certificate);
+                               }
+
+                               // Send Client Key Exchange
+                               this.protocol.SendRecord(HandshakeType.ClientKeyExchange);
+
+                               // Now initialize session cipher with the generated keys
+                               this.context.Negotiating.Cipher.InitializeCipher();
+
+                               // Send certificate verify if requested (optional)
+                               if (clientCertificate && (this.context.ClientSettings.ClientCertificate != null))
+                               {
+                                       this.protocol.SendRecord(HandshakeType.CertificateVerify);
+                               }
+
+                               // Send Cipher Spec protocol
+                               this.protocol.SendChangeCipherSpec ();
+
+                               // Send Finished message
+                               this.protocol.SendRecord (HandshakeType.Finished);
+
+                               // Read record until server finished is received
+                               while (this.context.HandshakeState != HandshakeState.Finished) {
+                                       // If all goes well this will process messages:
+                                       //              Change Cipher Spec
+                                       //              Server finished
+                                       SafeReceiveRecord (this.innerStream);
+                               }
+                       }
+
+                       // Reset Handshake messages information
+                       this.context.HandshakeMessages.Reset ();
+
+                       // Clear Key Info
+                       this.context.ClearKeyInfo();
+
+               }
+
+               #endregion
+
+               #region Event Methods
+
+               internal override X509Certificate OnLocalCertificateSelection(X509CertificateCollection clientCertificates, X509Certificate serverCertificate, string targetHost, X509CertificateCollection serverRequestedCertificates)
+               {
+                       if (this.ClientCertSelection != null)
+                       {
+                               return this.ClientCertSelection(
+                                       clientCertificates,
+                                       serverCertificate,
+                                       targetHost,
+                                       serverRequestedCertificates);
+                       }
+
+                       return null;
+               }
+               
+               internal override bool OnRemoteCertificateValidation(X509Certificate certificate, int[] errors)
+               {
+                       if (this.ServerCertValidation != null)
+                       {
+                               return this.ServerCertValidation(certificate, errors);
+                       }
+
+                       return (errors != null && errors.Length == 0);
+               }
+
+               internal virtual bool RaiseServerCertificateValidation(
+                       X509Certificate certificate, 
+                       int[]                   certificateErrors)
+               {
+                       return base.RaiseRemoteCertificateValidation(certificate, certificateErrors);
+               }
+
+               internal X509Certificate RaiseClientCertificateSelection(
+                       X509CertificateCollection       clientCertificates, 
+                       X509Certificate                         serverCertificate, 
+                       string                                          targetHost, 
+                       X509CertificateCollection       serverRequestedCertificates)
+               {
+                       return base.RaiseLocalCertificateSelection(clientCertificates, serverCertificate, targetHost, serverRequestedCertificates);
+               }
+
+               internal override AsymmetricAlgorithm OnLocalPrivateKeySelection(X509Certificate certificate, string targetHost)
+               {
+                       if (this.PrivateKeySelection != null)
+                       {
+                               return this.PrivateKeySelection(certificate, targetHost);
+                       }
+
+                       return null;
+               }
+
+               internal AsymmetricAlgorithm RaisePrivateKeySelection(
+                       X509Certificate certificate,
+                       string targetHost)
+               {
+                       return base.RaiseLocalPrivateKeySelection(certificate, targetHost);
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslHandshakeHash.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslHandshakeHash.cs
new file mode 100644 (file)
index 0000000..fba0339
--- /dev/null
@@ -0,0 +1,185 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class SslHandshakeHash : System.Security.Cryptography.HashAlgorithm
+       {
+               #region Fields
+
+               private HashAlgorithm   md5;
+               private HashAlgorithm   sha;
+               private bool                    hashing;
+               private byte[]                  secret;
+               private byte[]                  innerPadMD5;
+               private byte[]                  outerPadMD5;
+               private byte[]                  innerPadSHA;
+               private byte[]                  outerPadSHA;
+
+               #endregion
+
+               #region Constructors
+
+               public SslHandshakeHash(byte[] secret)
+               {
+                       // Create md5 and sha1 hashes
+                       this.md5 = HashAlgorithm.Create("MD5");
+                       this.sha = HashAlgorithm.Create("SHA1");
+                       
+                       // Set HashSizeValue
+                       this.HashSizeValue = md5.HashSize + sha.HashSize;
+
+                       // Update secret
+                       this.secret = secret;
+
+                       this.Initialize();
+               }
+
+               #endregion
+
+               #region Methods
+
+               public override void Initialize()
+               {
+                       this.md5.Initialize();
+                       this.sha.Initialize();
+                       this.initializePad();
+                       this.hashing = false;
+               }
+
+               protected override byte[] HashFinal()
+               {
+                       if (!this.hashing)
+                       {
+                               this.hashing = true;
+                       }
+
+                       // Finalize the md5 hash
+                       this.md5.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0);
+                       this.md5.TransformFinalBlock(this.innerPadMD5, 0, this.innerPadMD5.Length);
+
+                       byte[] firstResultMD5 = this.md5.Hash;
+
+                       this.md5.Initialize();
+                       this.md5.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0);
+                       this.md5.TransformBlock(this.outerPadMD5, 0, this.outerPadMD5.Length, this.outerPadMD5, 0);
+                       this.md5.TransformFinalBlock(firstResultMD5, 0, firstResultMD5.Length);
+                       
+                       // Finalize the sha1 hash
+                       this.sha.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0);
+                       this.sha.TransformFinalBlock(this.innerPadSHA, 0, this.innerPadSHA.Length);
+
+                       byte[] firstResultSHA = this.sha.Hash;
+                       
+                       this.sha.Initialize();
+                       this.sha.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0);
+                       this.sha.TransformBlock(this.outerPadSHA, 0, this.outerPadSHA.Length, this.outerPadSHA, 0);
+                       this.sha.TransformFinalBlock(firstResultSHA, 0, firstResultSHA.Length);
+
+                       this.Initialize();
+
+                       byte[] result = new byte[36];
+
+                       Buffer.BlockCopy(this.md5.Hash, 0, result, 0, 16);
+                       Buffer.BlockCopy(this.sha.Hash, 0, result, 16, 20);
+
+                       return result;
+               }
+
+               protected override void HashCore(byte[] array, int ibStart, int cbSize)
+               {
+                       if (!this.hashing)
+                       {
+                               this.hashing = true;
+                       }
+
+                       this.md5.TransformBlock(array, ibStart, cbSize, array, ibStart);
+                       this.sha.TransformBlock(array, ibStart, cbSize, array, ibStart);
+               }
+
+               public byte[] CreateSignature(RSA rsa) 
+               {
+                       if (rsa == null)
+                       {
+                               throw new CryptographicUnexpectedOperationException ("missing key");
+                       }
+
+                       RSASslSignatureFormatter f = new RSASslSignatureFormatter(rsa);
+                       f.SetHashAlgorithm("MD5SHA1");
+
+                       return f.CreateSignature(this.Hash);
+               }
+
+               public bool VerifySignature(RSA rsa, byte[] rgbSignature) 
+               {
+                       if (rsa == null)
+                       {
+                               throw new CryptographicUnexpectedOperationException ("missing key");
+                       }
+                       if (rgbSignature == null)
+                       {
+                               throw new ArgumentNullException ("rgbSignature");
+                       }
+
+                       RSASslSignatureDeformatter d = new RSASslSignatureDeformatter(rsa);
+                       d.SetHashAlgorithm("MD5SHA1");
+
+                       return d.VerifySignature(this.Hash, rgbSignature);
+               }
+
+               #endregion
+
+               #region Private Methods
+
+               private void initializePad()
+               {
+                       // Fill md5 arrays
+                       this.innerPadMD5 = new byte[48];
+                       this.outerPadMD5 = new byte[48];
+
+                       /* Pad the key for inner and outer digest */
+                       for (int i = 0; i < 48; ++i) 
+                       {
+                               this.innerPadMD5[i] = 0x36;
+                               this.outerPadMD5[i] = 0x5C;
+                       }
+
+                       // Fill sha arrays
+                       this.innerPadSHA = new byte[40];
+                       this.outerPadSHA = new byte[40];
+
+                       /* Pad the key for inner and outer digest */
+                       for (int i = 0; i < 40; ++i) 
+                       {
+                               this.innerPadSHA[i] = 0x36;
+                               this.outerPadSHA[i] = 0x5C;
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslServerStream.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslServerStream.cs
new file mode 100644 (file)
index 0000000..c453abb
--- /dev/null
@@ -0,0 +1,313 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+
+using Mono.Security.Protocol.Tls.Handshake;
+
+namespace Mono.Security.Protocol.Tls
+{
+       public class SslServerStream : SslStreamBase
+       {
+               #region Internal Events
+               
+               internal event CertificateValidationCallback    ClientCertValidation;
+               internal event PrivateKeySelectionCallback              PrivateKeySelection;
+               
+               #endregion
+
+               #region Properties
+
+               public X509Certificate ClientCertificate
+               {
+                       get
+                       {
+                               if (this.context.HandshakeState == HandshakeState.Finished)
+                               {
+                                       return this.context.ClientSettings.ClientCertificate;
+                               }
+
+                               return null;
+                       }
+               }
+
+               #endregion
+
+               #region Callback Properties
+
+               public CertificateValidationCallback ClientCertValidationDelegate 
+               {
+                       get { return this.ClientCertValidation; }
+                       set { this.ClientCertValidation = value; }
+               }
+
+               public PrivateKeySelectionCallback PrivateKeyCertSelectionDelegate
+               {
+                       get { return this.PrivateKeySelection; }
+                       set { this.PrivateKeySelection = value; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public SslServerStream(
+                       Stream                  stream, 
+                       X509Certificate serverCertificate) : this(
+                       stream, 
+                       serverCertificate, 
+                       false, 
+                       false, 
+                       SecurityProtocolType.Default)
+               {
+               }
+
+               public SslServerStream(
+                       Stream                  stream,
+                       X509Certificate serverCertificate,
+                       bool                    clientCertificateRequired,
+                       bool                    ownsStream): this(
+                       stream, 
+                       serverCertificate, 
+                       clientCertificateRequired, 
+                       ownsStream, 
+                       SecurityProtocolType.Default)
+               {
+               }
+
+               public SslServerStream(
+                       Stream                                  stream,
+                       X509Certificate                 serverCertificate,
+                       bool                                    clientCertificateRequired,
+                       bool                                    ownsStream,
+                       SecurityProtocolType    securityProtocolType)
+                       : base(stream, ownsStream)
+               {
+                       this.context = new ServerContext(
+                               this,
+                               securityProtocolType,
+                               serverCertificate,
+                               clientCertificateRequired);
+
+                       this.protocol = new ServerRecordProtocol(innerStream, (ServerContext)this.context);
+               }
+
+               #endregion
+
+               #region Finalizer
+
+               ~SslServerStream()
+               {
+                       this.Dispose(false);
+               }
+
+               #endregion
+
+               #region IDisposable Methods
+
+               protected override void Dispose(bool disposing)
+               {
+                       base.Dispose(disposing);
+
+                       if (disposing)
+                       {
+                               this.ClientCertValidation = null;
+                               this.PrivateKeySelection = null;
+                       }
+               }
+
+               #endregion
+
+               #region Handsake Methods
+
+               /*
+                       Client                                                                                  Server
+
+                       ClientHello                 -------->
+                                                                                                                       ServerHello
+                                                                                                                       Certificate*
+                                                                                                                       ServerKeyExchange*
+                                                                                                                       CertificateRequest*
+                                                                               <--------                       ServerHelloDone
+                       Certificate*
+                       ClientKeyExchange
+                       CertificateVerify*
+                       [ChangeCipherSpec]
+                       Finished                    -------->
+                                                                                                                       [ChangeCipherSpec]
+                                                                               <--------           Finished
+                       Application Data            <------->                   Application Data
+
+                                       Fig. 1 - Message flow for a full handshake              
+               */
+
+               internal override IAsyncResult OnBeginNegotiateHandshake(AsyncCallback callback, object state)
+               {
+                       // Reset the context if needed
+                       if (this.context.HandshakeState != HandshakeState.None)
+                       {
+                               this.context.Clear();
+                       }
+
+                       // Obtain supported cipher suites
+                       this.context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(this.context.SecurityProtocol);
+
+                       // Set handshake state
+                       this.context.HandshakeState = HandshakeState.Started;
+
+                       // Receive Client Hello message
+                       return this.protocol.BeginReceiveRecord(this.innerStream, callback, state);
+
+               }
+
+               internal override void OnNegotiateHandshakeCallback(IAsyncResult asyncResult)
+               {
+                       // Receive Client Hello message and ignore it
+                       this.protocol.EndReceiveRecord(asyncResult);
+
+                       // If received message is not an ClientHello send a
+                       // Fatal Alert
+                       if (this.context.LastHandshakeMsg != HandshakeType.ClientHello)
+                       {
+                               this.protocol.SendAlert(AlertDescription.UnexpectedMessage);
+                       }
+
+                       // Send ServerHello message
+                       this.protocol.SendRecord(HandshakeType.ServerHello);
+
+                       // Send ServerCertificate message
+                       this.protocol.SendRecord(HandshakeType.Certificate);
+
+                       // If the negotiated cipher is a KeyEx cipher send ServerKeyExchange
+                       if (this.context.Negotiating.Cipher.IsExportable)
+                       {
+                               this.protocol.SendRecord(HandshakeType.ServerKeyExchange);
+                       }
+
+                       bool certRequested = false;
+
+                       // If the negotiated cipher is a KeyEx cipher or
+                       // the client certificate is required send the CertificateRequest message
+                       if (this.context.Negotiating.Cipher.IsExportable ||
+                               ((ServerContext)this.context).ClientCertificateRequired)
+                       {
+                               this.protocol.SendRecord(HandshakeType.CertificateRequest);
+                               certRequested = true;
+                       }
+
+                       // Send ServerHelloDone message
+                       this.protocol.SendRecord(HandshakeType.ServerHelloDone);
+
+                       // Receive client response, until the Client Finished message
+                       // is received. IE can be interrupted at this stage and never
+                       // complete the handshake
+                       while (this.context.LastHandshakeMsg != HandshakeType.Finished)
+                       {
+                               byte[] record = this.protocol.ReceiveRecord(this.innerStream);
+                               if ((record == null) || (record.Length == 0))
+                               {
+                                       throw new TlsException(
+                                               AlertDescription.HandshakeFailiure,
+                                               "The client stopped the handshake.");
+                               }
+                       }
+
+                       if (certRequested && (this.context.ClientSettings.ClientCertificate == null))
+                       {
+                               // we asked for a certificate but didn't receive one
+                               // e.g. wget for SSL3
+                               if (!RaiseClientCertificateValidation(null, new int[0]))
+                               {
+                                       throw new TlsException(
+                                               AlertDescription.BadCertificate,
+                                               "No certificate received from client.");
+                               }
+                       }
+
+                       // Send ChangeCipherSpec and ServerFinished messages
+                       this.protocol.SendChangeCipherSpec();
+                       this.protocol.SendRecord (HandshakeType.Finished);
+
+                       // The handshake is finished
+                       this.context.HandshakeState = HandshakeState.Finished;
+
+                       // Reset Handshake messages information
+                       this.context.HandshakeMessages.Reset ();
+
+                       // Clear Key Info
+                       this.context.ClearKeyInfo();
+               }
+
+               #endregion
+
+               #region Event Methods
+
+               internal override X509Certificate OnLocalCertificateSelection(X509CertificateCollection clientCertificates, X509Certificate serverCertificate, string targetHost, X509CertificateCollection serverRequestedCertificates)
+               {
+                       throw new NotSupportedException();
+               }
+
+               internal override bool OnRemoteCertificateValidation(X509Certificate certificate, int[] errors)
+               {
+                       if (this.ClientCertValidation != null)
+                       {
+                               return this.ClientCertValidation(certificate, errors);
+                       }
+
+                       return (errors != null && errors.Length == 0);
+               }
+
+               internal bool RaiseClientCertificateValidation(
+                       X509Certificate certificate, 
+                       int[]                   certificateErrors)
+               {
+                       return base.RaiseRemoteCertificateValidation(certificate, certificateErrors);
+               }
+
+               internal override AsymmetricAlgorithm OnLocalPrivateKeySelection(X509Certificate certificate, string targetHost)
+               {
+                       if (this.PrivateKeySelection != null)
+                       {
+                               return this.PrivateKeySelection(certificate, targetHost);
+                       }
+
+                       return null;
+               }
+
+               internal AsymmetricAlgorithm RaisePrivateKeySelection(
+                       X509Certificate certificate,
+                       string targetHost)
+               {
+                       return base.RaiseLocalPrivateKeySelection(certificate, targetHost);
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslStreamBase.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/SslStreamBase.cs
new file mode 100644 (file)
index 0000000..988749b
--- /dev/null
@@ -0,0 +1,1230 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Threading;
+
+namespace Mono.Security.Protocol.Tls
+{
+       public abstract class SslStreamBase: Stream, IDisposable
+       {
+               private delegate void AsyncHandshakeDelegate(InternalAsyncResult asyncResult, bool fromWrite);
+               
+               #region Fields
+
+               static ManualResetEvent record_processing = new ManualResetEvent (true);
+
+               private const int WaitTimeOut = 5 * 60 * 1000;
+
+               internal Stream innerStream;
+               internal MemoryStream inputBuffer;
+               internal Context context;
+               internal RecordProtocol protocol;
+               internal bool ownsStream;
+               private volatile bool disposed;
+               private bool checkCertRevocationStatus;
+               private object negotiate;
+               private object read;
+               private object write;
+               private ManualResetEvent negotiationComplete;
+
+               #endregion
+
+
+               #region Constructors
+
+               protected SslStreamBase(
+                       Stream stream,
+                       bool ownsStream)
+               {
+                       if (stream == null)
+                       {
+                               throw new ArgumentNullException("stream is null.");
+                       }
+                       if (!stream.CanRead || !stream.CanWrite)
+                       {
+                               throw new ArgumentNullException("stream is not both readable and writable.");
+                       }
+
+                       this.inputBuffer = new MemoryStream();
+                       this.innerStream = stream;
+                       this.ownsStream = ownsStream;
+                       this.negotiate = new object();
+                       this.read = new object();
+                       this.write = new object();
+                       this.negotiationComplete = new ManualResetEvent(false);
+               }
+
+               #endregion
+
+               #region Handshakes
+               private void AsyncHandshakeCallback(IAsyncResult asyncResult)
+               {
+                       InternalAsyncResult internalResult = asyncResult.AsyncState as InternalAsyncResult;
+
+                       try
+                       {
+                               try
+                               {
+                                       this.OnNegotiateHandshakeCallback(asyncResult);
+                               }
+                               catch (TlsException ex)
+                               {
+                                       this.protocol.SendAlert(ex.Alert);
+
+                                       throw new IOException("The authentication or decryption has failed.", ex);
+                               }
+                               catch (Exception ex)
+                               {
+                                       this.protocol.SendAlert(AlertDescription.InternalError);
+
+                                       throw new IOException("The authentication or decryption has failed.", ex);
+                               }
+
+                               if (internalResult.ProceedAfterHandshake)
+                               {
+                                       //kick off the read or write process (whichever called us) after the handshake is complete
+                                       if (internalResult.FromWrite)
+                                       {
+                                               InternalBeginWrite(internalResult);
+                                       }
+                                       else
+                                       {
+                                               InternalBeginRead(internalResult);
+                                       }
+                                       negotiationComplete.Set();
+                               }
+                               else
+                               {
+                                       negotiationComplete.Set();
+                                       internalResult.SetComplete();
+                               }
+
+                       }
+                       catch (Exception ex)
+                       {
+                               negotiationComplete.Set();
+                               internalResult.SetComplete(ex);
+                       }
+               }
+
+               internal bool MightNeedHandshake
+               {
+                       get
+                       {
+                               if (this.context.HandshakeState == HandshakeState.Finished)
+                               {
+                                       return false;
+                               }
+                               else
+                               {
+                                       lock (this.negotiate)
+                                       {
+                                               return (this.context.HandshakeState != HandshakeState.Finished);
+                                       }
+                               }
+                       }
+               }
+
+               internal void NegotiateHandshake()
+               {
+                       if (this.MightNeedHandshake)
+                       {
+                               InternalAsyncResult ar = new InternalAsyncResult(null, null, null, 0, 0, false, false);
+
+                               //if something already started negotiation, wait for it.
+                               //otherwise end it ourselves.
+                               if (!BeginNegotiateHandshake(ar))
+                               {
+                                       this.negotiationComplete.WaitOne();
+                               }
+                               else
+                               {
+                                       this.EndNegotiateHandshake(ar);
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Abstracts/Virtuals
+
+               internal abstract IAsyncResult OnBeginNegotiateHandshake(AsyncCallback callback, object state);
+               internal abstract void OnNegotiateHandshakeCallback(IAsyncResult asyncResult);
+
+               internal abstract X509Certificate OnLocalCertificateSelection(X509CertificateCollection clientCertificates,
+                                                                                                                       X509Certificate serverCertificate,
+                                                                                                                       string targetHost,
+                                                                                                                       X509CertificateCollection serverRequestedCertificates);
+
+               internal abstract bool OnRemoteCertificateValidation(X509Certificate certificate, int[] errors);
+
+               internal abstract AsymmetricAlgorithm OnLocalPrivateKeySelection(X509Certificate certificate, string targetHost);
+
+               #endregion
+
+               #region Event Methods
+
+               internal X509Certificate RaiseLocalCertificateSelection(X509CertificateCollection certificates,
+                                                                                                                       X509Certificate remoteCertificate,
+                                                                                                                       string targetHost,
+                                                                                                                       X509CertificateCollection requestedCertificates)
+               {
+                       return OnLocalCertificateSelection(certificates, remoteCertificate, targetHost, requestedCertificates);
+               }
+
+               internal bool RaiseRemoteCertificateValidation(X509Certificate certificate, int[] errors)
+               {
+                       return OnRemoteCertificateValidation(certificate, errors);
+               }
+
+               internal AsymmetricAlgorithm RaiseLocalPrivateKeySelection(
+                       X509Certificate certificate,
+                       string targetHost)
+               {
+                       return OnLocalPrivateKeySelection(certificate, targetHost);
+               }
+               #endregion
+
+               #region Security Properties
+
+               public bool CheckCertRevocationStatus
+               {
+                       get { return this.checkCertRevocationStatus; }
+                       set { this.checkCertRevocationStatus = value; }
+               }
+
+               public CipherAlgorithmType CipherAlgorithm
+               {
+                       get
+                       {
+                               if (this.context.HandshakeState == HandshakeState.Finished)
+                               {
+                                       return this.context.Current.Cipher.CipherAlgorithmType;
+                               }
+
+                               return CipherAlgorithmType.None;
+                       }
+               }
+
+               public int CipherStrength
+               {
+                       get
+                       {
+                               if (this.context.HandshakeState == HandshakeState.Finished)
+                               {
+                                       return this.context.Current.Cipher.EffectiveKeyBits;
+                               }
+
+                               return 0;
+                       }
+               }
+
+               public HashAlgorithmType HashAlgorithm
+               {
+                       get
+                       {
+                               if (this.context.HandshakeState == HandshakeState.Finished)
+                               {
+                                       return this.context.Current.Cipher.HashAlgorithmType;
+                               }
+
+                               return HashAlgorithmType.None;
+                       }
+               }
+
+               public int HashStrength
+               {
+                       get
+                       {
+                               if (this.context.HandshakeState == HandshakeState.Finished)
+                               {
+                                       return this.context.Current.Cipher.HashSize * 8;
+                               }
+
+                               return 0;
+                       }
+               }
+
+               public int KeyExchangeStrength
+               {
+                       get
+                       {
+                               if (this.context.HandshakeState == HandshakeState.Finished)
+                               {
+                                       return this.context.ServerSettings.Certificates[0].RSA.KeySize;
+                               }
+
+                               return 0;
+                       }
+               }
+
+               public ExchangeAlgorithmType KeyExchangeAlgorithm
+               {
+                       get
+                       {
+                               if (this.context.HandshakeState == HandshakeState.Finished)
+                               {
+                                       return this.context.Current.Cipher.ExchangeAlgorithmType;
+                               }
+
+                               return ExchangeAlgorithmType.None;
+                       }
+               }
+
+               public SecurityProtocolType SecurityProtocol
+               {
+                       get
+                       {
+                               if (this.context.HandshakeState == HandshakeState.Finished)
+                               {
+                                       return this.context.SecurityProtocol;
+                               }
+
+                               return 0;
+                       }
+               }
+
+               public X509Certificate ServerCertificate
+               {
+                       get
+                       {
+                               if (this.context.HandshakeState == HandshakeState.Finished)
+                               {
+                                       if (this.context.ServerSettings.Certificates != null &&
+                                               this.context.ServerSettings.Certificates.Count > 0)
+                                       {
+                                               return new X509Certificate(this.context.ServerSettings.Certificates[0].RawData);
+                                       }
+                               }
+
+                               return null;
+                       }
+               }
+
+               // this is used by Mono's certmgr tool to download certificates
+               internal Mono.Security.X509.X509CertificateCollection ServerCertificates
+               {
+                       get { return context.ServerSettings.Certificates; }
+               }
+
+               #endregion
+
+               #region Internal Async Result/State Class
+
+               private class InternalAsyncResult : IAsyncResult
+               {
+                       private object locker = new object ();
+                       private AsyncCallback _userCallback;
+                       private object _userState;
+                       private Exception _asyncException;
+                       private ManualResetEvent handle;
+                       private bool completed;
+                       private int _bytesRead;
+                       private bool _fromWrite;
+                       private bool _proceedAfterHandshake;
+
+                       private byte[] _buffer;
+                       private int _offset;
+                       private int _count;
+
+                       public InternalAsyncResult(AsyncCallback userCallback, object userState, byte[] buffer, int offset, int count, bool fromWrite, bool proceedAfterHandshake)
+                       {
+                               _userCallback = userCallback;
+                               _userState = userState;
+                               _buffer = buffer;
+                               _offset = offset;
+                               _count = count;
+                               _fromWrite = fromWrite;
+                               _proceedAfterHandshake = proceedAfterHandshake;
+                       }
+
+                       public bool ProceedAfterHandshake
+                       {
+                               get { return _proceedAfterHandshake; }
+                       }
+
+                       public bool FromWrite
+                       {
+                               get { return _fromWrite; }
+                       }
+
+                       public byte[] Buffer
+                       {
+                               get { return _buffer; }
+                       }
+
+                       public int Offset
+                       {
+                               get { return _offset; }
+                       }
+
+                       public int Count
+                       {
+                               get { return _count; }
+                       }
+
+                       public int BytesRead
+                       {
+                               get { return _bytesRead; }
+                       }
+
+                       public object AsyncState
+                       {
+                               get { return _userState; }
+                       }
+
+                       public Exception AsyncException
+                       {
+                               get { return _asyncException; }
+                       }
+
+                       public bool CompletedWithError
+                       {
+                               get {
+                                       if (IsCompleted == false)
+                                               return false;
+                                       return null != _asyncException;
+                               }
+                       }
+
+                       public WaitHandle AsyncWaitHandle
+                       {
+                               get {
+                                       lock (locker) {
+                                               if (handle == null)
+                                                       handle = new ManualResetEvent (completed);
+                                       }
+                                       return handle;
+                               }
+                       }
+
+                       public bool CompletedSynchronously
+                       {
+                               get { return false; }
+                       }
+
+                       public bool IsCompleted
+                       {
+                               get {
+                                       lock (locker)
+                                               return completed;
+                               }
+                       }
+
+                       private void SetComplete(Exception ex, int bytesRead)
+                       {
+                               lock (locker) {
+                                       if (completed)
+                                               return;
+
+                                       completed = true;
+                                       _asyncException = ex;
+                                       _bytesRead = bytesRead;
+                                       if (handle != null)
+                                               handle.Set ();
+                               }
+                               if (_userCallback != null)
+                                       _userCallback.BeginInvoke (this, null, null);
+                       }
+
+                       public void SetComplete(Exception ex)
+                       {
+                               SetComplete(ex, 0);
+                       }
+
+                       public void SetComplete(int bytesRead)
+                       {
+                               SetComplete(null, bytesRead);
+                       }
+
+                       public void SetComplete()
+                       {
+                               SetComplete(null, 0);
+                       }
+               }
+               #endregion
+
+               #region Stream Overrides and Async Stream Operations
+
+               private bool BeginNegotiateHandshake(InternalAsyncResult asyncResult)
+               {
+                       try
+                       {
+                               lock (this.negotiate)
+                               {
+                                       if (this.context.HandshakeState == HandshakeState.None)
+                                       {
+                                               this.OnBeginNegotiateHandshake(new AsyncCallback(AsyncHandshakeCallback), asyncResult);
+
+                                               return true;
+                                       }
+                                       else
+                                       {
+                                               return false;
+                                       }
+                               }
+                       }
+                       catch (TlsException ex)
+                       {
+                               this.negotiationComplete.Set();
+                               this.protocol.SendAlert(ex.Alert);
+
+                               throw new IOException("The authentication or decryption has failed.", ex);
+                       }
+                       catch (Exception ex)
+                       {
+                               this.negotiationComplete.Set();
+                               this.protocol.SendAlert(AlertDescription.InternalError);
+
+                               throw new IOException("The authentication or decryption has failed.", ex);
+                       }
+               }
+
+               private void EndNegotiateHandshake(InternalAsyncResult asyncResult)
+               {
+                       if (asyncResult.IsCompleted == false)
+                               asyncResult.AsyncWaitHandle.WaitOne();
+
+                       if (asyncResult.CompletedWithError)
+                       {
+                               throw asyncResult.AsyncException;
+                       }
+               }
+
+               public override IAsyncResult BeginRead(
+                       byte[] buffer,
+                       int offset,
+                       int count,
+                       AsyncCallback callback,
+                       object state)
+               {
+                       this.checkDisposed();
+
+                       if (buffer == null)
+                       {
+                               throw new ArgumentNullException("buffer is a null reference.");
+                       }
+                       if (offset < 0)
+                       {
+                               throw new ArgumentOutOfRangeException("offset is less than 0.");
+                       }
+                       if (offset > buffer.Length)
+                       {
+                               throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
+                       }
+                       if (count < 0)
+                       {
+                               throw new ArgumentOutOfRangeException("count is less than 0.");
+                       }
+                       if (count > (buffer.Length - offset))
+                       {
+                               throw new ArgumentOutOfRangeException("count is less than the length of buffer minus the value of the offset parameter.");
+                       }
+
+                       InternalAsyncResult asyncResult = new InternalAsyncResult(callback, state, buffer, offset, count, false, true);
+
+                       if (this.MightNeedHandshake)
+                       {
+                               if (! BeginNegotiateHandshake(asyncResult))
+                               {
+                                       //we made it down here so the handshake was not started.
+                                       //another thread must have started it in the mean time.
+                                       //wait for it to complete and then perform our original operation
+                                       this.negotiationComplete.WaitOne();
+
+                                       InternalBeginRead(asyncResult);
+                               }
+                       }
+                       else
+                       {
+                               InternalBeginRead(asyncResult);
+                       }
+
+                       return asyncResult;
+               }
+
+               // bigger than max record length for SSL/TLS
+               private byte[] recbuf = new byte[16384];
+
+               private void InternalBeginRead(InternalAsyncResult asyncResult)
+               {
+                       try
+                       {
+                               int preReadSize = 0;
+
+                               lock (this.read)
+                               {
+                                       // If actual buffer is fully read, reset it
+                                       bool shouldReset = this.inputBuffer.Position == this.inputBuffer.Length && this.inputBuffer.Length > 0;
+
+                                       // If the buffer isn't fully read, but does have data, we need to immediately
+                                       // read the info from the buffer and let the user know that they have more data.
+                                       bool shouldReadImmediately = (this.inputBuffer.Length > 0) && (asyncResult.Count > 0);
+
+                                       if (shouldReset)
+                                       {
+                                               this.resetBuffer();
+                                       }
+                                       else if (shouldReadImmediately)
+                                       {
+                                               preReadSize = this.inputBuffer.Read(asyncResult.Buffer, asyncResult.Offset, asyncResult.Count);
+                                       }
+                               }
+
+                               // This is explicitly done outside the synclock to avoid 
+                               // any potential deadlocks in the delegate call.
+                               if (0 < preReadSize)
+                               {
+                                       asyncResult.SetComplete(preReadSize);
+                               }
+                               else if (!this.context.ConnectionEnd)
+                               {
+                                       // this will read data from the network until we have (at least) one
+                                       // record to send back to the caller
+                                       this.innerStream.BeginRead(recbuf, 0, recbuf.Length,
+                                               new AsyncCallback(InternalReadCallback), new object[] { recbuf, asyncResult });
+                               }
+                               else
+                               {
+                                       // We're done with the connection so we need to let the caller know with 0 bytes read
+                                       asyncResult.SetComplete(0);
+                               }
+                       }
+                       catch (TlsException ex)
+                       {
+                               this.protocol.SendAlert(ex.Alert);
+
+                               throw new IOException("The authentication or decryption has failed.", ex);
+                       }
+                       catch (Exception ex)
+                       {
+                               throw new IOException("IO exception during read.", ex);
+                       }
+               }
+
+
+               private MemoryStream recordStream = new MemoryStream();
+
+               // read encrypted data until we have enough to decrypt (at least) one
+               // record and return are the records (may be more than one) we have
+               private void InternalReadCallback(IAsyncResult result)
+               {
+                       if (this.disposed)
+                               return;
+
+                       object[] state = (object[])result.AsyncState;
+                       byte[] recbuf = (byte[])state[0];
+                       InternalAsyncResult internalResult = (InternalAsyncResult)state[1];
+
+                       try
+                       {
+                               int n = innerStream.EndRead(result);
+                               if (n > 0)
+                               {
+                                       // Add the just received data to the waiting data
+                                       recordStream.Write(recbuf, 0, n);
+                               }
+                               else
+                               {
+                                       // 0 length data means this read operation is done (lost connection in the case of a network stream).
+                                       internalResult.SetComplete(0);
+                                       return;
+                               }
+
+                               bool dataToReturn = false;
+                               long pos = recordStream.Position;
+
+                               recordStream.Position = 0;
+                               byte[] record = null;
+
+                               // don't try to decode record unless we have at least 5 bytes
+                               // i.e. type (1), protocol (2) and length (2)
+                               if (recordStream.Length >= 5)
+                               {
+                                       record = this.protocol.ReceiveRecord(recordStream);
+                               }
+
+                               // a record of 0 length is valid (and there may be more record after it)
+                               while (record != null)
+                               {
+                                       // we probably received more stuff after the record, and we must keep it!
+                                       long remainder = recordStream.Length - recordStream.Position;
+                                       byte[] outofrecord = null;
+                                       if (remainder > 0)
+                                       {
+                                               outofrecord = new byte[remainder];
+                                               recordStream.Read(outofrecord, 0, outofrecord.Length);
+                                       }
+
+                                       lock (this.read)
+                                       {
+                                               long position = this.inputBuffer.Position;
+
+                                               if (record.Length > 0)
+                                               {
+                                                       // Write new data to the inputBuffer
+                                                       this.inputBuffer.Seek(0, SeekOrigin.End);
+                                                       this.inputBuffer.Write(record, 0, record.Length);
+
+                                                       // Restore buffer position
+                                                       this.inputBuffer.Seek(position, SeekOrigin.Begin);
+                                                       dataToReturn = true;
+                                               }
+                                       }
+
+                                       recordStream.SetLength(0);
+                                       record = null;
+
+                                       if (remainder > 0)
+                                       {
+                                               recordStream.Write(outofrecord, 0, outofrecord.Length);
+                                               // type (1), protocol (2) and length (2)
+                                               if (recordStream.Length >= 5)
+                                               {
+                                                       // try to see if another record is available
+                                                       recordStream.Position = 0;
+                                                       record = this.protocol.ReceiveRecord(recordStream);
+                                                       if (record == null)
+                                                               pos = recordStream.Length;
+                                               }
+                                               else
+                                                       pos = remainder;
+                                       }
+                                       else
+                                               pos = 0;
+                               }
+
+                               if (!dataToReturn && (n > 0))
+                               {
+                                       // there is no record to return to caller and (possibly) more data waiting
+                                       // so continue reading from network (and appending to stream)
+                                       recordStream.Position = recordStream.Length;
+                                       this.innerStream.BeginRead(recbuf, 0, recbuf.Length,
+                                               new AsyncCallback(InternalReadCallback), state);
+                               }
+                               else
+                               {
+                                       // we have record(s) to return -or- no more available to read from network
+                                       // reset position for further reading
+                                       recordStream.Position = pos;
+
+                                       int bytesRead = 0;
+                                       lock (this.read)
+                                       {
+                                               bytesRead = this.inputBuffer.Read(internalResult.Buffer, internalResult.Offset, internalResult.Count);
+                                       }
+
+                                       internalResult.SetComplete(bytesRead);
+                               }
+                       }
+                       catch (Exception ex)
+                       {
+                               internalResult.SetComplete(ex);
+                       }
+
+               }
+
+               private void InternalBeginWrite(InternalAsyncResult asyncResult)
+               {
+                       try
+                       {
+                               // Send the buffer as a TLS record
+
+                               lock (this.write)
+                               {
+                                       byte[] record = this.protocol.EncodeRecord(
+                                               ContentType.ApplicationData, asyncResult.Buffer, asyncResult.Offset, asyncResult.Count);
+
+                                       this.innerStream.BeginWrite(
+                                               record, 0, record.Length, new AsyncCallback(InternalWriteCallback), asyncResult);
+                               }
+                       }
+                       catch (TlsException ex)
+                       {
+                               this.protocol.SendAlert(ex.Alert);
+                               this.Close();
+
+                               throw new IOException("The authentication or decryption has failed.", ex);
+                       }
+                       catch (Exception ex)
+                       {
+                               throw new IOException("IO exception during Write.", ex);
+                       }
+               }
+
+               private void InternalWriteCallback(IAsyncResult ar)
+               {
+                       if (this.disposed)
+                               return;
+                       
+                       InternalAsyncResult internalResult = (InternalAsyncResult)ar.AsyncState;
+
+                       try
+                       {
+                               this.innerStream.EndWrite(ar);
+                               internalResult.SetComplete();
+                       }
+                       catch (Exception ex)
+                       {
+                               internalResult.SetComplete(ex);
+                       }
+               }
+
+               public override IAsyncResult BeginWrite(
+                       byte[] buffer,
+                       int offset,
+                       int count,
+                       AsyncCallback callback,
+                       object state)
+               {
+                       this.checkDisposed();
+
+                       if (buffer == null)
+                       {
+                               throw new ArgumentNullException("buffer is a null reference.");
+                       }
+                       if (offset < 0)
+                       {
+                               throw new ArgumentOutOfRangeException("offset is less than 0.");
+                       }
+                       if (offset > buffer.Length)
+                       {
+                               throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
+                       }
+                       if (count < 0)
+                       {
+                               throw new ArgumentOutOfRangeException("count is less than 0.");
+                       }
+                       if (count > (buffer.Length - offset))
+                       {
+                               throw new ArgumentOutOfRangeException("count is less than the length of buffer minus the value of the offset parameter.");
+                       }
+
+
+                       InternalAsyncResult asyncResult = new InternalAsyncResult(callback, state, buffer, offset, count, true, true);
+
+                       if (this.MightNeedHandshake)
+                       {
+                               if (! BeginNegotiateHandshake(asyncResult))
+                               {
+                                       //we made it down here so the handshake was not started.
+                                       //another thread must have started it in the mean time.
+                                       //wait for it to complete and then perform our original operation
+                                       this.negotiationComplete.WaitOne();
+
+                                       InternalBeginWrite(asyncResult);
+                               }
+                       }
+                       else
+                       {
+                               InternalBeginWrite(asyncResult);
+                       }
+
+                       return asyncResult;
+               }
+
+               public override int EndRead(IAsyncResult asyncResult)
+               {
+                       this.checkDisposed();
+
+                       InternalAsyncResult internalResult = asyncResult as InternalAsyncResult;
+                       if (internalResult == null)
+                       {
+                               throw new ArgumentNullException("asyncResult is null or was not obtained by calling BeginRead.");
+                       }
+
+                       // Always wait until the read is complete
+                       if (!asyncResult.IsCompleted)
+                       {
+                               if (!asyncResult.AsyncWaitHandle.WaitOne (WaitTimeOut, false))
+                                       throw new TlsException (AlertDescription.InternalError, "Couldn't complete EndRead");
+                       }
+
+                       if (internalResult.CompletedWithError)
+                       {
+                               throw internalResult.AsyncException;
+                       }
+
+                       return internalResult.BytesRead;
+               }
+
+               public override void EndWrite(IAsyncResult asyncResult)
+               {
+                       this.checkDisposed();
+
+                       InternalAsyncResult internalResult = asyncResult as InternalAsyncResult;
+                       if (internalResult == null)
+                       {
+                               throw new ArgumentNullException("asyncResult is null or was not obtained by calling BeginWrite.");
+                       }
+
+
+                       if (!asyncResult.IsCompleted)
+                       {
+                               if (!internalResult.AsyncWaitHandle.WaitOne (WaitTimeOut, false))
+                                       throw new TlsException (AlertDescription.InternalError, "Couldn't complete EndWrite");
+                       }
+
+                       if (internalResult.CompletedWithError)
+                       {
+                               throw internalResult.AsyncException;
+                       }
+               }
+
+               public override void Close()
+               {
+#if NET_2_0
+                       base.Close ();
+#else
+                       ((IDisposable)this).Dispose();
+#endif
+               }
+
+               public override void Flush()
+               {
+                       this.checkDisposed();
+
+                       this.innerStream.Flush();
+               }
+
+               public int Read(byte[] buffer)
+               {
+                       return this.Read(buffer, 0, buffer.Length);
+               }
+
+               public override int Read(byte[] buffer, int offset, int count)
+               {
+                       this.checkDisposed ();
+                       
+                       if (buffer == null)
+                       {
+                               throw new ArgumentNullException ("buffer");
+                       }
+                       if (offset < 0)
+                       {
+                               throw new ArgumentOutOfRangeException("offset is less than 0.");
+                       }
+                       if (offset > buffer.Length)
+                       {
+                               throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
+                       }
+                       if (count < 0)
+                       {
+                               throw new ArgumentOutOfRangeException("count is less than 0.");
+                       }
+                       if (count > (buffer.Length - offset))
+                       {
+                               throw new ArgumentOutOfRangeException("count is less than the length of buffer minus the value of the offset parameter.");
+                       }
+
+                       if (this.context.HandshakeState != HandshakeState.Finished)
+                       {
+                               this.NegotiateHandshake (); // Handshake negotiation
+                       }
+
+                       lock (this.read) {
+                               try {
+                                       record_processing.Reset ();
+                                       // do we already have some decrypted data ?
+                                       if (this.inputBuffer.Position > 0) {
+                                               // or maybe we used all the buffer before ?
+                                               if (this.inputBuffer.Position == this.inputBuffer.Length) {
+                                                       this.inputBuffer.SetLength (0);
+                                               } else {
+                                                       int n = this.inputBuffer.Read (buffer, offset, count);
+                                                       if (n > 0) {
+                                                               record_processing.Set ();
+                                                               return n;
+                                                       }
+                                               }
+                                       }
+
+                                       bool needMoreData = false;
+                                       while (true) {
+                                               // we first try to process the read with the data we already have
+                                               if ((recordStream.Position == 0) || needMoreData) {
+                                                       needMoreData = false;
+                                                       // if we loop, then it either means we need more data
+                                                       byte[] recbuf = new byte[16384];
+                                                       int n = 0;
+                                                       if (count == 1) {
+                                                               int value = innerStream.ReadByte ();
+                                                               if (value >= 0) {
+                                                                       recbuf[0] = (byte) value;
+                                                                       n = 1;
+                                                               }
+                                                       } else {
+                                                               n = innerStream.Read (recbuf, 0, recbuf.Length);
+                                                       }
+                                                       if (n > 0) {
+                                                               // Add the new received data to the waiting data
+                                                               if ((recordStream.Length > 0) && (recordStream.Position != recordStream.Length))
+                                                                       recordStream.Seek (0, SeekOrigin.End);
+                                                               recordStream.Write (recbuf, 0, n);
+                                                       } else {
+                                                               // or that the read operation is done (lost connection in the case of a network stream).
+                                                               record_processing.Set ();
+                                                               return 0;
+                                                       }
+                                               }
+
+                                               bool dataToReturn = false;
+
+                                               recordStream.Position = 0;
+                                               byte[] record = null;
+
+                                               // don't try to decode record unless we have at least 5 bytes
+                                               // i.e. type (1), protocol (2) and length (2)
+                                               if (recordStream.Length >= 5) {
+                                                       record = this.protocol.ReceiveRecord (recordStream);
+                                                       needMoreData = (record == null);
+                                               }
+
+                                               // a record of 0 length is valid (and there may be more record after it)
+                                               while (record != null) {
+                                                       // we probably received more stuff after the record, and we must keep it!
+                                                       long remainder = recordStream.Length - recordStream.Position;
+                                                       byte[] outofrecord = null;
+                                                       if (remainder > 0) {
+                                                               outofrecord = new byte[remainder];
+                                                               recordStream.Read (outofrecord, 0, outofrecord.Length);
+                                                       }
+
+                                                       long position = this.inputBuffer.Position;
+
+                                                       if (record.Length > 0) {
+                                                               // Write new data to the inputBuffer
+                                                               this.inputBuffer.Seek (0, SeekOrigin.End);
+                                                               this.inputBuffer.Write (record, 0, record.Length);
+
+                                                               // Restore buffer position
+                                                               this.inputBuffer.Seek (position, SeekOrigin.Begin);
+                                                               dataToReturn = true;
+                                                       }
+
+                                                       recordStream.SetLength (0);
+                                                       record = null;
+
+                                                       if (remainder > 0) {
+                                                               recordStream.Write (outofrecord, 0, outofrecord.Length);
+                                                       }
+
+                                                       if (dataToReturn) {
+                                                               // we have record(s) to return -or- no more available to read from network
+                                                               // reset position for further reading
+                                                               int i = inputBuffer.Read (buffer, offset, count);
+                                                               record_processing.Set ();
+                                                               return i;
+                                                       }
+                                               }
+                                       }
+                               }
+                               catch (TlsException ex)
+                               {
+                                       throw new IOException("The authentication or decryption has failed.", ex);
+                               }
+                               catch (Exception ex)
+                               {
+                                       throw new IOException("IO exception during read.", ex);
+                               }
+                       }
+               }
+
+               public override long Seek(long offset, SeekOrigin origin)
+               {
+                       throw new NotSupportedException();
+               }
+
+               public override void SetLength(long value)
+               {
+                       throw new NotSupportedException();
+               }
+
+               public void Write(byte[] buffer)
+               {
+                       this.Write(buffer, 0, buffer.Length);
+               }
+
+               public override void Write(byte[] buffer, int offset, int count)
+               {
+                       this.checkDisposed ();
+                       
+                       if (buffer == null)
+                       {
+                               throw new ArgumentNullException ("buffer");
+                       }
+                       if (offset < 0)
+                       {
+                               throw new ArgumentOutOfRangeException("offset is less than 0.");
+                       }
+                       if (offset > buffer.Length)
+                       {
+                               throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
+                       }
+                       if (count < 0)
+                       {
+                               throw new ArgumentOutOfRangeException("count is less than 0.");
+                       }
+                       if (count > (buffer.Length - offset))
+                       {
+                               throw new ArgumentOutOfRangeException("count is less than the length of buffer minus the value of the offset parameter.");
+                       }
+
+                       if (this.context.HandshakeState != HandshakeState.Finished)
+                       {
+                               this.NegotiateHandshake ();
+                       }
+
+                       lock (this.write)
+                       {
+                               try
+                               {
+                                       // Send the buffer as a TLS record
+                                       byte[] record = this.protocol.EncodeRecord (ContentType.ApplicationData, buffer, offset, count);
+                                       this.innerStream.Write (record, 0, record.Length);
+                               }
+                               catch (TlsException ex)
+                               {
+                                       this.protocol.SendAlert(ex.Alert);
+                                       this.Close();
+                                       throw new IOException("The authentication or decryption has failed.", ex);
+                               }
+                               catch (Exception ex)
+                               {
+                                       throw new IOException("IO exception during Write.", ex);
+                               }
+                       }
+               }
+
+               public override bool CanRead
+               {
+                       get { return this.innerStream.CanRead; }
+               }
+
+               public override bool CanSeek
+               {
+                       get { return false; }
+               }
+
+               public override bool CanWrite
+               {
+                       get { return this.innerStream.CanWrite; }
+               }
+
+               public override long Length
+               {
+                       get { throw new NotSupportedException(); }
+               }
+
+               public override long Position
+               {
+                       get
+                       {
+                               throw new NotSupportedException();
+                       }
+                       set
+                       {
+                               throw new NotSupportedException();
+                       }
+               }
+               #endregion
+
+               #region IDisposable Members and Finalizer
+
+               ~SslStreamBase()
+               {
+                       this.Dispose(false);
+               }
+
+#if !NET_2_0
+               public void Dispose()
+               {
+                       this.Dispose(true);
+                       GC.SuppressFinalize(this);
+               }
+
+               protected virtual void Dispose (bool disposing)
+#else
+               protected override void Dispose (bool disposing)
+#endif
+               {
+                       if (!this.disposed)
+                       {
+                               if (disposing)
+                               {
+                                       if (this.innerStream != null)
+                                       {
+                                               if (this.context.HandshakeState == HandshakeState.Finished &&
+                                                       !this.context.ConnectionEnd)
+                                               {
+                                                       // Write close notify                                                   
+                                                       this.protocol.SendAlert(AlertDescription.CloseNotify);
+                                               }
+
+                                               if (this.ownsStream)
+                                               {
+                                                       // Close inner stream
+                                                       this.innerStream.Close();
+                                               }
+                                       }
+                                       this.ownsStream = false;
+                                       this.innerStream = null;
+                               }
+
+                               this.disposed = true;
+#if NET_2_0
+                               base.Dispose (disposing);
+#endif
+                       }
+               }
+
+               #endregion
+
+               #region Misc Methods
+
+               private void resetBuffer()
+               {
+                       this.inputBuffer.SetLength(0);
+                       this.inputBuffer.Position = 0;
+               }
+
+               internal void checkDisposed()
+               {
+                       if (this.disposed)
+                       {
+                               throw new ObjectDisposedException("The Stream is closed.");
+                       }
+               }
+
+               #endregion
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsCipherSuite.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsCipherSuite.cs
new file mode 100644 (file)
index 0000000..3eaaee0
--- /dev/null
@@ -0,0 +1,177 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Security.Cryptography;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class TlsCipherSuite : CipherSuite
+       {
+               private const int MacHeaderLength = 13;
+               private byte[] header;
+
+               #region Constructors
+               
+               public TlsCipherSuite(
+                       short code, string name, CipherAlgorithmType cipherAlgorithmType, 
+                       HashAlgorithmType hashAlgorithmType, ExchangeAlgorithmType exchangeAlgorithmType,
+                       bool exportable, bool blockMode, byte keyMaterialSize, 
+                       byte expandedKeyMaterialSize, short effectiveKeyBytes, 
+                       byte ivSize, byte blockSize) 
+                       :base(code, name, cipherAlgorithmType, hashAlgorithmType, 
+                       exchangeAlgorithmType, exportable, blockMode, keyMaterialSize, 
+                       expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize)
+               {
+               }
+
+               #endregion
+
+               #region MAC Generation Methods
+
+               public override byte[] ComputeServerRecordMAC(ContentType contentType, byte[] fragment)
+               {
+                       if (header == null)
+                               header = new byte [MacHeaderLength];
+
+                       ulong seqnum = (Context is ClientContext) ? Context.ReadSequenceNumber : Context.WriteSequenceNumber;
+                       Write (header, 0, seqnum);
+                       header [8] = (byte) contentType;
+                       Write (header, 9, this.Context.Protocol);
+                       Write (header, 11, (short)fragment.Length);
+
+                       HashAlgorithm mac = this.ServerHMAC;
+                       mac.TransformBlock (header, 0, header.Length, header, 0);
+                       mac.TransformBlock (fragment, 0, fragment.Length, fragment, 0);
+                       // hack, else the method will allocate a new buffer of the same length (negative half the optimization)
+                       mac.TransformFinalBlock (CipherSuite.EmptyArray, 0, 0);
+                       return mac.Hash;
+               }
+
+               public override byte[] ComputeClientRecordMAC(ContentType contentType, byte[] fragment)
+               {
+                       if (header == null)
+                               header = new byte [MacHeaderLength];
+
+                       ulong seqnum = (Context is ClientContext) ? Context.WriteSequenceNumber : Context.ReadSequenceNumber;
+                       Write (header, 0, seqnum);
+                       header [8] = (byte) contentType;
+                       Write (header, 9, this.Context.Protocol);
+                       Write (header, 11, (short)fragment.Length);
+
+                       HashAlgorithm mac = this.ClientHMAC;
+                       mac.TransformBlock (header, 0, header.Length, header, 0);
+                       mac.TransformBlock (fragment, 0, fragment.Length, fragment, 0);
+                       // hack, else the method will allocate a new buffer of the same length (negative half the optimization)
+                       mac.TransformFinalBlock (CipherSuite.EmptyArray, 0, 0);
+                       return mac.Hash;
+               }
+
+               #endregion
+
+               #region Key Generation Methods
+
+               public override void ComputeMasterSecret(byte[] preMasterSecret)
+               {
+                       // Create master secret
+                       this.Context.MasterSecret = new byte[preMasterSecret.Length];
+                       this.Context.MasterSecret = this.PRF(
+                               preMasterSecret, "master secret", this.Context.RandomCS, 48);
+
+                       DebugHelper.WriteLine(">>>> MasterSecret", this.Context.MasterSecret);
+               }
+
+               public override void ComputeKeys()
+               {
+                       // Create keyblock
+                       TlsStream keyBlock = new TlsStream(
+                               this.PRF(
+                               this.Context.MasterSecret, 
+                               "key expansion",
+                               this.Context.RandomSC,
+                               this.KeyBlockSize));
+
+                       this.Context.Negotiating.ClientWriteMAC = keyBlock.ReadBytes(this.HashSize);
+                       this.Context.Negotiating.ServerWriteMAC = keyBlock.ReadBytes(this.HashSize);
+                       this.Context.ClientWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize);
+                       this.Context.ServerWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize);
+
+                       if (!this.IsExportable)
+                       {
+                               if (this.IvSize != 0)
+                               {
+                                       this.Context.ClientWriteIV = keyBlock.ReadBytes(this.IvSize);
+                                       this.Context.ServerWriteIV = keyBlock.ReadBytes(this.IvSize);
+                               }
+                               else
+                               {
+                                       this.Context.ClientWriteIV = CipherSuite.EmptyArray;
+                                       this.Context.ServerWriteIV = CipherSuite.EmptyArray;
+                               }
+                       }
+                       else
+                       {
+                               // Generate final write keys
+                               byte[] finalClientWriteKey      = PRF(this.Context.ClientWriteKey, "client write key", this.Context.RandomCS, this.ExpandedKeyMaterialSize);
+                               byte[] finalServerWriteKey      = PRF(this.Context.ServerWriteKey, "server write key", this.Context.RandomCS, this.ExpandedKeyMaterialSize);
+                               
+                               this.Context.ClientWriteKey     = finalClientWriteKey;
+                               this.Context.ServerWriteKey     = finalServerWriteKey;
+
+                               if (this.IvSize > 0) 
+                               {
+                                       // Generate IV block
+                                       byte[] ivBlock = PRF(CipherSuite.EmptyArray, "IV block", this.Context.RandomCS, this.IvSize*2);
+
+                                       // Generate IV keys
+                                       this.Context.ClientWriteIV = new byte[this.IvSize];                             
+                                       Buffer.BlockCopy(ivBlock, 0, this.Context.ClientWriteIV, 0, this.Context.ClientWriteIV.Length);
+
+                                       this.Context.ServerWriteIV = new byte[this.IvSize];
+                                       Buffer.BlockCopy(ivBlock, this.IvSize, this.Context.ServerWriteIV, 0, this.Context.ServerWriteIV.Length);
+                               }
+                               else 
+                               {
+                                       this.Context.ClientWriteIV = CipherSuite.EmptyArray;
+                                       this.Context.ServerWriteIV = CipherSuite.EmptyArray;
+                               }
+                       }
+
+                       DebugHelper.WriteLine(">>>> KeyBlock", keyBlock.ToArray());
+                       DebugHelper.WriteLine(">>>> ClientWriteKey", this.Context.ClientWriteKey);
+                       DebugHelper.WriteLine(">>>> ClientWriteIV", this.Context.ClientWriteIV);
+                       DebugHelper.WriteLine(">>>> ClientWriteMAC", this.Context.Negotiating.ClientWriteMAC);
+                       DebugHelper.WriteLine(">>>> ServerWriteKey", this.Context.ServerWriteKey);
+                       DebugHelper.WriteLine(">>>> ServerWriteIV", this.Context.ServerWriteIV);
+                       DebugHelper.WriteLine(">>>> ServerWriteMAC", this.Context.Negotiating.ServerWriteMAC);
+
+                       ClientSessionCache.SetContextInCache (this.Context);
+                       // Clear no more needed data
+                       keyBlock.Reset();
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsClientSettings.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsClientSettings.cs
new file mode 100644 (file)
index 0000000..bcbc882
--- /dev/null
@@ -0,0 +1,124 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+using System.Security.Cryptography.X509Certificates;
+using Mono.Security.Cryptography;
+using X509 = Mono.Security.X509;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal sealed class TlsClientSettings
+       {
+               #region Fields
+
+               private string                                          targetHost;
+               private X509CertificateCollection       certificates;
+               //private SecurityCompressionType               compressionMethod;
+               private X509Certificate                         clientCertificate;
+               private RSAManaged                                      certificateRSA;
+       
+               #endregion
+
+               #region Properties
+
+               public string TargetHost
+               {
+                       get { return this.targetHost; }
+                       set { this.targetHost = value; }
+               }
+
+               public X509CertificateCollection Certificates
+               {
+                       get { return this.certificates; }
+                       set { this.certificates = value; }
+               }
+               
+               public X509Certificate ClientCertificate
+               {
+                       get { return this.clientCertificate; }
+                       set 
+                       { 
+                               this.clientCertificate = value; 
+                               this.UpdateCertificateRSA();
+                       }
+               }
+
+               public RSAManaged CertificateRSA
+               {
+                       get { return this.certificateRSA; }
+               }
+
+               /*
+               public SecurityCompressionType CompressionMethod
+               {
+                       get { return this.compressionMethod; }
+                       set 
+                       { 
+                               if (value != SecurityCompressionType.None)
+                               {
+                                       throw new NotSupportedException("Specified compression method is not supported");
+                               }
+                               this.compressionMethod = value; 
+                       }
+               }
+               */
+
+               #endregion
+
+               #region Constructors
+
+               public TlsClientSettings()
+               {
+                       // this.compressionMethod       = SecurityCompressionType.None;
+                       this.certificates               = new X509CertificateCollection();
+                       this.targetHost                 = String.Empty;
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void UpdateCertificateRSA()
+               {
+                       if (this.clientCertificate == null)
+                       {
+                               this.certificateRSA = null;
+                       }
+                       else
+                       {
+                               X509.X509Certificate cert = new X509.X509Certificate(this.clientCertificate.GetRawCertData());
+
+                               this.certificateRSA = new RSAManaged(
+                                       cert.RSA.KeySize);
+
+                               this.certificateRSA.ImportParameters(
+                                       cert.RSA.ExportParameters(false));
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsException.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsException.cs
new file mode 100644 (file)
index 0000000..ef2c5ce
--- /dev/null
@@ -0,0 +1,93 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+using System.Runtime.Serialization;
+
+namespace Mono.Security.Protocol.Tls
+{
+       [Serializable]
+       internal sealed class TlsException : Exception
+       {       
+               #region Fields
+
+               private Alert alert;
+
+               #endregion
+
+               #region Properties
+
+               public Alert Alert
+               {
+                       get { return this.alert; }
+               }
+
+               #endregion
+
+               #region Constructors
+               
+               internal TlsException(string message) : base(message)
+               {
+               }
+
+               internal TlsException(SerializationInfo info, StreamingContext context) : base(info, context)
+               {
+               }
+               
+               internal TlsException(string message, Exception ex) : base(message, ex)
+               {
+               }
+
+               internal TlsException(
+                       AlertLevel                      level,
+                       AlertDescription        description) 
+                       : this (level, description, Alert.GetAlertMessage(description))
+               {
+               }
+
+               internal TlsException(
+                       AlertLevel                      level,
+                       AlertDescription        description,
+                       string                          message) : base (message)
+               {
+                       this.alert = new Alert(level, description);
+               }
+
+               internal TlsException(
+                       AlertDescription description) 
+                       : this (description, Alert.GetAlertMessage(description))
+               {
+               }
+
+               internal TlsException(
+                       AlertDescription        description,
+                       string                          message) : base (message)
+               {
+                       this.alert = new Alert(description);
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsServerSettings.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsServerSettings.cs
new file mode 100644 (file)
index 0000000..fec3175
--- /dev/null
@@ -0,0 +1,129 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Security.Cryptography;
+
+using Mono.Security.Cryptography;
+using Mono.Security.X509;
+using Mono.Security.Protocol.Tls.Handshake;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class TlsServerSettings
+       {
+               #region Fields
+
+               private X509CertificateCollection       certificates;
+               private RSA                                                     certificateRSA;
+               private RSAParameters                           rsaParameters;
+               private byte[]                                          signedParams;
+               private string[]                                        distinguisedNames;
+               private bool                                            serverKeyExchange;
+               private bool                                            certificateRequest;
+               private ClientCertificateType[]         certificateTypes;
+
+               #endregion
+
+               #region Properties
+               
+               public bool     ServerKeyExchange
+               {
+                       get { return this.serverKeyExchange; }
+                       set { this.serverKeyExchange = value; }
+               }               
+
+               public X509CertificateCollection Certificates
+               {
+                       get { return this.certificates; }
+                       set { this.certificates = value; }
+               }
+
+               public RSA CertificateRSA
+               {
+                       get { return this.certificateRSA; }
+               }
+               
+               public RSAParameters RsaParameters
+               {
+                       get { return this.rsaParameters; }
+                       set { this.rsaParameters = value; }
+               }
+
+               public byte[] SignedParams
+               {
+                       get { return this.signedParams; }
+                       set { this.signedParams = value; }
+               }
+
+               public bool     CertificateRequest
+               {
+                       get { return this.certificateRequest; }
+                       set { this.certificateRequest = value; }
+               }
+               
+               public ClientCertificateType[] CertificateTypes
+               {
+                       get { return this.certificateTypes; }
+                       set { this.certificateTypes = value; }
+               }
+
+               public string[] DistinguisedNames
+               {
+                       get { return this.distinguisedNames; }
+                       set { this.distinguisedNames = value; }
+               }
+               
+               #endregion
+
+               #region Constructors
+
+               public TlsServerSettings()
+               {
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void UpdateCertificateRSA()
+               {
+                       if (this.certificates == null ||
+                               this.certificates.Count == 0)
+                       {
+                               this.certificateRSA = null;
+                       }
+                       else
+                       {
+                               this.certificateRSA = new RSAManaged(
+                                       this.certificates[0].RSA.KeySize);
+
+                               this.certificateRSA.ImportParameters(
+                                       this.certificates[0].RSA.ExportParameters(false));
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsStream.cs b/mcs/class/System.ServiceModel/Mono.Security.Protocol.Tls/TlsStream.cs
new file mode 100644 (file)
index 0000000..4130ad1
--- /dev/null
@@ -0,0 +1,274 @@
+// Transport Security Layer (TLS)
+// Copyright (c) 2003-2004 Carlos Guzman Alvarez
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+
+namespace Mono.Security.Protocol.Tls
+{
+       internal class TlsStream : Stream
+       {
+               #region Fields
+
+               private bool                            canRead;
+               private bool                            canWrite;
+               private MemoryStream            buffer;
+               private byte[] temp;
+               private const int temp_size = 4;
+
+               #endregion
+
+               #region Properties
+
+               public bool EOF
+               {
+                       get 
+                       {
+                               if (this.Position < this.Length)
+                               {
+                                       return false;
+                               }
+                               else
+                               {
+                                       return true;
+                               }
+                       }
+               }
+
+               #endregion
+
+               #region Stream Properties
+
+               public override bool CanWrite
+               {
+                       get { return this.canWrite; }
+               }
+
+               public override bool CanRead
+               {
+                       get { return this.canRead; }
+               }
+
+               public override bool CanSeek
+               {
+                       get { return this.buffer.CanSeek; }
+               }
+
+               public override long Position
+               {
+                       get { return this.buffer.Position; }
+                       set { this.buffer.Position = value; }
+               }
+
+               public override long Length
+               {
+                       get { return this.buffer.Length; }
+               }
+
+               #endregion
+
+               #region Constructors
+
+               public TlsStream() : base()
+               {
+                       this.buffer             = new MemoryStream(0);
+                       this.canRead    = false;
+                       this.canWrite   = true;
+               }
+
+               public TlsStream(byte[] data) : base()
+               {
+                       if (data != null)
+                               this.buffer = new MemoryStream(data);
+                       else
+                               this.buffer = new MemoryStream ();
+                       this.canRead = true;
+                       this.canWrite   = false;
+               }
+
+               #endregion
+
+               #region Specific Read Methods
+
+               // hack for reducing memory allocations
+               // returned value is valid only for the length asked *and*
+               // cannot be directly returned outside the class
+               // note: Mono's Stream.ReadByte does a 1 byte array allocation
+               private byte[] ReadSmallValue (int length)
+               {
+                       if (length > temp_size)
+                               throw new ArgumentException ("8 bytes maximum");
+                       if (temp == null)
+                               temp = new byte[temp_size];
+
+                       if (this.Read (temp, 0, length) != length)
+                               throw new TlsException (String.Format ("buffer underrun"));
+                       return temp;
+               }
+
+               public new byte ReadByte()
+               {
+                       byte[] result = ReadSmallValue (1);
+                       return result [0];
+               }
+
+               public short ReadInt16()
+               {
+                       byte[] result = ReadSmallValue (2);
+                       return (short) (result[0] << 8 | result[1]);
+               }
+
+               public int ReadInt24()
+               {
+                       byte[] result = ReadSmallValue (3);
+                       return ((result[0] << 16) | (result[1] << 8) | result[2]);
+               }
+
+               public int ReadInt32()
+               {
+                       byte[] result = ReadSmallValue (4);
+                       return ((result[0] << 24) | (result[1] << 16) | (result[2] << 8) | result[3]);
+               }
+
+               public byte[] ReadBytes(int count)
+               {
+                       byte[] bytes = new byte[count];
+                       if (this.Read(bytes, 0, count) != count)
+                               throw new TlsException ("buffer underrun");
+
+                       return bytes;
+               }
+
+               #endregion
+
+               #region Specific Write Methods
+
+               // note: Mono's Stream.WriteByte does a 1 byte array allocation
+               public void Write(byte value)
+               {
+                       if (temp == null)
+                               temp = new byte[temp_size];
+                       temp[0] = value;
+                       this.Write (temp, 0, 1);
+               }
+
+               public void Write(short value)
+               {
+                       if (temp == null)
+                               temp = new byte[temp_size];
+                       temp[0] = ((byte)(value >> 8));
+                       temp[1] = ((byte)value);
+                       this.Write (temp, 0, 2);
+               }
+
+               public void WriteInt24(int value)
+               {
+                       if (temp == null)
+                               temp = new byte[temp_size];
+                       temp[0] = ((byte)(value >> 16));
+                       temp[1] = ((byte)(value >> 8));
+                       temp[2] = ((byte)value);
+                       this.Write (temp, 0, 3);
+               }
+
+               public void Write(int value)
+               {
+                       if (temp == null)
+                               temp = new byte[temp_size];
+                       temp[0] = ((byte)(value >> 24));
+                       temp[1] = ((byte)(value >> 16));
+                       temp[2] = ((byte)(value >> 8));
+                       temp[3] = ((byte)value);
+                       this.Write (temp, 0, 4);
+               }
+
+               public void Write(ulong value)
+               {
+                       Write ((int)(value >> 32));
+                       Write ((int)value);
+               }
+
+               public void Write(byte[] buffer)
+               {
+                       this.Write(buffer, 0, buffer.Length);
+               }
+
+               #endregion
+
+               #region Methods
+
+               public void Reset()
+               {
+                       this.buffer.SetLength(0);
+                       this.buffer.Position = 0;
+               }
+
+               public byte[] ToArray()
+               {
+                       return this.buffer.ToArray();
+               }
+
+               #endregion
+
+               #region Stream Methods
+
+               public override void Flush()
+               {
+                       this.buffer.Flush();
+               }
+
+               public override void SetLength(long length)
+               {
+                       this.buffer.SetLength(length);
+               }
+
+               public override long Seek(long offset, System.IO.SeekOrigin loc)
+               {
+                       return this.buffer.Seek(offset, loc);
+               }
+
+               public override int Read(byte[] buffer, int offset, int count)
+               {
+                       if (this.canRead)
+                       {
+                               return this.buffer.Read(buffer, offset, count);
+                       }
+                       throw new InvalidOperationException("Read operations are not allowed by this stream");
+               }
+
+               public override void Write(byte[] buffer, int offset, int count)
+               {
+                       if (this.canWrite)
+                       {
+                               this.buffer.Write(buffer, offset, count);
+                       }
+                       else
+                       {
+                               throw new InvalidOperationException("Write operations are not allowed by this stream");
+                       }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Xml.XPath/ChangeLog b/mcs/class/System.ServiceModel/Mono.Xml.XPath/ChangeLog
new file mode 100755 (executable)
index 0000000..ea279da
--- /dev/null
@@ -0,0 +1,39 @@
+2007-07-02  Atsushi Enomoto <atsushi@ximian.com>
+
+       * DTMXPathDocumentBuilder2.cs : do not bork at non-document element
+         in XmlReader. Fixed bug #81932.
+
+2007-02-01  Atsushi Enomoto <atsushi@ximian.com>
+
+       * DTMXPathDocumentWriter2.cs : supply prefix when it was not passed.
+
+2007-02-01  Atsushi Enomoto <atsushi@ximian.com>
+
+       * DTMXPathNavigator2.cs : apply r72076 to olive too.
+
+2007-01-09  Atsushi Enomoto <atsushi@ximian.com>
+
+       * DTMXPathDocumentBuilder2.cs : fixed incorrect namespace node links
+         which happened to following siblings of a node with namespaces.
+
+2006-12-07  Atsushi Enomoto <atsushi@ximian.com>
+
+       * DTMXPathDocumentWriter2.cs : implemented several members that threw
+         NotSupportedException. Unlike inside sys.xml they could be invoked.
+
+2006-09-08  Atsushi Enomoto <atsushi@ximian.com>
+
+       * DTMXPathDocumentWriter2.cs : fill String.Empty for null ns in
+         WriteStartElement() and WriteStartAttribute().
+
+2006-08-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DTMXPathDocumentWriter2.cs : use String.Empty instead of null for
+         localName for those nodes which do not have own names.
+
+2006-08-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DTMXPathDocumentBuilder2.cs, DTMXPathNode2.cs,
+         DTMXPathNavigator2.cs, DTMXPathDocumentWriter2.cs,
+         DTMXPathDocument2.cs : initial import from System.XML and made
+         required changes to implement SeekableXPathNavigator.
diff --git a/mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathDocument2.cs b/mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathDocument2.cs
new file mode 100644 (file)
index 0000000..35f992e
--- /dev/null
@@ -0,0 +1,85 @@
+//
+// Mono.Xml.XPath.DTMXPathDocument2
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// (C) 2004 Novell Inc.
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Xml;
+using System.Xml.XPath;
+
+namespace Mono.Xml.XPath
+{
+#if OUTSIDE_SYSTEM_XML
+       public
+#else
+       internal
+#endif
+               class DTMXPathDocument2 : IXPathNavigable
+       {
+
+               public DTMXPathDocument2 (XmlNameTable nameTable,
+                       DTMXPathLinkedNode2 [] nodes,
+                       DTMXPathAttributeNode2 [] attributes,
+                       DTMXPathNamespaceNode2 [] namespaces,
+                       string [] atomicStringPool,
+                       string [] nonAtomicStringPool,
+                       Hashtable idTable)
+               {
+                       this.Nodes = nodes;
+                       this.Attributes = attributes;
+                       this.Namespaces = namespaces;
+                       this.AtomicStringPool = atomicStringPool;
+                       this.NonAtomicStringPool = nonAtomicStringPool;
+                       this.IdTable = idTable;
+                       this.NameTable = nameTable;
+
+                       root = new SeekableDTMXPathNavigator2 (this);
+               }
+
+               public XPathNavigator CreateNavigator ()
+               {
+                       return root.Clone ();
+               }
+
+               readonly XPathNavigator root;
+
+               internal readonly XmlNameTable NameTable;
+
+               internal readonly DTMXPathLinkedNode2 [] Nodes;
+               internal readonly DTMXPathAttributeNode2 [] Attributes;
+               internal readonly DTMXPathNamespaceNode2 [] Namespaces;
+
+               // String pool
+               internal readonly string [] AtomicStringPool;
+               internal readonly string [] NonAtomicStringPool;
+
+               // ID table
+               internal readonly Hashtable IdTable;
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs b/mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs
new file mode 100644 (file)
index 0000000..fd4eb7e
--- /dev/null
@@ -0,0 +1,577 @@
+//
+// Mono.Xml.XPath.DTMXPathDocumentBuilder2
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// (C)2004 Novell Inc.
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#pragma warning disable 618
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.XPath;
+
+namespace Mono.Xml.XPath
+{
+#if OUTSIDE_SYSTEM_XML
+       public
+#else
+       internal
+#endif
+       class DTMXPathDocumentBuilder2
+       {
+               public DTMXPathDocumentBuilder2 (string url)
+                       : this (url, XmlSpace.None, 200)
+               {
+               }
+
+               public DTMXPathDocumentBuilder2 (string url, XmlSpace space)
+                       : this (url, space, 200)
+               {
+               }
+
+               public DTMXPathDocumentBuilder2 (string url, XmlSpace space, int defaultCapacity)
+               {
+                       XmlReader r = null;
+                       try {
+                               r = new XmlTextReader (url);
+                               Init (r, space, defaultCapacity);
+                       } finally {
+                               if (r != null)
+                                       r.Close ();
+                       }
+               }
+
+               public DTMXPathDocumentBuilder2 (XmlReader reader)
+                       : this (reader, XmlSpace.None, 200)
+               {
+               }
+
+               public DTMXPathDocumentBuilder2 (XmlReader reader, XmlSpace space)
+                       : this (reader, space, 200)
+               {
+               }
+
+               public DTMXPathDocumentBuilder2 (XmlReader reader, XmlSpace space, int defaultCapacity)
+               {
+                       Init (reader, space, defaultCapacity);
+               }
+
+               private void Init (XmlReader reader, XmlSpace space, int defaultCapacity)
+               {
+                       this.xmlReader = reader;
+                       this.validatingReader = reader as XmlValidatingReader;
+                       lineInfo = reader as IXmlLineInfo;
+                       this.xmlSpace = space;
+                       this.nameTable = reader.NameTable;
+                       nodeCapacity = defaultCapacity;
+                       attributeCapacity = nodeCapacity;
+                       nsCapacity = 10;
+                       idTable = new Hashtable ();
+
+                       nodes = new DTMXPathLinkedNode2 [nodeCapacity];
+                       attributes = new DTMXPathAttributeNode2 [attributeCapacity];
+                       namespaces = new DTMXPathNamespaceNode2 [nsCapacity];
+                       atomicStringPool = new string [20];
+                       nonAtomicStringPool = new string [20];
+
+                       Compile ();
+               }
+               
+               XmlReader xmlReader;
+               XmlValidatingReader validatingReader;
+               XmlSpace xmlSpace;
+               XmlNameTable nameTable;
+               IXmlLineInfo lineInfo;
+               int nodeCapacity;
+               int attributeCapacity;
+               int nsCapacity;
+
+               // Linked Node
+               DTMXPathLinkedNode2 [] nodes;
+
+               // Attribute
+               DTMXPathAttributeNode2 [] attributes;
+
+               // NamespaceNode
+               DTMXPathNamespaceNode2 [] namespaces;
+
+               // String pool
+               string [] atomicStringPool;
+               int atomicIndex;
+               string [] nonAtomicStringPool;
+               int nonAtomicIndex;
+
+               // idTable [string value] -> int nodeId
+               Hashtable idTable;
+
+               int nodeIndex;
+               int attributeIndex;
+               int nsIndex;
+
+               // for attribute processing; should be reset per each element.
+               bool hasAttributes;
+               bool hasLocalNs;
+               int attrIndexAtStart;
+               int nsIndexAtStart;
+
+               int lastNsInScope;
+               bool skipRead = false;
+
+               int [] parentStack = new int [10];
+               int parentStackIndex = 0;
+
+               public DTMXPathDocument2 CreateDocument ()
+               {
+                       return new DTMXPathDocument2 (nameTable,
+                               nodes,
+                               attributes,
+                               namespaces,
+                               atomicStringPool,
+                               nonAtomicStringPool,
+                               idTable
+                       );
+               }
+
+               public void Compile ()
+               {
+                       // string pool index 0 to 3 are fixed.
+                       atomicStringPool [0] = nonAtomicStringPool [0] = "";
+                       atomicStringPool [1] = nonAtomicStringPool [1] = null;
+                       atomicStringPool [2] = nonAtomicStringPool [2] = XmlNamespaces.XML;
+                       atomicStringPool [3] = nonAtomicStringPool [3] = XmlNamespaces.XMLNS;
+                       atomicIndex = nonAtomicIndex = 4;
+
+                       // index 0 is dummy. No node (including Root) is assigned to this index
+                       // So that we can easily compare index != 0 instead of index < 0.
+                       // (Difference between jnz or jbe in 80x86.)
+                       AddNode (0, 0, 0, XPathNodeType.All, 0, false, 0, 0, 0, 0, 0, 0, 0, 0);
+                       nodeIndex++;
+                       AddAttribute (0, 0, 0, 0, 0, 0, 0);
+                       AddNsNode (0, 0, 0, 0);
+                       nsIndex++;
+                       AddNsNode (1, AtomicIndex ("xml"), AtomicIndex (XmlNamespaces.XML), 0);
+
+                       // add root.
+                       AddNode (0, 0, 0, XPathNodeType.Root, AtomicIndex (xmlReader.BaseURI), false, 0, 0, 0, 0, 0, 1, 0, 0);
+
+                       this.nodeIndex = 1;
+                       this.lastNsInScope = 1;
+                       parentStack [0] = nodeIndex;
+
+                       // LAMESPEC: it should not read more than one top-level element, but .NET sucks here. See bug #81932
+                       while (!xmlReader.EOF && parentStackIndex >= 0)
+                               Read ();
+                       SetNodeArrayLength (nodeIndex + 1);
+                       SetAttributeArrayLength (attributeIndex + 1);
+                       SetNsArrayLength (nsIndex + 1);
+
+                       string [] newArr = new string [atomicIndex];
+                       Array.Copy (atomicStringPool, newArr, atomicIndex);
+                       atomicStringPool = newArr;
+
+                       newArr = new string [nonAtomicIndex];
+                       Array.Copy (nonAtomicStringPool, newArr, nonAtomicIndex);
+                       nonAtomicStringPool = newArr;
+
+                       xmlReader = null;       // It is no more required.
+               }
+
+               public void Read ()
+               {
+                       if (!skipRead)
+                               if (!xmlReader.Read ())
+                                       return;
+                       skipRead = false;
+                       int parent = parentStack [parentStackIndex];
+                       int prevSibling = nodeIndex;
+
+                       switch (xmlReader.NodeType) {
+                       case XmlNodeType.Element:
+                       case XmlNodeType.CDATA:
+                       case XmlNodeType.SignificantWhitespace:
+                       case XmlNodeType.Comment:
+                       case XmlNodeType.Text:
+                       case XmlNodeType.ProcessingInstruction:
+                               if (parent == nodeIndex)
+                                       prevSibling = 0;
+                               else
+                                       while (nodes [prevSibling].Parent != parent)
+                                               prevSibling = nodes [prevSibling].Parent;
+
+                               nodeIndex++;
+
+                               if (prevSibling != 0)
+                                       nodes [prevSibling].NextSibling = nodeIndex;
+                               if (parentStack [parentStackIndex] == nodeIndex - 1)
+                                       nodes [parent].FirstChild = nodeIndex;
+                               break;
+                       case XmlNodeType.Whitespace:
+                               if (xmlSpace == XmlSpace.Preserve)
+                                       goto case XmlNodeType.Text;
+                               else
+                                       goto default;
+                       case XmlNodeType.EndElement:
+                               int endedNode = parentStack [parentStackIndex];
+                               AdjustLastNsInScope (endedNode);
+                               parentStackIndex--;
+                               return;
+                       default:
+                               // No operations. Doctype, EntityReference, 
+                               return;
+                       }
+
+                       string value = null;
+                       XPathNodeType nodeType = XPathNodeType.Text;
+
+                       switch (xmlReader.NodeType) {
+                       case XmlNodeType.Element:
+                               ProcessElement (parent, prevSibling);
+                               break;
+                       case XmlNodeType.SignificantWhitespace:
+                               nodeType = XPathNodeType.SignificantWhitespace;
+                               goto case XmlNodeType.Text;
+                       case XmlNodeType.Whitespace:
+                               nodeType = XPathNodeType.Whitespace;
+                               goto case XmlNodeType.Text;
+                       case XmlNodeType.CDATA:
+                       case XmlNodeType.Text:
+                               AddNode (parent,
+                                       0,
+                                       prevSibling,
+                                       nodeType,
+                                       AtomicIndex (xmlReader.BaseURI),
+                                       xmlReader.IsEmptyElement,
+                                       AtomicIndex (xmlReader.LocalName),      // for PI
+                                       AtomicIndex (xmlReader.NamespaceURI),   // for PI
+                                       AtomicIndex (xmlReader.Prefix),
+                                       value == null ? 0 : NonAtomicIndex (value),
+                                       AtomicIndex (xmlReader.XmlLang),
+                                       nsIndex,
+                                       lineInfo != null ? lineInfo.LineNumber : 0,
+                                       lineInfo != null ? lineInfo.LinePosition : 0);
+                               // this code is tricky, but after sequential
+                               // Read() invokation, xmlReader is moved to
+                               // next node.
+                               if (value == null) {
+                                       bool loop = true;
+                                       value = String.Empty;
+                                       XPathNodeType type = XPathNodeType.Whitespace;
+                                       do {
+                                               switch (xmlReader.NodeType) {
+                                               case XmlNodeType.Text:
+                                               case XmlNodeType.CDATA:
+                                                       type = XPathNodeType.Text;
+                                                       goto case XmlNodeType.Whitespace;
+                                               case XmlNodeType.SignificantWhitespace:
+                                                       if (type == XPathNodeType.Whitespace)
+                                                               type = XPathNodeType.SignificantWhitespace;
+                                                       goto case XmlNodeType.Whitespace;
+                                               case XmlNodeType.Whitespace:
+                                                       if (xmlReader.NodeType != XmlNodeType.Whitespace || xmlSpace == XmlSpace.Preserve)
+                                                               value += xmlReader.Value;
+                                                       loop = xmlReader.Read ();
+                                                       skipRead = true;
+                                                       continue;
+                                               default:
+                                                       loop = false;
+                                                       break;
+                                               }
+                                       } while (loop);
+                                       nodes [nodeIndex].Value = NonAtomicIndex (value);
+                                       nodes [nodeIndex].NodeType = type;
+                               }
+                               break;
+                       case XmlNodeType.Comment:
+                               value = xmlReader.Value;
+                               nodeType = XPathNodeType.Comment;
+                               goto case XmlNodeType.Text;
+                       case XmlNodeType.ProcessingInstruction:
+                               value = xmlReader.Value;
+                               nodeType = XPathNodeType.ProcessingInstruction;
+                               goto case XmlNodeType.Text;
+                       }
+               }
+
+               private void ProcessElement (int parent, int previousSibling)
+               {
+                       WriteStartElement (parent, previousSibling);
+
+                       // process namespaces and attributes.
+                       if (xmlReader.MoveToFirstAttribute ()) {
+                               do {
+                                       string prefix = xmlReader.Prefix;
+                                       string ns = xmlReader.NamespaceURI;
+                                       if (ns == XmlNamespaces.XMLNS)
+                                               ProcessNamespace ((prefix == null || prefix == String.Empty) ? "" : xmlReader.LocalName, xmlReader.Value);
+                                       else
+                                               ProcessAttribute (prefix, xmlReader.LocalName, ns, xmlReader.Value);
+
+                               } while (xmlReader.MoveToNextAttribute ());
+                               xmlReader.MoveToElement ();
+                       }
+
+                       CloseStartElement ();
+               }
+
+               private void PrepareStartElement (int previousSibling)
+               {
+                       hasAttributes = false;
+                       hasLocalNs = false;
+                       attrIndexAtStart = attributeIndex;
+                       nsIndexAtStart = nsIndex;
+                       AdjustLastNsInScope (previousSibling);
+               }
+
+               private void AdjustLastNsInScope (int target)
+               {
+                       while (namespaces [lastNsInScope].DeclaredElement == target) {
+                               lastNsInScope = namespaces [lastNsInScope].NextNamespace;
+                       }
+               }
+
+               private void WriteStartElement (int parent, int previousSibling)
+               {
+                       PrepareStartElement (previousSibling);
+
+                       AddNode (parent,
+                               0, // dummy:firstAttribute
+                               previousSibling,
+                               XPathNodeType.Element,
+                               AtomicIndex (xmlReader.BaseURI),
+                               xmlReader.IsEmptyElement,
+                               AtomicIndex (xmlReader.LocalName),
+                               AtomicIndex (xmlReader.NamespaceURI),
+                               AtomicIndex (xmlReader.Prefix),
+                               0,      // Element has no internal value.
+                               AtomicIndex (xmlReader.XmlLang),
+                               lastNsInScope,
+                               lineInfo != null ? lineInfo.LineNumber : 0,
+                               lineInfo != null ? lineInfo.LinePosition : 0);
+
+               }
+
+               private void CloseStartElement ()
+               {
+                       if (attrIndexAtStart != attributeIndex)
+                               nodes [nodeIndex].FirstAttribute = attrIndexAtStart + 1;
+                       if (nsIndexAtStart != nsIndex) {
+                               nodes [nodeIndex].FirstNamespace = nsIndex;
+                               if (!xmlReader.IsEmptyElement)
+                                       lastNsInScope = nsIndex;
+                       }
+
+                       if (!nodes [nodeIndex].IsEmptyElement) {
+                               parentStackIndex++;
+                               if (parentStack.Length == parentStackIndex) {
+                                       int [] tmp = new int [parentStackIndex * 2];
+                                       Array.Copy (parentStack, tmp, parentStackIndex);
+                                       parentStack = tmp;
+                               }
+                               parentStack [parentStackIndex] = nodeIndex;
+                       }
+               }
+
+               private void ProcessNamespace (string prefix, string ns)
+               {
+                       int nextTmp = hasLocalNs ?
+                               nsIndex : nodes [nodeIndex].FirstNamespace;
+
+                       nsIndex++;
+
+                       this.AddNsNode (nodeIndex,
+                               AtomicIndex (prefix),
+                               AtomicIndex (ns),
+                               nextTmp);
+                       hasLocalNs = true;
+               }
+
+               private void ProcessAttribute (string prefix, string localName, string ns, string value)
+               {
+                       attributeIndex ++;
+
+                       this.AddAttribute (nodeIndex,
+                               AtomicIndex (localName),
+                               AtomicIndex (ns), 
+                               prefix != null ? AtomicIndex (prefix) : 0, 
+                               NonAtomicIndex (value),
+                               lineInfo != null ? lineInfo.LineNumber : 0,
+                               lineInfo != null ? lineInfo.LinePosition : 0);
+                       if (hasAttributes)
+                               attributes [attributeIndex - 1].NextAttribute = attributeIndex;
+                       else
+                               hasAttributes = true;
+
+                       // Identity infoset
+                       if (validatingReader != null) {
+                               XmlSchemaDatatype dt = validatingReader.SchemaType as XmlSchemaDatatype;
+                               if (dt == null) {
+                                       XmlSchemaType xsType = validatingReader.SchemaType as XmlSchemaType;
+                                       if (xsType != null)
+                                               dt = xsType.Datatype;
+                               }
+                               if (dt != null && dt.TokenizedType == XmlTokenizedType.ID)
+                                       idTable.Add (value, nodeIndex);
+                       }
+               }
+
+               private int AtomicIndex (string s)
+               {
+                       if (s == "")
+                               return 0;
+                       if (s == null)
+                               return 1;
+                       int i = 2;
+                       for (; i < atomicIndex; i++)
+                               if (Object.ReferenceEquals (s, atomicStringPool [i]))
+                                       return i;
+
+                       if (atomicIndex == atomicStringPool.Length) {
+                               string [] newArr = new string [atomicIndex * 2];
+                               Array.Copy (atomicStringPool, newArr, atomicIndex);
+                               atomicStringPool = newArr;
+                       }
+                       atomicStringPool [atomicIndex] = s;
+                       return atomicIndex++;
+               }
+
+               private int NonAtomicIndex (string s)
+               {
+                       if (s == "")
+                               return 0;
+                       if (s == null)
+                               return 1;
+                       int i = 2;
+
+                       // Here we don't compare all the entries (sometimes it
+                       // goes extremely slow).
+                       int max = nonAtomicIndex < 100 ? nonAtomicIndex : 100;
+                       for (; i < max; i++)
+                               if (s == nonAtomicStringPool [i])
+                                       return i;
+
+                       if (nonAtomicIndex == nonAtomicStringPool.Length) {
+                               string [] newArr = new string [nonAtomicIndex * 2];
+                               Array.Copy (nonAtomicStringPool, newArr, nonAtomicIndex);
+                               nonAtomicStringPool = newArr;
+                       }
+                       nonAtomicStringPool [nonAtomicIndex] = s;
+                       return nonAtomicIndex++;
+               }
+
+               private void SetNodeArrayLength (int size)
+               {
+                       DTMXPathLinkedNode2 [] newArr = new DTMXPathLinkedNode2 [size];
+                       Array.Copy (nodes, newArr, System.Math.Min (size, nodes.Length));
+                       nodes = newArr;
+               }
+
+               private void SetAttributeArrayLength (int size)
+               {
+                       DTMXPathAttributeNode2 [] newArr = 
+                               new DTMXPathAttributeNode2 [size];
+                       Array.Copy (attributes, newArr, System.Math.Min (size, attributes.Length));
+                       attributes = newArr;
+               }
+
+               private void SetNsArrayLength (int size)
+               {
+                       DTMXPathNamespaceNode2 [] newArr =
+                               new DTMXPathNamespaceNode2 [size];
+                       Array.Copy (namespaces, newArr, System.Math.Min (size, namespaces.Length));
+                       namespaces = newArr;
+               }
+
+               // Here followings are skipped: firstChild, nextSibling, 
+               public void AddNode (int parent, int firstAttribute, int previousSibling, XPathNodeType nodeType, int baseUri, bool isEmptyElement, int localName, int ns, int prefix, int value, int xmlLang, int namespaceNode, int lineNumber, int linePosition)
+               {
+                       if (nodes.Length < nodeIndex + 1) {
+                               nodeCapacity *= 4;
+                               SetNodeArrayLength (nodeCapacity);
+                       }
+
+#if DTM_CLASS
+                       nodes [nodeIndex] = new DTMXPathLinkedNode2 ();
+#endif
+                       nodes [nodeIndex].FirstChild = 0;               // dummy
+                       nodes [nodeIndex].Parent = parent;
+                       nodes [nodeIndex].FirstAttribute = firstAttribute;
+                       nodes [nodeIndex].PreviousSibling = previousSibling;
+                       nodes [nodeIndex].NextSibling = 0;      // dummy
+                       nodes [nodeIndex].NodeType = nodeType;
+                       nodes [nodeIndex].BaseURI = baseUri;
+                       nodes [nodeIndex].IsEmptyElement = isEmptyElement;
+                       nodes [nodeIndex].LocalName = localName;
+                       nodes [nodeIndex].NamespaceURI = ns;
+                       nodes [nodeIndex].Prefix = prefix;
+                       nodes [nodeIndex].Value = value;
+                       nodes [nodeIndex].XmlLang = xmlLang;
+                       nodes [nodeIndex].FirstNamespace = namespaceNode;
+                       nodes [nodeIndex].LineNumber = lineNumber;
+                       nodes [nodeIndex].LinePosition = linePosition;
+               }
+
+               // Followings are skipped: nextAttribute,
+               public void AddAttribute (int ownerElement, int localName, int ns, int prefix, int value, int lineNumber, int linePosition)
+               {
+                       if (attributes.Length < attributeIndex + 1) {
+                               attributeCapacity *= 4;
+                               SetAttributeArrayLength (attributeCapacity);
+                       }
+
+#if DTM_CLASS
+                       attributes [attributeIndex] = new DTMXPathAttributeNode2 ();
+#endif
+                       attributes [attributeIndex].OwnerElement = ownerElement;
+                       attributes [attributeIndex].LocalName = localName;
+                       attributes [attributeIndex].NamespaceURI = ns;
+                       attributes [attributeIndex].Prefix = prefix;
+                       attributes [attributeIndex].Value = value;
+                       attributes [attributeIndex].LineNumber = lineNumber;
+                       attributes [attributeIndex].LinePosition = linePosition;
+               }
+
+               // Followings are skipped: nextNsNode (may be next attribute in the same element, or ancestors' nsNode)
+               public void AddNsNode (int declaredElement, int name, int ns, int nextNs)
+               {
+                       if (namespaces.Length < nsIndex + 1) {
+                               nsCapacity *= 4;
+                               SetNsArrayLength (nsCapacity);
+                       }
+
+#if DTM_CLASS
+                       namespaces [nsIndex] = new DTMXPathNamespaceNode2 ();
+#endif
+                       namespaces [nsIndex].DeclaredElement = declaredElement;
+                       namespaces [nsIndex].Name = name;
+                       namespaces [nsIndex].Namespace = ns;
+                       namespaces [nsIndex].NextNamespace = nextNs;
+               }
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathDocumentWriter2.cs b/mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathDocumentWriter2.cs
new file mode 100644 (file)
index 0000000..a496dfa
--- /dev/null
@@ -0,0 +1,770 @@
+//
+// Mono.Xml.XPath.DTMXPathDocumentWriter2
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// (C) 2004 Novell Inc.
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.IO;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.XPath;
+
+namespace Mono.Xml.XPath
+{
+#if OUTSIDE_SYSTEM_XML
+       public
+#else
+       internal
+#endif
+               class DTMXPathDocumentWriter2 : XmlWriter
+       {
+               public DTMXPathDocumentWriter2 (XmlNameTable nt, int defaultCapacity)
+               {
+                       nameTable = nt == null ? new NameTable () : nt;
+                       nodeCapacity = defaultCapacity;
+                       attributeCapacity = nodeCapacity;
+                       nsCapacity = 10;
+                       idTable = new Hashtable ();
+
+                       nodes = new DTMXPathLinkedNode2 [nodeCapacity];
+                       attributes = new DTMXPathAttributeNode2 [attributeCapacity];
+                       namespaces = new DTMXPathNamespaceNode2 [nsCapacity];
+
+                       atomicStringPool = new string [20];
+                       nonAtomicStringPool = new string [20];
+
+                       Init ();
+               }
+               
+               XmlNameTable nameTable;
+               int nodeCapacity;
+               int attributeCapacity;
+               int nsCapacity;
+
+               // Linked Node
+               DTMXPathLinkedNode2 [] nodes;
+
+               // Attribute
+               DTMXPathAttributeNode2 [] attributes;
+
+               // NamespaceNode
+               DTMXPathNamespaceNode2 [] namespaces;
+
+               // String pool
+               string [] atomicStringPool;
+               int atomicIndex;
+               string [] nonAtomicStringPool;
+               int nonAtomicIndex;
+
+               // idTable [string value] -> int nodeId
+               Hashtable idTable;
+
+               int nodeIndex;
+               int attributeIndex;
+               int nsIndex;
+               int [] parentStack = new int [10];
+               int parentStackIndex = 0;
+
+               // for attribute processing; should be reset per each element.
+               bool hasAttributes;
+               bool hasLocalNs;
+               int attrIndexAtStart;
+               int nsIndexAtStart;
+
+               int lastNsInScope;
+
+               // They are only used in Writer
+               int prevSibling;
+               WriteState state;
+               bool openNamespace;
+               bool isClosed;
+
+               public DTMXPathDocument2 CreateDocument ()
+               {
+                       if (!isClosed)
+                               Close ();
+                       return new DTMXPathDocument2 (nameTable,
+                               nodes,
+                               attributes,
+                               namespaces,
+                               atomicStringPool,
+                               nonAtomicStringPool,
+                               idTable
+                       );
+               }
+
+               public void Init ()
+               {
+                       // string pool index 0 to 3 are fixed.
+                       atomicStringPool [0] = nonAtomicStringPool [0] = "";
+                       atomicStringPool [1] = nonAtomicStringPool [1] = null;
+                       atomicStringPool [2] = nonAtomicStringPool [2] = XmlNamespaces.XML;
+                       atomicStringPool [3] = nonAtomicStringPool [3] = XmlNamespaces.XMLNS;
+                       atomicIndex = nonAtomicIndex = 4;
+
+                       // index 0 is dummy. No node (including Root) is assigned to this index
+                       // So that we can easily compare index != 0 instead of index < 0.
+                       // (Difference between jnz or jbe in 80x86.)
+                       AddNode (0, 0, 0, XPathNodeType.All, "", false, "", "", "", "", "", 0, 0, 0);
+                       nodeIndex++;
+                       AddAttribute (0, "", "", "", "", 0, 0);
+                       AddNsNode (0, "", "", 0);
+                       nsIndex++;
+                       AddNsNode (1, "xml", XmlNamespaces.XML, 0);
+
+                       // add root.
+                       AddNode (0, 0, 0, XPathNodeType.Root, "", false, "", "", "", "", "", 1, 0, 0);
+
+                       this.nodeIndex = 1;
+                       this.lastNsInScope = 1;
+                       parentStack [0] = nodeIndex;
+
+                       state = WriteState.Content;
+               }
+
+               private int GetParentIndex ()
+               {
+                       return parentStack [parentStackIndex];
+               }
+
+               private int GetPreviousSiblingIndex ()
+               {
+                       int parent = parentStack [parentStackIndex];
+                       if (parent == nodeIndex)
+                               return 0;
+                       int prevSibling = nodeIndex;
+                       while (nodes [prevSibling].Parent != parent)
+                               prevSibling = nodes [prevSibling].Parent;
+                       return prevSibling;
+               }
+
+               private void UpdateTreeForAddition ()
+               {
+                       int parent = GetParentIndex ();
+                       prevSibling = GetPreviousSiblingIndex ();
+
+                       nodeIndex++;
+
+                       if (prevSibling != 0)
+                               nodes [prevSibling].NextSibling = nodeIndex;
+                       if (parent == nodeIndex - 1)
+                               nodes [parent].FirstChild = nodeIndex;
+               }
+
+               private void CloseStartElement ()
+               {
+                       if (attrIndexAtStart != attributeIndex)
+                               nodes [nodeIndex].FirstAttribute = attrIndexAtStart + 1;
+                       if (nsIndexAtStart != nsIndex) {
+                               nodes [nodeIndex].FirstNamespace = nsIndex;
+                               lastNsInScope = nsIndex;
+                       }
+
+                       parentStackIndex++;
+                       if (parentStack.Length == parentStackIndex) {
+                               int [] tmp = new int [parentStackIndex * 2];
+                               Array.Copy (parentStack, tmp, parentStackIndex);
+                               parentStack = tmp;
+                       }
+                       parentStack [parentStackIndex] = nodeIndex;
+
+                       state = WriteState.Content;
+               }
+
+               #region Adding Nodes
+
+               private int AtomicIndex (string s)
+               {
+                       if (s == "")
+                               return 0;
+                       if (s == null)
+                               return 1;
+                       int i = 2;
+                       for (; i < atomicIndex; i++)
+                               if (Object.ReferenceEquals (s, atomicStringPool [i]))
+                                       return i;
+
+                       if (atomicIndex == atomicStringPool.Length) {
+                               string [] newArr = new string [atomicIndex * 2];
+                               Array.Copy (atomicStringPool, newArr, atomicIndex);
+                               atomicStringPool = newArr;
+                       }
+                       atomicStringPool [atomicIndex] = s;
+                       return atomicIndex++;
+               }
+
+               private int NonAtomicIndex (string s)
+               {
+                       if (s == "")
+                               return 0;
+                       if (s == null)
+                               return 1;
+                       int i = 2;
+
+                       // Here we don't compare all the entries (sometimes it
+                       // goes extremely slow).
+                       int max = nonAtomicIndex < 100 ? nonAtomicIndex : 100;
+                       for (; i < max; i++)
+                               if (s == nonAtomicStringPool [i])
+                                       return i;
+
+                       if (nonAtomicIndex == nonAtomicStringPool.Length) {
+                               string [] newArr = new string [nonAtomicIndex * 2];
+                               Array.Copy (nonAtomicStringPool, newArr, nonAtomicIndex);
+                               nonAtomicStringPool = newArr;
+                       }
+                       nonAtomicStringPool [nonAtomicIndex] = s;
+                       return nonAtomicIndex++;
+               }
+
+               private void SetNodeArrayLength (int size)
+               {
+                       DTMXPathLinkedNode2 [] newArr = new DTMXPathLinkedNode2 [size];
+                       Array.Copy (nodes, newArr, System.Math.Min (size, nodes.Length));
+                       nodes = newArr;
+               }
+
+               private void SetAttributeArrayLength (int size)
+               {
+                       DTMXPathAttributeNode2 [] newArr = 
+                               new DTMXPathAttributeNode2 [size];
+                       Array.Copy (attributes, newArr, System.Math.Min (size, attributes.Length));
+                       attributes = newArr;
+               }
+
+               private void SetNsArrayLength (int size)
+               {
+                       DTMXPathNamespaceNode2 [] newArr =
+                               new DTMXPathNamespaceNode2 [size];
+                       Array.Copy (namespaces, newArr, System.Math.Min (size, namespaces.Length));
+                       namespaces = newArr;
+               }
+
+               // Here followings are skipped: firstChild, nextSibling, 
+               public void AddNode (int parent, int firstAttribute, int previousSibling, XPathNodeType nodeType, string baseUri, bool isEmptyElement, string localName, string ns, string prefix, string value, string xmlLang, int namespaceNode, int lineNumber, int linePosition)
+               {
+                       if (nodes.Length < nodeIndex + 1) {
+                               nodeCapacity *= 4;
+                               SetNodeArrayLength (nodeCapacity);
+                       }
+
+#if DTM_CLASS
+                       nodes [nodeIndex] = new DTMXPathLinkedNode2 ();
+#endif
+                       nodes [nodeIndex].FirstChild = 0;               // dummy
+                       nodes [nodeIndex].Parent = parent;
+                       nodes [nodeIndex].FirstAttribute = firstAttribute;
+                       nodes [nodeIndex].PreviousSibling = previousSibling;
+                       nodes [nodeIndex].NextSibling = 0;      // dummy
+                       nodes [nodeIndex].NodeType = nodeType;
+                       nodes [nodeIndex].BaseURI = AtomicIndex (baseUri);
+                       nodes [nodeIndex].IsEmptyElement = isEmptyElement;
+                       nodes [nodeIndex].LocalName = AtomicIndex (localName);
+                       nodes [nodeIndex].NamespaceURI = AtomicIndex (ns);
+                       nodes [nodeIndex].Prefix = AtomicIndex (prefix);
+                       nodes [nodeIndex].Value = NonAtomicIndex (value);
+                       nodes [nodeIndex].XmlLang = AtomicIndex (xmlLang);
+                       nodes [nodeIndex].FirstNamespace = namespaceNode;
+                       nodes [nodeIndex].LineNumber = lineNumber;
+                       nodes [nodeIndex].LinePosition = linePosition;
+               }
+
+               // Followings are skipped: nextAttribute,
+               public void AddAttribute (int ownerElement, string localName, string ns, string prefix, string value, int lineNumber, int linePosition)
+               {
+                       if (attributes.Length < attributeIndex + 1) {
+                               attributeCapacity *= 4;
+                               SetAttributeArrayLength (attributeCapacity);
+                       }
+
+#if DTM_CLASS
+                       attributes [attributeIndex] = new DTMXPathAttributeNode2 ();
+#endif
+                       attributes [attributeIndex].OwnerElement = ownerElement;
+                       attributes [attributeIndex].LocalName = AtomicIndex (localName);
+                       attributes [attributeIndex].NamespaceURI = AtomicIndex (ns);
+                       attributes [attributeIndex].Prefix = AtomicIndex (prefix);
+                       attributes [attributeIndex].Value = NonAtomicIndex (value);
+                       attributes [attributeIndex].LineNumber = lineNumber;
+                       attributes [attributeIndex].LinePosition = linePosition;
+               }
+
+               // Followings are skipped: nextNsNode (may be next attribute in the same element, or ancestors' nsNode)
+               public void AddNsNode (int declaredElement, string name, string ns, int nextNs)
+               {
+                       if (namespaces.Length < nsIndex + 1) {
+                               nsCapacity *= 4;
+                               SetNsArrayLength (nsCapacity);
+                       }
+
+#if DTM_CLASS
+                       namespaces [nsIndex] = new DTMXPathNamespaceNode2 ();
+#endif
+                       namespaces [nsIndex].DeclaredElement = declaredElement;
+                       namespaces [nsIndex].Name = AtomicIndex (name);
+                       namespaces [nsIndex].Namespace = AtomicIndex (ns);
+                       namespaces [nsIndex].NextNamespace = nextNs;
+               }
+               #endregion
+
+               #region XmlWriter methods
+               // They are not supported
+               public override string XmlLang { get { return null; } }
+               public override XmlSpace XmlSpace { get { return XmlSpace.None; } }
+
+               public override WriteState WriteState { get { return state; } }
+
+               public override void Close ()
+               {
+                       // Fixup arrays
+                       SetNodeArrayLength (nodeIndex + 1);
+                       SetAttributeArrayLength (attributeIndex + 1);
+                       SetNsArrayLength (nsIndex + 1);
+
+                       string [] newArr = new string [atomicIndex];
+                       Array.Copy (atomicStringPool, newArr, atomicIndex);
+                       atomicStringPool = newArr;
+
+                       newArr = new string [nonAtomicIndex];
+                       Array.Copy (nonAtomicStringPool, newArr, nonAtomicIndex);
+                       nonAtomicStringPool = newArr;
+
+                       isClosed = true;
+               }
+
+               public override void Flush ()
+               {
+                       // do nothing
+               }
+
+               public override string LookupPrefix (string ns)
+               {
+                       int tmp = nsIndex;
+                       while (tmp != 0) {
+                               if (atomicStringPool [namespaces [tmp].Namespace] == ns)
+                                       return atomicStringPool [namespaces [tmp].Name];
+                               tmp = namespaces [tmp].NextNamespace;
+                       }
+                       return null;
+               }
+
+               public override void WriteCData (string data)
+               {
+                       AddTextNode (data);
+               }
+
+               private void AddTextNode (string data)
+               {
+                       switch (state) {
+                       case WriteState.Element:
+                               CloseStartElement ();
+                               break;
+                       case WriteState.Content:
+                               break;
+                       default:
+                               throw new InvalidOperationException ("Invalid document state for CDATA section: " + state);
+                       }
+
+                       // When text after text, just add the value, and return.
+                       if (nodes [nodeIndex].Parent == parentStack [parentStackIndex]) {
+                               switch (nodes [nodeIndex].NodeType) {
+                               case XPathNodeType.Text:
+                               case XPathNodeType.SignificantWhitespace:
+                                       string value = nonAtomicStringPool [nodes [nodeIndex].Value] + data;
+                                       nodes [nodeIndex].Value = NonAtomicIndex (value);
+                                       if (IsWhitespace (value))
+                                               nodes [nodeIndex].NodeType = XPathNodeType.SignificantWhitespace;
+                                       else
+                                               nodes [nodeIndex].NodeType = XPathNodeType.Text;
+                                       return;
+                               }
+                       }
+
+                       int parent = GetParentIndex ();
+                       UpdateTreeForAddition ();
+
+                       AddNode (parent,
+                               0, // attribute
+                               prevSibling,
+                               XPathNodeType.Text,
+                               null,
+                               false,
+                               String.Empty,
+                               String.Empty,
+                               String.Empty,
+                               data,
+                               null,
+                               0, // nsIndex
+                               0, // line info
+                               0);
+               }
+
+               private void CheckTopLevelNode ()
+               {
+                       switch (state) {
+                       case WriteState.Element:
+                               CloseStartElement ();
+                               break;
+                       case WriteState.Content:
+                       case WriteState.Prolog:
+                       case WriteState.Start:
+                               break;
+                       default:
+                               throw new InvalidOperationException ("Invalid document state for CDATA section: " + state);
+                       }
+               }
+
+               public override void WriteComment (string data)
+               {
+                       CheckTopLevelNode ();
+
+                       int parent = GetParentIndex ();
+                       UpdateTreeForAddition ();
+
+                       AddNode (parent,
+                               0, // attribute
+                               prevSibling,
+                               XPathNodeType.Comment,
+                               null,
+                               false,
+                               String.Empty,
+                               String.Empty,
+                               String.Empty,
+                               data,
+                               null,
+                               0, // nsIndex
+                               0, // line info
+                               0);
+               }
+
+               public override void WriteProcessingInstruction (string name, string data)
+               {
+                       CheckTopLevelNode ();
+
+                       int parent = GetParentIndex ();
+                       UpdateTreeForAddition ();
+
+                       AddNode (parent,
+                               0, // attribute
+                               prevSibling,
+                               XPathNodeType.ProcessingInstruction,
+                               null,
+                               false,
+                               name,
+                               String.Empty,
+                               String.Empty,
+                               data,
+                               null,
+                               0, // nsIndex
+                               0, // line info
+                               0);
+               }
+
+               public override void WriteWhitespace (string data)
+               {
+                       CheckTopLevelNode ();
+
+                       int parent = GetParentIndex ();
+                       UpdateTreeForAddition ();
+
+                       AddNode (parent,
+                               0, // attribute
+                               prevSibling,
+                               XPathNodeType.Whitespace,
+                               null,
+                               false,
+                               String.Empty,
+                               String.Empty,
+                               String.Empty,
+                               data,
+                               null,
+                               0, // nsIndex
+                               0, // line info
+                               0);
+               }
+
+               public override void WriteStartDocument ()
+               {
+                       // do nothing
+               }
+
+               public override void WriteStartDocument (bool standalone)
+               {
+                       // do nothing
+               }
+
+               public override void WriteEndDocument ()
+               {
+                       // do nothing
+               }
+
+               public override void WriteStartElement (string prefix, string localName, string ns)
+               {
+                       if (ns == null)
+                               ns = String.Empty;
+                       else if (prefix == null && ns.Length > 0)
+                               prefix = LookupPrefix (ns);
+                       if (prefix == null)
+                               prefix = String.Empty;
+
+                       switch (state) {
+                       case WriteState.Element:
+                               CloseStartElement ();
+                               break;
+                       case WriteState.Start:
+                       case WriteState.Prolog:
+                       case WriteState.Content:
+                               break;
+                       default:
+                               throw new InvalidOperationException ("Invalid document state for writing element: " + state);
+                       }
+
+                       int parent = GetParentIndex ();
+                       UpdateTreeForAddition ();
+
+                       WriteStartElement (parent, prevSibling, prefix, localName, ns);
+                       state = WriteState.Element;
+               }
+
+               private void WriteStartElement (int parent, int previousSibling, string prefix, string localName, string ns)
+               {
+                       PrepareStartElement (previousSibling);
+
+                       AddNode (parent,
+                               0, // dummy:firstAttribute
+                               previousSibling,
+                               XPathNodeType.Element,
+                               null,
+                               false,
+                               localName,
+                               ns,
+                               prefix,
+                               "",     // Element has no internal value.
+                               null,
+                               lastNsInScope,
+                               0,
+                               0);
+               }
+
+               private void PrepareStartElement (int previousSibling)
+               {
+                       hasAttributes = false;
+                       hasLocalNs = false;
+                       attrIndexAtStart = attributeIndex;
+                       nsIndexAtStart = nsIndex;
+
+                       while (namespaces [lastNsInScope].DeclaredElement == previousSibling) {
+                               lastNsInScope = namespaces [lastNsInScope].NextNamespace;
+                       }
+               }
+
+               public override void WriteEndElement ()
+               {
+                       WriteEndElement (false);
+               }
+
+               public override void WriteFullEndElement ()
+               {
+                       WriteEndElement (true);
+               }
+
+               private void WriteEndElement (bool full)
+               {
+                       switch (state) {
+                       case WriteState.Element:
+                               CloseStartElement ();
+                               break;
+                       case WriteState.Content:
+                               break;
+                       default:
+                               throw new InvalidOperationException ("Invalid state for writing EndElement: " + state);
+                       }
+                       parentStackIndex--;
+                       if (nodes [nodeIndex].NodeType == XPathNodeType.Element) {
+                               if (!full)
+                                       nodes [nodeIndex].IsEmptyElement = true;
+                       }
+               }
+
+               public override void WriteStartAttribute (string prefix, string localName, string ns)
+               {
+                       if (ns == null)
+                               ns = String.Empty;
+
+                       if (state != WriteState.Element)
+                               throw new InvalidOperationException ("Invalid document state for attribute: " + state);
+
+                       state = WriteState.Attribute;
+                       if (ns == XmlNamespaces.XMLNS)
+                               ProcessNamespace ((prefix == null || prefix == String.Empty) ? "" : localName, String.Empty); // dummy: Value should be completed
+                       else
+                               ProcessAttribute (prefix, localName, ns, String.Empty); // dummy: Value should be completed
+               }
+
+               private void ProcessNamespace (string prefix, string ns)
+               {
+                       int nextTmp = hasLocalNs ? nsIndex : nodes [nodeIndex].FirstNamespace;
+
+                       nsIndex++;
+
+                       this.AddNsNode (nodeIndex,
+                               prefix,
+                               ns,
+                               nextTmp);
+                       hasLocalNs = true;
+                       openNamespace = true;
+               }
+
+               private void ProcessAttribute (string prefix, string localName, string ns, string value)
+               {
+                       if (prefix == null && ns.Length > 0)
+                               prefix = LookupPrefix (ns);
+                       attributeIndex ++;
+
+                       this.AddAttribute (nodeIndex,
+                               localName,
+                               ns, 
+                               prefix != null ? prefix : String.Empty, 
+                               value,
+                               0,
+                               0);
+                       if (hasAttributes)
+                               attributes [attributeIndex - 1].NextAttribute = attributeIndex;
+                       else
+                               hasAttributes = true;
+               }
+
+               public override void WriteEndAttribute ()
+               {
+                       if (state != WriteState.Attribute)
+                               throw new InvalidOperationException ();
+
+                       openNamespace = false;
+                       state = WriteState.Element;
+               }
+
+               public override void WriteString (string text)
+               {
+                       if (WriteState == WriteState.Attribute) {
+                               if (openNamespace) {
+                                       string value = atomicStringPool [namespaces [nsIndex].Namespace] + text;
+                                       namespaces [nsIndex].Namespace = AtomicIndex (value);
+                               } else {
+                                       string value = nonAtomicStringPool [attributes [attributeIndex].Value] + text;
+                                       attributes [attributeIndex].Value = NonAtomicIndex (value);
+                               }
+                       }
+                       else
+                               AddTextNode (text);
+               }
+
+               // Well, they cannot be supported, but actually used to
+               // disable-output-escaping = "true"
+               public override void WriteRaw (string data)
+               {
+                       WriteString (data);
+               }
+
+               public override void WriteRaw (char [] data, int start, int len)
+               {
+                       WriteString (new string (data, start, len));
+               }
+
+               public override void WriteName (string name)
+               {
+                       WriteString (name);
+               }
+
+               public override void WriteNmToken (string name)
+               {
+                       WriteString (name);
+               }
+
+               public override void WriteBase64 (byte [] buffer, int index, int count)
+               {
+                       WriteString (Convert.ToBase64String (buffer, index, count));
+               }
+
+               public override void WriteBinHex (byte [] buffer, int index, int count)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override void WriteChars (char [] buffer, int index, int count)
+               {
+                       WriteString (new string (buffer, index, count));
+               }
+
+               public override void WriteCharEntity (char c)
+               {
+                       WriteString (c.ToString ());
+               }
+
+               public override void WriteDocType (string name, string pub, string sys, string intSubset)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override void WriteEntityRef (string name)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override void WriteQualifiedName (string localName, string ns)
+               {
+                       string prefix = (ns == null || ns.Length == 0) ? null : LookupPrefix (ns);
+                       if (prefix != null && prefix.Length > 0)
+                               WriteString (prefix + ":" + localName);
+                       else
+                               WriteString (localName);
+               }
+
+               public override void WriteSurrogateCharEntity (char high, char low)
+               {
+                       WriteString (high.ToString ());
+                       WriteString (low.ToString ());
+               }
+
+               private bool IsWhitespace (string data)
+               {
+                       for (int i = 0; i < data.Length; i++) {
+                               switch (data [i]) {
+                               case ' ':
+                               case '\r':
+                               case '\n':
+                               case '\t':
+                                       continue;
+                               default:
+                                       return false;
+                               }
+                       }
+                       return true;
+               }
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathNavigator2.cs b/mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathNavigator2.cs
new file mode 100644 (file)
index 0000000..df60874
--- /dev/null
@@ -0,0 +1,713 @@
+//
+// Mono.Xml.XPath.DTMXPathNavigator2
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// (C) 2004 Novell Inc.
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.XPath;
+using System.ServiceModel.Dispatcher;
+
+namespace Mono.Xml.XPath
+{
+#if OUTSIDE_SYSTEM_XML
+       public
+#else
+       internal
+#endif
+               class SeekableDTMXPathNavigator2 : SeekableXPathNavigator, IXmlLineInfo
+       {
+
+               public SeekableDTMXPathNavigator2 (DTMXPathDocument2 document)
+               {
+                       this.MoveToRoot ();
+                       this.document = document;
+               }
+
+               // Copy constructor including position informations.
+               public SeekableDTMXPathNavigator2 (SeekableDTMXPathNavigator2 org)
+               {
+                       document = org.document;
+                       currentIsNode = org.currentIsNode;
+                       currentIsAttr = org.currentIsAttr;
+
+                       currentNode = org.currentNode;
+                       currentAttr = org.currentAttr;
+                       currentNs = org.currentNs;
+               }
+
+               #region SeekableXPathNavigator members
+
+               public override long CurrentPosition {
+                       get { return currentIsNode ? currentNode : currentIsAttr ? nodes.Length + currentAttr : nodes.Length + attributes.Length + currentNs; }
+                       set {
+                               int pos = (int) value;
+                               if (pos < nodes.Length) {
+                                       currentIsAttr = false;
+                                       currentIsNode = true;
+                                       currentNode = pos;
+                               } else if (pos < nodes.Length + attributes.Length) {
+                                       currentIsAttr = true;
+                                       currentIsNode = false;
+                                       currentAttr = pos - nodes.Length;
+                               } else if (pos < nodes.Length + attributes.Length + namespaces.Length) {
+                                       currentIsAttr = false;
+                                       currentIsNode = false;
+                                       currentNs = pos - nodes.Length - attributes.Length;
+                               } else
+                                       throw new ArgumentOutOfRangeException ();
+                       }
+               }
+
+               public override XPathNodeType GetNodeType (long nodePosition)
+               {
+                       return
+                               nodePosition < nodes.Length ? nodes [nodePosition].NodeType :
+                               nodePosition < nodes.Length + attributes.Length ? XPathNodeType.Attribute :
+                               XPathNodeType.Namespace;
+               }
+
+               public override string GetLocalName (long nodePosition)
+               {
+                       switch (GetNodeType (nodePosition)) {
+                       case XPathNodeType.Namespace:
+                               return atomicStringPool [namespaces [nodePosition - nodes.Length - attributes.Length].Name];
+                       case XPathNodeType.Attribute:
+                               return atomicStringPool [attributes [nodePosition - nodes.Length].LocalName];
+                       default:
+                               return atomicStringPool [nodes [nodePosition].LocalName];
+                       }
+               }
+
+               public override string GetName (long nodePosition)
+               {
+                       switch (GetNodeType (nodePosition)) {
+                       case XPathNodeType.Namespace:
+                               return atomicStringPool [namespaces [nodePosition - nodes.Length - attributes.Length].Name];
+                       case XPathNodeType.Attribute:
+                               return atomicStringPool [attributes [nodePosition - nodes.Length].LocalName];
+                       default:
+                               return atomicStringPool [nodes [nodePosition].LocalName];
+                       }
+               }
+
+               public override string GetNamespace (long nodePosition)
+               {
+                       switch (GetNodeType (nodePosition)) {
+                       case XPathNodeType.Namespace:
+                               return atomicStringPool [namespaces [nodePosition - nodes.Length - attributes.Length].Namespace];
+                       case XPathNodeType.Attribute:
+                               return atomicStringPool [attributes [nodePosition - nodes.Length].NamespaceURI];
+                       default:
+                               return atomicStringPool [nodes [nodePosition].NamespaceURI];
+                       }
+               }
+
+               public override string GetValue (long nodePosition)
+               {
+                       switch (GetNodeType (nodePosition)) {
+                       case XPathNodeType.Namespace:
+                               return atomicStringPool [namespaces [nodePosition - nodes.Length - attributes.Length].Namespace];
+                       case XPathNodeType.Attribute:
+                               return nonAtomicStringPool [attributes [nodePosition - nodes.Length].Value];
+                       default:
+                               return nonAtomicStringPool [nodes [nodePosition].Value];
+                       }
+               }
+
+               int GetOwnerPosition (long position)
+               {
+                       int pos = (int) position;
+                       return pos < nodes.Length ? pos :
+                               pos < nodes.Length + attributes.Length ?
+                               attributes [(int) pos].OwnerElement :
+                               namespaces [(int) pos].DeclaredElement;
+               }
+
+               public override XmlNodeOrder ComparePosition (long firstPosition, long secondPosition)
+               {
+                       if (firstPosition == secondPosition)
+                               return XmlNodeOrder.Same;
+
+                       int link1 = GetOwnerPosition (firstPosition);
+                       int link2 = GetOwnerPosition (secondPosition);
+                       if (link1 == link2)
+                               // on the same element. Comparison could be done numerically.
+                               return firstPosition < secondPosition ? XmlNodeOrder.Before :
+                                       XmlNodeOrder.After;
+                       else
+                               // on different linked nodes.
+                               return link1 < link2 ?
+                                       XmlNodeOrder.Before :
+                                       XmlNodeOrder.After;
+               }
+
+               #endregion
+
+               XmlNameTable nameTable {
+                       get { return document.NameTable; }
+               }
+
+               // Created XPathDocument. This is used to identify the origin of the navigator.
+               DTMXPathDocument2 document;
+
+               DTMXPathLinkedNode2 [] nodes {
+                       get { return document.Nodes; }
+               }
+               DTMXPathAttributeNode2 [] attributes {
+                       get { return document.Attributes; }
+               }
+               DTMXPathNamespaceNode2 [] namespaces {
+                       get { return document.Namespaces; }
+               }
+               string [] atomicStringPool {
+                       get { return document.AtomicStringPool; }
+               }
+               string [] nonAtomicStringPool {
+                       get { return document.NonAtomicStringPool; }
+               }
+
+               // ID table
+               Hashtable idTable {
+                       get { return document.IdTable; }
+               }
+
+               bool currentIsNode;
+               bool currentIsAttr;
+
+               int currentNode;
+               int currentAttr;
+               int currentNs;
+
+#region Properties
+
+               public override string BaseURI {
+                       get { return atomicStringPool [nodes [currentNode].BaseURI]; }
+               }
+
+               public override bool HasAttributes {
+                       get { return currentIsNode ? nodes [currentNode].FirstAttribute != 0 : false; }
+               }
+               
+               public override bool HasChildren {
+                       get { return currentIsNode ? nodes [currentNode].FirstChild != 0 : false; }
+               }
+
+               public override bool IsEmptyElement {
+                       get { return currentIsNode ? nodes [currentNode].IsEmptyElement : false; }
+               }
+
+               int IXmlLineInfo.LineNumber {
+                       get {
+                               return currentIsAttr ? attributes [currentAttr].LineNumber :
+                                       nodes [currentNode].LineNumber;
+                       }
+               }
+
+               int IXmlLineInfo.LinePosition {
+                       get {
+                               return currentIsAttr ? attributes [currentAttr].LinePosition :
+                                       nodes [currentNode].LinePosition;
+                       }
+               }
+
+               public override string LocalName {
+                       get {
+                               if (currentIsNode)
+                                       return atomicStringPool [nodes [currentNode].LocalName];
+                               else if (currentIsAttr)
+                                       return atomicStringPool [attributes [currentAttr].LocalName];
+                               else
+                                       return atomicStringPool [namespaces [currentNs].Name];
+                       }
+               }
+
+               // It maybe scarcely used, so I decided to compute it always.
+               public override string Name {
+                       get {
+                               string prefix;
+                               string localName;
+                               if (currentIsNode) {
+                                       prefix = atomicStringPool [nodes [currentNode].Prefix];
+                                       localName = atomicStringPool [nodes [currentNode].LocalName];
+                               } else if (currentIsAttr) {
+                                       prefix = atomicStringPool [attributes [currentAttr].Prefix];
+                                       localName = atomicStringPool [attributes [currentAttr].LocalName];
+                               } else
+                                       return atomicStringPool [namespaces [currentNs].Name];
+
+                               if (prefix != "")
+                                       return prefix + ':' + localName;
+                               else
+                                       return localName;
+                       }
+               }
+
+               public override string NamespaceURI {
+                       get {
+                               if (currentIsNode)
+                                       return atomicStringPool [nodes [currentNode].NamespaceURI];
+                               if (currentIsAttr)
+                                       return atomicStringPool [attributes [currentAttr].NamespaceURI];
+                               return String.Empty;
+                       }
+               }
+
+               public override XmlNameTable NameTable {
+                       get { return nameTable; }
+               }
+
+               public override XPathNodeType NodeType {
+                       get {
+                               if (currentIsNode)
+                                       return nodes [currentNode].NodeType;
+                               else if (currentIsAttr)
+                                       return XPathNodeType.Attribute;
+                               else
+                                       return XPathNodeType.Namespace;
+                       }
+               }
+
+               public override string Prefix {
+                       get {
+                               if (currentIsNode)
+                                       return atomicStringPool [nodes [currentNode].Prefix];
+                               else if (currentIsAttr)
+                                       return atomicStringPool [attributes [currentAttr].Prefix];
+                               return String.Empty;
+                       }
+               }
+
+               public override string Value {
+                       get {
+                               if (currentIsAttr)
+                                       return nonAtomicStringPool [attributes [currentAttr].Value];
+                               else if (!currentIsNode)
+                                       return atomicStringPool [namespaces [currentNs].Namespace];
+                               
+                               switch (nodes [currentNode].NodeType) {
+                               case XPathNodeType.Comment:
+                               case XPathNodeType.ProcessingInstruction:
+                               case XPathNodeType.Text:
+                               case XPathNodeType.Whitespace:
+                               case XPathNodeType.SignificantWhitespace:
+                                       return nonAtomicStringPool [nodes [currentNode].Value];
+                               }
+
+                               // Element - collect all content values
+                               int iter = nodes [currentNode].FirstChild;
+                               if (iter == 0)
+                                       return String.Empty;
+
+                               StringBuilder builder = null;
+                               BuildValue (iter, ref builder);
+                               return builder == null ? String.Empty : builder.ToString ();
+                       }
+               }
+
+               void BuildValue (int iter, ref StringBuilder valueBuilder)
+               {
+                       int end = nodes [currentNode].NextSibling;
+                       if (end == 0) {
+                               int tmp = currentNode;
+                               do {
+                                       tmp = nodes [tmp].Parent;
+                                       end = nodes [tmp].NextSibling;
+                               } while (end == 0 && tmp != 0);
+                               if (end == 0)
+                                       end = nodes.Length;
+                       }
+
+                       while (iter < end) {
+                               switch (nodes [iter].NodeType) {
+                               case XPathNodeType.Text:
+                               case XPathNodeType.SignificantWhitespace:
+                               case XPathNodeType.Whitespace:
+                                       if (valueBuilder == null)
+                                               valueBuilder = new StringBuilder ();
+                                       valueBuilder.Append (nonAtomicStringPool [nodes [iter].Value]);
+                                       break;
+                               }
+                               iter++;
+                       }
+               }
+
+               public override string XmlLang {
+                       get { return atomicStringPool [nodes [currentNode].XmlLang]; }
+               }
+
+#endregion
+
+#region Methods
+
+               public override XPathNavigator Clone ()
+               {
+                       return new SeekableDTMXPathNavigator2 (this);
+               }
+
+               public override XmlNodeOrder ComparePosition (XPathNavigator nav)
+               {
+                       SeekableDTMXPathNavigator2 another = nav as SeekableDTMXPathNavigator2;
+
+                       if (another == null || another.document != this.document)
+                               return XmlNodeOrder.Unknown;
+
+                       if (currentNode > another.currentNode)
+                               return XmlNodeOrder.After;
+                       else if (currentNode < another.currentNode)
+                               return XmlNodeOrder.Before;
+
+                       // another may attr or ns, 
+                       // and this may be also attr or ns.
+                       if (another.currentIsAttr) {
+                               if (this.currentIsAttr) {
+                                       if (currentAttr > another.currentAttr)
+                                               return XmlNodeOrder.After;
+                                       else if (currentAttr < another.currentAttr)
+                                               return XmlNodeOrder.Before;
+                                       else
+                                               return XmlNodeOrder.Same;
+                               } else
+                                       return XmlNodeOrder.Before;
+                       } else if (!another.currentIsNode) {
+                               if (!this.currentIsNode) {
+                                       if (currentNs > another.currentNs)
+                                               return XmlNodeOrder.After;
+                                       else if (currentNs < another.currentNs)
+                                               return XmlNodeOrder.Before;
+                                       else
+                                               return XmlNodeOrder.Same;
+                               } else
+                                       return XmlNodeOrder.Before;
+                       } else
+                               return !another.currentIsNode ? XmlNodeOrder.Before : XmlNodeOrder.Same;
+               }
+
+               private int findAttribute (string localName, string namespaceURI)
+               {
+                       if (currentIsNode && nodes [currentNode].NodeType == XPathNodeType.Element) {
+                               int cur = nodes [currentNode].FirstAttribute;
+                               while (cur != 0) {
+                                       if (atomicStringPool [attributes [cur].LocalName] == localName && atomicStringPool [attributes [cur].NamespaceURI] == namespaceURI)
+                                               return cur;
+                                       cur = attributes [cur].NextAttribute;
+                               }
+                       }
+                       return 0;
+               }
+
+               public override string GetAttribute (string localName,
+                       string namespaceURI)
+               {
+                       int attr = findAttribute (localName, namespaceURI);
+                       return (attr != 0) ? nonAtomicStringPool [attributes [attr].Value] : String.Empty;
+               }
+
+               public override string GetNamespace (string name)
+               {
+                       if (currentIsNode && nodes [currentNode].NodeType == XPathNodeType.Element) {
+                               int nsNode = nodes [currentNode].FirstNamespace;
+                               while (nsNode != 0) {
+                                       if (atomicStringPool [namespaces [nsNode].Name] == name)
+                                               return atomicStringPool [namespaces [nsNode].Namespace];
+                                       nsNode = namespaces [nsNode].NextNamespace;
+                               }
+                       }
+                       return String.Empty;
+               }
+
+               bool IXmlLineInfo.HasLineInfo ()
+               {
+                       return true;
+               }
+
+               public override bool IsDescendant (XPathNavigator nav)
+               {
+                       SeekableDTMXPathNavigator2 another = nav as SeekableDTMXPathNavigator2;
+
+                       if (another == null || another.document != this.document)
+                               return false;
+
+                       if (another.currentNode == currentNode)
+                               return !another.currentIsNode;
+                       int tmp = nodes [another.currentNode].Parent;
+
+                       // ancestors must appear in prior on the node list.
+                       if (tmp < currentNode)
+                               return false;
+
+                       while (tmp != 0) {
+                               if (tmp == currentNode)
+                                       return true;
+                               tmp = nodes [tmp].Parent;
+                       }
+                       return false;
+               }
+
+               public override bool IsSamePosition (XPathNavigator other)
+               {
+                       SeekableDTMXPathNavigator2 another = other as SeekableDTMXPathNavigator2;
+
+                       if (another == null || another.document != this.document)
+                               return false;
+
+                       if (this.currentNode != another.currentNode ||
+                               this.currentIsAttr != another.currentIsAttr ||
+                               this.currentIsNode != another.currentIsNode)
+                               return false;
+
+                       if (currentIsAttr)
+                               return this.currentAttr == another.currentAttr;
+                       else if (!currentIsNode)
+                               return this.currentNs == another.currentNs;
+                       return true;
+               }
+
+               public override bool MoveTo (XPathNavigator other)
+               {
+                       SeekableDTMXPathNavigator2 another = other as SeekableDTMXPathNavigator2;
+
+                       if (another == null || another.document != this.document)
+                               return false;
+
+                       this.currentNode = another.currentNode;
+                       this.currentAttr = another.currentAttr;
+                       this.currentNs = another.currentNs;
+                       this.currentIsNode = another.currentIsNode;
+                       this.currentIsAttr = another.currentIsAttr;
+                       return true;
+               }
+
+               public override bool MoveToAttribute (string localName,
+                       string namespaceURI)
+               {
+                       int attr = findAttribute (localName, namespaceURI);
+                       if (attr == 0)
+                               return false;
+
+                       currentAttr = attr;
+                       currentIsAttr = true;
+                       currentIsNode = false;
+                       return true;
+               }
+
+               public override bool MoveToFirst ()
+               {
+                       if (currentIsAttr)
+                               return false;
+
+                       int cur = nodes [currentNode].PreviousSibling;
+                       if (cur == 0)
+                               return false;
+
+                       cur = nodes [cur].Parent;
+                       cur = nodes [cur].FirstChild;
+                       currentNode = cur;
+                       currentIsNode = true;
+                       return true;
+               }
+
+               public override bool MoveToFirstAttribute ()
+               {
+                       if (!currentIsNode)
+                               return false;
+
+                       int first = nodes [currentNode].FirstAttribute;
+                       if (first == 0)
+                               return false;
+
+                       currentAttr = first;
+                       currentIsAttr = true;
+                       currentIsNode = false;
+                       return true;
+               }
+
+               public override bool MoveToFirstChild ()
+               {
+                       if (!currentIsNode)
+                               return false;
+
+                       int first = nodes [currentNode].FirstChild;
+                       if (first == 0)
+                               return false;
+
+                       currentNode = first;
+                       return true;
+               }
+               
+               private bool moveToSpecifiedNamespace (int cur,
+                       XPathNamespaceScope namespaceScope)
+               {
+                       if (cur == 0)
+                               return false;
+
+                       if (namespaceScope == XPathNamespaceScope.Local &&
+                                       namespaces [cur].DeclaredElement != currentNode)
+                               return false;
+
+                       if (namespaceScope != XPathNamespaceScope.All
+                               && namespaces [cur].Namespace == XmlNamespaces.IndexXML)
+                               return false;
+
+                       if (cur != 0) {
+                               moveToNamespace (cur);
+                               return true;
+                       }
+                       else
+                               return false;
+               }
+
+               public override bool MoveToFirstNamespace (
+                       XPathNamespaceScope namespaceScope)
+               {
+                       if (!currentIsNode)
+                               return false;
+                       int cur = nodes [currentNode].FirstNamespace;
+                       return moveToSpecifiedNamespace (cur, namespaceScope);
+               }
+
+               // Note that this support is extension to XPathDocument.
+               // XPathDocument does not support ID reference.
+               public override bool MoveToId (string id)
+               {
+                       if (idTable.ContainsKey (id)) {
+                               currentNode = (int) idTable [id];
+                               currentIsNode = true;
+                               currentIsAttr = false;
+                               return true;
+                       }
+                       else
+                               return false;
+               }
+
+               private void moveToNamespace (int nsNode)
+               {
+                       currentIsNode = currentIsAttr = false;
+                       currentNs = nsNode;
+               }
+
+               public override bool MoveToNamespace (string name)
+               {
+                       int cur = nodes [currentNode].FirstNamespace;
+                       if (cur == 0)
+                               return false;
+
+                       while (cur != 0) {
+                               if (atomicStringPool [namespaces [cur].Name] == name) {
+                                       moveToNamespace (cur);
+                                       return true;
+                               }
+                               cur = namespaces [cur].NextNamespace;
+                       }
+                       return false;
+               }
+
+               public override bool MoveToNext ()
+               {
+                       if (currentIsAttr)
+                               return false;
+
+                       int next = nodes [currentNode].NextSibling;
+                       if (next == 0)
+                               return false;
+                       currentNode = next;
+                       currentIsNode = true;
+                       return true;
+               }
+
+               public override bool MoveToNextAttribute ()
+               {
+                       if (!currentIsAttr)
+                               return false;
+
+                       int next = attributes [currentAttr].NextAttribute;
+                       if (next == 0)
+                               return false;
+                       currentAttr = next;
+                       return true;
+               }
+
+               public override bool MoveToNextNamespace (
+                       XPathNamespaceScope namespaceScope)
+               {
+                       if (currentIsAttr || currentIsNode)
+                               return false;
+
+                       int cur = namespaces [currentNs].NextNamespace;
+                       return moveToSpecifiedNamespace (cur, namespaceScope);
+               }
+
+               public override bool MoveToParent ()
+               {
+                       if (!currentIsNode) {
+                               currentIsNode = true;
+                               currentIsAttr = false;
+                               return true;
+                       }
+
+                       int parent = nodes [currentNode].Parent;
+                       if (parent == 0)        // It is root itself.
+                               return false;
+
+                       currentNode = parent;
+                       return true;
+               }
+
+               public override bool MoveToPrevious ()
+               {
+                       if (currentIsAttr)
+                               return false;
+
+                       int previous = nodes [currentNode].PreviousSibling;
+                       if (previous == 0)
+                               return false;
+                       currentNode = previous;
+                       currentIsNode = true;
+                       return true;
+               }
+
+               public override void MoveToRoot ()
+               {
+                       currentNode = 1;        // root is 1.
+                       currentIsNode = true;
+                       currentIsAttr = false;
+               }
+
+#endregion
+       }
+
+       class XmlNamespaces
+       {
+               public const string XML = "http://www.w3.org/XML/1998/namespace";
+               public const string XMLNS = "http://www.w3.org/2000/xmlns/";
+               public const int IndexXML = 2;
+               public const int IndexXMLNS = 3;
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathNode2.cs b/mcs/class/System.ServiceModel/Mono.Xml.XPath/DTMXPathNode2.cs
new file mode 100644 (file)
index 0000000..b094972
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// Mono.Xml.XPath.DTMXPathNode2.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// (C) 2004 Novell Inc
+//
+// These classes represent each node of DTMXPathNavigator.
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Xml.XPath;
+
+namespace Mono.Xml.XPath
+{
+#if OUTSIDE_SYSTEM_XML
+       public
+#else
+       internal
+#endif
+#if DTM_CLASS
+               class DTMXPathLinkedNode2
+#else
+               struct DTMXPathLinkedNode2
+#endif
+       {
+               public int FirstChild;
+               public int Parent;
+               public int PreviousSibling;
+               public int NextSibling;
+               public int FirstAttribute;
+               public int FirstNamespace;
+               public XPathNodeType NodeType;
+               public int BaseURI;
+               public bool IsEmptyElement;
+               public int LocalName;
+               public int NamespaceURI;
+               public int Prefix;
+               public int Value;
+               public int XmlLang;
+               public int LineNumber;
+               public int LinePosition;
+       }
+
+#if OUTSIDE_SYSTEM_XML
+       public
+#else
+       internal
+#endif
+#if DTM_CLASS
+               class DTMXPathAttributeNode2
+#else
+               struct DTMXPathAttributeNode2
+#endif
+       {
+               public int OwnerElement;
+               public int NextAttribute;
+               public int LocalName;
+               public int NamespaceURI;
+               public int Prefix;
+               public int Value;
+               public int LineNumber;
+               public int LinePosition;
+       }
+
+#if OUTSIDE_SYSTEM_XML
+       public
+#else
+       internal
+#endif
+#if DTM_CLASS
+               class DTMXPathNamespaceNode2
+#else
+               struct DTMXPathNamespaceNode2
+#endif
+       {
+               public int DeclaredElement;
+               public int NextNamespace;
+               public int Name;
+               public int Namespace;
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Mono.Xml.XPath/README b/mcs/class/System.ServiceModel/Mono.Xml.XPath/README
new file mode 100644 (file)
index 0000000..063cbd9
--- /dev/null
@@ -0,0 +1,2 @@
+The code in this directory is here to support the
+SeekableXPahtNavigator class in System.ServideModel.Dispatcher
diff --git a/mcs/class/System.ServiceModel/System.Collections.Generic/ChangeLog b/mcs/class/System.ServiceModel/System.Collections.Generic/ChangeLog
new file mode 100644 (file)
index 0000000..bf31538
--- /dev/null
@@ -0,0 +1,4 @@
+2006-07-13 Ankit Jain  <jankit@novell.com>
+
+       * KeyedByTypeCollection.cs (.ctor): Add IEnumerable<> overload.
+
diff --git a/mcs/class/System.ServiceModel/System.Collections.Generic/KeyedByTypeCollection.cs b/mcs/class/System.ServiceModel/System.Collections.Generic/KeyedByTypeCollection.cs
new file mode 100644 (file)
index 0000000..3e79f9e
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// KeyedByTypeCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+
+namespace System.Collections.Generic
+{
+       public class KeyedByTypeCollection<TItem>
+               : KeyedCollection<Type, TItem>
+       {
+               public KeyedByTypeCollection ()
+               {
+               }
+
+               public KeyedByTypeCollection (IEnumerable<TItem> items)
+               {
+                       foreach (TItem item in items)
+                               Add (item);
+               }
+
+               protected override Type GetKeyForItem (TItem item)
+               {
+                       return item.GetType ();
+               }
+
+               public T Find<T> ()
+               {
+                       foreach (TItem k in this)
+                               if (k is T)
+                                       return (T) (object) k;
+                       return default (T);
+               }
+
+               public Collection<T> FindAll<T> ()
+               {
+                       Collection<T> list = new Collection<T> ();
+                       foreach (TItem k in this)
+                               if (k is T)
+                                       list.Add ((T) (object) k);
+                       return list;
+               }
+
+               protected override void InsertItem (int index, TItem kind)
+               {
+                       base.InsertItem (index, kind);
+               }
+
+               protected override void SetItem (int index, TItem kind)
+               {
+                       base.SetItem (index, kind);
+               }
+
+               public T Remove<T> ()
+               {
+                       foreach (TItem k in this)
+                               if (k is T) {
+                                       Remove (k);
+                                       return (T) (object) k;
+                               }
+                       return default (T);
+               }
+
+               public Collection<T> RemoveAll<T> ()
+               {
+                       return RemoveAll<T> ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.Collections.Generic/SynchronizedCollection.cs b/mcs/class/System.ServiceModel/System.Collections.Generic/SynchronizedCollection.cs
new file mode 100644 (file)
index 0000000..ff9a2b8
--- /dev/null
@@ -0,0 +1,260 @@
+//
+// SynchronizedCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.InteropServices;
+
+namespace System.Collections.Generic
+{
+       [ComVisibleAttribute (false)] 
+       public class SynchronizedCollection<T> : IList<T>, ICollection<T>, 
+               IEnumerable<T>, IList, ICollection, IEnumerable
+       {
+               object root;
+               List<T> list;
+
+               public SynchronizedCollection ()
+                       : this (new object (), null, false)
+               {
+               }
+
+               public SynchronizedCollection (object syncRoot)
+                       : this (syncRoot, null, false)
+               {
+               }
+
+               public SynchronizedCollection (object syncRoot,
+                       IEnumerable<T> list)
+                       : this (syncRoot, new List<T> (list), false)
+               {
+               }
+
+               public SynchronizedCollection (object syncRoot,
+                       params T [] list)
+                       : this (syncRoot, new List<T> (list), false)
+               {
+               }
+
+               public SynchronizedCollection (object syncRoot,
+                       List<T> list, bool makeCopy)
+               {
+                       if (syncRoot == null)
+                               syncRoot = new object ();
+                       root = syncRoot;
+                       if (list == null)
+                               this.list = new List<T> ();
+                       else if (makeCopy)
+                               this.list = new List<T> (list);
+                       else
+                               this.list = list;
+               }
+
+               public int Count {
+                       get {
+                               lock (root) {
+                                       return list.Count;
+                               }
+                       }
+               }
+
+               public T this [int index] {
+                       get {
+                               lock (root) {
+                                       return list [index];
+                               }
+                       }
+                       set {
+                               SetItem (index, value);
+                       }
+               }
+
+               public object SyncRoot {
+                       get { return root; }
+               }
+
+               protected List<T> Items {
+                       get { return list; }
+               }
+
+               public void Add (T item)
+               {
+                       InsertItem (list.Count, item);
+               }
+
+               public void Clear ()
+               {
+                       ClearItems ();
+               }
+
+               public bool Contains (T item)
+               {
+                       lock (root) {
+                               return list.Contains (item);
+                       }
+               }
+
+               public void CopyTo (T [] array, int index)
+               {
+                       lock (root) {
+                               list.CopyTo (array, index);
+                       }
+               }
+
+               [MonoTODO ("Should be synchronized enumerator?")]
+               public IEnumerator<T> GetEnumerator ()
+               {
+                       lock (root) {
+                               return list.GetEnumerator ();
+                       }
+               }
+
+               public int IndexOf (T item)
+               {
+                       lock (root) {
+                               return list.IndexOf (item);
+                       }
+               }
+
+               public void Insert (int index, T item)
+               {
+                       InsertItem (index, item);
+               }
+
+               [MonoTODO ("should we lock and remove item without invoking RemoveItem() instead?")]
+               public bool Remove (T item)
+               {
+                       int index = IndexOf (item);
+                       if (index < 0)
+                               return false;
+                       RemoveAt (index);
+                       return true;
+               }
+
+               public void RemoveAt (int index)
+               {
+                       RemoveItem (index);
+               }
+
+               protected virtual void ClearItems ()
+               {
+                       lock (root) {
+                               list.Clear ();
+                       }
+               }
+
+               protected virtual void InsertItem (int index, T item)
+               {
+                       lock (root) {
+                               list.Insert (index, item);
+                       }
+               }
+
+               protected virtual void RemoveItem (int index)
+               {
+                       lock (root) {
+                               list.RemoveAt (index);
+                       }
+               }
+
+               protected virtual void SetItem (int index, T item)
+               {
+                       lock (root) {
+                               list [index] = item;
+                       }
+               }
+
+               #region Explicit interface implementations
+
+               void ICollection.CopyTo (Array array, int index)
+               {
+                       CopyTo ((T []) array, index);
+               }
+
+               IEnumerator IEnumerable.GetEnumerator ()
+               {
+                       return GetEnumerator ();
+               }
+
+               int IList.Add (object value)
+               {
+                       lock (root) {
+                               Add ((T) value);
+                               return list.Count - 1;
+                       }
+               }
+
+               bool IList.Contains (object value)
+               {
+                       return Contains ((T) value);
+               }
+
+               int IList.IndexOf (object value)
+               {
+                       return IndexOf ((T) value);
+               }
+
+               void IList.Insert (int index, object value)
+               {
+                       Insert (index, (T) value);
+               }
+
+               void IList.Remove (object value)
+               {
+                       Remove ((T) value);
+               }
+
+               bool ICollection<T>.IsReadOnly {
+                       get { return false; }
+               }
+
+               bool ICollection.IsSynchronized {
+                       get { return true; }
+               }
+
+               object ICollection.SyncRoot {
+                       get { return root; }
+               }
+
+               bool IList.IsFixedSize {
+                       get { return false; }
+               }
+
+               bool IList.IsReadOnly {
+                       get { return false; }
+               }
+
+               object IList.this [int index] {
+                       get { return this [index]; }
+                       set { this [index] = (T) value; }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.Collections.Generic/SynchronizedKeyedCollection.cs b/mcs/class/System.ServiceModel/System.Collections.Generic/SynchronizedKeyedCollection.cs
new file mode 100644 (file)
index 0000000..5e47797
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// SynchronizedKeyedCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.ServiceModel.Channels;
+
+namespace System.Collections.Generic
+{
+       [ComVisibleAttribute (false)] 
+       public abstract class SynchronizedKeyedCollection<K, T>
+               : SynchronizedCollection<T>
+       {
+               Dictionary<K, T> dict;
+
+               protected SynchronizedKeyedCollection ()
+                       : this (new object ())
+               {
+               }
+
+               protected SynchronizedKeyedCollection (object syncRoot)
+                       : base (syncRoot)
+               {
+                       dict = new Dictionary<K, T> ();
+               }
+
+               protected SynchronizedKeyedCollection (object syncRoot,
+                       IEqualityComparer<K> comparer)
+                       : base (syncRoot)
+               {
+                       dict = new Dictionary<K, T> (comparer);
+               }
+
+               protected SynchronizedKeyedCollection (object syncRoot,
+                       IEqualityComparer<K> comparer, int capacity)
+                       : base (syncRoot)
+               {
+                       dict = new Dictionary<K, T> (capacity, comparer);
+               }
+
+               // see bug #76417
+               /*
+               public T this [int index] {
+                       get { return base [index]; }
+                       set { base [index] = value; }
+               }
+               */
+
+               public T this [K key] {
+                       get {
+                               lock (SyncRoot) {
+                                       return dict [key];
+                               }
+                       }
+               }
+
+               protected IDictionary<K, T> Dictionary {
+                       get { return dict; }
+               }
+
+               public bool Contains (K key)
+               {
+                       lock (SyncRoot) {
+                               return dict.ContainsKey (key);
+                       }
+               }
+
+               public bool Remove (K key)
+               {
+                       lock (SyncRoot) {
+                               return dict.Remove (key);
+                       }
+               }
+
+               protected void ChangeItemKey (T item, K newKey)
+               {
+                       lock (SyncRoot) {
+                               K old = GetKeyForItem (item);
+                               dict [old] = default (T);
+                               dict [newKey] = item;
+                       }
+               }
+
+               [MonoTODO ("This lock is not an atomic.")]
+               protected override void ClearItems ()
+               {
+                       base.ClearItems ();
+                       lock (SyncRoot) {
+                               dict.Clear ();
+                       }
+               }
+
+               protected abstract K GetKeyForItem (T item);
+
+               [MonoTODO ("This lock is not an atomic.")]
+               protected override void InsertItem (int index, T item)
+               {
+                       base.InsertItem (index, item);
+                       dict.Add (GetKeyForItem (item), item);
+               }
+
+               [MonoTODO ("This lock is not an atomic.")]
+               protected override void RemoveItem (int index)
+               {
+                       K key = GetKeyForItem (base [index]);
+                       base.RemoveItem (index);
+                       dict.Remove (key);
+               }
+
+               [MonoTODO ("This lock is not an atomic.")]
+               protected override void SetItem (int index, T item)
+               {
+                       base.SetItem (index, item);
+                       dict [GetKeyForItem (item)] = item;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.Collections.Generic/SynchronizedReadOnlyCollection.cs b/mcs/class/System.ServiceModel/System.Collections.Generic/SynchronizedReadOnlyCollection.cs
new file mode 100644 (file)
index 0000000..fdc7c3e
--- /dev/null
@@ -0,0 +1,223 @@
+//
+// System.ServiceModel.SynchronizedReadOnlyCollection.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Runtime.InteropServices;
+
+namespace System.Collections.Generic
+{
+       [ComVisible (false)]
+       public class SynchronizedReadOnlyCollection<T>
+               : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable
+       {
+               List<T> l;
+               object sync_root;
+
+               public SynchronizedReadOnlyCollection ()
+                       : this (new object ())
+               {
+               }
+
+               public SynchronizedReadOnlyCollection (object sync_root)
+                       : this (sync_root, new List<T> ())
+               {
+               }
+
+               public SynchronizedReadOnlyCollection (object sync_root, IEnumerable<T> list)
+               {
+                       if (sync_root == null)
+                               throw new ArgumentNullException ("sync_root");
+
+                       if (list == null)
+                               throw new ArgumentNullException ("list");
+
+                       this.sync_root = sync_root;
+                       this.l = new List<T> (list);
+               }
+
+               public SynchronizedReadOnlyCollection (object sync_root, params T [] list)
+                       : this (sync_root, (IEnumerable<T>) list)
+               {
+               }
+
+               public SynchronizedReadOnlyCollection (object sync_root, List<T> list, bool make_copy)
+                       : this (sync_root,
+                               list == null ? null : make_copy ? new List<T> (list) : list)
+               {
+               }
+
+               public bool Contains (T value)
+               {
+                       bool retval;
+
+                       lock (sync_root) {
+                               retval = l.Contains (value);
+                       }
+
+                       return retval;
+               }
+
+               public void CopyTo (T [] array, int index)
+               {
+                       lock (sync_root) {
+                               l.CopyTo (array, index);
+                       }
+               }
+
+               public IEnumerator<T> GetEnumerator ()
+               {
+                       IEnumerator<T> retval;
+
+                       lock (sync_root) {
+                               retval = l.GetEnumerator ();
+                       }
+
+                       return retval;
+               }
+
+               public int IndexOf (T value)
+               {
+                       int retval;
+
+                       lock (sync_root) {
+                               retval = l.IndexOf (value);
+                       }
+
+                       return retval;
+               }
+
+               void ICollection<T>.Add (T value) { throw new NotSupportedException (); }
+               void ICollection<T>.Clear () { throw new NotSupportedException (); }
+               bool ICollection<T>.Remove (T value) { throw new NotSupportedException (); }
+
+               void IList<T>.Insert (int index, T value) { throw new NotSupportedException (); }
+               void IList<T>.RemoveAt (int index) { throw new NotSupportedException (); }
+
+               void ICollection.CopyTo (Array array, int index)
+               {
+                       ICollection<T> a = array as ICollection<T>;
+
+                       if (a == null)
+                               throw new ArgumentException ("The array type is not compatible.");
+
+                       lock (sync_root) {
+                               ((ICollection) l).CopyTo (array, index);
+                       }
+               }
+
+               IEnumerator IEnumerable.GetEnumerator ()
+               {
+                       return GetEnumerator ();
+               }
+
+               int IList.Add (object value) { throw new NotSupportedException (); }
+               void IList.Clear () { throw new NotSupportedException (); }
+
+               bool IList.Contains (object value)
+               {
+                       if (typeof (T).IsValueType)
+                               throw new ArgumentException ("This is a collection of ValueTypes.");
+
+                       // null always gets thru
+                       if (value is T == false && value != null)
+                               throw new ArgumentException ("value is not of the same type as this collection.");
+
+                       bool retval;
+                       T val = (T) value;
+                       lock (sync_root) {
+                               retval = l.Contains (val);
+                       }
+
+                       return retval;
+               }
+
+               int IList.IndexOf (object value)
+               {
+                       if (typeof (T).IsValueType)
+                               throw new ArgumentException ("This is a collection of ValueTypes.");
+
+                       if (value is T == false)
+                               throw new ArgumentException ("value is not of the same type as this collection.");
+
+                       int retval;
+                       T val = (T) value;
+                       lock (sync_root) {
+                               retval = l.IndexOf (val);
+                       }
+
+                       return retval;
+               }
+
+               void IList.Insert (int index, object value) { throw new NotSupportedException (); }
+               void IList.Remove (object value) { throw new NotSupportedException (); }
+               void IList.RemoveAt (int index) { throw new NotSupportedException (); }
+
+               public int Count {
+                       get {
+                               int retval;
+                               lock (sync_root) {
+                                       retval = l.Count;
+                               }
+                               return retval;
+                       }
+               }
+
+               public T this [int index] {
+                       get {
+                               T retval;
+                               lock (sync_root) {
+                                       retval = l [index];
+                               }
+                               return retval;
+                       }
+               }
+
+               protected IList<T> Items {
+                       get { return l; }
+               }
+
+
+               bool ICollection<T>.IsReadOnly { get { return true; }}
+
+               bool ICollection.IsSynchronized { get { return true; }}
+               object ICollection.SyncRoot { get { return sync_root; }}
+
+               bool IList.IsFixedSize { get { return true; }}
+               bool IList.IsReadOnly { get { return true; }}
+
+               T IList<T>.this [int index] {
+                       get { return this [index]; }
+                       set { throw new NotSupportedException (); }
+               }
+
+               object IList.this [int index] {
+                       get { return this [index]; }
+                       set { throw new NotSupportedException (); }
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Activation/AspNetIntegrationRequirementsAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Activation/AspNetIntegrationRequirementsAttribute.cs
new file mode 100644 (file)
index 0000000..295fc0e
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// AspNetCompatibilityRequirementsAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Activation
+{
+       [MonoTODO]
+       [AttributeUsage (AttributeTargets.Class)]
+       public sealed class AspNetCompatibilityRequirementsAttribute
+               : Attribute, IServiceBehavior
+       {
+               AspNetCompatibilityRequirementsMode requirements_mode;
+
+               public AspNetCompatibilityRequirementsMode RequirementsMode {
+                       get { return requirements_mode; }
+                       set { requirements_mode = value; }
+               }
+
+               void IServiceBehavior.AddBindingParameters (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase,
+                       Collection<ServiceEndpoint> endpoints,
+                       BindingParameterCollection parameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IServiceBehavior.ApplyDispatchBehavior (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IServiceBehavior.Validate (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Activation/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel.Activation/ChangeLog
new file mode 100644 (file)
index 0000000..e2f30a2
--- /dev/null
@@ -0,0 +1,16 @@
+2008-02-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostFactory.cs : 
+         Now CreateServiceHost(Type,...) is used as internal.
+
+2008-02-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostFactoryBase.cs, ServiceHostFactory.cs :
+         updated inheritance. new file.
+       * IServiceHostFactory.cs : removed old code.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AspNetIntegrationRequirementsAttribute.cs,
+         IServiceHostFactory.cs, ServiceHostFactory.cs :
+         - from Sys.ServiceModel.
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpHandler.cs
new file mode 100644 (file)
index 0000000..a130b28
--- /dev/null
@@ -0,0 +1,40 @@
+//\r
+// HttpHandler.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Web;\r
+using System.ServiceModel.Channels;\r
+\r
+namespace System.ServiceModel.Activation\r
+{\r
+       class HttpHandler : SvcHttpHandlerFactory\r
+       {\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpModule.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Activation/HttpModule.cs
new file mode 100644 (file)
index 0000000..c4d16ea
--- /dev/null
@@ -0,0 +1,48 @@
+//\r
+// BasicHttpBindingElementTest.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Web;\r
+\r
+namespace System.ServiceModel.Activation\r
+{\r
+       class HttpModule : IHttpModule\r
+       {\r
+               #region IHttpModule Members\r
+\r
+               public void Dispose () {\r
+               }\r
+\r
+               public void Init (HttpApplication context) {\r
+               }\r
+\r
+               #endregion\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Activation/IServiceHostFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Activation/IServiceHostFactory.cs
new file mode 100644 (file)
index 0000000..e16bc10
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// IServiceHostFactory.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Activation
+{
+       public interface IServiceHostFactory
+       {
+               ServiceHostBase CreateServiceHost (string constructorString,
+                       Uri [] baseAddresses);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Activation/ServiceHostFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Activation/ServiceHostFactory.cs
new file mode 100644 (file)
index 0000000..a34e6d4
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// ServiceHostFactory.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Activation
+{
+       public class ServiceHostFactory : ServiceHostFactoryBase
+       {
+               [MonoTODO]
+               public override ServiceHostBase CreateServiceHost (
+                       string constructorString, Uri [] baseAddresses)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO ("untested")]
+               protected internal virtual ServiceHost CreateServiceHost (
+                       Type serviceType, Uri [] baseAddresses)
+               {
+                       return new ServiceHost (serviceType, baseAddresses);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Activation/ServiceHostFactoryBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Activation/ServiceHostFactoryBase.cs
new file mode 100644 (file)
index 0000000..d5e42e5
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// ServiceHostFactoryBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2008 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Activation
+{
+       public abstract class ServiceHostFactoryBase
+       {
+               public abstract ServiceHostBase CreateServiceHost (
+                       string constructorString, Uri [] baseAddresses);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AddressHeader.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AddressHeader.cs
new file mode 100644 (file)
index 0000000..ebaeaeb
--- /dev/null
@@ -0,0 +1,181 @@
+//
+// System.ServiceModel.AddressHeader.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class AddressHeader
+       {
+               protected AddressHeader () {}
+
+               public static AddressHeader CreateAddressHeader (object value)
+               {
+                       return new DefaultAddressHeader (value);
+               }
+
+               public static AddressHeader CreateAddressHeader (object value, XmlObjectSerializer formatter)
+               {
+                       return new DefaultAddressHeader (value, formatter);
+               }
+
+               public static AddressHeader CreateAddressHeader (string name, string ns, object value)
+               {
+                       return new DefaultAddressHeader (name, ns, value);
+               }
+
+               public static AddressHeader CreateAddressHeader (string name, string ns, object value, 
+                                                                XmlObjectSerializer formatter)
+               {
+                       if (formatter == null)
+                               throw new ArgumentNullException ("formatter");
+                       return new DefaultAddressHeader (name, ns, value, formatter);
+               }
+
+               public override bool Equals (object obj)
+               {
+                       AddressHeader o = obj as AddressHeader;
+
+                       if (o == null)
+                               return false;
+
+                       return o.Name == this.Name && o.Namespace == this.Namespace; 
+               }
+
+               [MonoTODO]
+               public virtual XmlDictionaryReader GetAddressHeaderReader ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override int GetHashCode ()
+               {
+                       return this.Name.GetHashCode () + this.Namespace.GetHashCode ();
+               }
+
+               public T GetValue<T> ()
+               {
+                       return GetValue<T> (new DataContractSerializer (typeof (T)));
+               }
+
+               public T GetValue<T> (XmlObjectSerializer formatter)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected abstract void OnWriteAddressHeaderContents (XmlDictionaryWriter writer);
+               protected virtual void OnWriteStartAddressHeader (XmlDictionaryWriter writer)
+               {
+                       if (Name != null && Namespace != null)
+                               writer.WriteStartElement (Name, Namespace);
+               }
+
+               public MessageHeader ToMessageHeader ()
+               {
+                       throw new NotImplementedException ();                   
+               }
+
+               public void WriteAddressHeader (XmlDictionaryWriter writer)
+               {
+                       if (writer == null)
+                               throw new ArgumentNullException ("writer is null");
+                       
+                       this.WriteStartAddressHeader (writer);
+                       this.WriteAddressHeaderContents (writer);
+                       if (Name != null && Namespace != null)
+                               writer.WriteEndElement ();
+               }
+
+               public void WriteAddressHeader (XmlWriter writer)
+               {
+                       this.WriteAddressHeader (XmlDictionaryWriter.CreateDictionaryWriter (writer));
+               }
+
+               public void WriteAddressHeaderContents (XmlDictionaryWriter writer)
+               {
+                       this.OnWriteAddressHeaderContents (writer);
+               }
+
+               public void WriteStartAddressHeader (XmlDictionaryWriter writer)
+               {
+                       this.OnWriteStartAddressHeader (writer);
+               }
+
+               public abstract string Name { get; }
+               public abstract string Namespace { get; }
+
+               internal class DefaultAddressHeader : AddressHeader
+               {
+                       string name, ns;
+                       XmlObjectSerializer formatter;
+                       object value;
+
+                       internal DefaultAddressHeader (object value)
+                               : this (null, null, value) {}
+
+                       
+                       internal DefaultAddressHeader (object value, XmlObjectSerializer formatter)
+                               : this (null, null, value, formatter)
+                       {
+                       }
+
+                       internal DefaultAddressHeader (string name, string ns, object value)
+                               : this (name, ns, value, null) {}
+                       
+                       internal DefaultAddressHeader (string name, string ns, object value, XmlObjectSerializer formatter)
+                       {
+                               if (formatter == null) {
+                                       if (value == null)
+                                               formatter = new NetDataContractSerializer ();
+                                       else
+                                               formatter = new DataContractSerializer (value.GetType ());
+                               }
+                               this.name = name;
+                               this.ns = ns;
+                               this.formatter = formatter;
+                               this.value = value;
+                       }
+
+                       public override string Name {
+                               get { return name; }
+                       }
+
+                       public override string Namespace {
+                               get { return ns; }
+                       }
+
+                       protected override void OnWriteAddressHeaderContents (XmlDictionaryWriter writer)
+                       {
+                               this.formatter.WriteObject (writer, value);
+                       }
+               }
+               
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AddressHeaderCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AddressHeaderCollection.cs
new file mode 100644 (file)
index 0000000..8b3a250
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// System.ServiceModel.AddressHeaderCollection.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class AddressHeaderCollection : ReadOnlyCollection<AddressHeader>
+       {
+               static readonly AddressHeader [] empty = new AddressHeader [0];
+
+               static IList<AddressHeader> GetList (IEnumerable<AddressHeader> arg)
+               {
+                       IList<AddressHeader> list = arg as IList<AddressHeader>;
+                       return list != null ? list : new List<AddressHeader> (arg);
+               }
+
+               public AddressHeaderCollection ()
+                       : base (empty)
+               {
+               }
+
+               public AddressHeaderCollection (IEnumerable<AddressHeader> headers)
+                       : base (GetList (headers))
+               {
+               }
+
+               public void AddHeadersTo (Message message)
+               {
+                       if (message == null)
+                               throw new ArgumentNullException ("message");
+                       foreach (AddressHeader header in this)
+                               message.Headers.Add (header.ToMessageHeader ());
+               }
+
+               public AddressHeader FindHeader (string name, string ns)
+               {
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+                       if (ns == null)
+                               throw new ArgumentNullException ("ns");
+                       foreach (AddressHeader header in this)
+                               if (header.Name == name && header.Namespace == ns)
+                                       return header;
+
+                       return null;
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AddressingVersion.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AddressingVersion.cs
new file mode 100644 (file)
index 0000000..6b45f5d
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// System.ServiceModel.AddressingVersion.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class AddressingVersion
+       {
+               string name;
+               string address;
+
+               AddressingVersion (string name, string address)
+               {
+                       this.name = name;
+                       this.address = address;
+               }
+
+               static AddressingVersion addressing200408 = new AddressingVersion (
+                       "Addressing200408",
+                       "http://schemas.xmlsoap.org/ws/2004/08/addressing");
+
+               static AddressingVersion addressing1_0 = new AddressingVersion (
+                       "Addressing10",
+                       "http://www.w3.org/2005/08/addressing");
+
+               static AddressingVersion none = new AddressingVersion (
+                       "AddressingNone",
+                       "http://schemas.microsoft.com/ws/2005/05/addressing/none");
+
+               public static AddressingVersion WSAddressing10 {
+                       get { return addressing1_0; }
+               }
+
+               public static AddressingVersion WSAddressingAugust2004 {
+                       get { return addressing200408; }
+               }
+
+               public static AddressingVersion None {
+                       get { return none; }
+               }
+
+               internal string Namespace {
+                       get { return address; }
+               }
+
+               internal string ActionNotSupported {
+                       get { return "ActionNotSupported"; }
+               }
+
+               public override string ToString ()
+               {
+                       return name + " (" + address + ")";
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AspNetReplyChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AspNetReplyChannel.cs
new file mode 100644 (file)
index 0000000..b026eb2
--- /dev/null
@@ -0,0 +1,132 @@
+//
+// AspNetReplyChannel.cs
+//
+// Author:
+//     Ankit Jain  <jankit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.ServiceModel;
+using System.Text;
+using System.Threading;
+using System.Web;
+
+namespace System.ServiceModel.Channels
+{
+       internal class AspNetReplyChannel : HttpReplyChannel
+       {
+               HttpContext http_context;
+               Uri uri;
+
+               public AspNetReplyChannel (HttpChannelListener<IReplyChannel> listener,
+                       TimeSpan timeout)
+                       : base (listener, timeout)
+               {
+                       uri = listener.Uri;
+               }
+
+               public override bool TryReceiveRequest (TimeSpan timeout, out RequestContext context)
+               {
+#if false
+                       context = null;
+                       if (waiting.Count == 0 && !WaitForRequest (timeout))
+                               return false;
+                       HttpListenerContext ctx = null;
+                       lock (waiting) {
+                               if (waiting.Count > 0) {
+                                       ctx = waiting [0];
+                                       waiting.RemoveAt (0);
+                               }
+                       }
+                       if (ctx == null) 
+                               // Though as long as this instance is used
+                               // synchronously, it should not happen.
+                               return false;
+#endif
+
+                       Message msg;
+                       if (http_context.Request.HttpMethod == "GET") {
+                               if (http_context.Request.QueryString ["wsdl"] != null) {
+                                       msg = Message.CreateMessage (Encoder.MessageVersion,
+                                               "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get");
+                                       msg.Headers.To = http_context.Request.Url;
+                               } else {
+                                       msg = Message.CreateMessage (Encoder.MessageVersion, null);
+                                       msg.Headers.To = http_context.Request.Url;
+                               }
+                       } else {
+                               //FIXME: Do above stuff for HttpContext ?
+                               int maxSizeOfHeaders = 0x10000;
+
+                               msg = Encoder.ReadMessage (
+                                       http_context.Request.InputStream, maxSizeOfHeaders);
+
+                               if (Encoder.MessageVersion.Envelope == EnvelopeVersion.Soap11) {
+                                       string action = GetHeaderItem (http_context.Request.Headers ["SOAPAction"]);
+                                       if (action != null)
+                                               msg.Headers.Action = action;
+                               }
+                       }
+                       context = new AspNetRequestContext (this, msg, http_context);
+
+                       return true;
+               }
+
+               public HttpContext Context {
+                       get { return http_context; }
+                       set { http_context = value; }
+               }
+
+               public override bool WaitForRequest (TimeSpan timeout)
+               {
+                       // FIXME: we might want to take other approaches.
+                       if (timeout.Ticks > int.MaxValue)
+                               timeout = TimeSpan.FromDays (20);
+
+                       SvcHttpHandler h = SvcHttpHandlerFactory.GetHandler (uri.OriginalString.Replace ("file://", ""));
+                       return h.WaitForRequest (this, timeout);
+
+#if false
+                       AutoResetEvent wait = new AutoResetEvent (false);
+                       source.Http.BeginGetContext (HttpContextReceived, wait);
+                       // FIXME: we might want to take other approaches.
+                       if (timeout.Ticks > int.MaxValue)
+                               timeout = TimeSpan.FromDays (20);
+                       return wait.WaitOne (timeout, false);
+#endif
+               }
+
+               void HttpContextReceived (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+#if false      
+                       waiting.Add (source.Http.EndGetContext (result));
+                       AutoResetEvent wait = (AutoResetEvent) result.AsyncState;
+                       wait.Set ();
+#endif
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AspNetRequestContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AspNetRequestContext.cs
new file mode 100644 (file)
index 0000000..6a17b1b
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// AspNetRequestContext.cs
+//
+// Author:
+//     Ankit Jain  <jankit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.IO;
+using System.Web;
+
+namespace System.ServiceModel.Channels {
+
+       class AspNetRequestContext : HttpRequestContext
+       {
+               HttpContext ctx;
+
+               public AspNetRequestContext (
+                       HttpReplyChannel channel,
+                       Message msg, HttpContext ctx)
+                       : base (channel, msg, null)
+               {
+                       this.ctx = ctx;
+               }
+
+               public override void Abort ()
+               {
+                       throw new NotImplementedException ();
+                       //ctx.Response.Abort ();
+               }
+
+               protected override void ProcessReply (Message msg, TimeSpan timeout)
+               {
+                       MemoryStream ms = new MemoryStream ();
+                       Channel.Encoder.WriteMessage (msg, ms);
+                       ctx.Response.ContentType = Channel.Encoder.ContentType;
+                       //ctx.Response.ContentLength64 = ms.Length;
+                       ctx.Response.OutputStream.Write (ms.GetBuffer (), 0, (int) ms.Length);
+                       ctx.Response.OutputStream.Flush ();
+               }
+
+               public override void Close (TimeSpan timeout)
+               {
+                       // FIXME: use timeout
+                       ctx.Response.Close ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AsymmetricSecurityBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/AsymmetricSecurityBindingElement.cs
new file mode 100644 (file)
index 0000000..468e409
--- /dev/null
@@ -0,0 +1,204 @@
+//
+// AsymmetricSecurityBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class AsymmetricSecurityBindingElement
+               : SecurityBindingElement, IPolicyExportExtension
+       {
+               public AsymmetricSecurityBindingElement ()
+                       : this (null, null)
+               {
+               }
+
+               public AsymmetricSecurityBindingElement (
+                       SecurityTokenParameters recipientTokenParameters)
+                       : this (recipientTokenParameters, null)
+               {
+               }
+
+               public AsymmetricSecurityBindingElement (
+                       SecurityTokenParameters recipientTokenParameters,
+                       SecurityTokenParameters initiatorTokenParameters)
+               {
+                       this.initiator_token_params = initiatorTokenParameters;
+                       this.recipient_token_params = recipientTokenParameters;
+                       msg_protection_order = MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature;
+               }
+
+               private AsymmetricSecurityBindingElement (
+                       AsymmetricSecurityBindingElement other)
+                       : base (other)
+               {
+                       msg_protection_order = other.msg_protection_order;
+                       require_sig_confirm = other.require_sig_confirm;
+                       if (other.initiator_token_params != null)
+                               initiator_token_params = other.initiator_token_params.Clone ();
+                       if (other.recipient_token_params != null)
+                               recipient_token_params = other.recipient_token_params.Clone ();
+                       allow_serialized_sign = other.allow_serialized_sign;
+               }
+
+               MessageProtectionOrder msg_protection_order;
+               SecurityTokenParameters initiator_token_params,
+                       recipient_token_params;
+               bool allow_serialized_sign, require_sig_confirm;
+
+               public bool AllowSerializedSigningTokenOnReply {
+                       get { return allow_serialized_sign; }
+                       set { allow_serialized_sign = value; }
+               }
+
+               public MessageProtectionOrder MessageProtectionOrder {
+                       get { return msg_protection_order; }
+                       set { msg_protection_order = value; }
+               }
+
+               public SecurityTokenParameters InitiatorTokenParameters {
+                       get { return initiator_token_params; }
+                       set { initiator_token_params = value; }
+               }
+
+               public SecurityTokenParameters RecipientTokenParameters {
+                       get { return recipient_token_params; }
+                       set { recipient_token_params = value; }
+               }
+
+               public bool RequireSignatureConfirmation {
+                       get { return require_sig_confirm; }
+                       set { require_sig_confirm = value; }
+               }
+
+               public override void SetKeyDerivation (bool requireDerivedKeys)
+               {
+                       base.SetKeyDerivation (requireDerivedKeys);
+                       if (InitiatorTokenParameters != null)
+                               InitiatorTokenParameters.RequireDerivedKeys = requireDerivedKeys;
+                       if (RecipientTokenParameters != null)
+                               RecipientTokenParameters.RequireDerivedKeys = requireDerivedKeys;
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+
+               [MonoTODO]
+               protected override IChannelFactory<TChannel>
+                       BuildChannelFactoryCore<TChannel> (
+                       BindingContext context)
+               {
+                       if (InitiatorTokenParameters == null)
+                               throw new InvalidOperationException ("InitiatorTokenParameters must be set before building channel factory.");
+                       if (RecipientTokenParameters == null)
+                               throw new InvalidOperationException ("RecipientTokenParameters must be set before building channel factory.");
+
+                       SetIssuerBindingContextIfRequired (InitiatorTokenParameters, context);
+                       SetIssuerBindingContextIfRequired (RecipientTokenParameters, context);
+
+                       ClientCredentials cred = context.BindingParameters.Find<ClientCredentials> ();
+                       if (cred == null)
+                               // it happens when there is no ChannelFactory<T>.
+                               cred = new ClientCredentials ();
+                       SecurityTokenManager manager = cred.CreateSecurityTokenManager ();
+                       ChannelProtectionRequirements requirements =
+                               context.BindingParameters.Find<ChannelProtectionRequirements> ();
+
+                       return new SecurityChannelFactory<TChannel> (
+                               context.BuildInnerChannelFactory<TChannel> (), new InitiatorMessageSecurityBindingSupport (GetCapabilities (), manager, requirements));
+               }
+
+               [MonoTODO]
+               protected override IChannelListener<TChannel>
+                       BuildChannelListenerCore<TChannel> (
+                       BindingContext context)
+               {
+                       if (InitiatorTokenParameters == null)
+                               throw new InvalidOperationException ("InitiatorTokenParameters must be set before building channel factory.");
+                       if (RecipientTokenParameters == null)
+                               throw new InvalidOperationException ("RecipientTokenParameters must be set before building channel factory.");
+
+                       SetIssuerBindingContextIfRequired (InitiatorTokenParameters, context);
+                       SetIssuerBindingContextIfRequired (RecipientTokenParameters, context);
+
+                       ServiceCredentials cred = context.BindingParameters.Find<ServiceCredentials> ();
+                       if (cred == null)
+                               // it happens when there is no ChannelFactory<T>.
+                               cred = new ServiceCredentials ();
+                       ServiceCredentialsSecurityTokenManager manager = (ServiceCredentialsSecurityTokenManager) cred.CreateSecurityTokenManager ();
+                       ChannelProtectionRequirements requirements =
+                               context.BindingParameters.Find<ChannelProtectionRequirements> ();
+
+                       return new SecurityChannelListener<TChannel> (
+                               context.BuildInnerChannelListener<TChannel> (), new RecipientMessageSecurityBindingSupport (GetCapabilities (), manager, requirements));
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new AsymmetricSecurityBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       if (typeof (T) == typeof (ISecurityCapabilities))
+                               return (T) (object) GetCapabilities ();
+                       if (typeof (T) == typeof (IdentityVerifier))
+                               throw new NotImplementedException ();
+                       return context.GetInnerProperty<T> ();
+               }
+
+               AsymmetricSecurityCapabilities GetCapabilities ()
+               {
+                       return new AsymmetricSecurityCapabilities (this);
+               }
+
+               #region explicit interface implementations
+
+               [MonoTODO]
+               void IPolicyExportExtension.ExportPolicy (
+                       MetadataExporter exporter,
+                       PolicyConversionContext policyContext)
+               {
+                       throw new NotImplementedException ();
+               }
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncoder.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncoder.cs
new file mode 100644 (file)
index 0000000..0583e1f
--- /dev/null
@@ -0,0 +1,99 @@
+//
+// BinaryMessageEncoder.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       internal class BinaryMessageEncoder : MessageEncoder
+       {
+               public BinaryMessageEncoder ()
+               {
+               }
+
+               public BinaryMessageEncoder (BinaryMessageEncoderFactory owner)
+               {
+               }
+
+               public override string ContentType {
+                       get { return "application/soap+msbin1"; }
+               }
+
+               public override string MediaType {
+                       get { return "application/soap+msbin1"; }
+               }
+
+               public override MessageVersion MessageVersion {
+                       get { return MessageVersion.Default; }
+               }
+
+               [MonoTODO]
+               public override Message ReadMessage (ArraySegment<byte> buffer,
+                       BufferManager bufferManager, string contentType)
+               {
+                       // FIXME: use bufferManager
+                       // FIXME: set quotas properly.
+                       return Message.CreateMessage (
+                               XmlDictionaryReader.CreateBinaryReader (
+                                       buffer.Array, buffer.Offset, buffer.Count,
+                                       new XmlDictionaryReaderQuotas ()),
+                               int.MaxValue, MessageVersion);
+               }
+
+               [MonoTODO]
+               public override Message ReadMessage (Stream stream,
+                       int maxSizeOfHeaders, string contentType)
+               {
+                       // FIXME: set quotas properly.
+                       return Message.CreateMessage (
+                               XmlDictionaryReader.CreateBinaryReader (stream, new XmlDictionaryReaderQuotas ()),
+                               maxSizeOfHeaders, MessageVersion);
+               }
+
+               [MonoTODO]
+               public override void WriteMessage (Message message, Stream stream)
+               {
+                       VerifyMessageVersion (message);
+
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override ArraySegment<byte> WriteMessage (
+                       Message message, int maxMessageSize,
+                       BufferManager bufferManager, int messageOffset)
+               {
+                       VerifyMessageVersion (message);
+
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncoderFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncoderFactory.cs
new file mode 100644 (file)
index 0000000..86de4e0
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// BinaryMessageEncoderFactory.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Text;
+
+namespace System.ServiceModel.Channels
+{
+       internal class BinaryMessageEncoderFactory : MessageEncoderFactory
+       {
+               BinaryMessageEncodingBindingElement owner;
+               BinaryMessageEncoder encoder;
+
+               public BinaryMessageEncoderFactory (
+                       BinaryMessageEncodingBindingElement owner)
+               {
+                       this.owner = owner;
+                       encoder = new BinaryMessageEncoder (this);
+               }
+
+               public BinaryMessageEncodingBindingElement Owner {
+                       get { return owner; }
+               }
+
+               [MonoTODO]
+               public override MessageEncoder Encoder {
+                       get { return encoder; }
+               }
+
+               public override MessageVersion MessageVersion {
+                       get { return MessageVersion.Default; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncodingBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncodingBindingElement.cs
new file mode 100644 (file)
index 0000000..a35077b
--- /dev/null
@@ -0,0 +1,156 @@
+//
+// BinaryMessageEncodingBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public sealed class BinaryMessageEncodingBindingElement
+               : MessageEncodingBindingElement,
+                 IWsdlExportExtension, IPolicyExportExtension
+       {
+               int max_session_size;
+               // FIXME: they might be configurable.
+               int max_read_pool_size = 64;
+               int max_write_pool_size = 16;
+               XmlDictionaryReaderQuotas quotas =
+                       new XmlDictionaryReaderQuotas ();
+               MessageVersion version = MessageVersion.Default;
+
+               public BinaryMessageEncodingBindingElement ()
+               {
+               }
+
+               private BinaryMessageEncodingBindingElement (
+                       BinaryMessageEncodingBindingElement other)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override MessageVersion MessageVersion {
+                       get { return version; }
+                       set { version = value; }
+               }
+
+               public int MaxSessionSize {
+                       get { return max_session_size; }
+                       set { max_session_size = value; }
+               }
+
+               public int MaxReadPoolSize {
+                       get { return max_read_pool_size; }
+                       set { max_read_pool_size = value; }
+               }
+
+               public int MaxWritePoolSize {
+                       get { return max_write_pool_size; }
+                       set { max_write_pool_size = value; }
+               }
+
+               public XmlDictionaryReaderQuotas ReaderQuotas {
+                       get { return quotas; }
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       context.RemainingBindingElements.Add (this);
+                       return base.BuildChannelFactory<TChannel> (context);
+               }
+
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       context.RemainingBindingElements.Add (this);
+                       return base.BuildChannelListener<TChannel> (context);
+               }
+
+               public override bool CanBuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       return context.CanBuildInnerChannelListener<TChannel> ();
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new BinaryMessageEncodingBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override MessageEncoderFactory
+                       CreateMessageEncoderFactory ()
+               {
+                       return new BinaryMessageEncoderFactory (this);
+               }
+
+               [MonoTODO]
+               protected override void OnImportPolicy (XmlElement assertion,
+                       MessageVersion messageVersion,
+                       MetadataImporter exporter,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IWsdlExportExtension.ExportContract (WsdlExporter exporter,
+                       WsdlContractConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IWsdlExportExtension.ExportEndpoint (WsdlExporter exporter,
+                       WsdlEndpointConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void ExportPolicy (MetadataExporter exporter,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Binding.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Binding.cs
new file mode 100644 (file)
index 0000000..dab08fb
--- /dev/null
@@ -0,0 +1,315 @@
+//
+// Binding.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class Binding : IDefaultCommunicationTimeouts
+       {
+               string name, ns;
+               TimeSpan open_timeout, close_timeout;
+               TimeSpan receive_timeout, send_timeout;
+
+               protected Binding ()
+               {
+                       Initialize ();
+                       name = GetType ().Name;
+                       ns = "http://tempuri.org/";
+               }
+
+               protected Binding (string name, string ns)
+               {
+                       this.name = name;
+                       this.ns = ns;
+                       Initialize ();
+               }
+
+               public TimeSpan CloseTimeout {
+                       get { return close_timeout; }
+                       set { close_timeout = value; }
+               }
+
+               public TimeSpan OpenTimeout {
+                       get { return open_timeout; }
+                       set { open_timeout = value; }
+               }
+
+               public TimeSpan ReceiveTimeout {
+                       get { return receive_timeout; }
+                       set { receive_timeout = value; }
+               }
+
+               public TimeSpan SendTimeout {
+                       get { return send_timeout; }
+                       set { send_timeout = value; }
+               }
+
+               public string Name {
+                       get { return name; }
+                       set { name = value; }
+               }
+
+               public string Namespace {
+                       get { return ns; }
+                       set { ns = value; }
+               }
+
+               public abstract string Scheme { get; }
+
+               public MessageVersion MessageVersion {
+                       get {
+                               foreach (BindingElement e in CreateBindingElements ()) {
+                                       MessageEncodingBindingElement me = e as MessageEncodingBindingElement;
+                                       if (me != null)
+                                               return me.MessageVersion;
+                               }
+                               return null;
+                       }
+               }
+
+               BindingContext CreateContext (
+                       BindingParameterCollection parameters)
+               {
+                       // FIXME: it seems that binding elements are
+                       // "validated" so that the last item is a transport.
+                       return new BindingContext (
+                               new CustomBinding (this), parameters);
+               }
+
+               BindingContext CreateContext (
+                       Uri listenUriBaseAddress,
+                       string listenUriRelativeAddress,
+                       ListenUriMode listenUriMode,
+                       BindingParameterCollection parameters)
+               {
+                       // FIXME: it seems that binding elements are
+                       // "validated" so that the last item is a transport.
+                       return new BindingContext (
+                               new CustomBinding (this),
+                               parameters,
+                               listenUriBaseAddress,
+                               listenUriRelativeAddress,
+                               listenUriMode);
+               }
+
+               public IChannelFactory<TChannel>
+                       BuildChannelFactory<TChannel> (
+                       params object [] parameters)
+               {
+                       BindingParameterCollection pl =
+                               new BindingParameterCollection ();
+                       foreach (object o in parameters)
+                               pl.Add (o);
+                       return BuildChannelFactory<TChannel> (pl);
+               }
+
+               public virtual IChannelFactory<TChannel>
+                       BuildChannelFactory<TChannel> (
+                       BindingParameterCollection parameters)
+               {
+                       if (parameters == null)
+                               throw new ArgumentNullException ("parameters");
+                       return CreateContext (parameters).BuildInnerChannelFactory<TChannel> ();
+               }
+
+               public virtual IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       Uri listenUriBaseAddress,
+                       string listenUriRelativeAddress,
+                       ListenUriMode listenUriMode,
+                       params object [] parameters)
+                       where TChannel : class, IChannel
+               {
+                       BindingParameterCollection pl =
+                               new BindingParameterCollection ();
+                       foreach (object o in parameters)
+                               pl.Add (o);
+                       return BuildChannelListener<TChannel> (
+                               listenUriBaseAddress,
+                               listenUriRelativeAddress,
+                               listenUriMode,
+                               pl);
+               }
+
+               public virtual IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       Uri listenUriBaseAddress,
+                       string listenUriRelativeAddress,
+                       ListenUriMode listenUriMode,
+                       BindingParameterCollection parameters)
+                       where TChannel : class, IChannel
+               {
+                       if (listenUriBaseAddress == null)
+                               throw new ArgumentNullException ("listenUriBaseAddress");
+                       if (listenUriRelativeAddress == null)
+                               throw new ArgumentNullException ("listenUriRelativeAddress");
+                       if (parameters == null)
+                               throw new ArgumentNullException ("parameters");
+                       BindingContext ctx = CreateContext (listenUriBaseAddress,
+                               listenUriRelativeAddress,
+                               listenUriMode,
+                               parameters);
+                       return ctx.BuildInnerChannelListener<TChannel> ();
+               }
+
+               public virtual IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       Uri listenUri,
+                       params object [] parameters)
+                       where TChannel : class, IChannel
+               {
+                       BindingParameterCollection pl =
+                               new BindingParameterCollection ();
+                       foreach (object o in parameters)
+                               pl.Add (o);
+                       return BuildChannelListener<TChannel> (listenUri, pl);
+               }
+
+               public virtual IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       Uri listenUri,
+                       BindingParameterCollection parameters)
+                       where TChannel : class, IChannel
+               {
+                       return BuildChannelListener<TChannel> (listenUri,
+                               String.Empty, parameters);
+               }
+
+               public virtual IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       Uri listenUriBaseAddress,
+                       string listenUriRelativeAddress,
+                       params object [] parameters)
+                       where TChannel : class, IChannel
+               {
+                       BindingParameterCollection pl =
+                               new BindingParameterCollection ();
+                       foreach (object o in parameters)
+                               pl.Add (o);
+                       return BuildChannelListener<TChannel> (
+                               listenUriBaseAddress, listenUriRelativeAddress, pl);
+               }
+
+               public virtual IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       Uri listenUriBaseAddress,
+                       string listenUriRelativeAddress,
+                       BindingParameterCollection parameters)
+                       where TChannel : class, IChannel
+               {
+                       return BuildChannelListener<TChannel> (
+                               listenUriBaseAddress,
+                               listenUriRelativeAddress,
+                               ListenUriMode.Explicit,
+                               parameters);
+               }
+
+               public virtual IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       params object [] parameters)
+                       where TChannel : class, IChannel
+               {
+                       BindingParameterCollection pl =
+                               new BindingParameterCollection ();
+                       foreach (object o in parameters)
+                               pl.Add (o);
+                       return BuildChannelListener<TChannel> (pl);
+               }
+
+               public virtual IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       BindingParameterCollection parameters)
+                       where TChannel : class, IChannel
+               {
+                       if (parameters == null)
+                               throw new ArgumentNullException ("parameters");
+                       return CreateContext (parameters).BuildInnerChannelListener<TChannel> ();
+               }
+
+               public bool CanBuildChannelFactory<TChannel> (
+                       params object [] parameters)
+               {
+                       BindingParameterCollection pl =
+                               new BindingParameterCollection ();
+                       foreach (object o in parameters)
+                               pl.Add (o);
+                       return CanBuildChannelFactory<TChannel> (pl);
+               }
+
+               public virtual bool CanBuildChannelFactory<TChannel> (
+                       BindingParameterCollection parameters)
+               {
+                       if (parameters == null)
+                               throw new ArgumentNullException ("parameters");
+                       return CreateContext (parameters).CanBuildInnerChannelFactory<TChannel> ();
+               }
+
+               public bool CanBuildChannelListener<TChannel> (
+                       params object [] parameters)
+                       where TChannel : class, IChannel
+               {
+                       BindingParameterCollection pl =
+                               new BindingParameterCollection ();
+                       foreach (object o in parameters)
+                               pl.Add (o);
+                       return CanBuildChannelListener<TChannel> (pl);
+               }
+
+               public virtual bool CanBuildChannelListener<TChannel> (
+                       BindingParameterCollection parameters)
+                       where TChannel : class, IChannel
+               {
+                       if (parameters == null)
+                               throw new ArgumentNullException ("parameters");
+                       return CreateContext (parameters).CanBuildInnerChannelListener<TChannel> ();
+               }
+
+               public abstract BindingElementCollection CreateBindingElements ();
+
+               public T GetProperty<T> (BindingParameterCollection parameters)
+                       where T : class
+               {
+                       if (parameters == null)
+                               throw new ArgumentNullException ("parameters");
+                       return CreateContext (parameters).GetInnerProperty<T> ();
+               }
+
+               private void Initialize ()
+               {
+                       IDefaultCommunicationTimeouts t =
+                               DefaultCommunicationTimeouts.Instance;
+                       open_timeout = t.OpenTimeout;
+                       close_timeout = t.CloseTimeout;
+                       receive_timeout = t.ReceiveTimeout;
+                       send_timeout = t.SendTimeout;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingContext.cs
new file mode 100644 (file)
index 0000000..885fdd6
--- /dev/null
@@ -0,0 +1,206 @@
+//
+// BindingContext.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Channels
+{
+       public class BindingContext
+       {
+               static BindingElementCollection empty_collection =
+                       new BindingElementCollection ();
+
+               CustomBinding binding;
+               BindingParameterCollection parameters;
+               BindingElementCollection elements = empty_collection;
+               BindingElementCollection remaining_elements;
+               Uri listen_uri_base;
+               string listen_uri_relative;
+               ListenUriMode listen_uri_mode;
+
+               public BindingContext (CustomBinding binding,
+                       BindingParameterCollection parameters)
+               {
+                       if (binding == null)
+                               throw new ArgumentNullException ("binding");
+                       if (parameters == null)
+                               throw new ArgumentNullException ("parameters");
+
+                       this.binding = binding;
+                       this.parameters = parameters;
+               }
+
+               public BindingContext (CustomBinding binding,
+                       BindingParameterCollection parameters,
+                       Uri listenUriBaseAddress,
+                       string listenUriRelativeAddress,
+                       ListenUriMode listenUriMode)
+                       : this (binding, parameters)
+               {
+                       listen_uri_base = listenUriBaseAddress;
+                       listen_uri_relative = listenUriRelativeAddress;
+                       listen_uri_mode = listenUriMode;
+               }
+
+               // copy .ctor().
+               private BindingContext (BindingContext other)
+               {
+                       binding = other.binding;
+                       parameters = other.parameters;
+                       elements = other.elements == empty_collection ?
+                               empty_collection : other.elements.Clone ();
+               }
+
+               public CustomBinding Binding {
+                       get { return binding; }
+               }
+
+               public BindingParameterCollection BindingParameters {
+                       get { return parameters; }
+               }
+
+               public Uri ListenUriBaseAddress {
+                       get { return listen_uri_base; }
+                       set { listen_uri_base = value; }
+               }
+
+               public string ListenUriRelativeAddress {
+                       get { return listen_uri_relative; }
+                       set { listen_uri_relative = value; }
+               }
+
+               public ListenUriMode ListenUriMode {
+                       get { return listen_uri_mode; }
+                       set { listen_uri_mode = value; }
+               }
+
+               public BindingElementCollection RemainingBindingElements {
+                       get {
+                               if (remaining_elements == null)
+                                       remaining_elements = new BindingElementCollection ();
+                               return remaining_elements;
+                       }
+               }
+
+               internal BindingElement DequeueBindingElement ()
+               {
+                       return DequeueBindingElement (true);
+               }
+
+               BindingElement DequeueBindingElement (bool raiseError)
+               {
+                       if (elements.Count == 0) {
+                               if (raiseError)
+                                       throw new InvalidOperationException ("There is no more available binding element.");
+                               else
+                                       return null;
+                       }
+                       BindingElement el = elements [0];
+                       elements.RemoveAt (0);
+                       return el;
+               }
+
+               private bool PrepareElements ()
+               {
+                       if (elements != empty_collection)
+                               return false;
+                       elements = binding.CreateBindingElements ();
+                       return true;
+               }
+
+               public IChannelFactory<TChannel>
+                       BuildInnerChannelFactory<TChannel> ()
+               {
+                       bool restore = PrepareElements ();
+                       try {
+                               return DequeueBindingElement ().BuildChannelFactory<TChannel> (this);
+                       } finally {
+                               if (restore)
+                                       elements = empty_collection;
+                       }
+               }
+
+               public IChannelListener<TChannel>
+                       BuildInnerChannelListener<TChannel> ()
+                       where TChannel : class, IChannel
+               {
+                       bool restore = PrepareElements ();
+                       try {
+                               return DequeueBindingElement ().BuildChannelListener<TChannel> (this);
+                       } finally {
+                               if (restore)
+                                       elements = empty_collection;
+                       }
+               }
+
+               public bool CanBuildInnerChannelFactory<TChannel> ()
+               {
+                       bool restore = PrepareElements ();
+                       try {
+                               return elements.Count > 0 &&
+                                       DequeueBindingElement ().CanBuildChannelFactory<TChannel> (this);
+                       } finally {
+                               if (restore)
+                                       elements = empty_collection;
+                       }
+               }
+
+               public bool CanBuildInnerChannelListener<TChannel> ()
+                       where TChannel : class, IChannel
+               {
+                       bool restore = PrepareElements ();
+                       try {
+                               return elements.Count > 0 &&
+                                       DequeueBindingElement ().CanBuildChannelListener<TChannel> (this);
+                       } finally {
+                               if (restore)
+                                       elements = empty_collection;
+                       }
+               }
+
+               public T GetInnerProperty<T> () where T : class
+               {
+                       bool restore = PrepareElements ();
+                       try {
+                               BindingElement e = DequeueBindingElement (false);
+                               return e == null ? default (T) : e.GetProperty<T> (this);
+                       } finally {
+                               if (restore)
+                                       elements = empty_collection;
+                       }
+               }
+
+               public BindingContext Clone ()
+               {
+                       return new BindingContext (this);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingElement.cs
new file mode 100644 (file)
index 0000000..e1cd1d7
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// BindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class BindingElement
+       {
+               protected BindingElement ()
+               {
+               }
+
+               [MonoTODO]
+               protected BindingElement (BindingElement other)
+               {
+               }
+
+               public virtual IChannelFactory<TChannel>
+                       BuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       return context.BuildInnerChannelFactory<TChannel> ();
+               }
+
+               public virtual IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       BindingContext context)
+                       where TChannel : class, IChannel
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       return context.BuildInnerChannelListener<TChannel> ();
+               }
+
+               public virtual bool CanBuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       return context.CanBuildInnerChannelFactory<TChannel> ();
+               }
+
+               public virtual bool CanBuildChannelListener<TChannel> (
+                       BindingContext context)
+                       where TChannel : class, IChannel
+               {
+                       return context.CanBuildInnerChannelListener<TChannel> ();
+               }
+
+               public abstract BindingElement Clone ();
+
+               public abstract T GetProperty<T> (BindingContext context)
+                       where T : class;
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingElementCollection.cs
new file mode 100644 (file)
index 0000000..762cb61
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// BindingElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public class BindingElementCollection : Collection<BindingElement>
+       {
+               public BindingElementCollection ()
+               {
+               }
+
+               public BindingElementCollection (BindingElement [] bindings)
+               {
+                       AddRange (bindings);
+               }
+
+               public BindingElementCollection (IEnumerable<BindingElement> bindings)
+               {
+                       foreach (BindingElement e in bindings)
+                               Add (e);
+               }
+
+               public void AddRange (params BindingElement[] elements)
+               {
+                       foreach (BindingElement e in elements)
+                               Add (e);
+               }
+
+               public BindingElementCollection Clone ()
+               {
+                       return new BindingElementCollection (this);
+               }
+
+               public bool Contains (Type bindingElementType)
+               {
+                       foreach (BindingElement b in this)
+                               if (bindingElementType.IsAssignableFrom (b.GetType ()))
+                                       return true;
+                       return false;
+               }
+
+               public T Find<T> ()
+               {
+                       foreach (BindingElement b in this)
+                               if ((object) b is T)
+                                       return (T) (object) b;
+                       return default (T);
+               }
+
+               public Collection<T> FindAll<T> ()
+               {
+                       Collection<T> coll = new Collection<T> ();
+                       foreach (BindingElement b in this)
+                               if ((object) b is T)
+                                       coll.Add ((T) (object) b);
+                       return coll;
+               }
+
+               public T Remove<T> ()
+               {
+                       foreach (BindingElement b in this) {
+                               if ((object) b is T) {
+                                       Remove (b);
+                                       return (T) (object) b;
+                               }
+                       }
+                       return default (T);
+               }
+
+               public Collection<T> RemoveAll<T> ()
+               {
+                       Collection<T> coll = new Collection<T> ();
+                       foreach (BindingElement b in this) {
+                               if ((object) b is T) {
+                                       Remove (b);
+                                       coll.Add ((T) (object) b);
+                               }
+                       }
+                       return coll;
+               }
+
+               protected override void InsertItem (int index,
+                       BindingElement item)
+               {
+                       Items.Insert (index, item);
+               }
+
+               protected override void SetItem (int index, BindingElement item)
+               {
+                       Items [index] = item;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingParameterCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingParameterCollection.cs
new file mode 100644 (file)
index 0000000..dbac384
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// BindingParameterCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+
+namespace System.ServiceModel.Channels
+{
+       public class BindingParameterCollection
+               : KeyedByTypeCollection<object>
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BodyWriter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BodyWriter.cs
new file mode 100644 (file)
index 0000000..243d1a2
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// BodyWriter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class BodyWriter
+       {
+               bool is_buffered;
+
+               protected BodyWriter (bool isBuffered)
+               {
+                       is_buffered = isBuffered;
+               }
+
+               public bool IsBuffered {
+                       get { return is_buffered; }
+               }
+
+               public BodyWriter CreateBufferedCopy (
+                       int maxBufferSize)
+               {
+                       return OnCreateBufferedCopy (maxBufferSize);
+               }
+
+               public void WriteBodyContents (XmlDictionaryWriter writer)
+               {
+                       OnWriteBodyContents (writer);
+               }
+
+               [MonoTODO]
+               protected virtual BodyWriter OnCreateBufferedCopy (
+                       int maxBufferSize)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected abstract void OnWriteBodyContents (
+                       XmlDictionaryWriter writer);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BufferManager.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BufferManager.cs
new file mode 100644 (file)
index 0000000..9078b9d
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// BufferManager.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class BufferManager
+       {
+               protected BufferManager ()
+               {
+               }
+
+               public abstract void Clear ();
+
+               [MonoTODO]
+               public static BufferManager CreateBufferManager (
+                       long maxBufferPoolSize, int maxBufferSize)
+               {
+                       return new DefaultBufferManager (maxBufferPoolSize,
+                               maxBufferSize);
+               }
+
+               public abstract void ReturnBuffer (byte[] buffer);
+
+               public abstract byte[] TakeBuffer (int bufferSize);
+
+               class DefaultBufferManager : BufferManager
+               {
+                       long max_pool_size;
+                       int max_size;
+                       byte [] buffer;
+
+                       public DefaultBufferManager (long maxBufferPoolSize,
+                               int maxBufferSize)
+                       {
+                               this.max_pool_size = maxBufferPoolSize;
+                               this.max_size = maxBufferSize;
+                       }
+
+                       public override void Clear ()
+                       {
+                               if (buffer != null)
+                                       Array.Clear (buffer, 0, buffer.Length);
+                       }
+
+                       public override void ReturnBuffer (byte [] buffer)
+                       {
+                               // is this correct?
+
+                               if (this.buffer == null)
+                                       return;
+                               Array.Copy (this.buffer, buffer, this.buffer.Length);
+                       }
+
+                       public override byte [] TakeBuffer (int bufferSize)
+                       {
+                               if (bufferSize > max_size)
+                                       throw new ArgumentOutOfRangeException ();
+
+                               if (buffer == null || buffer.Length < bufferSize)
+                                       buffer = new byte [bufferSize];
+                               return buffer;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CachingCompiler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CachingCompiler.cs
new file mode 100644 (file)
index 0000000..bcd183d
--- /dev/null
@@ -0,0 +1,187 @@
+//
+// CachingCompiler
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//     Ankit Jain  (jankit@novell.com)
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+// (c) Copyright Novell, Inc. (http://www.novell.com)
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Code taken from System.Web.Compilation.CachingCompiler
+//
+
+using System;
+using System.CodeDom.Compiler;
+using System.Collections;
+using System.Collections.Specialized;
+using System.IO;
+using System.Reflection;
+using System.Threading;
+using System.Web;
+using System.Web.UI;
+using System.Web.Caching;
+using System.Web.Configuration;
+
+namespace System.ServiceModel.Channels
+{
+       class CachingCompiler
+       {
+               static string dynamicBase = AppDomain.CurrentDomain.SetupInformation.DynamicBase;
+               static Hashtable compilationTickets = new Hashtable ();
+               public const string cachePrefix = "@@Assembly";
+               public const string cacheTypePrefix = "@@@Type";
+
+               public static void InsertTypeFileDep (Type type, string filename)
+               {
+                       CacheDependency dep = new CacheDependency (filename);
+                       HttpRuntime.Cache.Insert (cacheTypePrefix + filename, type, dep);
+               }
+
+               public static void InsertType (Type type, string filename, string key,
+                               CacheItemRemovedCallback removed_callback)
+               {
+                       //string [] cacheKeys = new string [] { cachePrefix + filename };
+                       //CacheDependency dep = new CacheDependency (null, cacheKeys);
+                       CacheDependency dep = new CacheDependency (filename);
+
+                       HttpRuntime.Cache.Insert (cacheTypePrefix + key, type, dep,
+                               Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
+                               CacheItemPriority.Normal, removed_callback);
+               }
+
+               public static Type GetTypeFromCache (string filename)
+               {
+                       return (Type) HttpRuntime.Cache [cacheTypePrefix + filename];
+               }
+
+               internal static CompilerParameters GetOptions (ICollection assemblies)
+               {
+                       CompilerParameters options = new CompilerParameters ();
+                       if (assemblies != null) {
+                               StringCollection coll = options.ReferencedAssemblies;
+                               foreach (string str in assemblies)
+                                       coll.Add (str);
+                       }
+
+                       return options;
+               }
+
+               public static CompilerResults Compile (string language, string key, string source,
+                                                       string filename, ArrayList assemblies)
+               {
+                       Cache cache = HttpRuntime.Cache;
+                       CompilerResults results = (CompilerResults) cache [cachePrefix + key];
+                       if (results != null)
+                               return results;
+
+                       if (!Directory.Exists (dynamicBase))
+                               Directory.CreateDirectory (dynamicBase);
+
+                       object ticket;
+                       bool acquired = AcquireCompilationTicket (cachePrefix + key, out ticket);
+
+                       try {
+                               Monitor.Enter (ticket);
+                               results = (CompilerResults) cache [cachePrefix + key];
+                               if (results != null)
+                                       return results;
+                               CompilationSection config = (CompilationSection) WebConfigurationManager.GetSection ("system.web/compilation");
+                               Compiler c = config.Compilers[language];
+                               Type t = Type.GetType (c.Type, true);
+                               CodeDomProvider provider = Activator.CreateInstance (t) as CodeDomProvider;
+
+                               if (provider == null)
+                                       throw new HttpException ("Configuration error. Language not supported: " +
+                                                                 language, 500);
+
+                               CompilerParameters options = GetOptions (assemblies);
+                               TempFileCollection tempcoll = new TempFileCollection (config.TempDirectory, true);
+                               string dllfilename = Path.GetFileName (tempcoll.AddExtension ("dll", true));
+                               options.OutputAssembly = Path.Combine (dynamicBase, dllfilename);
+
+                               results = provider.CompileAssemblyFromSource (options, source);
+
+                               ArrayList realdeps = new ArrayList (assemblies.Count + 1);
+                               realdeps.Add (filename);
+                               for (int i = assemblies.Count - 1; i >= 0; i--) {
+                                       string current = (string) assemblies [i];
+                                       if (Path.IsPathRooted (current))
+                                               realdeps.Add (current);
+                               }
+
+                               string [] deps = (string []) realdeps.ToArray (typeof (string));
+                               //cache results
+                               cache.Insert (cachePrefix + key, results, new CacheDependency (deps));
+                       } finally {
+                               Monitor.Exit (ticket);
+                               if (acquired)
+                                       ReleaseCompilationTicket (cachePrefix + key);
+                       }
+
+                       return results;
+               }
+
+               public static Type CompileAndGetType (ServiceHostParser parser,
+                       string key, CacheItemRemovedCallback removed_callback)
+               {
+                       CompilerResults result = CachingCompiler.Compile (parser.Language, key, parser.Program, parser.Filename, parser.Assemblies);
+                       if (result.NativeCompilerReturnValue != 0)
+                               throw new CompilationException (parser.Filename, result.Errors, parser.Program);
+
+                       Assembly assembly = result.CompiledAssembly;
+                       if (assembly == null)
+                               throw new CompilationException (parser.Filename, result.Errors, parser.Program);
+               
+                       Type type = assembly.GetType (parser.TypeName, true);
+                       //cache type
+                       InsertType (type, parser.Filename, key, removed_callback);
+
+                       return type;
+               }
+
+               static bool AcquireCompilationTicket (string key, out object ticket)
+               {
+                       lock (compilationTickets.SyncRoot) {
+                               ticket = compilationTickets [key];
+                               if (ticket == null) {
+                                       ticket = new object ();
+                                       compilationTickets [key] = ticket;
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+
+               static void ReleaseCompilationTicket (string key)
+               {
+                       lock (compilationTickets.SyncRoot) {
+                               compilationTickets.Remove (key);
+                       }
+               }
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
new file mode 100755 (executable)
index 0000000..dcb9920
--- /dev/null
@@ -0,0 +1,2264 @@
+2008-05-22  Noam Lampert <noaml@mainsoft.com>
+
+       * MessageFault.cs: Correctly serialize ExceptionDetails. Expose SimpleMessageFault to allow
+         internal users to know the type of the detail. 
+       
+2008-05-20  Noam Lampert <noaml@mainsoft.com>
+
+       * Message.c: Use private setter for state private variable to ease debugging.
+                                Modify ToString not to change the state, as it is called quite often by VS debugger
+                                
+2008-04-21  Roei Erez <roeie@mainsoft.com>
+
+       * HttpChannleManager: Fix for multithreaded use.
+       * HttpReplyChannel: Fix crash during sutdown.
+
+2008-04-17  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * HttpChannleManager: ensure trailing slash in uri.
+
+2008-04-17  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * added: HttpChannleManager,
+       * HttpChannelListener: added use of HttpChannelManager
+
+2008-04-17  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * MessageEncodingBindingElement.cs: fixed ctor
+
+2008-04-17  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * XmlReaderBodyWriter.cs: fixed ctor, skip xml declaration
+
+2008-04-17  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * HttpReplyChannel.cs: fixed TryReceiveRequest, fix message header To
+
+2008-04-17  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * MessageFault.cs: fixed CreateFault11, implemented "detail"
+
+2008-04-17  Noam Lampert <noaml@mainsoft.com>
+
+       * HttpReplyChannel.cs: fix API - Fix crash during service shutdown.
+
+2008-04-13  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * BindingElementCollection.cs: fix API - .ctor's signature.
+
+2008-04-10  Eyal Alaluf <eyala@mainsoft.com>
+
+       * XmlSerializerBodyWriter.cs: Removed.
+
+2008-03-25  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * MessageFault.cs: fixed WriteReason, .net XmlWriter compatible
+
+2008-02-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DuplexSessionChannelBase.cs : made it non-session (more reusable).
+       * TcpChannelFactory.cs, TcpChannelListener.cs :
+         unify factory and listener into TcpChannelInfo for use in
+         TCP channel implementation. Do not store stream in the listener.
+         Factory now uses BinaryMessageEncoder.
+       * TcpDuplexSessionChannel.cs : changes explained above, and now it
+         holds TcpClient that the listener has accepted.
+
+         tcp-transport-binding-element sample now communicates (though
+         only when both sides are mono: there seems binary mismatch).
+
+2008-02-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TcpTransportBindingElement.cs, TcpConnectionPoolSettings.cs :
+         clone connection pool settings too.
+       * NamedPipetransportBindingElement.cs,
+         NamedPipeConnectionPoolSettings.cs : let's clean them up too (not
+         being likely implemented though).
+
+2008-02-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ConnectionOrientedTransportBindingElement.cs, 
+         TcpTransportBindingElement.cs : some API updates.
+         Initialize default values.
+       * TcpConnectionPoolSettings.cs : new file.
+
+2008-02-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostParser.cs, SvcHttpHandlerFactory.cs, SvcHttpHandler.cs:
+         added support for "factory" attribute.
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestContent.cs : consider HttpResponseMessageProperty.
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs : pass response ContentType to ReadMessage().
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs : create WebRequest against To message header
+         item (if exists).
+         Consider HttpRequestMessageProperty.
+         Do not output body when suppressed or the method is GET.
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpChannelListener.cs : BindingContext may not have listenUri
+         at its .ctor() step.
+
+2008-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingContext.cs : RemainingBindingElements is not just a dummy
+         collection but is actually user-controlled.
+
+2008-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TcpChannelFactory.cs, TcpChannelListener.cs, 
+         HttpChannelFactory.cs, HttpChannelListener.cs,
+         MsmqChannelFactory.cs, MsmqChannelListener.cs,
+         TextMessageEncodingBindingElement.cs,
+         BinaryMessageEncodingBindingElement.cs,
+         MtomMessageEncodingBindingElement.cs :
+         message encoder should be retrieved only through public API.
+       * BindingContext.cs : so my old guess was wrong.
+
+       See also: http://blogs.msdn.com/drnick/archive/2006/05/10/594134.aspx
+
+2008-02-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElement.cs : implemented copy constructor.
+
+2007-08-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs, HttpReplyChannel.cs : treat SOAPAction HTTP
+         header when AddressingVersion is None.
+
+2007-08-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeaders.cs : AddressingVersion.None rejects some WSA
+         property setters.
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OneWayBindingElementImporter.cs
+         CompositeDuplexBindingElementImporter.cs : new files.
+
+2007-08-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeaders.cs : due to the DataContractSerializer.ReadObject()
+         semantic change, its bool parameter must be false, not true.
+
+2007-07-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InputChannelBase.cs, MsmqChannelListener.cs, MsmqInputChannel.cs :
+         new files. Msmq transport listener Implementation.
+       * MsmqOutputChannel.cs : implemented Send(). Not sure if it works
+         (wait for System.Messaging impl.)
+       * HttpReplyChannel.cs : added comment
+
+2007-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MsmqChannelFactory.cs MsmqOutputChannel.cs OutputChannelBase.cs :
+         new files. internal stuff for msmq channel.
+       * BinaryMessageEncoder.cs : added another .ctor().
+       * MsmqTransportBindingElement.cs :
+         implemented [Can]BuildChannelFactory().
+
+2007-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MsmqBindingElementBase.cs MsmqTransportBindingElement.cs :
+         initialize some fields.
+
+2007-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MsmqBindingElementBase.cs MsmqMessageProperty.cs
+         MsmqTransportBindingElement.cs ITransactedBindingElement.cs :
+         couple of msmq stubs.
+
+2007-04-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : SecurityContextToken support (though
+         it is still regarded as invalid by WCF).
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs, SecureMessageGenerator.cs :
+         make header.Contents.Add() more strict.
+         Use HasAsymmetricKey to determine whether to use asymmetric algorithm
+         or not.
+         Added some hack to allow ssl token external mode.
+         Commented out such lines that always premised asymmtric key.
+
+2007-03-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TransactionFlowBindingElement.cs : forgot necessary Clone().
+
+2007-03-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : support check to create
+         authenticator is now done in both initiator/recipient sides.
+       * SecurityRequestContext.cs : don't encrypt WS-Trust RSTR.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : for now, comment out the code
+         that makes authenticator creation optional.
+       * SecurityRequestContext.cs : don't decrypt message when it is
+         WS-Trust messages. Also, do not secure SOAP Fault (it is likely
+         to fail).
+       * SecurityChannelListener.cs : GetProperty<T>() now returns
+         MessageSecurityBindingSupport when requested. It is used by
+         EndpointDispatcher to check if it supports WS-Trust negotiation.
+       * ChannelListenerBase.cs :
+         removed extra TODO and field. Implemented GetProperty<T>().
+       * Message.cs : In CreateMessage() for SOAP Fault, create
+         SimpleMessage with IsFault = true.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityRequestContext.cs : try to reply fault with the inner
+         channel when an error occurred internally.
+       * FaultConverter.cs : implemented based on OperationContext (at normal
+         state it does not seem to create messages, so I implemented it this
+         way).
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TransportBindingElement.cs : implemented GetProperty<T>().
+       * TransactionFlowBindingElement.cs : on building factory or listener,
+         reject channel types that cannot build.
+       * SecurityBindingElement.cs : added some TODO comments.
+       * HttpTransportBindingElement.cs : GetProperty<T>() should rather
+         delegate to base, not BindingContext.
+       * SecurityRequestContext.cs : somewhat late decryption.
+
+2007-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs,
+         AsymmetricSecurityBindingElement.cs,
+         SymmetricSecurityBindingElement.cs :
+         renamed *SecurityBindingElementSupport to *SecurityCapabilities and
+         implemented ISecurityCapabilities on them. Now those binding
+         elements support GetProperty<ISecurityCapabilities>().
+
+2007-03-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElement.cs : SetIssuerBindingContextIfRequired()
+         will work only for predefined parameter types.
+
+2007-03-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs :
+         Set proper MessageDirection to the requirement after creation.
+         split CreateTokenAuthenticator() as MessageDirection is different.
+         Removed extra creation of requirement.
+
+2007-03-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : token authenticator is not
+         always created on channel-opening stage.
+       * SecurityBindingElement.cs : use SslSecurityTokenParameters for
+         Sslnego binding factory method.
+
+2007-02-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : inconsistent ReferenceList has caused
+         signature velification failure.
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : encrypt signature confirmations only
+         when they are required.
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : SignatureConfirmation must be encrypted
+         when [Signature Protection is true i.e. when we use
+         SignBeforeEncryptAndEncryptSignature.
+
+         With this change finally samplesvc.cs/samplecli.cs became
+         interoperable(!)
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageDecryptor.cs : signature verification was not done
+         for endorsing supporting tokens.
+       * SecureMessageGenerator.cs : moved SignatureConfirmation position
+         in the security header. Don't output empty ReferenceList.
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : signingToken was added before being
+         initialized and thus caused NRE.
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs, SecureMessageDecryptor.cs,
+         SecureMessageGenerator.cs : use SHA1 instead of HMACSHA1. Now we
+         don't need workaround for symmetric key restoration.
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs, SecureMessageDecryptor.cs,
+         SecureMessageGenerator.cs :
+         Avoid extra reference search from the request's ReferenceList.
+         create HMACSHA1 always with the key to compute hash (I'm not sure
+         it is correct; it is rather to adjust all hash consistent.)
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageDecryptor.cs : verify that endorsing supporting tokens
+         actually endorsed the primary signature.
+       * SecureMessageGenerator.cs : implemented endorsing of the primary
+         signature. So, now supporting tokens are fully implemented.
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : so, those supporting tokens are
+         totally signing tokens.
+       * SecureMessageGenerator.cs : Endorsing tokens should also be
+         included in the message. They are just not signed.
+
+2007-02-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : support signing and encryption of
+         supporting tokens. Some required refactory to do it.
+       * MessageSecurityBindingSupport.cs : added EncryptedData member.
+
+2007-02-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageDecryptor.cs : fix exception message.
+       * WSSecurityMessageHeader.cs, WSSignedXml.cs, WSEncryptedXml.cs :
+         XmlNamespaceManager is not required for GetIdElement().
+
+2007-02-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageDecryptor.cs, WSSecurityMessageHeader.cs :
+         moved decryption part from former file to latter file, to reuse
+         SignedXml instance (though now I doubt how it actually was good)
+         which in turn required to replace EncryptedData in
+         WSSecurityMessageHeader with decrypted one.
+       * WSEncryptedXml.cs : similar to WSSignedXml.cs, to handle wsu:Id.
+
+2007-02-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : when we create DerivedKeyToken, those
+         EncryptedData should contain KeyInfo as it is not obvious which key
+         is used there. .net<->mono DerivedKeyToken introp is done.
+       * SecureMessageDecryptor.cs : check derived key requirement.
+         Reduce dom-dependent parts.
+
+2007-02-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs : ReferenceList needs to be bound to
+         the related DerivedKeyToken (if any).
+       * SecureMessageGenerator.cs : largely done with DerivedKeyToken
+         support. Some refactoring to distinguish deried-token-related
+         variables.
+       * SecureMessageDecryptor.cs : removed its own support for derived
+         key tokens. Now it fully works with DerivedKeySecurityToken.
+
+2007-02-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs, SecureMessageDecryptor.cs,
+         SecureMessageDecryptor.cs :
+         Implemented increment token reading in o:Security, as
+         DerivedKeyToken could reference to existing wrapped key.
+         Removed WsscDerivedKeyToken and all relevant code.
+       * SecureMessageGenerator.cs : replaced WsscDerivedKeyToken with
+         DerivedKeySecurityToken.
+
+2007-02-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : it was setting security tokens into
+         incorrect SecurityMessageProperty.
+         Use correct WrappedKeySecurityToken for EncryptedKeySHA1.
+         Now it uses SecurityRequestContext instead of just primary key.
+       * SecureMessageDecryptor.cs : removed extra lines. Limit workarounds
+         to symmetric reply decryption, which is the only trouble case.
+         Do not create another SignedXml.
+       * WSSecurityMessageHeader.cs : SignedXml processing changes above.
+
+2007-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageDecryptor.cs : Now it uses union token resolver and
+         the resolver works with in-progress token reading in o:Security.
+       * WSSecurityMessageHeader.cs : now it does not read EncryptedKey
+         as EncryptedKeyIdentifierClause. It is rather a SecurityToken.
+       * SecureMessageGenerator.cs : cosmetic refactoring.
+
+2007-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs : read EncryptedKeyIdentifierClause
+         instead of EncryptedKey.
+
+2007-02-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : SigningToken and EncryptionToken
+         should not be always prepared at channel Open(). It also caused
+         that extra token requirements.
+       * SecureMessageGenerator.cs : use correct key clause for encryption.
+       * SecureMessageDecryptor.cs : reduce extra key acquisition.
+
+2007-02-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : added CreateTokenAuthenticator()
+         for supporting 'supporting tokens' .
+       * SecureMessageGenerator.cs : Supporting token creation is done only
+         at initiator (not sure if it is supposed that, but for now it is).
+         Removed extraneous CollectSupportingTokens().
+       * SecureMessageDecryptor.cs : implemented supporting token
+         authentication (partly). "Signed" supporting tokens are expected
+         to work fine.
+
+2007-02-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs :
+         make SignBeforeEncryptAndEncryptSignature working.
+
+2007-02-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : EncryptedKeySHA1 needs key hash, not
+         the key itself. ProtectionToken is WrappedKey.
+       * SecureMessageDecryptor.cs : now it is internal encrypted key clause,
+         not EncryptedKeyIdentifierClause which is not for embedded key.
+       * MessageProperties.cs : Fixed copy direction in CopyProperties().
+
+2007-02-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : added DefaultKeyWrapAlgorithm
+         to switch asymmetric and symmetric. Not used yet.
+       * SecurityRequestChannel.cs : now it pass the request security
+         property to reply receiver so that it could use the primary key
+         used at request phase.
+       * SecurityRequestContext.cs : now it pass the context itself to
+         reply sender so that it could embed related MessageID.
+       * SecureMessageGenerator.cs : ongoing changes to support symmetric
+         binding element. Add RelatesTo output and remove MessageID when
+         replying to the sender. Added some hacks to get symmetric binding
+         (kind of) working.
+       * SecureMessageDecryptor.cs : ditto. Handle embedded encryption key
+         in SecurityTokenReference (it also involved existing encrypted key 
+         retrieval). In reply receiver, reuse the key that was used at
+         request phase. It needs significant token resolution refactoring.
+
+2007-02-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : cosmetic refactoring.
+       * SecureMessageDecryptor.cs : store token and its authentication
+         policies into the security property, and reuse it on reply.
+         Some code refactoring; there is at most one o:Security to solve at
+         one endpoint (depends on Actor). Some attempt to use correct
+         token parameters (but for now I have only samples that use x509).
+       * SecureMessageGenerator.cs : For replying message, use initiator's
+         signing token as the encryption token. Simply reuse security
+         property from the input message.
+
+         I have some nasty workaround at decryptor for initiator that could
+         not retrieve decryption key.
+
+2007-02-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs, SecurityChannelListener.cs,
+         SecurityRequestContext.cs, MessageSecurityBindingSupport.cs:
+         several refactoring on token acquisition. Large part of
+         MessageSecurityBindingSupport code is unified.
+
+2007-02-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageProperties.cs : Security property should be one of the items.
+         Actually many other properties should be similar as well.
+       * MessageImpl.cs, MessageBufferImpl.cs, Message.cs :
+         when copying a message, copy properties as well.
+       * SecurityRequestContext.cs : on replying, pass input 
+         SecurityMessageProperty to the security generator.
+       * SecureMessageGenerator.cs : both of above, for SignatureConfirmation
+         support.
+       * WSSecurityMessageHeader.cs : fixed lazy .ctor() that did nothing.
+
+2007-02-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSignedXml.cs:
+         MessageHeader.cs, Message.cs, WSSecurityMessageHeader.cs,
+         SecureMessageDecryptor.cs, SecureMessageGenerator.cs:
+         use new WSSignedXml instead of SignedXml, and remove coexisting
+         Id and wsu:Id. Now we can live only with wsu:Id and therefore
+         - our reply messages could be consumed by .NET, and
+         - .NET signature could be verified.
+
+2007-02-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageDecryptor.cs : The signing key must be passed as
+         CheckSignature() argument, not SigningKey.
+
+2007-01-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageImpl.cs : don't read attribute after ReadStartElement().
+
+2007-01-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : some Release() refactoring.
+       * SecureMessageGenerator.cs : use correct signing key clause for
+         SecurityTokenReferenceKeyInfo to be serialized.
+       * SecureMessageDecryptor.cs : now it can try to parse signature.
+
+2007-01-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       Ongoing changes to support signature confirmation
+       * SecureMessageGenerator.cs :
+         Don't output ReplyTo onto reply message.
+         Write SignatureConfirmation if needed.
+       * SecureMessageDecryptor.cs :
+         Some refactoring for header cunsumption. Added commented-out
+         signature verification part (not working yet, on client side due
+         to incorrect reply from service and insufficient clause reader).
+       * WSSecurityMessageHeader.cs :
+         Added SignatureConfirmation support.
+         KeyInfoClause for o:SecurityTokenReference should be replaced with
+         SecurityTokenReferenceKeyInfo.
+
+2007-01-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : support Timestamp signature.
+         Removed unused code, and extra argument in CreateReference().
+       * WSSecurityMessageHeader.cs : Timestamp also needs Id for SignedXml.
+
+2007-01-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs :
+         Several fixes to make asymmetric binding working:
+         - Differentiate signing and encryption token in several areas.
+         - Fixed signing keyinfo.
+         Use SenderIdPrefix.
+         Added initial SecurityMessageProperty handling, not sure if it is
+         appropriate here though.
+       * HttpRequestChannel.cs : (some debugging lines)
+
+2007-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       Woohoo! Here is a very basic WS-Security compliant message which could
+       be allowed by Indigo.
+       * MessageHeader.cs : added Id support for writing.
+       * Message.cs : added internal BodyId for signature reference.
+       * MessageImpl.cs : write Body Id if required.
+       * SecureMessageGenerator.cs : Before signing, the target elements must
+         be given wsu:Id. Since I still use System.Security.dll, I need some
+         trick for signing (I give both Id and wsu:Id, former to sign and
+         latter to be consumed). Maybe I will have to replace xmldsig/xmlenc
+         implementation later. Now singning mechanism works except for
+         wsu:Timestamp (which is kind of mandatory).
+
+       I can's still consume replies from Indigo but it's a big progress :)
+
+2007-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeaderInfo.cs : added internal Id.
+       * MessageHeader.cs : read and write wsu:Id.
+       * Message.cs : output wsu namespace if Id exists in any header.
+       * HttpReplyChannel.cs : (some debugging lines.)
+       * SecureMessageDecryptor.cs : (remove debugging lines.)
+       * MessageImpl.cs : removed obsolete code.
+       * WSSecurityMessageHeader.cs : output "o" prefix.
+       * SecureMessageGenerator.cs : replaced XmlElement-based header
+         signing with MessageHeader-based signing, to support Id correctly.
+
+2007-01-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : some more refactoring and code comments.
+       * MessageSecurityUtility.cs : made decryptor into an instance class,
+         like I've done for SecureMessageGenerator.
+       * SecurityRequestContext.cs, SecurityRequestChannel.cs :
+         dependent changes for above.
+
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : fixed derived keysize. derived key was
+         causing NRE due to the lack of token reference.
+         No need to pass doc to SignedXml.ctor() anymore.
+         Moved ReferenceList before the signature(s).
+
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : add wsu:Timestamp to signing target.
+         Moved signing key generation code to non-HMACSHA1 signing part.
+         Don't try to sign wss:Security.
+         Pass document itself to SignedXml.ctor().
+         Use temporary DataObjects to avoid adding Ids (not sure what is the
+         expected processing yet).
+       * WSSecurityMessageHeader.cs : to support timestamp signing, add
+         WriteTo() method in WsuTimestamp.
+
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : wrong key was used for signing.
+         Omit KeyInfo for now - it seems that .net (sometimes?) omits it.
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs :
+         Now ID generation process does not modify input message.
+         Moved derived key generation part into (virtual) signing loop.
+         MessagePartSpecification support for signing is done.
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : some reordering to handle signing and
+         encryption with supporting tokens. Fixed XPath query bug for
+         soap header contents (we want s:Header/*, not s:Header).
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : more refactoring.
+         Made it abstract and added Initiator- and Recipient- classes.
+         Several members were moved to those derived types.
+       * AsymmetricSecurityBindingElement.cs, 
+         SymmetricSecurityBindingElement.cs
+         SecurityChannelFactory.cs, SecurityChannelListener.cs,
+         SecurityRequestChannel.cs, SecurityOutputChannel.cs,
+         SecurityRequestContext.cs, SecureMessageGenerator.cs :
+         All dependent changes by above. Removed ISecurityChannelSource
+         which became useless.
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureMessageGenerator.cs : encryption parts should exist too.
+       * AsymmetricSecurityBindingElement.cs
+         SymmetricSecurityBindingElement.cs,
+         MessageSecurityBindingSupport.cs : some refactoring.
+         Split MessageSecurityBindingSupport into security binding element
+         specific parts and made MessageSecurityBindingSupport concrete.
+         It is likely split again, next time based on initiator/recipient.
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs, SecureMessageGenerator.cs :
+         split encryptor part in the former file into latter file, and
+         make it nonstatic.
+       * SecurityRequestChannel.cs, SecurityOutputChannel.cs,
+         SecurityRequestContext.cs : apply the change above.
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs :
+         Fixed incorrect TrgGetValue() use.
+         Added CollectRecipientSupportingTokens().
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs: acctually ReferenceList was inside
+         EncryptedKey. So, when a key itself is used to encrypt data,
+         ReferenceList is contained by itself.
+       * MessageSecurityBindingSupport.cs :
+         added CollectInitiatorSupportingTokens().
+
+2007-01-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs: it should support ReferenceList-less
+         messages.
+
+2007-01-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs : reverted previous unnecessary change.
+       * MessageSecurityUtility.cs : there already was uuid.
+
+2007-01-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : replaced EncryptedKey with
+         WrappedKeySecurityToken, which seems to be in actual use in .net.
+       * WSSecurityMessageHeader.cs : added internal Guid so that it
+         could be shared between header items.
+
+2006-12-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestContext.cs, TextMessageEncoder.cs :
+         some null arg check.
+
+2006-12-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : reducing DOM dependency. Use KeyInfoNode
+         for SecurityTokenReference resolution.
+
+2006-12-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : fixed EncryptedData decryption to
+         consider DerivedKeyTokens correctly.
+         When creating LocalId, don't add '#' here.
+
+2006-12-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs :
+         handle key mapping for each wsse:Security.
+
+2006-12-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs : use prefix "c" for ws-secureconv.
+
+2006-12-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs : write top-level ReferenceList in
+         wsse:Security.
+       * MessageSecurityUtility.cs :
+         Now ReferenceList is placed under wsse:Security as WS-Security 1.1 
+         suggests, and it is used to dereference decryption targets.
+         Now it premises multiple wsse:Security elements to read.
+
+2006-12-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs : don't write o:SecurityTokenReference
+         manually (and actually the namespace URI was wrong).
+
+2006-12-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs : improved DerivedKeyToken writing
+         and reading.
+       * MessageSecurityUtility.cs : DerivedKeyToken creation.
+
+2006-12-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElement.cs,
+         SymmetricSecurityBindingElement.cs,
+         AsymmetricSecurityBindingElement.cs :
+         implemented SetKeyDerivation().
+
+2006-12-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : don't add KeyInfoClause to EncryptedKey
+         more than once.
+
+2006-12-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageBufferImpl.cs : XmlReader-based buffer is not possible, so
+         don't use it.
+
+2006-12-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : u:Timestamp will be encrypted/signed,
+         thus move it in front of encryption/signing.
+
+2006-12-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TransactionFlowBindingElement.cs : OnOpen()/OnClose() should not
+         check state by themselves (btw it's not really working).
+       * HttpChannelListener.cs : If the url does not end with '/' add it
+         so that it could be fed to HttpListener.
+
+2006-12-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpChannelFactory.cs : check scheme on CreateChannel.
+       * MessageHeader.cs : finish IsMessageVersionSupported().
+
+2006-12-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultConverter.cs : new file, not used yet though.
+
+2006-10-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SvcHttpHandler.cs : set GET URL to ServiceMetadataBehavior.
+
+2006-10-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SvcHttpHandler.cs : once AspNetReplyChannel get working with HTTP
+         GET as well as HttpReplyChannel, configuration would be ready now.
+
+2006-10-18  Ankit Jain  <jankit@novell.com>
+
+       * TextMessageEncoder.cs (MediaType): Use 'application/soap+xml' for
+       EnvelopeVersion.Soap12 and 'text/xml' for others.
+       * HttpReplyChannel.cs (TryReceiveRequest): Revert earlier patch for GET
+       handling.
+       Strip '?' from the query string.
+
+2006-10-13  Ankit Jain  <jankit@novell.com>
+
+       * MessageVersion.cs (None): Set AddressingVersion.None
+
+2006-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SvcHttpHandler.cs : added config-based endpoint addition code.
+         Though due to some weird bug in mono-core it does not seem to work,
+         so commented out for now.
+       * HttpReplyChannel.cs : handle wsdl query parameter. btw creating
+         mex request message might just be wrong.
+         Use expected MessageVersion by the channel.
+       * AspNetReplyChannel.cs : ditto. Plus, HTTP GET support.
+
+2006-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : added DefaultSignatureAlgorithm
+         which differs depending on whether it is asymmetric or symmetric.
+       * SecurityRequestChannel.cs, SecurityRequestContext.cs :
+         simplify SecureMessage() and DecryptMessage() arguments (just
+         take MessageSecurityBindingSupport instead of several parameters).
+       * MessageSecurityUtility.cs :
+         - simplify SecureMessage() and DecryptMessage() arguments (just
+           take MessageSecurityBindingSupport instead of several parameters).
+         - Take token inclusion mode into account. Don't include them when
+           it is not expected. Also, change the token reference style.
+         - add wsa:MessageID to the headers.
+         - For hmac-sha1 signing (default for symmetric binding), use
+           symmetric key created for encryption as well to create HMACSHA1.
+         - add Id to wsu:Timestamp.
+         - start to handle SecurityMessageProperty.
+       * WSSecurityMessageHeader.cs :
+         Added Id to WsuTimestamp. Also use prefixes for its XML output.
+         Changed date format.
+
+2006-10-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObject.cs : reject faulted state on Open()/Close().
+       * MessageHeaders.cs : removed extra fields.
+
+2006-10-06  Ankit Jain  <jankit@novell.com>
+
+       * HttpReplyChannel.cs (TryReceiveRequest): Handle HTTP GET.
+
+2006-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs, SecurityRequestContext.cs :
+         added some FIXMEs and additional arg.
+
+2006-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : remove duplicate Action header.
+
+2006-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageFault.cs : partly implemented CreateFault(Message, int).
+       * Message.cs, MessageImpl.cs, MessageBufferImpl.cs :
+         handle IsFault correctly in each implementation.
+
+2006-10-04  Ankit Jain  <jankit@novell.com>
+
+       * HttpRequestChannel.cs (ProcessRequest): Read till the end.
+
+2006-10-04  Ankit Jain  <jankit@novell.com>
+
+       * HttpRequestChannel.cs (ProcessRequest): Temporary workaround for a bug
+       in WebConnectionStream.
+
+2006-10-04  Ankit Jain  <jankit@novell.com>
+
+       * MessageHeaders.cs (To): Use GetHeader<string> till
+       DataContractSerializer gets ISerializable support.
+       * CustomBinding.cs (.ctor): Get scheme from TransportBindingElement.
+
+2006-10-04  Ankit Jain  <jankit@novell.com>
+
+       * ServiceHostParser.cs (Parse):
+       (Split): Add some error checks.
+
+2006-10-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslStreamSecurityBindingElement.cs : updated API to Sep. CTP.
+       * StreamUpgradeAcceptor.cs : Fix AcceptUpgrade().
+       * SslStreamSecurityUpgradeProvider.cs,
+         SslStreamSecurityUpgradeAcceptor.cs :
+         new files for Ssl upgrade provider implementation.
+       * MessageSecurityUtility.cs :
+         Create proper C14NTransform. Don't use enveloped signature
+         transform but sign every significant bits. On securing messages
+         use ChannelProtectionRequirements.
+       * SecurityRequestContext.cs : pass ChannelProtectionRequirements to
+         SecureMessage().
+       * MessageEncoder.cs : fix API (missing constraint).
+       * WSSecurityMessageHeader.cs : it is MustUnderstand.
+       * StreamUpgradeProvider.cs : API fix and implemented .ctor().
+       * AsymmetricSecurityBindingElement.cs : default protection order is
+         SignBeforeEncryptAndEncryptSignature.
+
+2006-09-29  Ankit Jain  <jankit@novell.com>
+
+       * SvcHttpHandlerFactory.cs (GetTypeFromSvc): Extract and move code to
+       ServicHostParser and use that here.
+       (PrivateBinPath): New.
+       (GetTypeFromBin): New. Load assembly from PrivateBinPath.
+       (RemovedCallback): Remove and close the SvcHttpHandler when its
+       corresponding file (.svc) changes.
+       * SvcHttpHandler.cs (Close): New. Close the ServiceHost.
+
+       * ServiceHostParser.cs : New.
+       * CachingCompiler.cs : New. Code extracted from
+       System.Web.Compilation.CachingCompiler
+       * CompilationException.cs : New. From System.Web.Compilation
+       * HtmlizedException.cs : New. Likewise.
+
+2006-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : For client side, it is always
+         InitiatorServiceModelSecurityTokenRequirement which should be
+         created. Fixed wrong client encryption key acquisition.
+
+2006-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityChannelListener.cs, SecurityRequestContext.cs,
+         MessageSecurityBindingSupport.cs : made similar changes as factories
+         to listener so that session channels and input channels would work.
+         Added authenticator creation.
+
+2006-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Binding.cs : added missing members.
+
+2006-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityRequestChannel.cs, SecurityOutputChannel.cs,
+         MessageSecurityUtility.cs, MessageSecurityBindingSupport.cs :
+         reduce code duplication between request and output channels.
+         The common parts are now in MessageSecurityBindingSupport.
+         Now reduced several arguments in SecureMessage() for client.
+
+2006-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactoryBase.cs : implemented ValidateCreateChannel().
+
+2006-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElement.cs,
+         SecurityChannelListener.cs,
+         SecurityRequestContext.cs,
+         SymmetricSecurityBindingElement.cs,
+         SecurityRequestChannel.cs,
+         SecurityOutputChannel.cs,
+         SecurityChannelFactory.cs,
+         MessageSecurityBindingSupport.cs : 1) Refactoring. 
+         IMessageSecurityBindingSupport now becomes a class and contains
+         all the members which resided in ISecurityChannelSource.
+         Now it takes more constructor params.
+         Made dependent changes on all sources above.
+
+         2) Added SecurityTokenAuthenticator creation in
+         SecurityRequestChannel (SecurityOutputChannel should do the same).
+
+2006-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityRequestChannel.cs : ongoing improvements on conditional
+         key creation. Actually there must be some part that creates an
+         authenticator (WinFX does that).
+
+2006-09-27  Ankit Jain  <jankit@novell.com>
+
+       Add suport for handling .svc files.
+       * SvcHttpHandlerFactory.cs: New.
+       * SvcHttpHandler.cs: New.
+
+       * HttpChannelListener.cs (PopulateChannel): Use AspNetReplyChannel if in
+       asp.net environment.
+       (OnOpen): Do nothing in asp.net environment.
+       (OnClose): Likewise.
+       * HttpReplyChannel.cs (HttpRequestContext): Move to ..
+       * HttpRequestContext.cs: .. here.
+
+       * AspNetReplyChannel.cs: New.
+       * AspNetRequestContext.cs: New.
+
+2006-09-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs :
+         Significantly rewritten decryption parts to respect ReferenceList
+         to decrypt (so no workaround anymore).
+         Now e:ReferenceList inside o:Security is treated as the referenced
+         EncryptedType items are encrypted by 1) the derived key which is
+         immediately in front of it, or 2) the default key (it is according
+         to WS-SecureConversation section 9.1). Thus removed immediately
+         previous hack to auto-fill wsu:Id attributes.
+
+         On securing a message, generate correct Id and add DataReference
+         to ReferenceList properly.
+
+2006-09-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs : handle ReferenceList. It is being
+         practically used.
+
+2006-09-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs : handle DerivedKeyToken as a header content.
+         Actually WSSecurityTokenSerializer should be able to consume it, but after
+         spending a lot of time I still cannot successfully read it on WinFX.
+         Skip ReferenceList for now.
+       * MessageSecurityUtility.cs :
+         Replaced some string literals with constants.
+         Added some workaround for DerivedKeyToken retrieval.
+         WinFX somehow sends incomplete ISO10126 padding which contains
+         bigger number than the key size and is rejected by EncryptedXml,
+         so added DecryptLax() which processes such ones in PaddingMode.None
+         to workaround it (only for cross-connection between mono and winfx).
+         Added some incomplete implicit wsu:Id processing.
+         Don't try to replace SignedXml with EncryptedData. It is not added
+         to the document tree.
+
+2006-09-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : support message signature encryption. Some
+         more refactoring.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElement.cs : implement Clone(). Remove some MonoTODOs.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : fix warnings.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : actually there would be more than one
+         EncryptedData. Decrypt all.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : supply correct URIs in SecureMessage().
+         Use ISO10126 padding mode (it is not required but in manner).
+
+2006-09-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : now that EncryptedXml decryption bug is
+         fixed, remove 16 bytes workaround (we still need encryption bugfix in
+         that class to make it work fine with mono client).
+         Removed buggy lines that reset decryption key to AES.
+         Modified GetKey() argument to take EncryptedData/EncryptedKey element.
+       * WSSecurityMessageHeader.cs :
+         (SecurityTokenReferenceKeyInfo) support LoadXml.
+
+2006-09-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TransactionMessageProperty.cs : new file.
+
+2006-09-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelPoolSettings.cs, OneWayBindingElement.cs : build fix, as
+         gmcs happened to report wrong code.
+
+2006-09-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityChannelFactory.cs, SecurityChannelListener.cs :
+         .ctor() now requires ChannelProtectionRequirements which will be
+         supplied via BindingParameterCollection.
+       * SymmetricSecurityBindingElement.cs,
+         AsymmetricSecurityBindingElement.cs : thus add
+         ChannelProtectionRequirement parameter to factory/listener.
+       * SecurityRequestChannel.cs : use recipient token requirement to
+         create an encryption token. Thus differentiate the logic from
+         signing (initiator) token.
+
+2006-09-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityChannelFactory.cs, SecurityChannelFactory.cs :
+         renamed former to latter.
+       * SymmetricSecurityChannelListener.cs, SecurityChannelListener.cs :
+         ditto.
+
+2006-09-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityBindingSupport.cs : new internal types to commonize
+         AsymmetricSecurityBindingElement and SymmetricSecurityBindingElement
+         and thus make internal factory and listener reusable.
+       * SymmetricSecurityChannelFactory.cs, SecurityRequestContext.cs,
+         SecurityRequestChannel.cs, SecurityOutputChannel.cs,
+         SymmetricSecurityChannelListener.cs : rewrote dependent parts on
+         SymmetricSecurityBindingElement, using the new types above.
+       * SymmetricSecurityBindingElement.cs :
+         Use SymmetricMessageSecurityBindingSupport.
+       * AsymmetricSecurityBindingElement.cs :
+         thus implemented, using AsymmetricMessageSecurityBindingSupport.
+
+2006-09-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactoryBase.cs : more RC1 update.
+
+2006-09-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageEncoder.cs, BinaryMessageEncoder.cs, MtomMessageEncoder.cs,
+         TextMessageEncoder.cs : updated ReadMessage() API to RC1.
+       * ChannelListenerBase.cs, ChannelListenerBase_1.cs,
+         ChannelBase.cs : RC1 API updates.
+       * MessageImpl.cs : implemented Properties.
+       * HttpReplyChannel.cs : added HttpRequestMessageProperty support.
+
+2006-09-18  Ankit Jain  <jankit@novell.com>
+
+       * MessageHeaders.cs (MessageId):
+       (RelatesTo): UniqueId is not serializable, serialize it as a string.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelParameterCollection.cs : new file.
+       * LayeredOutputChannel.cs, SecurityOutputChannel.cs :
+         new files for IOutputChannel implementation.
+       * OneWayBindingElement.cs : hacky implementation.
+       * SymmetricSecurityChannelFactory.cs : support IOutputChannel.
+       * MessageSecurityUtility.cs : now create identifier from the security
+         token and the token parameters which is added as an argument.
+       * SecurityRequestContext.cs,
+         SecurityRequestChannel.cs : SecureMessage() argument changes.
+         Set MessageSecurityVersion (SecurityTokenVersion) to the token
+         requirement.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs : close the HttpWebRequest.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs,
+         HttpChannelFactory.cs : implement async request/reply.
+       * HttpChannelFactory.cs :
+         verify factory state when creating a channel.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageEncoder.cs, TextMessageEncoder.cs, MtomMessageEncoder.cs,
+         BinaryMessageEncoder.cs : added message version mismatch check.
+
+2006-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityChannelListener.cs, SecurityRequestContext.cs :
+         Making incomplete changes to handle different tokens for encryption
+         and signature.
+       * SymmetricSecurityChannelFactory.cs, SecurityRequestChannel.cs :
+         split channel implementation classes out to the latter file.
+       * MessageSecurityUtility.cs : seems like there is
+         TimeStampValidityDuration property, so use it (incomplete; a server
+         needs another love).
+
+2006-09-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs, SymmetricSecurityChannelFactory.cs,
+         SecurityRequestContext.cs : now that we have key identifier clause
+         and working ResolveKeyIdentifierClause(), just create keys inside
+         SecureMessage(). Add KeyInfo to the xmldsig.
+
+2006-09-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityChannelFactory.cs, SecurityRequestContext.cs :
+         pass SecurityKeyIdentifierClause to SecureMessage().
+       * SecurityBindingElement.cs : set X509ReferenceStyle as Thumbprint
+         for IssuedToken binding element.
+       * SymmetricSecurityChannelListener.cs : removed hack to just create
+         X509 security token, and implemented correct token creation.
+       * WSSecurityMessageHeader.cs : added new KeyInfoClause type that
+         wraps SecurityTokenReference element.
+       * MessageSecurityUtility.cs : use the above.
+
+2006-09-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs : raise MessageSecurityException when it
+         could not find a security header.
+       * SymmetricSecurityChannelFactory.cs : now it also supports
+         IRequestSessionChannel. Extracted SecurityRequestChannel out from
+         the factory type.
+
+2006-09-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityRequestContext.cs : moved securing message part to
+         MessageSecurityUtility.cs.
+       * MessageSecurityUtility.cs : the change above.
+         use DateTime.Now for timestamp basis. Don't append signature to
+         the document. Instead it is added to the header. Capture body
+         content instead of the body itself.
+       * SymmetricSecurityChannelFactory.cs : decrypt reply message to
+         be processed by upper layers.
+
+2006-09-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityUtility.cs, WSSecurityMessageHeader.cs,
+         SymmetricSecurityChannelListener.cs,
+         SymmetricSecurityChannelFactory.cs, SecurityRequestContext.cs :
+         more refactoring. Request serialization became much more conformant
+         and add required header items.
+         Security Token retrieval is needed to send it in the request.
+         Fixed wrong key encryption.
+
+2006-09-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityRequestContext.cs : the workaround was not functional.
+
+2006-09-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityRequestContext.cs : some more refactoring. Use EncryptedXml
+         API, especially ReplaceData(), instead of native crypto stuff.
+       * WSSecurityMessageHeader.cs : handle dsig:Signature as well (for
+         MessageProtectionOrder.SignBeforeEncrypt).
+
+2006-09-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityRequestContext.cs : label should be combined of both
+         the client's and the server's.
+
+2006-09-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityRequestContext.cs : enable key derivation (though for now
+         GenerateDerivedKey() is unimplemented). Create meaningful,
+         decrypted request message to be consumed by the upper layer.
+
+2006-09-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityRequestContext.cs : implement Close() and Reply().
+         ongoing implementation of Reply(TimeSpan).
+       * MessageSecurityUtility.cs : new file to collect utility methods.
+       * SymmetricSecurityChannelFactory.cs : moved securing message code
+         to the above file.
+       * SymmetricSecurityChannelListener.cs : tiny renaming.
+
+2006-09-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityRequestContext.cs : security header is also stored.
+         removed NotImpl.
+       * WSSecurityMessageHeader.cs : read EncryptedKey and EncryptedData
+         as well.
+
+2006-09-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityChannelFactory.cs : tiny progress on securing
+         message.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityChannelFactory.cs : specify KeyUsage.Exchange
+         so that it retrieves the security key in that manner.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Binding.cs : MessageVersion is null when there is no
+         MessageEncodingBindingElement.
+       * Message.cs : null arg check.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelPoolSettings.cs, OneWayBindingElement.cs : new files.
+
+2006-09-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityChannelListener.cs, SecurityRequestContext.cs, 
+         LayeredReplyChannel.cs, LayeredCommunicationObject.cs,
+         LayeredRequestChannel.cs : some refactoring.
+       * SymmetricSecurityChannelFactory.cs :
+         ongoing secure message creation implementation.
+
+2006-09-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElement.cs :
+         pass specific ServiceCredentialsSecurityTokenManager type to
+         SymmetricSecurityChannelListener as it needs ServiceCertificate.
+       * SymmetricSecurityChannelListener.cs :
+         get service certificate. It's a temporary hack.
+         Move RequestContext code to below.
+       * SecurityRequestContext.cs : new file.
+       * WSSecurityMessageHeader.cs : implementing Read(), but to finish
+         it I have to finish decryption of the incoming message.
+
+2006-08-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageImpl.cs : don't write attributes on the first body content
+         element *on soap Body element*.
+       * MessageBufferImpl.cs : don't throw ArgumentNullException.
+         ObjectDisposedException is appropriate.
+       * MessageHeader.cs : (RawMessageHeader) don't write element itself
+         in OnWriteHeader*Contents*().
+
+2006-08-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityMessageHeader.cs : new file.
+       * SymmetricSecurityChannelFactory.cs :
+         moved WSSecurityHeader and related types to the above.
+       * SymmetricSecurityChannelListener.cs :
+         reject SOAP-env-less message.
+
+2006-08-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityChannelListener.cs, SymmetricSecurityChannelListener.cs :
+         renamed former to latter.
+       * SymmetricSecurityChannelFactory.cs :
+         create requirements every time. It is also likely that I need
+         another requirement instance to get service credentials here.
+
+2006-08-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElement.cs : make BuildChannelListener()
+         similar to BuildChannelFactory() (set credentials, issuer binding
+         context etc.).
+       * SecurityChannelListener.cs :
+         more ongoing security support implementation.
+       * SymmetricSecurityChannelFactory.cs :
+         moved GetSecurityKey() to SymmetricSecurityRequestChannel.
+
+2006-08-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityChannelListener.cs, SymmetricSecurityBindingElement.cs :
+         Renamed SecurityChannelListener to SymmetricSecurityChannelListener.
+         Implementation is underway.
+       * LayeredReplyChannel.cs :
+         like LayeredRequestChannel, use ChannelListenerBase to provide
+         default timeouts.
+
+2006-08-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeader.cs : added another implementation type that uses
+         XmlElement, for buffering purpose.
+       * MessageImpl.cs : Header item types are user-driven by
+         MessageHeader.GetHeader<T>(int), so at storing phase just store
+         nodes as XmlElement.
+       * MessageHeaders.cs : avoid dumping XmlNode to string to create
+         another XmlReader.
+
+2006-08-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElement.cs : find ClientCredentials from
+         BindingParameterCollection, not from binding element properties.
+
+2006-08-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityChannelFactory.cs, SymmetricSecurityChannelFactory.cs :
+         renamed former to latter.
+
+2006-08-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElement.cs : SetIssuerBindingContext should also
+         work for SslSecurityTokenParameters.
+
+2006-08-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElement.cs :
+         Added SetIssuerBindingContextIfRequired().
+       * SecurityChannelFactory.cs :
+         Changed .ctor() arg again, just to receive binding element.
+       * SymmetricSecurityBindingElement.cs :
+         Call SetIssuerBindingContextIfRequired() in BuildChannelFactory().
+         SymmetricSecurityChannelFactory .ctor() arg changes.
+         "ProtectionTokenParameters" is not passed now.
+
+2006-08-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElement.cs : requirements should be
+         filled at InitializeSecurityTokenParameters as long as possible.
+         SymmetricSecurityChannelFactory<T> now does not receive
+         requirements (it now creates one inside it) at .ctor().
+       * SecurityChannelFactory.cs : remove requirement argument.
+
+2006-08-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElement.cs : implemented copy constructor.
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElement.cs :
+         MessageSecurityVersion property is of type SecurityTokenVersion.
+       * SecurityBindingElement.cs :
+         Implemented CreateSecureConversationBindingElement().
+         For CreateIssuedTokenBindingElement(), ProtectionTokenParameters is
+         the argument IssuedSecurityTokenParameters itself.
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElement.cs :
+         CreateSecurityTokenManager() can be directly used now. 
+         Use CallInitializeSecurityTokenRequirement() to fill requirement
+         properties.
+
+2006-08-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactoryBase.cs : GetProperty() is virtual.
+
+2006-08-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElement.cs : in BuildChannelFactory(),
+         create token manager, token parameters and token requirements,
+         and fill some requirements.
+       * TransportBindingElement.cs, HttpTransportBindingElement.cs,
+         TextMessageEncodingBindingElement.cs : workaround to not throw NIE.
+       * BindingContext.cs : implemented RemainingBindingElements.
+         kill "no remaining binding element" error in GetInnerProperty()
+       * SecurityChannelFactory.cs : now it became 
+         SymmetricSecurityChannelFactory, thus soon to be renamed.
+         Several ongoing actual security resolution is on.
+
+2006-08-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObject.cs :
+         add GetCommunicationObjectType() and use it.
+       * ChannelFactoryBase.cs, ChannelListenerBase_1.cs :
+         use ThrowIfDisposedOrNotOpen().
+       * LayeredCommunicationObject.cs : have similar ThrowIf...() methods
+         to CommunicationObject. Make it IDisposable.
+       * LayeredRequestChannel.cs : use above.
+       * SecurityChannelFactory.cs : removed state check as it is done at
+         above class.
+
+2006-08-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElement.cs : (CanBuildChannelFactory and
+         CanBuildChannelListener) directly dispatch to BindingContext.
+       * SymmetricSecurityBindingElement.cs : require protection token
+         parameters before building a channel or a listener.
+       * ChannelFactoryBase.cs : raise an error when a channel is being
+         created without opening the factory.
+       * ChannelListenerBase_1.cs : ditto for the listener.
+       * SecurityChannelFactory.cs : before sending a request, it must be
+         opened.
+
+2006-08-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageBufferImpl.cs : initialize fields.
+         workaround BufferSize just to return 0.
+       * MessageImpl.cs : for BodyWriter, don't use DefaultMessageBuffer
+         which does not support multi time write.
+       * Message.cs : implemented State.
+
+2006-08-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Message.cs : OnGetBodyAttribute() cannot return anything unless it
+         is consuming XmlReader.
+         Implemented OnCreateBufferedCopy(), to return XPathMessageBuffer.
+       * MessageBuffer.cs : implemented CreateNavigator().
+       * MessageBufferImpl.cs : added XPathMessageBuffer class.
+
+       I kinda know that MS heavily depends on binary XmlReader and may have
+       XPathNavigator implementation based on the binary stuff, but at
+       least for now we have almost no motivation to mimick it.
+
+2006-08-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityChannelFactory.cs : a bit more of security header code.
+
+2006-08-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElement.cs :
+         set default MessageProtectionOrder in every construction.
+
+2006-08-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * LayeredRequestChannel.cs, SecurityChannelFactory.cs : 
+         changed to require ChannelFactoryBase to support default timeout.
+         Made some methods non-virtual. Preparing code to add security
+         headers (empty yet).
+       * SecurityBindingElement.cs : implemented several factory methods
+         that return SymmetricSecurityBindingElement.
+
+2006-08-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IStreamUpgradeBindingElement.cs,
+         StreamUpgradeBindingElement.cs : renamed from former to latter.
+
+2006-08-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IStreamUpgradeBindingElement.cs : API update, soon to be renamed.
+
+2006-07-31  Ankit Jain  <jankit@novell.com>
+
+       * MessageHeaders.cs (From): Use Constants.WSA1
+       (MessageId): Implement the same pattern as other properties (From etc).
+
+2006-07-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * LocalClientSecuritySettings.cs : initialize IdentityVerifier as well.
+       * SecurityBindingElement.cs : some cosmetic changes.
+
+2006-07-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElement.cs : LocalClientSettings and 
+         LocalServiceSettings returns an instance for each.
+       * LocalClientSecuritySettings.cs : initialized fields.
+
+2006-07-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * LocalClientSecuritySettings.cs : moved from S.SM.Description, and
+         kinda implemented Clone() just with MemberwiseClone().
+
+2006-07-27  Ankit Jain  <jankit@novell.com>
+
+       * MessageHeaders.cs (set_To): Use Uri.AbsoluteUri .
+       * MessageHeader.cs (knownTypes): New. Known type array containing
+       EndpointAddress10.
+       (CreateHeader): Use knownTypes with the DataContractSerializer .ctor
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * LayeredRequestChannel.cs, LayeredReplyChannel.cs,
+         LayeredCommunicationObject.cs,
+         SecurityChannelFactory.cs, SecurityChannelListener.cs :
+         new files to support security channels, though right now they
+         just pass inner channels through.
+       * SymmetricSecurityBindingElement.cs : use above.
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElement.cs,
+         SymmetricSecurityBindingElement.cs :
+         Default SecurityTokenParameters is null.
+
+2006-07-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElement.cs : remove NotImpl for now.
+
+2006-07-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Message.cs : When EnvelopeVersion is None, don't write SOAP
+         envelope.
+       * MessageHeader.cs : don't write headers when EnvelopeVersion is None.
+       * MessageHeaders.cs : When EnvelopeVersion is None, don't output
+         headers. When AddressingVersion is None, don't output addressing
+         headers as well, except for Action which is still needed by
+         service dispatcher.
+
+2006-07-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeaders.cs : changed specific properties to find it from
+         headers as Action property does (local variables won't be set by
+         setter). Cache serializers. Check null serializer arguments.
+         For EndpointAddress, GetHeader<T>() shouldn't use serializer.
+
+2006-07-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeader.cs : WriteTo() should treat EndpointAddress to not
+         use XmlObjectSerializer (since it is not data contract type).
+
+2006-07-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageImpl.cs : Improved ReadHeaders().
+         For certain header items, use EndpointAddress.ReadFrom().
+
+2006-07-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElement.cs :
+         it is not ISecurityCapabilities anymore.
+
+2006-07-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageVersion.cs : added None.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Message.cs : GetReaderAtBodyContents() implementation using
+         writer methods.
+
+2006-07-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Message.cs : CreateMessage(version,action,xmlReader) incorrectly
+         used MessageVersion.Default.
+
+2006-07-12  Duncan Mak  <duncan@novell.com>
+
+       * MessageBuffer.cs (MessageContentType): Return
+       "application/soap+msbin1".
+
+       * MessageImpl.cs (EmptyMessage.OnCreateBufferedCopy):
+       (SimpleMessage.OnCreateBufferedCopy):
+       (XmlReaderMessage.OnCreateBufferedCopy): Hook up with the new
+       MessageBuffer implementations.
+
+       * MessageBufferImpl.cs: Concrete implmentations for MessageBuffer.
+       (DefaultMessageBuffer): Used by EmptyMessage and SimpleMessage.
+       (XmlReaderMessageBuffer): Used by XmlReaderMessage.
+
+2006-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageImpl.cs : Action should be added in request messages. Omit
+         it only in reply message, thus moved to dispatcher logic.
+
+2006-07-12  Ankit Jain  <jankit@novell.com>
+
+       * HttpRequestChannel.cs (HttpRequestChannel.Request): Workaround for a
+       bug in WebConnectionStream.
+       * MessageHeaders.cs (MessageHeaders.From):
+       (MessageHeaders.ReplyTo):
+       (MessageHeaders.To): Add the corresponding MessageHeader on set.
+
+2006-07-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageImpl.cs : when AddressingVersion is None (e.g. POX), don't
+         add SOAP Action to the response at any time.
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElement.cs,
+         SecurityBindingElement.cs : They are not ISecurityCapabilities now.
+         Implemented .ctor() and some properties.
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TransactionFlowBindingElement.cs : new file.
+       * HttpTransportBindingElement.cs : added missing KeepAliveEnabled.
+
+2006-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageFault.cs :
+         DefaultAction vanished. CreateFault() now takes bufferSize arg.
+       * MessageHeaders.cs : ArgumentException -> MessageHeaderException.
+       * AddressingVersion.cs : added None. Equals() and GetHashCode()
+         vanished (there is anyways no way to instantiate this type).
+       * MessageVersion.cs : added Soap11 and Soap12.
+       * TextMessageEncoder.cs : silly quotation mark wrapper disappeared
+         in June CTP. goodie.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MtomMessageEncoder.cs, BinaryMessageEncoder.cs, Message.cs :
+         removed some vanished CreateMessage() overloads.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CustomBinding.cs, HttpsTransportBindingElement.cs, 
+         HttpTransportBindingElement.cs :
+         They are not ISecurityCapabilities anymore.
+         Modified code to match June CTP behavior.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * StreamSecurityUpgradeProvider.cs : Identity -> EndpointIdentity.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EmptyFaultException.cs : removed unused code.
+       * IRequestContext.cs, RequestContext.cs : renamed former to latter.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * LayeredChannelFactory.cs : removed obsolete class.
+       * ChannelFactoryBase.cs, HttpChannelFactory.cs,
+         ChannelListenerBase.cs, HttpChannelListener.cs,
+         HttpReplyChannel.cs, ChannelManagerBase.cs :
+         all those changes were brought by ChannelManagerBase changes.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ReplyChannelBase.cs, HttpChannelFactory.cs, ChannelBase.cs
+         CommunicationObject.cs, HttpChannelListener.cs,
+         ChannelFactoryBase.cs :
+         CommunicationObject abstract changes brought this madness.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingContext.cs : listenUri address parameters could be null in
+         June CTP.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IRequestContext.cs :
+         Now it became a class. File renaming will follow soon.
+       * IChannelFactory.cs, IInputChannel.cs, IReplyChannel.cs,
+         IDuplexChannel.cs, IDuplexSessionChannel.cs,
+         IOutputChannel.cs, IOutputSessionChannel.cs,
+         IRequestChannel.cs, IRequestSessionChannel.cs :
+         They are not IDisposable anymore.
+         For IReplyChannel, IRequestContext -> RequestContext.
+       * IChannelListener.cs : removed Identity. Added GetProperty().
+       * ChannelListenerBase.cs, ChannelListenerBase.cs,
+         ReplyChannelBase.cs, HttpReplyChannel.cs :
+         Several members disappeared, and dependent changes.
+       * HttpTransportBindingElement.cs,
+         HttpChannelListener.cs, :
+         ChannelListenerBase.SharedChannelListener vanished.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageEncodingBindingElement.cs
+         MtomMessageEncodingBindingElement.cs,
+         TextMessageEncodingBindingElement.cs,
+         BinaryMessageEncodingBindingElement.cs :
+         June CTP updates: AddressingVersion -> MessageVersion.
+       * Binding.cs : June CTP. MessageVersion is added.
+       * ChannelBase.cs, BindingContext.cs, IChannel.cs
+         ChannelListenerBase_1.cs,
+         ChannelListenerBase.cs, IChannelListener.cs,
+         IChannelFactory.cs,
+         ChannelFactoryBase.cs, ChannelManagerBase.cs :
+         June CTP. Several interface changes.
+       * HttpTransportBindingElement.cs : June CTP. HttpMappingMode is gone.
+       * IChannelManager.cs, LayeredChannelListener.cs,
+         GenericWrapperChannelFactory.cs,
+         GenericWrapperChannelListener.cs : They are not used anymore.
+
+2006-07-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MtomMessageEncoder.cs, BinaryMessageEncoder.cs :
+         sync fix with June CTP API updates.
+
+2006-07-03  Ankit Jain  <jankit@novell.com>
+
+       * MessageEncodingBindingElementConverter.cs:
+       * StandardBindingConverter.cs:
+       * TransportBindingElementConverter.cs:
+       * TransactionFlowBindingElementConverter.cs:
+       * ReliableSessionBindingElementConverter.cs:
+       * SecurityBindingElementConverter.cs:
+       Rename *Converter.cs to *Importer.cs
+
+       * TransferMode.cs: Move to System.ServiceModel
+
+2006-06-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObject.cs : make sure to change State before
+         OnClosing/OnClosed/OnOpening/OnOpened when they are overriden.
+
+2006-06-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Message.cs : output WSAddressing xmlns only when Action is
+         specified (To should be affected, but seems like it is ignored).
+
+2006-06-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageImpl.cs : don't set Action when it is null.
+
+2006-06-12  Ankit Jain  <jankit@novell.com>
+
+       * TransportBindingElementConverter.cs (ImportEndpoint): Implement.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElement.cs, SecurityBindingElementConverter.cs :
+         some updated API fixes.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EnvelopeVersion.cs : moved back to S.SM.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IBindingManualAddressing.cs : vanished in beta2.
+       * HostedTransportConfiguration.cs, EnvelopeVersion.cs,
+         LocalClientSecuritySettings.cs, LocalServiceSecuritySettings.cs :
+         namespace changes.
+       * SecurityBindingElement.cs :
+         SecurityStandardsManager -> SecurityTokenSerializer.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlSerializerBodyWriter.cs : new file to handle 
+         TypedMessageConverter.ToMessage().
+
+2006-04-26  Ankit Jain  <jankit@novell.com>
+
+       * TransportBindingElementConverter.cs (BeforeImport): Remove
+       NotImplementedException.
+       (ImportContract): Likewise.
+       * CustomBinding.cs (.ctor): Use scheme from the binding parameter.
+
+2006-04-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs, HttpChannelFactory.cs : message encoder 
+         being used was not reflecting that of Binding elements.
+
+2006-04-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpReplyChannel.cs : when SOAP action is not set as a header item,
+         just assume that it is in the message.
+
+2006-04-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpReplyChannel.cs : actually HTTP header item might be null.
+
+2006-04-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpReplyChannel.cs : under SOAP 1.1 SOAP Action is sent as HTTP
+         header.
+
+2006-04-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TextMessageEncoder.cs : for SOAP 1.1 content type is text/xml.
+
+2006-04-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageFault.cs : Fixed SOAP12 reason output.
+
+2006-04-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpReplyChannel.cs : no need to set response ContentEncoding since
+         MessageEncoder.ContentType explicitly contains encoding.
+       * AddressingVersion.cs : added ActionNotSupported property. Not sure
+         if it is SOAP version dependent.
+
+2006-03-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpReplyChannel.cs : actually I could just workaround bug #77816.
+
+2006-03-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpChannelFactory.cs BindingContext.cs
+         HttpChannelListener.cs HttpTransportBindingElement.cs :
+         Now BindingContext holds MessageEncoder, and non-custom
+         channel factory/listener should use it.
+       * MtomMessageEncodingBindingElement.cs
+         TextMessageEncodingBindingElement.cs
+         BinaryMessageEncodingBindingElement.cs : BuildChannelFactory()/
+         -Listener() now sets internal BindingContext.MessageEncoder.
+         Fixed some public API.
+
+2006-03-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingContext.cs : CanBuildChannelXXX() should not raise error
+         for insufficient elements.
+       * DispatchRuntime.cs : OperationDescription name is not action. So
+         OperationSelector is created by name, not by action.
+       * TextMessageEncodingBindingElement.cs : Feb. CTP API fixes.
+
+2006-03-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageFaultBodyWriter.cs
+         XmlReaderBodyWriter.cs
+         XmlObjectSerializerBodyWriter.cs : made internal.
+       * SecurityBindingElement.cs
+         AsymmetricSecurityBindingElement.cs
+         SymmetricSecurityBindingElement.cs : API fixes.
+       * TransportBindingElementConverter.cs : ditto.
+       * TextMessageEncodingBindingElement.cs : added set_AddressingVersion.
+       * WindowsStreamSecurityBindingElement.cs
+         SslStreamSecurityBindingElement.cs
+         TransportSecurityBindingElement.cs : new files.
+
+2006-03-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageImpl.cs : according to the W3C REC, mustUnderstand when
+         reading can be any xs:boolean value.
+
+2006-03-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Message.cs MessageImpl.cs : more sorting out the role of each
+         write method.
+       * MessageHeader.cs : use envelope namespace, not addressing namespace.
+
+2006-03-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Message.cs : don't write body contents if it is empty.
+         Moved WriteStartElement(,"Header",) to OnWriteStartHeaders().
+       * MessageImpl.cs : implemented XmlReaderMessage.OnWriteBodyContents().
+       * TextMessageEncoder.cs : WriteMessage() should close XmlWriter.
+       * HttpRequestChannel.cs : close request stream before GetResponse().
+
+2006-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TextMessageEncoderFactory.cs
+         TextMessageEncoder.cs : encoder does not hold reference to the
+         factory anymore. Use MessageVersion property in CreateMssage().
+       * HttpChannelListener.cs : now it holds message encoder.
+       * HttpReplyChannel.cs : now it uses listener's shared message encoder.
+       * MessageImpl.cs : header is optional.
+       * EnvelopeVersion.cs : namespace URI is missing.
+
+2006-03-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CustomBinding.cs : removed Initialize().
+       * Message.cs : renamed ForwardingMessage -> XmlReaderMessage.
+       * MessageImpl.cs : renamed ForwardingMessage to XmlReaderMessage (used
+         by Message.CreateMessage(MessageVersion,XmlReader,int) and
+         implemented Headers, IsEmpty and GetReaderAtBodyContents().
+
+2006-03-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeaders.cs : implemented GetReaderAtHeader() and Action (it
+         could be also added by Add() method and could be reset by Remove()).
+       * MessageImpl.cs : implemented more. As noted above, Now we don't 
+         have to add Action header explicitly.
+       * MessageHeader.cs : recovered Writer methods and ToString() from
+         commented old version. Use prefixes for writing.
+         Use WriteObjectContent() rather than WriteObject() (it needs
+         DataContractSerializer fix btw).
+
+2006-03-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeader.cs : added missing IsReferenceParameter.
+       * MessageHeaderInfo.cs : added missing IsReferenceParameter.
+       * MessageHeaders.cs : avoid NullRef when actors is null.
+       * MessageImpl.cs : (MessageImplBase) add Action header in .ctor().
+         (ForwardingMessage) reader consumer is being added (not done).
+       * MtomMessageEncodingBindingElement.cs : simply use Mtom factory.
+       * MtomMessageEncoder.cs : updated ContentType value to Feb. CTP.
+       * HttpRequestChannel.cs : this channel automatically call Open()
+         when Request() is called. Set content length for request.
+         Use MessageEncoder's ContentType to also handle charset.
+
+2006-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageImpl.cs : make them internal.
+       * HttpReplyChannel.cs : set HttpListenerResponse properties correctly.
+
+2006-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelManagerBase.cs : cleanup MonoTODO and unused field.
+       * HttpChannelListener.cs : removed commented line.
+       * RequestChannelBase.cs : new base class for request channel classes.
+       * ChannelListenerBase.cs : OnEndClose() is rather NotImplemented yet.
+       * HttpReplyChannel.cs : WaitHandle accepts limited timeout value.
+       * Message.cs : default IsEmpty and IsFault false by default.
+       * LayeredChannelListener.cs : removed Uri (no chance to set).
+       * ChannelBase.cs : reimplemented timeout properties.
+       * HttpRequestChannel.cs : now it is mostly based on
+         RequestChannelBase. Some more attempt to implement Request().
+
+2006-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Binding.cs CustomBinding.cs : removed OnApplyConfiguration() and
+         OnInitialize(). Added more BuildChannelListener() overloads.
+
+2006-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Binding.cs : added some more missing members especially to support
+         listener creation.
+       * HttpChannelListener.cs : Uri should not be null.
+       * HttpTransportBindingElement.cs : implemented
+         CanBuildChannelFactory() and CanBuildChannelListener().
+       * ServiceHostBase.cs : make Initialize() practically work at OnOpen().
+
+2006-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Binding.cs : updated default namespace property value to Feb. CTP.
+
+2006-03-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AddressHeader.cs : avoid null reference when value is null.
+       * BindingContext.cs : check null ListenUri args.
+
+2006-03-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageFault.cs : Fixed default action name. Null arg check.
+
+2006-03-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingElement.cs : Dequeue elements in BindingContext directly.
+       * BindingContext.cs : Added GetProperty<T>().
+       * GenericWrapperChannelFactory.cs GenericWrapperChannelListener.cs :
+         Now we don't need these extra classes, so marked as deprecated.
+
+2006-03-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Binding.cs : null arg check.
+       * AddressingVersion.cs : fixed constants to pass the tests.
+       * BindingElement.cs : tiny meessage fix.
+
+2006-03-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageEncodingBindingElement.cs
+         BinaryMessageEncodingBindingElement.cs
+         TextMessageEncodingBindingElement.cs
+         MtomMessageEncodingBindingElement.cs
+         MessageEncodingBindingElementConverter.cs : several API fixes.
+       * BindingElement.cs : now if we use generic wrapper it causes
+         infinite loop, so for now replace it with most-possible-but-
+         untested logic.
+
+2006-03-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       (back to normal "record-ChangeLogs" mode after the big API change mess)
+       * HttpTransportBindingElement.cs : fixed minor API differences.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElement.cs SecurityBindingElement.cs
+         SymmetricSecurityBindingElement.cs :
+         Dependent fixes for System.IdentityModel reorgainzation.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InputChannelBase.cs.notused IInputSession.cs IOutputSession.cs
+         IProxyFormatter.cs WSHttpBindingBase.cs 
+         PnrpPeerResolverBindingElement.cs IMessageHeaderInfo.cs
+         MessageInterceptorEventArgs.cs WSHttpBinding.cs
+         WSFederationBinding.cs ISessionChannel.cs
+         CompositeDuplexBindingElement.cs MessageVersion.cs
+         MessageHeader.cs IRequestSessionChannel.cs 
+         BindingElementCollection.cs IReplySessionChannel.cs
+         MessageProperties.cs IDuplexClientChannel.cs
+         IInputSessionChannel.cs MessageImpl.cs IDuplexSessionChannel.cs
+         TcpTransportBindingElement.cs EmptyFaultException.cs
+         IBindingRuntimePreferences.cs AddressHeaderCollection.cs
+         IStubFormatter.cs AsymmetricSecurityBindingElement.cs
+         ConnectionOrientedTransportBindingElement.cs
+         IProxyOperationSelector.cs MessageBuffer.cs IChannel.cs
+         PeerResolverBindingElement.cs Message.cs
+         HttpsTransportBindingElement.cs BindingElement.cs
+         NamedPipetransportBindingElement.cs IBindingManualAddressing.cs
+         MessageFaultBodyWriter.cs IReplyChannel.cs
+         IBindingCapabilities.cs AddressHeader.cs IInputChannel.cs
+         IMessageProperty.cs IOutputChannel.cs NetPeerTcpBinding.cs
+         IRequestContext.cs IInputSessionShutdown.cs
+         SecurityBindingElement.cs PeerTransportBindingElement.cs
+         IDuplexSession.cs IChannelInitializer.cs
+         IProxyMessageInspector.cs IChannelListener.cs NetTcpBinding.cs
+         AddressingVersion.cs FaultException.cs
+         IRequestChannel.cs MtomMessageEncodingBindingElement.cs
+         TransportBindingElement.cs BinaryMessageEncodingBindingElement.cs
+         TextMessageEncodingBindingElement.cs IChannelFactory.cs Binding.cs
+         ITransportBindingElement.cs IChannelManager.cs MessageFault.cs
+         MessageHeaders.cs IStubMessageInspector.cs UnderstoodHeaders.cs
+         BindingParameterCollection.cs IInstanceProvider.cs
+         WSDualHttpBinding.cs ISession.cs IErrorHandler.cs
+         MessageEncodingBindingElement.cs HttpTransportBindingElement.cs
+         IDuplexChannel.cs CustomBinding.cs IOutputSessionChannel.cs
+         MessageContractAttribute.cs SymmetricSecurityBindingElement.cs :
+         moved from System.ServiceModel due to the API changes.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactoryBase.cs ChannelListenerBase.cs HttpChannelFactory.cs
+         HttpChannelListener.cs HttpRequestChannel.cs
+         LayeredChannelListener.cs PeerMessagePropagationFilter.cs
+         PeerNode.cs ReplyChannelBase.cs :
+         Feb. CTP API changes - chapter 1.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBase.cs : OnOpen() and OnClosed() do nothing.
+       * ReplyChannelBase.cs : now it is based on ChannelBase.
+       * ChannelListenerBase_1.cs : use DefaultCommunicationTimeouts.Instance
+         and check null argument in .ctor().
+       * HttpReplyChannel.cs : several changes.
+         Non-async members are mostly implemented.
+       * HttpChannelListener.cs : no need to receive 
+         IDefaultCommunicationTimeouts.
+       * HttpRequestChannel.cs : maxSizeOfHeaders is used in MessageHeaders
+         to allocate buffer array and int.MaxValue causes OutOfMemory.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientFramingDecoderState.cs : added missing enum.
+       * HttpRequestMessageProperty.cs HttpResponseMessageProperty.cs :
+         added missing bits.
+       * ChannelBase.cs, LayeredChannelListener.cs : tiny API fixes.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpChannelListener.cs : Added GetChannels() and OnClose().
+         AcceptChannel() has some code now but it needs more love.
+
+2006-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObject.cs : Close() does not call Begin/EndClose().
+       * ChannelManagerBase.cs : implemented AbortChannel and CloseChannel.
+       * ChannelListenerBase.cs : implemented OnAbort and OnClose.
+
+2006-02-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs : close the streams.
+       * HttpListener.cs
+         HttpChannelListener.cs : renamed from former to latter.
+
+2006-02-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ReplyChannelBase.cs : new file for IReplyChannel implementations.
+       * HttpReplyChannel.cs : new file for HTTP IReplyChannel.
+       * HttpListenerFactory.cs : removed obsolete file.
+       * HttpListener.cs : hacky WaitForChannel and AcceptChannel.
+       * ChannelListenerBase_1.cs : implemented virtual stuff.
+       * CommunicationObject.cs : Open() should not call BeginOpen() and
+         EndOpen(). Instead, invoke events individually.
+       * ChannelListenerBase.cs : its Open() is WaitForChannel().
+
+2006-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs : call Flush() after serializing message
+         into HTTP stream.
+
+2006-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs : implemented pretty hacky Request().
+
+2006-02-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs : Manager is HttpChannelFactory.
+
+2006-02-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactoryBase.cs : removed some NotImplementedException for
+         further internal implementation.
+
+2006-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestChannel.cs : new file. mostly not implemented.
+       * HttpChannelFactory.cs : Implemented CanCreateChannel().
+         Partly implemented CreateChannel().
+
+2006-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpChannelFactory.cs : (.ctor())
+         Don't take ChannelBuildContext.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * StreamSecurityUpgradeInitiator.cs PeerMessageOrigination.cs
+         ChannelBase.cs StreamSecurityUpgradeAcceptor.cs
+         PeerMessagePropagation.cs : updated to Nov. CTP.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelListenerBase.cs, ChannelManagerBase.cs,
+         ChannelListenerBase_1.cs, LayeredChannelListener.cs,
+         StreamSecurityUpgradeAcceptor.cs,
+         StreamSecurityUpgradeInitiator.cs :
+         Updated to Nov. CTP API.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       Now we can rename ListenerFactoryBase.cs to ChannelListenerBase.cs.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       renamed ChannelListenerBase.cs to ChannelListenerBase_1.cs.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBase.cs : tiny filename fix.
+       * ChannelListenerBase.cs : added more .ctor()s.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpListenerFactory.cs LayeredChannelListener.cs HttpListener.cs
+         ListenerFactoryBase.cs ChannelListenerBase.cs :
+         updated IListener related stuff to Nov. CTP.
+         file renaming will come soon.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ListenerBase.cs, ChannelListenerBase.cs :
+         moved from former to latter.
+       * LayeredListenerFactory.cs, LayeredChannelListener.cs :
+         moved from former to latter.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SessionFaultedException.cs : removed in Nov. CTP
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObject.cs : updated to Nov. CTP.
+       * SessionFaultedException.cs : removed (in Nov. CTP)
+
+2005-11-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TextMessageEncoder.cs : kinda implemented (untested; Message is not
+         working).
+
+2005-11-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MtomMessageEncoder.cs, BinaryMessageEncoderFactory.cs,
+         TextMessageEncoderFactory.cs, BinaryMessageEncoder.cs,
+         TextMessageEncoder.cs, MtomMessageEncoderFactory.cs : new files.
+       * MessageEncoder.cs : largely implemented.
+
+2005-11-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IRequestReplyCorrelator.cs : new file.
+
+2005-11-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObject.cs : OnClose() and OnError() are not virtual.
+       * DirectionalAction.cs : implemented IComparable<DirectionalAction>.
+       * MessageEncoder.cs : added misssing ToString().
+
+2005-11-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBehaviorCollection.cs : moved to sys.sm.
+
+2005-10-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpListenerFactory.cs, HttpListener.cs : new files.
+       * ListenerFactoryBase.cs, ChannelManagerBase.cs,
+         CommunicationObject.cs, ChannelFactoryBase.cs,
+         StreamUpgradeProvider.cs, ChannelBase.cs : timeouts are now
+         protected internal.
+       * CommunicationObject.cs : Aborted is bool. Added InternalClose()
+       * ListenerFactoryBase.cs : kinda implemented GetListeners().
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ListenerFactoryBase.cs : some implementation.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObject.cs : more state fixes.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObject.cs : some state machine fixes.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PeerNode.cs, ChannelManagerBase.cs :
+         several API fixes detected by improved corcompare.
+
+2005-10-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * LayeredListenerFactory.cs : added missing generic class constraint.
+
+2005-10-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ListenerFactoryBase.cs,
+         ListenerBase.cs : class constraints were missing for generic args.
+
+2005-10-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * StreamUpgradeInitiator.cs : tiny API fix.
+
+2005-10-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PeerMessagePropagationFilter.cs : tiny build fix.
+
+2005-10-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpRequestMessageProperty.cs, HttpResponseMessageProperty.cs :
+         added Name. fixed StatusCode type.
+       * StreamSecurityUpgradeInitiator.cs, StreamUpgradeAcceptor.cs,
+         PeerNode.cs, StreamSecurityUpgradeAcceptor.cs,
+         StreamUpgradeProvider.cs, StreamUpgradeInitiator.cs,
+         DirectionalAction.cs, HostedTransportConfiguration.cs,
+         StreamSecurityUpgradeProvider.cs, SessionFaultedException.cs,
+         PeerMessagePropagationFilter.cs : added missing files.
+       * Dummy.cs : removed. MSMQ stuff can be added later.
+
+2005-10-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DeliveryStatus.cs, DeliveryFailure.cs,
+         HttpRequestMessageProperty.cs, PeerMessageOrigination.cs,
+         PeerMessagePropagation.cs, HttpResponseMessageProperty.cs :
+         new files.
+       * Dummy.cs : removed above.
+
+2005-10-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactoryBase.cs : tiny .ctor() delegation fix.
+
+2005-10-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageEncoderFactory.cs, LayeredListenerFactory.cs,
+         MessageEncoder.cs, BufferManager.cs : new files.
+       * Dummy.cs : removed above.
+
+2005-10-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBase.cs, ChannelBehaviorCollection.cs : new channel files.
+       * Dummy.cs : removed above.
+       * CommunicationObject.cs, ListenerFactoryBase.cs : added missing bits.
+
+2005-10-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpChannelFactory.cs : new file.
+
+2005-10-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IReplyChannel.cs, IRequestContext.cs, IRequestChannel.cs:
+         moved to ../System.ServiceModel (correct location).
+       * ChannelFactoryBase.cs, LayeredChannelFactory.cs, TransferMode.cs:
+         new files for channels.
+       * Dummy.cs : reflected above changes.
+       * ChannelManagerBase.cs : added a bit of code and todos.
+
+2005-10-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelManagerBase.cs, ListenerBase.cs, ListenerFactoryBase.cs :
+         added listener support files.
+       * Dummy.cs : removed above.
+
+2005-10-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IReplyChannel.cs, IRequestContext.cs, IRequestChannel.cs :
+         added request/reply channel interfaces.
+       * Dummy.cs : removed above.
+       * CommunicationObject.cs : FIXME comments.
+
+2005-10-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObject.cs : implemented some members.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObject.cs : some signature fixes.
+
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelBase.cs
new file mode 100644 (file)
index 0000000..03d883f
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// ChannelBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public abstract class ChannelBase : CommunicationObject,
+               ICommunicationObject, IChannel,
+               IDefaultCommunicationTimeouts
+       {
+               ChannelManagerBase manager;
+
+               protected ChannelBase (ChannelManagerBase manager)
+               {
+                       this.manager = manager;
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { throw new NotImplementedException ("Actually it should be overriden before being used."); }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { throw new NotImplementedException ("Actually it should be overriden before being used."); }
+               }
+
+               protected internal TimeSpan DefaultReceiveTimeout {
+                       get { return manager.DefaultReceiveTimeout; }
+               }
+
+               protected internal TimeSpan DefaultSendTimeout {
+                       get { return manager.DefaultSendTimeout; }
+               }
+
+               protected ChannelManagerBase Manager {
+                       get { return manager; }
+               }
+
+               [MonoTODO]
+               public virtual T GetProperty<T> () where T : class
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClosed ()
+               {
+               }
+
+               TimeSpan IDefaultCommunicationTimeouts.CloseTimeout {
+                       get { return DefaultCloseTimeout; }
+               }
+
+               TimeSpan IDefaultCommunicationTimeouts.OpenTimeout {
+                       get { return DefaultOpenTimeout; }
+               }
+
+               TimeSpan IDefaultCommunicationTimeouts.ReceiveTimeout {
+                       get { return DefaultReceiveTimeout; }
+               }
+
+               TimeSpan IDefaultCommunicationTimeouts.SendTimeout {
+                       get { return DefaultSendTimeout; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelFactoryBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelFactoryBase.cs
new file mode 100644 (file)
index 0000000..17f4bb4
--- /dev/null
@@ -0,0 +1,165 @@
+//
+// ChannelFactoryBase.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class ChannelFactoryBase<TChannel>
+               : ChannelFactoryBase, IChannelFactory<TChannel>
+       {
+               [MonoTODO]
+               protected ChannelFactoryBase ()
+                       : this (DefaultCommunicationTimeouts.Instance)
+               {
+               }
+
+               protected ChannelFactoryBase (
+                       IDefaultCommunicationTimeouts timeouts)
+                       : base (timeouts)
+               {
+               }
+
+               public TChannel CreateChannel (
+                       EndpointAddress remoteAddress)
+               {
+                       return CreateChannel (remoteAddress, null);
+               }
+
+               public TChannel CreateChannel (
+                       EndpointAddress remoteAddress, Uri via)
+               {
+                       ValidateCreateChannel ();
+                       return OnCreateChannel (remoteAddress, via);
+               }
+
+               protected abstract TChannel OnCreateChannel (
+                       EndpointAddress remoteAddress, Uri via);
+
+               [MonoTODO ("find out what to do here.")]
+               protected override void OnAbort ()
+               {
+                       base.OnAbort ();
+               }
+
+               [MonoTODO ("find out what to do here.")]
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       base.OnClose (timeout);
+               }
+
+               [MonoTODO ("find out what to do here.")]
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return base.OnBeginClose (timeout, callback, state);
+               }
+
+               [MonoTODO ("find out what to do here.")]
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       base.OnEndClose (result);
+               }
+
+               protected void ValidateCreateChannel ()
+               {
+                       ThrowIfDisposedOrNotOpen ();
+                       if (State == CommunicationState.Faulted)
+                               throw new CommunicationObjectFaultedException ();
+               }
+       }
+
+       public abstract class ChannelFactoryBase
+               : ChannelManagerBase, IChannelFactory, ICommunicationObject
+       {
+               TimeSpan open_timeout, close_timeout, receive_timeout, send_timeout;
+
+               [MonoTODO]
+               protected ChannelFactoryBase ()
+                       : this (DefaultCommunicationTimeouts.Instance)
+               {
+               }
+
+               protected ChannelFactoryBase (
+                       IDefaultCommunicationTimeouts timeouts)
+               {
+                       open_timeout = timeouts.OpenTimeout;
+                       close_timeout = timeouts.CloseTimeout;
+                       send_timeout = timeouts.SendTimeout;
+                       receive_timeout = timeouts.ReceiveTimeout;
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return close_timeout; }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return open_timeout; }
+               }
+
+               protected internal override TimeSpan DefaultReceiveTimeout {
+                       get { return receive_timeout; }
+               }
+
+               protected internal override TimeSpan DefaultSendTimeout {
+                       get { return send_timeout; }
+               }
+
+               [MonoTODO]
+               public virtual T GetProperty<T> () where T : class
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO ("find out what to do here.")]
+               protected override void OnAbort ()
+               {
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnClose (TimeSpan timeout)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelListenerBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelListenerBase.cs
new file mode 100644 (file)
index 0000000..7a6c295
--- /dev/null
@@ -0,0 +1,114 @@
+//
+// ChannelListenerBase.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public abstract class ChannelListenerBase : ChannelManagerBase, 
+               IChannelListener, ICommunicationObject,
+               IDefaultCommunicationTimeouts
+       {
+               IDefaultCommunicationTimeouts timeouts;
+
+               protected ChannelListenerBase ()
+                       : this (DefaultCommunicationTimeouts.Instance)
+               {
+               }
+
+               protected ChannelListenerBase (
+                       IDefaultCommunicationTimeouts timeouts)
+               {
+                       this.timeouts = timeouts;
+               }
+
+               public abstract Uri Uri { get; }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return timeouts.CloseTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return timeouts.OpenTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultReceiveTimeout {
+                       get { return timeouts.ReceiveTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultSendTimeout {
+                       get { return timeouts.SendTimeout; }
+               }
+
+               TimeSpan IDefaultCommunicationTimeouts.CloseTimeout {
+                       get { return timeouts.CloseTimeout; }
+               }
+
+               TimeSpan IDefaultCommunicationTimeouts.OpenTimeout {
+                       get { return timeouts.OpenTimeout; }
+               }
+
+               TimeSpan IDefaultCommunicationTimeouts.ReceiveTimeout {
+                       get { return timeouts.ReceiveTimeout; }
+               }
+
+               TimeSpan IDefaultCommunicationTimeouts.SendTimeout {
+                       get { return timeouts.SendTimeout; }
+               }
+
+               public virtual T GetProperty<T> () where T : class
+               {
+                       return null;
+               }
+
+               public IAsyncResult BeginWaitForChannel (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return OnBeginWaitForChannel (timeout, callback, state);
+               }
+
+               public bool EndWaitForChannel (IAsyncResult result)
+               {
+                       return OnEndWaitForChannel (result);
+               }
+
+               public bool WaitForChannel (TimeSpan timeout)
+               {
+                       return OnWaitForChannel (timeout);
+               }
+
+               protected abstract IAsyncResult OnBeginWaitForChannel (
+                       TimeSpan timeout, AsyncCallback callback, object state);
+
+               protected abstract bool OnEndWaitForChannel (IAsyncResult result);
+
+               protected abstract bool OnWaitForChannel (TimeSpan timeout);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelListenerBase_1.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelListenerBase_1.cs
new file mode 100644 (file)
index 0000000..8d11e8c
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// ChannelListenerBase.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class ChannelListenerBase<TChannel>
+               : ChannelListenerBase, IChannelListener<TChannel>, 
+               IChannelListener,  ICommunicationObject
+               where TChannel : class, IChannel
+       {
+               IDefaultCommunicationTimeouts timeouts;
+
+               protected ChannelListenerBase ()
+                       : this (DefaultCommunicationTimeouts.Instance)
+               {
+               }
+
+               protected ChannelListenerBase (
+                       IDefaultCommunicationTimeouts timeouts)
+               {
+                       if (timeouts == null)
+                               throw new ArgumentNullException ("timeouts");
+                       this.timeouts = timeouts;
+               }
+
+               public TChannel AcceptChannel ()
+               {
+                       return AcceptChannel (timeouts.ReceiveTimeout);
+               }
+
+               public TChannel AcceptChannel (TimeSpan timeout)
+               {
+                       ThrowIfDisposedOrNotOpen ();
+                       return OnAcceptChannel (timeout);
+               }
+
+               public IAsyncResult BeginAcceptChannel (
+                       AsyncCallback callback, object asyncState)
+               {
+                       return BeginAcceptChannel (
+                               timeouts.ReceiveTimeout, callback, asyncState);
+               }
+
+               public IAsyncResult BeginAcceptChannel (TimeSpan timeout,
+                       AsyncCallback callback, object asyncState)
+               {
+                       return OnBeginAcceptChannel (timeout, callback, asyncState);
+               }
+
+               public TChannel EndAcceptChannel (IAsyncResult result)
+               {
+                       return OnEndAcceptChannel (result);
+               }
+
+               protected abstract TChannel OnAcceptChannel (TimeSpan timeout);
+
+               protected abstract IAsyncResult OnBeginAcceptChannel (TimeSpan timeout,
+                       AsyncCallback callback, object asyncState);
+
+               protected abstract TChannel OnEndAcceptChannel (IAsyncResult result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelManagerBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelManagerBase.cs
new file mode 100644 (file)
index 0000000..9ec77da
--- /dev/null
@@ -0,0 +1,69 @@
+//
+// ChannelManagerBase.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class ChannelManagerBase : CommunicationObject,
+               ICommunicationObject, IDefaultCommunicationTimeouts
+       {
+               protected ChannelManagerBase ()
+               {
+               }
+
+               protected internal abstract TimeSpan DefaultReceiveTimeout { get; }
+
+               protected internal abstract TimeSpan DefaultSendTimeout { get; }
+
+               // The reason why this class implements 
+               // IDefaultCommunicationTimeouts is not clear, so they
+               // are likely to be refactored.
+
+               [MonoTODO ("verify it.")]
+               TimeSpan IDefaultCommunicationTimeouts.OpenTimeout {
+                       get { return TimeSpan.FromMinutes (1); }
+               }
+
+               [MonoTODO ("verify it.")]
+               TimeSpan IDefaultCommunicationTimeouts.CloseTimeout {
+                       get { return TimeSpan.FromMinutes (1); }
+               }
+
+               TimeSpan IDefaultCommunicationTimeouts.ReceiveTimeout {
+                       get { return DefaultReceiveTimeout; }
+               }
+
+               TimeSpan IDefaultCommunicationTimeouts.SendTimeout {
+                       get { return DefaultSendTimeout; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelParameterCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelParameterCollection.cs
new file mode 100644 (file)
index 0000000..c6aa3ee
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// ChannelParameterCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+
+namespace System.ServiceModel.Channels
+{
+       public class ChannelParameterCollection : Collection<object>
+       {
+               IChannel channel;
+
+               public ChannelParameterCollection ()
+               {
+               }
+
+               public ChannelParameterCollection (IChannel channel)
+               {
+                       this.channel = channel;
+               }
+
+               protected virtual IChannel Channel {
+                       get { return channel; }
+               }
+
+               [MonoTODO]
+               public void PropagateChannelParameters (IChannel innerChannel)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void ClearItems ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void InsertItem (int index, object item)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void RemoveItem (int index)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void SetItem (int index, object item)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelPoolSettings.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelPoolSettings.cs
new file mode 100644 (file)
index 0000000..2c648ab
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// ChannelPoolSettings.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Channels
+{
+       public class ChannelPoolSettings
+       {
+               [MonoTODO]
+               public ChannelPoolSettings ()
+               {
+               }
+
+               internal ChannelPoolSettings (ChannelPoolSettings other)
+               {
+                       IdleTimeout = other.IdleTimeout;
+                       LeaseTimeout = other.LeaseTimeout;
+                       MaxOutboundChannelsPerEndpoint = other.MaxOutboundChannelsPerEndpoint;
+               }
+
+               TimeSpan idle_timeout, lease_timeout;
+               int max_outbound;
+
+               [MonoTODO]
+               public TimeSpan IdleTimeout {
+                       get { return idle_timeout; }
+                       set { idle_timeout = value; }
+               }
+
+               [MonoTODO]
+               public TimeSpan LeaseTimeout {
+                       get { return lease_timeout; }
+                       set { lease_timeout = value; }
+               }
+
+               [MonoTODO]
+               public int MaxOutboundChannelsPerEndpoint {
+                       get { return max_outbound; }
+                       set { max_outbound = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs
new file mode 100644 (file)
index 0000000..c0e5f50
--- /dev/null
@@ -0,0 +1,316 @@
+//
+// CommunicationObject.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.Threading;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class CommunicationObject : ICommunicationObject
+       {
+               object mutex;
+               CommunicationState state = CommunicationState.Created;
+               TimeSpan open_timeout, close_timeout;
+               bool aborted;
+
+               protected CommunicationObject ()
+                       : this (new object ())
+               {
+               }
+
+               protected CommunicationObject (object mutex)
+               {
+                       this.mutex = mutex;
+               }
+
+               #region Events
+
+               public event EventHandler Closed;
+
+               public event EventHandler Closing;
+
+               public event EventHandler Faulted;
+
+               public event EventHandler Opened;
+
+               public event EventHandler Opening;
+
+               #endregion
+
+               #region Properties
+
+               public CommunicationState State {
+                       get { return state; }
+               }
+
+               protected bool IsDisposed {
+                       get { return state == CommunicationState.Closed; }
+               }
+
+               protected object ThisLock {
+                       get { return mutex; }
+               }
+
+               protected internal abstract TimeSpan DefaultCloseTimeout { get; }
+
+               protected internal abstract TimeSpan DefaultOpenTimeout { get; }
+
+               #endregion
+
+               #region Methods
+
+               [MonoTODO]
+               public void Abort ()
+               {
+                       OnAbort ();
+               }
+
+               [MonoTODO]
+               protected void Fault ()
+               {
+                       state = CommunicationState.Faulted;
+                       OnFaulted ();
+               }
+
+               public IAsyncResult BeginClose (AsyncCallback callback,
+                       object state)
+               {
+                       return BeginClose (close_timeout, callback, state);
+               }
+
+               public IAsyncResult BeginClose (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       ProcessClosing ();
+                       return OnBeginClose (timeout, callback, state);
+               }
+
+               public IAsyncResult BeginOpen (AsyncCallback callback,
+                       object state)
+               {
+                       return BeginOpen (open_timeout, callback, state);
+               }
+
+               public IAsyncResult BeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       ProcessOpening ();
+                       return OnBeginOpen (timeout, callback, state);
+               }
+
+               public void Close ()
+               {
+                       Close (close_timeout);
+               }
+
+               public void Close (TimeSpan timeout)
+               {
+                       ProcessClosing ();
+                       OnClose (timeout);
+                       ProcessClosed ();
+               }
+
+               public void EndClose (IAsyncResult result)
+               {
+                       OnEndClose (result);
+                       ProcessClosed ();
+               }
+
+               public void EndOpen (IAsyncResult result)
+               {
+                       OnEndOpen (result);
+                       ProcessOpened ();
+               }
+
+               public void Open ()
+               {
+                       Open (open_timeout);
+               }
+
+               public void Open (TimeSpan timeout)
+               {
+                       ProcessOpening ();
+                       OnOpen (timeout);
+                       ProcessOpened ();
+               }
+
+               protected abstract void OnAbort ();
+
+               protected abstract IAsyncResult OnBeginClose (TimeSpan timeout,
+                       AsyncCallback callback, object state);
+
+               protected abstract IAsyncResult OnBeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state);
+
+               protected abstract void OnClose (TimeSpan timeout);
+
+               void ProcessClosing ()
+               {
+                       if (State == CommunicationState.Faulted)
+                               throw new CommunicationObjectFaultedException ();
+                       state = CommunicationState.Closing;
+                       OnClosing ();
+               }
+
+               protected virtual void OnClosing ()
+               {
+                       // This means, if this method is overriden, then
+                       // Opening event is surpressed.
+                       if (Closing != null)
+                               Closing (this, new EventArgs ());
+               }
+
+               void ProcessClosed ()
+               {
+                       state = CommunicationState.Closed;
+                       OnClosed ();
+               }
+
+               protected virtual void OnClosed ()
+               {
+                       // This means, if this method is overriden, then
+                       // Closed event is surpressed.
+                       if (Closed != null)
+                               Closed (this, new EventArgs ());
+               }
+
+               protected abstract void OnEndClose (IAsyncResult result);
+
+               protected abstract void OnEndOpen (IAsyncResult result);
+
+               [MonoTODO]
+               protected virtual void OnFaulted ()
+               {
+                       // This means, if this method is overriden, then
+                       // Opened event is surpressed.
+                       if (Faulted != null)
+                               Faulted (this, new EventArgs ());
+               }
+
+               protected abstract void OnOpen (TimeSpan timeout);
+
+               void ProcessOpened ()
+               {
+                       state = CommunicationState.Opened;
+                       OnOpened ();
+               }
+
+               protected virtual void OnOpened ()
+               {
+                       // This means, if this method is overriden, then
+                       // Opened event is surpressed.
+                       if (Opened != null)
+                               Opened (this, new EventArgs ());
+               }
+
+               void ProcessOpening ()
+               {
+                       ThrowIfDisposedOrImmutable ();
+                       state = CommunicationState.Opening;
+                       OnOpening ();
+               }
+
+               protected virtual void OnOpening ()
+               {
+                       // This means, if this method is overriden, then
+                       // Opening event is surpressed.
+                       if (Opening != null)
+                               Opening (this, new EventArgs ());
+               }
+
+               protected void ThrowIfDisposed ()
+               {
+                       if (IsDisposed)
+                               throw new ObjectDisposedException (String.Format ("This communication object {0} is already disposed.", GetCommunicationObjectType ()));
+               }
+
+               protected void ThrowIfDisposedOrNotOpen ()
+               {
+                       ThrowIfDisposed ();
+                       if (State == CommunicationState.Faulted)
+                               throw new CommunicationObjectFaultedException ();
+                       if (State != CommunicationState.Opened)
+                               throw new InvalidOperationException (String.Format ("The communication object {0} must be at opened state.", GetCommunicationObjectType ()));
+               }
+
+               protected void ThrowIfDisposedOrImmutable ()
+               {
+                       ThrowIfDisposed ();
+                       // hmm, according to msdn, Closing is OK here.
+                       switch (State) {
+                       case CommunicationState.Faulted:
+                               throw new CommunicationObjectFaultedException ();
+                       case CommunicationState.Opening:
+                       case CommunicationState.Opened:
+                               throw new InvalidOperationException (String.Format ("The communication object {0} is not at created state.", GetType ()));
+                       }
+               }
+
+               protected virtual Type GetCommunicationObjectType ()
+               {
+                       return GetType ();
+               }
+
+               #endregion
+
+
+               class SimpleAsyncResult : IAsyncResult
+               {
+                       CommunicationState comm_state;
+                       object async_state;
+
+                       public SimpleAsyncResult (
+                               CommunicationState communicationState,
+                               TimeSpan timeout, AsyncCallback callback,
+                               object asyncState)
+                       {
+                               comm_state = communicationState;
+                               async_state = asyncState;
+                       }
+
+                       public object AsyncState {
+                               get { return async_state; }
+                       }
+
+                       // FIXME: implement
+                       public WaitHandle AsyncWaitHandle {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       // FIXME: implement
+                       public bool CompletedSynchronously {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       // FIXME: implement
+                       public bool IsCompleted {
+                               get { throw new NotImplementedException (); }
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CompilationException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CompilationException.cs
new file mode 100644 (file)
index 0000000..77bbb64
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// CompilationException
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.CodeDom.Compiler;
+using System.Text;
+using System.Web;
+
+namespace System.ServiceModel.Channels
+{
+       internal class CompilationException : HtmlizedException
+       {
+               string filename;
+               CompilerErrorCollection errors;
+               string fileText;
+               string errmsg;
+               int [] errorLines;
+
+               public CompilationException (string filename, CompilerErrorCollection errors, string fileText)
+               {
+                       this.filename = filename;
+                       this.errors = errors;
+                       this.fileText = fileText;
+               }
+
+               public override string SourceFile {
+                       get {
+                               if (errors == null || errors.Count == 0)
+                                       return filename;
+
+                               return errors [0].FileName;
+                       }
+               }
+               
+               public override string FileName {
+                       get { return filename; }
+               }
+               
+               public override string Title {
+                       get { return "Compilation Error"; }
+               }
+
+               public override string Description {
+                       get {
+                               return "Error compiling a resource required to service this request. " +
+                                      "Review your source file and modify it to fix this error.";
+                       }
+               }
+
+               public override string ErrorMessage {
+                       get {
+                               if (errmsg == null && errors != null) {
+                                       StringBuilder sb = new StringBuilder ();
+                                       foreach (CompilerError err in errors) {
+                                               sb.Append (err);
+                                               sb.Append ("\n");
+                                       }
+                                       errmsg = sb.ToString ();
+                               }
+
+                               return errmsg;
+                       }
+               }
+
+               public override string FileText {
+                       get { return fileText; }
+               }
+
+               public override int [] ErrorLines {
+                       get {
+                               if (errorLines == null && errors != null) {
+                                       ArrayList list = new ArrayList ();
+                                       foreach (CompilerError err in errors) {
+                                               if (err.Line != 0 && !list.Contains (err.Line))
+                                                       list.Add (err.Line);
+                                       }
+                                       errorLines = (int []) list.ToArray (typeof (int));
+                                       Array.Sort (errorLines);
+                               }
+
+                               return errorLines;
+                       }
+               }
+
+               public override bool ErrorLinesPaired {
+                       get { return false; }
+               }
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CompositeDuplexBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CompositeDuplexBindingElement.cs
new file mode 100644 (file)
index 0000000..6709b29
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// BinaryMessageEncodingBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.Text;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public sealed class CompositeDuplexBindingElement
+               : BindingElement
+       {
+               EndpointAddress endpoint;
+
+               public CompositeDuplexBindingElement ()
+               {
+               }
+
+               private CompositeDuplexBindingElement (EndpointAddress endpoint)
+               {
+                       this.endpoint = endpoint;
+               }
+
+               public Uri ClientBaseAddress {
+                       get { return endpoint.Uri; }
+                       set { endpoint = new EndpointAddress (value); }
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new CompositeDuplexBindingElement (endpoint);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CompositeDuplexBindingElementImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CompositeDuplexBindingElementImporter.cs
new file mode 100644 (file)
index 0000000..21fce02
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// CompositeDuplexBindingElementImporter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class CompositeDuplexBindingElementImporter
+               : IPolicyImportExtension
+       {
+               [MonoTODO]
+               void IPolicyImportExtension.ImportPolicy (MetadataImporter importer, PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ConnectionOrientedTransportBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ConnectionOrientedTransportBindingElement.cs
new file mode 100644 (file)
index 0000000..cfded02
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// ConnectionOrientedTransportBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public abstract class ConnectionOrientedTransportBindingElement
+               : TransportBindingElement
+       {
+               int connection_buf_size = 0x2000, max_buf_size = 0x10000,
+                       max_pending_conn = 10, max_pending_accepts = 1;
+               HostNameComparisonMode host_cmp_mode = HostNameComparisonMode.StrongWildcard;
+               TimeSpan max_output_delay = TimeSpan.FromMilliseconds (200);
+               TimeSpan ch_init_timeout = TimeSpan.FromSeconds (5);
+               TransferMode transfer_mode = TransferMode.Buffered;
+
+               internal ConnectionOrientedTransportBindingElement ()
+               {
+               }
+
+               internal ConnectionOrientedTransportBindingElement (
+                       ConnectionOrientedTransportBindingElement other)
+                       : base (other)
+               {
+                       connection_buf_size = other.connection_buf_size;
+                       max_buf_size = other.max_buf_size;
+                       max_pending_conn = other.max_pending_conn;
+                       max_pending_accepts = other.max_pending_accepts;
+                       host_cmp_mode = other.host_cmp_mode;
+                       max_output_delay = other.max_output_delay;
+                       transfer_mode = other.transfer_mode;
+               }
+
+               public TimeSpan ChannelInitializationTimeout {
+                       get { return ch_init_timeout; }
+                       set { ch_init_timeout = value; }
+               }
+
+               public int ConnectionBufferSize {
+                       get { return connection_buf_size; }
+                       set { connection_buf_size = value; }
+               }
+
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return host_cmp_mode; }
+                       set { host_cmp_mode = value; }
+               }
+
+               public int MaxBufferSize {
+                       get { return max_buf_size; }
+                       set { max_buf_size = value; }
+               }
+
+               public int MaxPendingConnections {
+                       get { return max_pending_conn; }
+                       set { max_pending_conn = value; }
+               }
+
+               public TimeSpan MaxOutputDelay {
+                       get { return max_output_delay; }
+                       set { max_output_delay = value; }
+               }
+
+               public int MaxPendingAccepts {
+                       get { return max_pending_accepts; }
+                       set { max_pending_accepts = value; }
+               }
+
+               public TransferMode TransferMode {
+                       get { return transfer_mode; }
+                       set { transfer_mode = value; }
+               }
+               
+               [MonoTODO]
+               public override bool CanBuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       return typeof (TChannel) == typeof (IDuplexSessionChannel);
+               }
+
+               [MonoTODO]
+               public override bool CanBuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       return typeof (TChannel) == typeof (IDuplexSessionChannel);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CustomBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CustomBinding.cs
new file mode 100644 (file)
index 0000000..273bffb
--- /dev/null
@@ -0,0 +1,112 @@
+//
+// CustomBinding.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       public class CustomBinding : Binding
+       {
+               const string default_ns = "http://tempuri.org";
+
+               BindingElementCollection elements;
+               Binding binding;
+               ISecurityCapabilities security;
+               string scheme = "";
+
+               public CustomBinding (string name)
+                       : this (name, default_ns)
+               {
+               }
+
+               public CustomBinding ()
+                       : base ()
+               {
+                       elements = new BindingElementCollection ();
+               }
+
+               // Binding passed to .ctor() seems to have nothing to do
+               // with the properties on this class.
+               public CustomBinding (Binding binding)
+                       : this (binding.CreateBindingElements (),
+                               binding.Name, binding.Namespace)
+               {
+                       this.binding = binding;
+                       scheme = binding.Scheme;
+                       security = binding as ISecurityCapabilities;
+               }
+
+               public CustomBinding (params BindingElement [] binding)
+                       : this ("CustomBinding", default_ns, binding)
+               {
+               }
+
+               public CustomBinding (IEnumerable<BindingElement> bindingElements)
+                       : this (bindingElements, "CustomBinding", default_ns)
+               {
+               }
+
+               public CustomBinding (string name, string ns,
+                       params BindingElement [] binding)
+                       : this (binding, name, ns)
+               {
+               }
+
+               private CustomBinding (IEnumerable<BindingElement> binding,
+                       string name, string ns)
+                       : base (name, ns)
+               {
+                       elements = new BindingElementCollection (binding);
+                       foreach (BindingElement be in elements) {
+                               TransportBindingElement tbe = be as TransportBindingElement;
+                               if (tbe == null)
+                                       continue;
+                               scheme = tbe.Scheme;
+                               break;
+                       }
+               }
+
+               public BindingElementCollection Elements {
+                       get { return elements; }
+               }
+
+               public override string Scheme {
+                       get { return scheme; }
+               }
+
+               public override BindingElementCollection CreateBindingElements ()
+               {
+                       return elements;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/DeliveryFailure.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/DeliveryFailure.cs
new file mode 100644 (file)
index 0000000..2c973af
--- /dev/null
@@ -0,0 +1,50 @@
+//
+// DeliveryFailure.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel.Channels
+{
+       public enum DeliveryFailure {
+               Unknown,
+
+               BadDestinationQueue = 0x8000,
+               Purged,
+               ReachQueueTimeout,
+               QueueExceedMaximumSize,
+               AccessDenied,
+               HopCountExceeded,
+               BadSignature,
+               BadEncryption,
+               CouldNotEncrypt,
+               NotTransactionalQueue,
+               NotTransactionalMessage,
+
+               QueueDeleted = 0xC000,
+               QueuePurged,
+               ReceiveTimeout,
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/DeliveryStatus.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/DeliveryStatus.cs
new file mode 100644 (file)
index 0000000..c535de8
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// DeliveryStatus.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel.Channels
+{
+       public enum DeliveryStatus {
+               InDoubt,
+               NotDelivered,
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/DirectionalAction.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/DirectionalAction.cs
new file mode 100644 (file)
index 0000000..28fc64e
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// DirectionalAction.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Runtime.Serialization;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       internal class DirectionalAction : IComparable<DirectionalAction>
+       {
+               public DirectionalAction (MessageDirection direction, string action)
+               {
+                       this.dir = direction;
+                       this.action = action;
+               }
+
+               MessageDirection dir;
+               string action;
+
+               public MessageDirection Direction {
+                       get { return dir; }
+               }
+
+               public string Action {
+                       get { return action; }
+               }
+
+               public int CompareTo (DirectionalAction other)
+               {
+                       int diff = (int) Direction - (int) other.Direction;
+                       return diff != 0 ? diff :
+                               String.CompareOrdinal (Action, other.Action);
+               }
+
+               public bool Equals (DirectionalAction other)
+               {
+                       return other != null && Direction ==
+                               other.Direction &&
+                               Action == other.Action;
+               }
+
+               public override bool Equals (object other)
+               {
+                       DirectionalAction d = other as DirectionalAction;
+                       return d != null && Equals (d);
+               }
+
+               public override int GetHashCode ()
+               {
+                       return Action.GetHashCode () ^ ((int) Direction << 24);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/DuplexSessionChannelBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/DuplexSessionChannelBase.cs
new file mode 100644 (file)
index 0000000..d6b6117
--- /dev/null
@@ -0,0 +1,71 @@
+// 
+// DuplexSessionChannelBase.cs
+// 
+// Author:
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Channels
+{
+       internal abstract class DuplexChannelBase : ChannelBase, IDuplexChannel
+       {
+               ChannelFactoryBase channel_factory_base;
+               ChannelListenerBase channel_listener_base;
+               EndpointAddress local_address;
+               EndpointAddress remote_address;
+               Uri via;
+               
+               public DuplexChannelBase (ChannelFactoryBase factory) : base (factory)
+               {
+                       channel_factory_base = factory;
+               }
+               
+               public DuplexChannelBase (ChannelListenerBase listener) : base (listener)
+               {
+                       channel_listener_base = listener;
+               }
+
+               public abstract EndpointAddress LocalAddress { get; }
+               
+               public abstract EndpointAddress RemoteAddress { get; }
+               
+               public abstract Uri Via { get; }
+               
+               public abstract IAsyncResult BeginSend (Message message, AsyncCallback callback, object state);
+               
+               public abstract IAsyncResult BeginSend (Message message, TimeSpan timeout, AsyncCallback callback, object state);
+               
+               public abstract void EndSend (IAsyncResult result);
+               
+               public abstract void Send (Message message);
+               
+               public abstract void Send (Message message, TimeSpan timeout);
+               
+               public abstract IAsyncResult BeginReceive (AsyncCallback callback, object state);
+               
+               public abstract IAsyncResult BeginReceive (TimeSpan timeout, AsyncCallback callback, object state);
+               
+               public abstract IAsyncResult BeginTryReceive (TimeSpan timeout, AsyncCallback callback, object state);
+               
+               public abstract IAsyncResult BeginWaitForMessage (TimeSpan timeout, AsyncCallback callback, object state);
+               
+               public abstract Message EndReceive (IAsyncResult result);
+               
+               public abstract bool EndTryReceive (IAsyncResult result, out Message message);
+               
+               public abstract bool EndWaitForMessage (IAsyncResult result);
+               
+               public abstract Message Receive ();
+               
+               public abstract Message Receive (TimeSpan timeout);
+               
+               public abstract bool TryReceive (TimeSpan timeout, out Message message);
+               
+               public abstract bool WaitForMessage (TimeSpan timeout);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/FaultConverter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/FaultConverter.cs
new file mode 100644 (file)
index 0000000..ec475c1
--- /dev/null
@@ -0,0 +1,117 @@
+//
+// FaultConverter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class FaultConverter
+       {
+               public static FaultConverter GetDefaultFaultConverter (MessageVersion version)
+               {
+                       if (version == null)
+                               throw new ArgumentNullException ("version");
+                       return new SimpleFaultConverter (version);
+               }
+
+               protected FaultConverter ()
+               {
+               }
+
+               [MonoTODO]
+               protected abstract bool OnTryCreateException (
+                       Message message, MessageFault fault, out Exception error);
+
+               [MonoTODO]
+               protected abstract bool OnTryCreateFaultMessage (
+                       Exception error, out Message message);
+
+               public bool TryCreateException (Message message, MessageFault fault, out Exception error)
+               {
+                       return OnTryCreateException (message, fault, out error);
+               }
+
+               public bool TryCreateFaultMessage (Exception error, out Message message)
+               {
+                       return OnTryCreateFaultMessage (error, out message);
+               }
+
+               Message CreateSimpleFaultMessage (Exception error, MessageVersion version)
+               {
+Console.WriteLine (error);
+                       OperationContext ctx = OperationContext.Current;
+                       // FIXME: support more fault code depending on the exception type.
+                       FaultCode fc = null;
+                       if (error is EndpointNotFoundException)
+                               fc = new FaultCode (
+                                       "DestinationUnreachable",
+                                       version.Addressing.Namespace);
+                       else
+                               fc = new FaultCode (
+                                       "FIXME_InternalError",
+                                       version.Addressing.Namespace);
+
+                       // FIXME: set correct fault reason.
+                       if (ctx.EndpointDispatcher.ChannelDispatcher.IncludeExceptionDetailInFaults) {
+                               ExceptionDetail detail = new ExceptionDetail (error);
+                               return Message.CreateMessage (version, fc,
+                                       "error occured", detail, ctx.IncomingMessageHeaders.Action);
+                       }
+                       return Message.CreateMessage (version, fc, "error occured", ctx.IncomingMessageHeaders.Action);
+               }
+
+               class SimpleFaultConverter : FaultConverter
+               {
+                       MessageVersion version;
+                       public SimpleFaultConverter (MessageVersion version)
+                       {
+                               this.version = version;
+                       }
+
+                       protected override bool OnTryCreateException (
+                               Message message, MessageFault fault, out Exception error)
+                       {
+                               error = null;
+                               return false;
+                       }
+
+                       protected override bool OnTryCreateFaultMessage (
+                               Exception error, out Message message)
+                       {
+                               message = null;
+                               if (OperationContext.Current == null)
+                                       return false;
+
+                               message = CreateSimpleFaultMessage (error, version);
+                               return true;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HostedTransportConfiguration.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HostedTransportConfiguration.cs
new file mode 100644 (file)
index 0000000..141dde1
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// HostedTransportConfiguration.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel.Activation
+{
+       public abstract class HostedTransportConfiguration
+       {
+               protected HostedTransportConfiguration ()
+               {
+               }
+
+               public abstract Uri[] GetBaseAddresses (string virtualPath);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HtmlizedException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HtmlizedException.cs
new file mode 100644 (file)
index 0000000..e84ba18
--- /dev/null
@@ -0,0 +1,63 @@
+//
+// HtmlizedException
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2003 Ximian, Inc (http://www.ximian.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Text;
+
+namespace System.ServiceModel.Channels
+{
+       internal abstract class HtmlizedException : Exception
+       {
+               protected HtmlizedException ()
+               {
+               }
+
+               protected HtmlizedException (string message)
+                       : base (message)
+               {
+               }
+
+               protected HtmlizedException (string message, Exception inner)
+                       : base (message, inner)
+               {
+               }
+
+               public abstract string Title { get; }
+               public abstract string Description { get; }
+               public abstract string ErrorMessage { get; }
+               public abstract string FileName { get; }
+               public abstract string SourceFile { get; }
+               public abstract string FileText { get; }
+               public abstract int [] ErrorLines { get; }
+               public abstract bool ErrorLinesPaired { get; }
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelFactory.cs
new file mode 100644 (file)
index 0000000..38c247a
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// HttpChannelFactory.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.Text;
+
+namespace System.ServiceModel.Channels
+{
+       internal class HttpChannelFactory<TChannel> : ChannelFactoryBase<TChannel>
+       {
+               // not sure if they are required.
+               HttpTransportBindingElement source;
+               MessageEncoder encoder;
+
+               public HttpChannelFactory (HttpTransportBindingElement source, BindingContext ctx)
+               {
+                       this.source = source;
+                       foreach (BindingElement be in ctx.RemainingBindingElements) {
+                               MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
+                               if (mbe != null) {
+                                       encoder = mbe.CreateMessageEncoderFactory ().Encoder;
+                                       break;
+                               }
+                       }
+                       if (encoder == null)
+                               encoder = new TextMessageEncoder (MessageVersion.Default, Encoding.UTF8);
+               }
+
+               public MessageEncoder MessageEncoder {
+                       get { return encoder; }
+               }
+
+               protected override TChannel OnCreateChannel (
+                       EndpointAddress address, Uri via)
+               {
+                       ThrowIfDisposedOrNotOpen ();
+
+                       if (source.Scheme != address.Uri.Scheme)
+                               throw new ArgumentException (String.Format ("Argument EndpointAddress has unsupported URI scheme: {0}", address.Uri.Scheme));
+
+                       Type t = typeof (TChannel);
+                       if (t == typeof (IRequestChannel))
+                               return (TChannel) (object) new HttpRequestChannel ((HttpChannelFactory<IRequestChannel>) (object) this, address, via);
+                       else if (t == typeof (IOutputChannel))
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       throw new InvalidOperationException (String.Format ("channel type {0} is not supported.", typeof (TChannel).Name));
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelListener.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelListener.cs
new file mode 100644 (file)
index 0000000..98d31da
--- /dev/null
@@ -0,0 +1,185 @@
+//
+// HttpChannelListener.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.Text;
+
+namespace System.ServiceModel.Channels
+{
+       internal class HttpChannelListener<TChannel> : ChannelListenerBase<TChannel>
+               where TChannel : class, IChannel
+       {
+               HttpTransportBindingElement source;
+               BindingContext context;
+               Uri listen_uri;
+               List<IChannel> channels = new List<IChannel> ();
+               MessageEncoder encoder;
+               HttpChannelManager<TChannel> httpChannelManager;
+
+               public HttpChannelListener (HttpTransportBindingElement source,
+                       BindingContext context)
+                       : base (context.Binding)
+               {
+                       // FIXME: consider ListenUriMode
+                       // FIXME: there should be some way to post-provide Uri in case of null listenerUri in context.
+                       listen_uri = context.ListenUriBaseAddress != null ?
+                               new Uri (context.ListenUriBaseAddress, context.ListenUriRelativeAddress) : null;
+                       foreach (BindingElement be in context.RemainingBindingElements) {
+                               MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
+                               if (mbe != null) {
+                                       encoder = mbe.CreateMessageEncoderFactory ().Encoder;
+                                       break;
+                               }
+                       }
+                       if (encoder == null)
+                               encoder = new TextMessageEncoder (MessageVersion.Default, Encoding.UTF8);
+               }
+
+               public HttpListener Http {
+                       get {  return httpChannelManager.HttpListener; }
+               }
+
+               public MessageEncoder MessageEncoder {
+                       get { return encoder; }
+               }
+
+               public override Uri Uri {
+                       get { return listen_uri; }
+               }
+
+               protected override TChannel OnAcceptChannel (TimeSpan timeout)
+               {
+                       TChannel ch = PopulateChannel (timeout);
+                       channels.Add (ch);
+                       return ch;
+               }
+
+               TChannel PopulateChannel (TimeSpan timeout)
+               {
+                       if (typeof (TChannel) == typeof (IReplyChannel)) {
+                               if (ServiceHostingEnvironment.InAspNet)
+                                       return (TChannel) (object) new AspNetReplyChannel (
+                                               (HttpChannelListener<IReplyChannel>) (object) this, timeout);
+                               else
+                                       return (TChannel) (object) new HttpReplyChannel (
+                                               (HttpChannelListener<IReplyChannel>) (object) this, timeout);
+                       }
+
+                       // FIXME: implement more
+
+                       throw new NotImplementedException ();
+               }
+
+               protected override IAsyncResult OnBeginAcceptChannel (
+                       TimeSpan timeout, AsyncCallback callback,
+                       object asyncState)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override TChannel OnEndAcceptChannel (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override IAsyncResult OnBeginWaitForChannel (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override bool OnEndWaitForChannel (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override bool OnWaitForChannel (TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               void StartListening (TimeSpan timeout)
+               {
+                       httpChannelManager = new HttpChannelManager<TChannel> (this);
+                       httpChannelManager.Open (timeout);
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       if (ServiceHostingEnvironment.InAspNet)
+                               return;
+
+                       StartListening (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       if (ServiceHostingEnvironment.InAspNet)
+                               return;
+
+                       foreach (TChannel ch in channels)
+                               ch.Close(timeout);
+                       httpChannelManager.Stop ();
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO ("find out what to do here.")]
+               protected override void OnAbort ()
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelManager.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelManager.cs
new file mode 100644 (file)
index 0000000..e791441
--- /dev/null
@@ -0,0 +1,97 @@
+//\r
+// HttpChannelManager.cs\r
+//\r
+// Author:\r
+//     Vladimir Krasnov <vladimirk@mainsoft.com>\r
+//\r
+// Copyright (C) 2005-2006 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Net;
+
+namespace System.ServiceModel.Channels
+{
+       internal class HttpChannelManager<TChannel> where TChannel : class, IChannel
+       {
+               static Dictionary<Uri, HttpListener> opened_listeners;\r
+               static Dictionary<Uri, List<HttpChannelListener<TChannel>>> registered_channels;
+               HttpChannelListener<TChannel> channel_listener;
+               HttpListener http_listener;
+
+               static HttpChannelManager ()
+               {
+                       opened_listeners = new Dictionary<Uri, HttpListener> ();\r
+                       registered_channels = new Dictionary<Uri, List<HttpChannelListener<TChannel>>> ();
+               }
+
+               public HttpChannelManager (HttpChannelListener<TChannel> channel_listener)
+               {
+                       this.channel_listener = channel_listener;
+               }
+
+               public void Open (TimeSpan timeout)
+               {\r
+                       lock (opened_listeners) {\r
+                               if (!opened_listeners.ContainsKey (channel_listener.Uri)) {\r
+                                       HttpListener listener = new HttpListener ();\r
+\r
+                                       string uriString = channel_listener.Uri.ToString ();\r
+                                       if (!uriString.EndsWith ("/", StringComparison.Ordinal))\r
+                                               uriString += "/";\r
+                                       listener.Prefixes.Add (uriString);\r
+                                       listener.Start ();\r
+\r
+                                       opened_listeners [channel_listener.Uri] = listener;\r
+                                       List<HttpChannelListener<TChannel>> registeredList = new List<HttpChannelListener<TChannel>> ();                                        \r
+                                       registered_channels [channel_listener.Uri] = registeredList;\r
+                               }\r
+\r
+                               http_listener = opened_listeners [channel_listener.Uri];\r
+                               registered_channels [channel_listener.Uri].Add (channel_listener);                              \r
+                       }
+               }
+
+               public void Stop ()
+               {\r
+                       lock (opened_listeners) {\r
+                               if (http_listener == null)\r
+                                       return;\r
+                               List<HttpChannelListener<TChannel>> channelsList = registered_channels [channel_listener.Uri];\r
+                               channelsList.Remove (channel_listener);\r
+                               if (channelsList.Count == 0) {                                  \r
+                                       if (http_listener.IsListening)\r
+                                               http_listener.Stop ();\r
+                                       ((IDisposable) http_listener).Dispose ();\r
+\r
+                                       opened_listeners.Remove (channel_listener.Uri);                         \r
+                               }                               \r
+                       }
+               }
+
+               public HttpListener HttpListener
+               {
+                       get { return http_listener; }
+               }
+       }       
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpReplyChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpReplyChannel.cs
new file mode 100644 (file)
index 0000000..0412b7b
--- /dev/null
@@ -0,0 +1,222 @@
+//
+// HttpReplyChannel.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.ServiceModel;
+using System.Text;
+using System.Threading;
+
+namespace System.ServiceModel.Channels
+{
+       internal class HttpReplyChannel : ReplyChannelBase
+       {
+               HttpChannelListener<IReplyChannel> source;
+               List<HttpListenerContext> waiting = new List<HttpListenerContext> ();
+               TimeSpan timeout;
+               EndpointAddress local_address;
+
+               public HttpReplyChannel (HttpChannelListener<IReplyChannel> listener,
+                       TimeSpan timeout)
+                       : base (listener)
+               {
+                       this.source = listener;
+                       this.timeout = timeout;
+               }
+
+               public MessageEncoder Encoder {
+                       get { return source.MessageEncoder; }
+               }
+
+               // FIXME: where is it set?
+               public override EndpointAddress LocalAddress {
+                       get { return local_address; }
+               }
+
+               public override bool TryReceiveRequest (TimeSpan timeout, out RequestContext context)
+               {
+                       context = null;
+                       if (waiting.Count == 0 && !WaitForRequest (timeout))
+                               return false;
+                       HttpListenerContext ctx = null;
+                       lock (waiting) {
+                               if (waiting.Count > 0) {
+                                       ctx = waiting [0];
+                                       waiting.RemoveAt (0);
+                               }
+                       }
+                       if (ctx == null) 
+                               // Though as long as this instance is used
+                               // synchronously, it should not happen.
+                               return false;
+
+                       // FIXME: supply maxSizeOfHeaders.
+                       int maxSizeOfHeaders = 0x10000;
+
+                       Message msg = null;
+                       if (ctx.Request.HttpMethod == "POST") {
+                               if (!Encoder.IsContentTypeSupported (ctx.Request.ContentType)) {
+                                       ctx.Response.StatusCode = (int) HttpStatusCode.UnsupportedMediaType;
+                                       ctx.Response.StatusDescription = String.Format (
+                                                       "Expected content-type '{0}' but got '{1}'", Encoder.ContentType, ctx.Request.ContentType);
+                                       ctx.Response.Close ();
+
+                                       return false;
+                               }
+
+                               msg = Encoder.ReadMessage (
+                                       ctx.Request.InputStream, maxSizeOfHeaders);
+                               if (source.MessageEncoder.MessageVersion.Envelope == EnvelopeVersion.Soap11 ||
+                                   source.MessageEncoder.MessageVersion.Addressing == AddressingVersion.None) {
+                                       string action = GetHeaderItem (ctx.Request.Headers ["SOAPAction"]);
+                                       if (action != null)
+                                               msg.Headers.Action = action;
+                               }
+                       } else if (ctx.Request.HttpMethod == "GET") {
+                               msg = Message.CreateMessage (source.MessageEncoder.MessageVersion, null);
+                       }
+                       msg.Headers.To = ctx.Request.Url;
+                       
+                       HttpRequestMessageProperty prop =
+                               new HttpRequestMessageProperty ();
+                       prop.Method = ctx.Request.HttpMethod;
+                       prop.QueryString = ctx.Request.Url.Query;
+                       if (prop.QueryString.StartsWith ("?"))
+                               prop.QueryString = prop.QueryString.Substring (1);
+                       // FIXME: prop.SuppressEntityBody
+                       prop.Headers.Add (ctx.Request.Headers);
+                       msg.Properties.Add (HttpRequestMessageProperty.Name, prop);
+/*
+MessageBuffer buf = msg.CreateBufferedCopy (0x10000);
+msg = buf.CreateMessage ();
+System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter (Console.Out);
+w.Formatting = System.Xml.Formatting.Indented;
+buf.CreateMessage ().WriteMessage (w);
+w.Close ();
+*/
+                       context = new HttpRequestContext (this, msg, ctx);
+                       return true;
+               }
+
+               protected string GetHeaderItem (string raw)
+               {
+                       if (raw == null || raw.Length == 0)
+                               return raw;
+                       switch (raw [0]) {
+                       case '\'':
+                       case '"':
+                               if (raw [raw.Length - 1] == raw [0])
+                                       return raw.Substring (1, raw.Length - 2);
+                               // FIXME: is it simply an error?
+                               break;
+                       }
+                       return raw;
+               }
+
+               public override IAsyncResult BeginTryReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool EndTryReceiveRequest (IAsyncResult result, out RequestContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool WaitForRequest (TimeSpan timeout)
+               {
+                       AutoResetEvent wait = new AutoResetEvent (false);
+                       try {
+                               source.Http.BeginGetContext (HttpContextReceived, wait);
+                       } catch (HttpListenerException e) {
+                               if (e.ErrorCode == 0x80004005) // invalid handle. Happens during shutdown.
+                                       while (true) Thread.Sleep (1000); // thread is about to be terminated.
+                               throw;
+                       } catch (ObjectDisposedException) { return false; }
+                       // FIXME: we might want to take other approaches.
+                       if (timeout.Ticks > int.MaxValue)
+                               timeout = TimeSpan.FromDays (20);
+                       return wait.WaitOne (timeout, false);
+               }
+
+               void HttpContextReceived (IAsyncResult result)
+               {
+                       if (State == CommunicationState.Closing || State == CommunicationState.Closed)
+                               return;
+
+                       waiting.Add (source.Http.EndGetContext (result));
+                       AutoResetEvent wait = (AutoResetEvent) result.AsyncState;
+                       wait.Set ();
+               }
+
+               public override IAsyncResult BeginWaitForRequest (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool EndWaitForRequest (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override RequestContext ReceiveRequest (TimeSpan timeout)
+               {
+                       RequestContext ctx;
+                       TryReceiveRequest (timeout, out ctx);
+                       return ctx;
+               }
+
+               public override IAsyncResult BeginReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override RequestContext EndReceiveRequest (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnAbort ()
+               {
+                       foreach (HttpListenerContext ctx in waiting)
+                               ctx.Request.InputStream.Close ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       // FIXME: consider timeout
+                       foreach (HttpListenerContext ctx in waiting)
+                               ctx.Request.InputStream.Close ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs
new file mode 100644 (file)
index 0000000..4315faa
--- /dev/null
@@ -0,0 +1,296 @@
+//
+// HttpRequestChannel.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.Threading;
+
+namespace System.ServiceModel.Channels
+{
+       internal class HttpRequestChannel : RequestChannelBase
+       {
+               HttpChannelFactory<IRequestChannel> source;
+               EndpointAddress address;
+               Uri via;
+
+               WebRequest web_request;
+
+               // FIXME: supply maxSizeOfHeaders.
+               int max_headers = 0x10000;
+
+               // Constructor
+
+               public HttpRequestChannel (HttpChannelFactory<IRequestChannel> factory,
+                       EndpointAddress address, Uri via)
+                       : base (factory)
+               {
+                       this.source = factory;
+                       this.address = address;
+                       this.via = via;
+               }
+
+               public int MaxSizeOfHeaders {
+                       get { return max_headers; }
+               }
+
+               public MessageEncoder Encoder {
+                       get { return source.MessageEncoder; }
+               }
+
+               public override EndpointAddress RemoteAddress {
+                       get { return address; }
+               }
+
+               public override Uri Via {
+                       get { return via; }
+               }
+
+               // Request
+
+               public override Message Request (Message message, TimeSpan timeout)
+               {
+                       return ProcessRequest (message, timeout);
+               }
+
+               Message ProcessRequest (Message message, TimeSpan timeout)
+               {
+                       // FIXME: is distination really like this?
+                       Uri destination = message.Headers.To ?? Via ?? RemoteAddress.Uri;
+
+                       web_request = HttpWebRequest.Create (destination);
+                       web_request.Method = "POST";
+                       web_request.ContentType = Encoder.ContentType;
+
+                       web_request.Timeout = (int) timeout.TotalMilliseconds;
+
+                       // There is no SOAP Action/To header when AddressingVersion is None.
+                       if (message.Version.Addressing == AddressingVersion.None) {
+                               if (message.Headers.Action != null) {
+                                       web_request.Headers ["SOAPAction"] = message.Headers.Action;
+                                       message.Headers.RemoveAll ("Action", message.Version.Addressing.Namespace);
+                                       if (message.Headers.Action != null) throw new Exception (message.Headers.Action);
+                               }
+                       }
+
+                       // apply HttpRequestMessageProperty if exists.
+                       bool suppressEntityBody = false;
+                       string pname = HttpRequestMessageProperty.Name;
+                       if (message.Properties.ContainsKey (pname)) {
+                               HttpRequestMessageProperty hp = (HttpRequestMessageProperty) message.Properties [pname];
+                               web_request.Headers.Add (hp.Headers);
+                               web_request.Method = hp.Method;
+                               // FIXME: do we have to handle hp.QueryString ?
+                               if (hp.SuppressEntityBody)
+                                       suppressEntityBody = true;
+                       }
+
+                       if (!suppressEntityBody && String.Compare (web_request.Method, "GET", StringComparison.OrdinalIgnoreCase) != 0) {
+                               MemoryStream buffer = new MemoryStream ();
+                               Encoder.WriteMessage (message, buffer);
+
+                               if (buffer.Length > int.MaxValue)
+                                       throw new InvalidOperationException ("The argument message is too large.");
+
+                               web_request.ContentLength = (int) buffer.Length;
+                               Stream requestStream = web_request.GetRequestStream ();
+                               requestStream.Write (buffer.GetBuffer (), 0, (int) buffer.Length);
+                               requestStream.Close ();
+                       }
+
+                       WebResponse res;
+                       try {
+                               res = web_request.GetResponse ();
+                       }
+                       catch (WebException we) {
+                               res = we.Response;
+                       }
+                       try {
+                               using (Stream responseStream = res.GetResponseStream ()) {
+                                       MemoryStream ms = new MemoryStream ();
+                                       byte [] b = new byte [65536];
+                                       int n = 0;
+
+                                       while (true) {
+                                               n = responseStream.Read (b, 0, 65536);
+                                               if (n == 0)
+                                                       break;
+                                               ms.Write (b, 0, n);
+                                       }
+                                       ms.Seek (0, SeekOrigin.Begin);
+
+                                       Message ret = Encoder.ReadMessage (
+                                               //responseStream, MaxSizeOfHeaders);
+                                               ms, MaxSizeOfHeaders, res.ContentType);
+/*
+MessageBuffer buf = ret.CreateBufferedCopy (0x10000);
+ret = buf.CreateMessage ();
+System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter (Console.Out);
+w.Formatting = System.Xml.Formatting.Indented;
+buf.CreateMessage ().WriteMessage (w);
+w.Close ();
+*/
+                                       return ret;
+                               }
+                       } finally {
+                               res.Close ();
+                       }
+               }
+
+               public override IAsyncResult BeginRequest (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       ThrowIfDisposedOrNotOpen ();
+
+                       return new HttpChannelRequestAsyncResult (this, message, timeout, callback, state);
+               }
+
+               public override Message EndRequest (IAsyncResult result)
+               {
+                       if (result == null)
+                               throw new ArgumentNullException ("result");
+                       HttpChannelRequestAsyncResult r = result as HttpChannelRequestAsyncResult;
+                       if (r == null)
+                               throw new InvalidOperationException ("Wrong IAsyncResult");
+                       r.WaitEnd ();
+                       return r.Response;
+               }
+
+               // Abort
+
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               // Close
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       if (web_request != null)
+                               web_request.Abort ();
+                       web_request = null;
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               // Open
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               class HttpChannelRequestAsyncResult : IAsyncResult
+               {
+                       HttpRequestChannel channel;
+                       Message message;
+                       TimeSpan timeout;
+                       AsyncCallback callback;
+                       object state;
+                       AutoResetEvent wait;
+                       bool done, waiting;
+                       Message response;
+                       Exception error;
+
+                       public HttpChannelRequestAsyncResult (HttpRequestChannel channel, Message message, TimeSpan timeout, AsyncCallback callback, object state)
+                       {
+                               this.channel = channel;
+                               this.message = message;
+                               this.timeout = timeout;
+                               this.callback = callback;
+                               this.state = state;
+
+                               wait = new AutoResetEvent (false);
+                               Thread t = new Thread (delegate () {
+                                       try {
+                                               response = channel.ProcessRequest (message, timeout);
+                                               if (callback != null)
+                                                       callback (this);
+                                       } catch (Exception ex) {
+                                               error = ex;
+                                       } finally {
+                                               done = true;
+                                               wait.Set ();
+                                       }
+                               });
+                               t.Start ();
+                       }
+
+                       public Message Response {
+                               get { return response; }
+                       }
+
+                       public WaitHandle AsyncWaitHandle {
+                               get { return wait; }
+                       }
+
+                       public object AsyncState {
+                               get { return state; }
+                       }
+
+                       public bool CompletedSynchronously {
+                               get { return done && !waiting; }
+                       }
+
+                       public bool IsCompleted {
+                               get { return done; }
+                       }
+
+                       public void WaitEnd ()
+                       {
+                               if (!done) {
+                                       waiting = true;
+                                       wait.WaitOne (timeout, true);
+                               }
+                               if (error != null)
+                                       throw error;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestContext.cs
new file mode 100644 (file)
index 0000000..d56e31d
--- /dev/null
@@ -0,0 +1,205 @@
+//
+// HttpRequestContext.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.IO;
+using System.Net;
+using System.Threading;
+
+namespace System.ServiceModel.Channels
+{
+       internal class HttpRequestContext : RequestContext
+       {
+               class HttpRequestContextAsyncResult : IAsyncResult
+               {
+                       AutoResetEvent wait;
+                       AsyncCallback callback;
+                       object state;
+                       bool done, waiting;
+                       TimeSpan timeout;
+                       Exception error;
+
+                       public HttpRequestContextAsyncResult (
+                               HttpRequestContext context,
+                               Message msg,
+                               TimeSpan timeout,
+                               AsyncCallback callback,
+                               object state)
+                       {
+                               this.timeout = timeout;
+                               this.wait = new AutoResetEvent (false);
+                               ThreadStart ts = delegate () {
+                                       try {
+                                               context.ProcessReply (msg, timeout);
+                                               if (callback != null)
+                                                       callback (this);
+                                       } catch (Exception ex) {
+                                               error = ex;
+                                       } finally {
+                                               done = true;
+                                               wait.Set ();
+                                       }
+                               };
+                               Thread t = new Thread (ts);
+                               t.Start ();
+                       }
+
+                       public WaitHandle AsyncWaitHandle {
+                               get { return wait; }
+                       }
+
+                       public object AsyncState {
+                               get { return state; }
+                       }
+
+                       public bool CompletedSynchronously {
+                               get { return done && !waiting; }
+                       }
+
+                       public bool IsCompleted {
+                               get { return done; }
+                       }
+
+                       public void WaitEnd ()
+                       {
+                               if (!done) {
+                                       waiting = true;
+                                       wait.WaitOne (timeout, true);
+                               }
+                               if (error != null)
+                                       throw error;
+                       }
+               }
+
+               Message msg;
+               HttpListenerContext ctx;
+               HttpReplyChannel channel;
+
+               public HttpRequestContext (
+                       HttpReplyChannel channel,
+                       Message msg, HttpListenerContext ctx)
+               {
+                       if (channel == null)
+                               throw new ArgumentNullException ("channel");
+                       if (msg == null)
+                               throw new ArgumentNullException ("msg");
+                       if (ctx == null)
+                               throw new ArgumentNullException ("ctx");
+                       this.channel = channel;
+                       this.msg = msg;
+                       this.ctx = ctx;
+               }
+
+               public override Message RequestMessage {
+                       get { return msg; }
+               }
+
+               public HttpReplyChannel Channel {
+                       get { return channel; }
+               }
+
+               public override void Abort ()
+               {
+                       ctx.Response.Abort ();
+               }
+
+               public override IAsyncResult BeginReply (
+                       Message msg, AsyncCallback callback, object state)
+               {
+                       return BeginReply (msg,
+                               channel.DefaultSendTimeout,
+                               callback, state);
+               }
+
+               public override IAsyncResult BeginReply (
+                       Message msg, TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       return new HttpRequestContextAsyncResult (this, msg, timeout, callback, state);
+               }
+
+               public override void EndReply (IAsyncResult result)
+               {
+                       if (result == null)
+                               throw new ArgumentNullException ("result");
+                       HttpRequestContextAsyncResult r = result as HttpRequestContextAsyncResult;
+                       if (r == null)
+                               throw new InvalidOperationException ("Wrong IAsyncResult");
+                       r.WaitEnd ();
+               }
+
+               public override void Reply (Message msg)
+               {
+                       Reply (msg, channel.DefaultSendTimeout);
+               }
+
+               public override void Reply (Message msg, TimeSpan timeout)
+               {
+                       ProcessReply (msg, timeout);
+               }
+
+               protected virtual void ProcessReply (Message msg, TimeSpan timeout)
+               {
+                       if (msg == null)
+                               throw new ArgumentNullException ("msg");
+                       MemoryStream ms = new MemoryStream ();
+                       channel.Encoder.WriteMessage (msg, ms);
+                       ctx.Response.ContentType = channel.Encoder.ContentType;
+
+                       string pname = HttpResponseMessageProperty.Name;
+                       bool suppressEntityBody = false;
+                       if (msg.Properties.ContainsKey (pname)) {
+                               HttpResponseMessageProperty hp = (HttpResponseMessageProperty) msg.Properties [pname];
+                               string contentType = hp.Headers ["Content-Type"];
+                               if (contentType != null)
+                                       ctx.Response.ContentType = contentType;
+                               ctx.Response.Headers.Add (hp.Headers);
+                               if (hp.StatusCode != default (HttpStatusCode))
+                                       ctx.Response.StatusCode = (int) hp.StatusCode;
+                               ctx.Response.StatusDescription = hp.StatusDescription;
+                               if (hp.SuppressEntityBody)
+                                       suppressEntityBody = true;
+                       }
+                       if (!suppressEntityBody) {
+                               ctx.Response.ContentLength64 = ms.Length;
+                               ctx.Response.OutputStream.Write (ms.GetBuffer (), 0, (int) ms.Length);
+                               ctx.Response.OutputStream.Flush ();
+                       }
+               }
+
+               public override void Close ()
+               {
+                       Close (channel.DefaultSendTimeout);
+               }
+
+               public override void Close (TimeSpan timeout)
+               {
+                       // FIXME: use timeout
+                       ctx.Response.Close ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestMessageProperty.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestMessageProperty.cs
new file mode 100644 (file)
index 0000000..2dee755
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// HttpRequestMessageProperty.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class HttpRequestMessageProperty
+       {
+               public static string Name {
+                       get { return "httpRequest"; }
+               }
+
+               WebHeaderCollection headers = new WebHeaderCollection ();
+               string method, query_string;
+               bool suppress_entity;
+
+               public HttpRequestMessageProperty ()
+               {
+               }
+
+               public WebHeaderCollection Headers {
+                       get { return headers; }
+               }
+
+               public string Method {
+                       get { return method; }
+                       set { method = value; }
+               }
+
+               public string QueryString {
+                       get { return query_string; }
+                       set { query_string = value; }
+               }
+
+               public bool SuppressEntityBody {
+                       get { return suppress_entity; }
+                       set { suppress_entity = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpResponseMessageProperty.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpResponseMessageProperty.cs
new file mode 100644 (file)
index 0000000..11da8e1
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// HttpResponseMessageProperty.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class HttpResponseMessageProperty
+       {
+               public static string Name {
+                       get { return "httpResponse"; }
+               }
+
+               WebHeaderCollection headers = new WebHeaderCollection ();
+               string status_desc;
+               HttpStatusCode status_code;
+               bool suppress_entity;
+
+               public HttpResponseMessageProperty ()
+               {
+               }
+
+               public WebHeaderCollection Headers {
+                       get { return headers; }
+               }
+
+               public HttpStatusCode StatusCode {
+                       get { return status_code; }
+                       set { status_code = value; }
+               }
+
+               public string StatusDescription {
+                       get { return status_desc; }
+                       set { status_desc = value; }
+               }
+
+               public bool SuppressEntityBody {
+                       get { return suppress_entity; }
+                       set { suppress_entity = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpTransportBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpTransportBindingElement.cs
new file mode 100644 (file)
index 0000000..7feed4b
--- /dev/null
@@ -0,0 +1,205 @@
+//
+// HttpTransportBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public class HttpTransportBindingElement : TransportBindingElement,
+               IPolicyExportExtension, IWsdlExportExtension
+       {
+               bool allow_cookies, bypass_proxy_on_local,
+                       unsafe_ntlm_auth;
+               bool use_default_proxy = true, keep_alive_enabled = true;
+               int max_buffer_size = 0x10000;
+               AuthenticationSchemes auth_scheme =
+                       AuthenticationSchemes.Anonymous;
+               AuthenticationSchemes proxy_auth_scheme =
+                       AuthenticationSchemes.Anonymous;
+               HostNameComparisonMode host_cmp_mode;
+               Uri proxy_address;
+               string realm = String.Empty;
+               TransferMode transfer_mode;
+               IDefaultCommunicationTimeouts timeouts;
+               // If you add fields, do not forget them in copy constructor.
+
+               public HttpTransportBindingElement ()
+               {
+               }
+
+               protected HttpTransportBindingElement (
+                       HttpTransportBindingElement other)
+                       : base (other)
+               {
+                       allow_cookies = other.allow_cookies;
+                       bypass_proxy_on_local = other.bypass_proxy_on_local;
+                       unsafe_ntlm_auth = other.unsafe_ntlm_auth;
+                       use_default_proxy = other.use_default_proxy;
+                       keep_alive_enabled = other.keep_alive_enabled;
+                       max_buffer_size = other.max_buffer_size;
+                       auth_scheme = other.auth_scheme;
+                       proxy_auth_scheme = other.proxy_auth_scheme;
+                       host_cmp_mode = other.host_cmp_mode;
+                       proxy_address = other.proxy_address;
+                       realm = other.realm;
+                       transfer_mode = other.transfer_mode;
+                       // FIXME: it does not look safe
+                       timeouts = other.timeouts;
+               }
+
+               public bool AllowCookies {
+                       get { return allow_cookies; }
+                       set { allow_cookies = value; }
+               }
+
+               public AuthenticationSchemes AuthenticationScheme {
+                       get { return auth_scheme; }
+                       set { auth_scheme = value; }
+               }
+
+               public bool BypassProxyOnLocal {
+                       get { return bypass_proxy_on_local; }
+                       set { bypass_proxy_on_local = value; }
+               }
+
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return host_cmp_mode; }
+                       set { host_cmp_mode = value; }
+               }
+
+               public bool KeepAliveEnabled {
+                       get { return keep_alive_enabled; }
+                       set { keep_alive_enabled = value; }
+               }
+
+               public int MaxBufferSize {
+                       get { return max_buffer_size; }
+                       set { max_buffer_size = value; }
+               }
+
+               public Uri ProxyAddress {
+                       get { return proxy_address; }
+                       set { proxy_address = value; }
+               }
+
+               public AuthenticationSchemes ProxyAuthenticationScheme {
+                       get { return proxy_auth_scheme; }
+                       set { proxy_auth_scheme = value; }
+               }
+
+               public string Realm {
+                       get { return realm; }
+                       set { realm = value; }
+               }
+
+               public override string Scheme {
+                       get { return Uri.UriSchemeHttp; }
+               }
+
+               public TransferMode TransferMode {
+                       get { return transfer_mode; }
+                       set { transfer_mode = value; }
+               }
+
+               public bool UnsafeConnectionNtlmAuthentication {
+                       get { return unsafe_ntlm_auth; }
+                       set { unsafe_ntlm_auth = value; }
+               }
+
+               public bool UseDefaultWebProxy {
+                       get { return use_default_proxy; }
+                       set { use_default_proxy = value; }
+               }
+
+               public override bool CanBuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       return typeof (TChannel) == typeof (IRequestChannel);
+               }
+
+               public override bool CanBuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       return typeof (TChannel) == typeof (IReplyChannel);
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       // remaining contexts are ignored ... e.g. such binding
+                       // element that always causes an error is ignored.
+                       return new HttpChannelFactory<TChannel> (this, context);
+               }
+
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       // remaining contexts are ignored ... e.g. such binding
+                       // element that always causes an error is ignored.
+                       return new HttpChannelListener<TChannel> (this, context);
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new HttpTransportBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       return base.GetProperty<T> (context);
+               }
+
+               [MonoTODO]
+               void IPolicyExportExtension.ExportPolicy (
+                       MetadataExporter exporter,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IWsdlExportExtension.ExportContract (WsdlExporter exporter,
+                       WsdlContractConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IWsdlExportExtension.ExportEndpoint (WsdlExporter exporter,
+                       WsdlEndpointConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpsTransportBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpsTransportBindingElement.cs
new file mode 100644 (file)
index 0000000..8d83e7e
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// HttpsTransportBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public class HttpsTransportBindingElement
+               : HttpTransportBindingElement, ITransportTokenAssertionProvider,
+               IPolicyExportExtension, IWsdlExportExtension
+       {
+               bool req_cli_cert = true;
+
+               public HttpsTransportBindingElement ()
+               {
+               }
+
+               protected HttpsTransportBindingElement (
+                       HttpsTransportBindingElement other)
+                       : base (other)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool RequireClientCertificate {
+                       get { return req_cli_cert; }
+                       set { req_cli_cert = value; }
+               }
+
+               public override string Scheme {
+                       get { return Uri.UriSchemeHttps; }
+               }
+
+               [MonoTODO]
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new HttpsTransportBindingElement (this);
+               }
+
+               [MonoTODO]
+               public XmlElement GetTransportTokenAssertion ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IBindingDeliveryCapabilities.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IBindingDeliveryCapabilities.cs
new file mode 100644 (file)
index 0000000..3374c32
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// IBindingDeliveryCapabilities.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+namespace System.ServiceModel.Channels
+{
+       public interface IBindingDeliveryCapabilities
+       {
+               bool AssuresOrderedDelivery { get; }
+
+               bool QueuedDelivery { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IBindingMulticastCapabilities.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IBindingMulticastCapabilities.cs
new file mode 100644 (file)
index 0000000..393592d
--- /dev/null
@@ -0,0 +1,34 @@
+//
+// IBindingMulticastCapabilities.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+namespace System.ServiceModel.Channels
+{
+       public interface IBindingMulticastCapabilities
+       {
+               bool IsMulticast { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IBindingRuntimePreferences.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IBindingRuntimePreferences.cs
new file mode 100644 (file)
index 0000000..b440ba5
--- /dev/null
@@ -0,0 +1,34 @@
+//
+// IBindingRuntimePreferences.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+namespace System.ServiceModel.Channels
+{
+       public interface IBindingRuntimePreferences
+       {
+               bool ReceiveSynchronously { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IChannel.cs
new file mode 100644 (file)
index 0000000..1312728
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// System.ServiceModel.IChannel.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+
+       public interface IChannel : ICommunicationObject
+       {
+               T GetProperty<T> () where T : class;
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IChannelFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IChannelFactory.cs
new file mode 100644 (file)
index 0000000..485cc3a
--- /dev/null
@@ -0,0 +1,42 @@
+//
+// System.ServiceModel.IChannelFactory.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.ServiceModel;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IChannelFactory : ICommunicationObject
+       {
+               T GetProperty<T> () where T : class;
+       }
+
+       public interface IChannelFactory<TChannel> : IChannelFactory, ICommunicationObject
+       {
+               TChannel CreateChannel (EndpointAddress to);
+               TChannel CreateChannel (EndpointAddress to, Uri via);
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IChannelListener.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IChannelListener.cs
new file mode 100644 (file)
index 0000000..0f80597
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// IChannelListener.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IChannelListener : ICommunicationObject
+       {
+               Uri Uri { get; }
+
+               T GetProperty<T> () where T : class;
+
+               IAsyncResult BeginWaitForChannel (TimeSpan timeout,
+                       AsyncCallback callback, object state);
+               bool EndWaitForChannel (IAsyncResult result);
+               bool WaitForChannel (TimeSpan timeout);
+
+       }
+
+       public interface IChannelListener<TChannel> : IChannelListener
+               where TChannel : class, IChannel
+       {
+               TChannel AcceptChannel ();
+               TChannel AcceptChannel (TimeSpan timeout);
+
+               IAsyncResult BeginAcceptChannel (AsyncCallback callback,
+                       object state);
+               IAsyncResult BeginAcceptChannel (TimeSpan timeout,
+                       AsyncCallback callback, object state);
+
+               TChannel EndAcceptChannel (IAsyncResult result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IDuplexChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IDuplexChannel.cs
new file mode 100644 (file)
index 0000000..af5fc61
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// IDuplexChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IDuplexChannel : IOutputChannel,
+               IInputChannel, ICommunicationObject
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IDuplexSession.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IDuplexSession.cs
new file mode 100644 (file)
index 0000000..3501018
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// IDuplexSession.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IDuplexSession
+               : IInputSession, IOutputSession, ISession
+       {
+               IAsyncResult BeginCloseOutputSession (
+                       AsyncCallback callback, object state);
+               IAsyncResult BeginCloseOutputSession (TimeSpan timeout,
+                       AsyncCallback callback, object state);
+
+               void CloseOutputSession ();
+               void CloseOutputSession (TimeSpan timeout);
+
+               void EndCloseOutputSession (IAsyncResult result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IDuplexSessionChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IDuplexSessionChannel.cs
new file mode 100644 (file)
index 0000000..9f7acfe
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// IDuplexSessionChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IDuplexSessionChannel : IDuplexChannel,
+               IInputChannel, IOutputChannel,
+               IChannel, ICommunicationObject,
+               ISessionChannel<IDuplexSession>
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IInputChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IInputChannel.cs
new file mode 100644 (file)
index 0000000..eb8596e
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// IInputChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IInputChannel
+               : IChannel, ICommunicationObject
+       {
+               EndpointAddress LocalAddress { get; }
+               IAsyncResult BeginReceive (AsyncCallback callback, object state);
+               IAsyncResult BeginReceive (TimeSpan timeout, AsyncCallback callback, object state);
+               IAsyncResult BeginTryReceive (TimeSpan timeout, AsyncCallback callback, object state);
+               IAsyncResult BeginWaitForMessage (TimeSpan timeout, AsyncCallback callback, object state);
+               Message EndReceive (IAsyncResult result);
+               bool EndTryReceive (IAsyncResult result, out Message message);
+               bool EndWaitForMessage (IAsyncResult result);
+               Message Receive ();
+               Message Receive (TimeSpan timeout);
+               bool TryReceive (TimeSpan timeout, out Message message);
+               bool WaitForMessage (TimeSpan timeout);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IInputSession.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IInputSession.cs
new file mode 100644 (file)
index 0000000..769cd91
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// IInputSession.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IInputSession
+               : ISession
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IInputSessionChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IInputSessionChannel.cs
new file mode 100644 (file)
index 0000000..2884937
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// IInputSessionChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IInputSessionChannel
+               : IInputChannel, IChannel, ISessionChannel<IInputSession>
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IMessageProperty.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IMessageProperty.cs
new file mode 100644 (file)
index 0000000..fefe297
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// IMessageProperty.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IMessageProperty
+       {
+               IMessageProperty CreateCopy ();
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IOutputChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IOutputChannel.cs
new file mode 100644 (file)
index 0000000..126a8de
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// IOutputChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IOutputChannel
+               : IChannel, ICommunicationObject
+       {
+               EndpointAddress RemoteAddress { get; }
+               IAsyncResult BeginSend (Message message, AsyncCallback callback, object state);
+               IAsyncResult BeginSend (Message message, TimeSpan timeout, AsyncCallback callback, object state);
+               void EndSend (IAsyncResult result);
+               void Send (Message message);
+               void Send (Message message, TimeSpan timeout);
+               Uri Via { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IOutputSession.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IOutputSession.cs
new file mode 100644 (file)
index 0000000..b3ed31a
--- /dev/null
@@ -0,0 +1,34 @@
+//
+// IOutputSession.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IOutputSession : ISession
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IOutputSessionChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IOutputSessionChannel.cs
new file mode 100644 (file)
index 0000000..3c0a587
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// IOutputSessionChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IOutputSessionChannel : IOutputChannel,
+               IChannel, ICommunicationObject,
+               ISessionChannel<IOutputSession>
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IReplyChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IReplyChannel.cs
new file mode 100644 (file)
index 0000000..12bc9e4
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// IReplyChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IReplyChannel
+               : IChannel, ICommunicationObject
+       {
+               EndpointAddress LocalAddress { get; }
+               IAsyncResult BeginReceiveRequest (AsyncCallback callback, object state);
+               IAsyncResult BeginReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state);
+               IAsyncResult BeginTryReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state);
+               IAsyncResult BeginWaitForRequest (TimeSpan timeout, AsyncCallback callback, object state);
+               RequestContext EndReceiveRequest (IAsyncResult result);
+               bool EndTryReceiveRequest (IAsyncResult result, out RequestContext context);
+               bool EndWaitForRequest (IAsyncResult result);
+               RequestContext ReceiveRequest ();
+               RequestContext  ReceiveRequest (TimeSpan timeout);
+               bool TryReceiveRequest (TimeSpan timeout, out RequestContext context);
+               bool WaitForRequest (TimeSpan timeout);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IReplySessionChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IReplySessionChannel.cs
new file mode 100644 (file)
index 0000000..929499b
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// IReplySessionChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IReplySessionChannel : ISessionChannel<IInputSession>,
+               IReplyChannel, IChannel, ICommunicationObject
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IRequestChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IRequestChannel.cs
new file mode 100644 (file)
index 0000000..e1619b9
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// IRequestChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IRequestChannel
+               : IChannel, ICommunicationObject
+       {
+               EndpointAddress RemoteAddress { get; }
+               IAsyncResult BeginRequest (Message message, AsyncCallback callback, object state);
+               IAsyncResult BeginRequest (Message message, TimeSpan timeout, AsyncCallback callback, object state);
+               Message EndRequest (IAsyncResult result);
+               Message Request (Message message);
+               Message Request (Message message, TimeSpan timeout);
+               Uri Via { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IRequestSessionChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/IRequestSessionChannel.cs
new file mode 100644 (file)
index 0000000..5e9da41
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// IRequestSessionChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface IRequestSessionChannel : ICommunicationObject,
+               ISessionChannel<IOutputSession>, IChannel, IRequestChannel
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ISecurityCapabilities.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ISecurityCapabilities.cs
new file mode 100644 (file)
index 0000000..199b1e9
--- /dev/null
@@ -0,0 +1,45 @@
+//
+// ISecurityCapabilities.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net.Security;
+
+namespace System.ServiceModel.Channels
+{
+       public interface ISecurityCapabilities
+       {
+               ProtectionLevel SupportedRequestProtectionLevel { get; }
+
+               ProtectionLevel SupportedResponseProtectionLevel { get; }
+
+               bool SupportsClientAuthentication { get; }
+
+               bool SupportsServerAuthentication { get; }
+
+               bool SupportsClientWindowsIdentity { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ISession.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ISession.cs
new file mode 100644 (file)
index 0000000..3c022de
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// ISession.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel.Channels
+{
+       public interface ISession
+       {
+               string Id { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ISessionChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ISessionChannel.cs
new file mode 100644 (file)
index 0000000..0d71914
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// ISessionChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface ISessionChannel<TSession>
+               where TSession : ISession
+       {
+               TSession Session { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ITransactedBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ITransactedBindingElement.cs
new file mode 100644 (file)
index 0000000..e5bddc1
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// ITransactedBindingElement.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public interface ITransactedBindingElement
+       {
+               bool TransactedReceiveEnabled { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ITransportTokenAssertionProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ITransportTokenAssertionProvider.cs
new file mode 100644 (file)
index 0000000..c6d953e
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// ITransportTokenAssertionProvider.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       public interface ITransportTokenAssertionProvider
+       {
+               XmlElement GetTransportTokenAssertion ();
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/InputChannelBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/InputChannelBase.cs
new file mode 100644 (file)
index 0000000..ed2729d
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// InputChannelBase.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class InputChannelBase : ChannelBase, IInputChannel
+       {
+               ChannelListenerBase channel_listener;
+
+               public InputChannelBase (ChannelListenerBase listener)
+                       : base (listener)
+               {
+                       this.channel_listener = listener;
+               }
+
+               public abstract EndpointAddress LocalAddress { get; }
+
+               public IAsyncResult BeginReceive (AsyncCallback callback, object state)
+               {
+                       return BeginReceive (DefaultReceiveTimeout, callback, state);
+               }
+
+               public abstract IAsyncResult BeginReceive (TimeSpan timeout, AsyncCallback callback, object state);
+
+               public abstract IAsyncResult BeginTryReceive (TimeSpan timeout, AsyncCallback callback, object state);
+
+               public abstract IAsyncResult BeginWaitForMessage (TimeSpan timeout, AsyncCallback callback, object state);
+
+               public abstract Message EndReceive (IAsyncResult result);
+
+               public abstract bool EndTryReceive (IAsyncResult result, out Message message);
+
+               public abstract bool EndWaitForMessage (IAsyncResult result);
+
+               public Message Receive ()
+               {
+                       return Receive (DefaultReceiveTimeout);
+               }
+
+               public abstract Message Receive (TimeSpan timeout);
+
+               public abstract bool TryReceive (TimeSpan timeout, out Message message);
+
+               public abstract bool WaitForMessage (TimeSpan timeout);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/InvalidChannelBindingException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/InvalidChannelBindingException.cs
new file mode 100644 (file)
index 0000000..e718158
--- /dev/null
@@ -0,0 +1,62 @@
+//
+// InvalidChannelBindingException.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Configuration;
+
+namespace System.ServiceModel.Channels
+{
+       [Serializable]
+       public class InvalidChannelBindingException : Exception
+       {
+               [MonoTODO]
+               public InvalidChannelBindingException ()
+                       : this ("Invalid settings.")
+               {
+               }
+
+               public InvalidChannelBindingException (string message)
+                       : base (message)
+               {
+               }
+
+               public InvalidChannelBindingException (SerializationInfo info,
+                       StreamingContext context)
+                       : base (info, context)
+               {
+               }
+
+               public InvalidChannelBindingException (string message,
+                       Exception innerException)
+                       : base (message, innerException)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredCommunicationObject.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredCommunicationObject.cs
new file mode 100644 (file)
index 0000000..b6b7ae9
--- /dev/null
@@ -0,0 +1,180 @@
+//
+// SecurityReplyChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       internal abstract class LayeredCommunicationObject : ICommunicationObject, IDisposable
+       {
+               ICommunicationObject inner;
+
+               protected LayeredCommunicationObject (ICommunicationObject source)
+               {
+                       inner = source;
+               }
+
+               public abstract ChannelManagerBase ChannelManager { get; }
+
+               IDefaultCommunicationTimeouts Timeouts {
+                       get { return (IDefaultCommunicationTimeouts) ChannelManager; }
+               }
+
+               // ICommunicationObject
+
+               public virtual CommunicationState State {
+                       get { return inner.State; }
+               }
+
+               public virtual void Abort ()
+               {
+                       inner.Abort ();
+               }
+
+               public IAsyncResult BeginClose (AsyncCallback callback, object state)
+               {
+                       return BeginClose (Timeouts.CloseTimeout, callback, state);
+               }
+
+               public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return OnBeginClose (timeout, callback, state);
+               }
+
+               protected virtual IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginClose (timeout, callback, state);
+               }
+
+               public virtual void EndClose (IAsyncResult result)
+               {
+                       OnEndClose (result);
+               }
+
+               protected void OnEndClose (IAsyncResult result)
+               {
+                       inner.EndClose (result);
+               }
+
+               public void Close ()
+               {
+                       Close (Timeouts.CloseTimeout);
+               }
+
+               public void Close (TimeSpan timeout)
+               {
+                       OnClose (timeout);
+               }
+
+               protected virtual void OnClose (TimeSpan timeout)
+               {
+                       inner.Close (timeout);
+               }
+
+               public void Dispose ()
+               {
+                       Close ();
+               }
+
+               public IAsyncResult BeginOpen (AsyncCallback callback, object state)
+               {
+                       return BeginOpen (Timeouts.OpenTimeout, callback, state);
+               }
+
+               public IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return OnBeginOpen (timeout, callback, state);
+               }
+
+               protected virtual IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginOpen (timeout, callback, state);
+               }
+
+               public virtual void EndOpen (IAsyncResult result)
+               {
+                       OnEndOpen (result);
+               }
+
+               protected virtual void OnEndOpen (IAsyncResult result)
+               {
+                       inner.EndOpen (result);
+               }
+
+               public void Open ()
+               {
+                       Open (Timeouts.OpenTimeout);
+               }
+
+               public void Open (TimeSpan timeout)
+               {
+                       inner.Open (timeout);
+               }
+
+               protected virtual Type GetCommunicationObjectType ()
+               {
+                       return GetType ();
+               }
+
+               protected void ThrowIfNotOpen ()
+               {
+                       if (State != CommunicationState.Opened)
+                               throw new InvalidOperationException (String.Format ("The communication object {0} must be at opened state.", GetCommunicationObjectType ()));
+               }
+
+               protected void ThrowIfImmutable ()
+               {
+                       if (State != CommunicationState.Created)
+                               throw new InvalidOperationException (String.Format ("The communication object {0} is being closed while it is not opened.", GetType ()));
+               }
+
+               public event EventHandler Closing {
+                       add { inner.Closing += value; }
+                       remove { inner.Closing -= value; }
+               }
+
+               public event EventHandler Closed {
+                       add { inner.Closed += value; }
+                       remove { inner.Closed -= value; }
+               }
+
+               public event EventHandler Opening {
+                       add { inner.Opening += value; }
+                       remove { inner.Opening -= value; }
+               }
+
+               public event EventHandler Opened {
+                       add { inner.Opened += value; }
+                       remove { inner.Opened -= value; }
+               }
+
+               public event EventHandler Faulted {
+                       add { inner.Faulted += value; }
+                       remove { inner.Faulted -= value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredOutputChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredOutputChannel.cs
new file mode 100644 (file)
index 0000000..27708a3
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// LayeredOutputChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       internal abstract class LayeredOutputChannel : LayeredCommunicationObject, IOutputChannel
+       {
+               IOutputChannel inner;
+
+               public LayeredOutputChannel (IOutputChannel source)
+                       : base (source)
+               {
+                       inner = source;
+               }
+
+               public abstract ChannelFactoryBase Factory { get; }
+
+               public override ChannelManagerBase ChannelManager {
+                       get { return Factory; }
+               }
+
+               // IOutputChannel
+               public virtual EndpointAddress RemoteAddress {
+                       get { return inner.RemoteAddress; }
+               }
+
+               public IAsyncResult BeginSend (Message message, AsyncCallback callback, object state)
+               {
+                       // FIXME: send + receive?
+                       return BeginSend (message, Factory.DefaultSendTimeout, callback, state);
+               }
+
+               public virtual IAsyncResult BeginSend (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       ThrowIfNotOpen ();
+                       return OnBeginSend (message, timeout, callback, state);
+               }
+
+               protected virtual IAsyncResult OnBeginSend (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginSend (message, timeout, callback, state);
+               }
+
+               public void EndSend (IAsyncResult result)
+               {
+                       OnEndSend (result);
+               }
+
+               protected virtual void OnEndSend (IAsyncResult result)
+               {
+                       inner.EndSend (result);
+               }
+
+               public void Send (Message message)
+               {
+                       // FIXME: send + receive?
+                       Send (message, Factory.DefaultSendTimeout);
+               }
+
+               public void Send (Message message, TimeSpan timeout)
+               {
+                       ThrowIfNotOpen ();
+                       OnSend (message, timeout);
+               }
+
+               protected virtual void OnSend (Message message, TimeSpan timeout)
+               {
+                       inner.Send (message, timeout);
+               }
+
+               public virtual Uri Via {
+                       get { return inner.Via; }
+               }
+
+               // IChannel
+
+               public virtual T GetProperty<T> () where T : class
+               {
+                       return inner.GetProperty<T> ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredReplyChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredReplyChannel.cs
new file mode 100644 (file)
index 0000000..eff3308
--- /dev/null
@@ -0,0 +1,120 @@
+//
+// SecurityReplyChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       internal abstract class LayeredReplyChannel : LayeredCommunicationObject, IReplyChannel
+       {
+               IReplyChannel inner;
+
+               public LayeredReplyChannel (IReplyChannel innerChannel)
+                       : base (innerChannel)
+               {
+                       inner = innerChannel;
+               }
+
+               public abstract ChannelListenerBase Listener { get; }
+
+               public override ChannelManagerBase ChannelManager {
+                       get { return Listener; }
+               }
+
+               // IReplyChannel
+
+               public virtual EndpointAddress LocalAddress {
+                       get { return inner.LocalAddress; }
+               }
+
+               public virtual IAsyncResult BeginReceiveRequest (
+                       AsyncCallback callback, object state)
+               {
+                       return BeginReceiveRequest (Listener.DefaultReceiveTimeout, callback, state);
+               }
+
+               public virtual IAsyncResult BeginReceiveRequest (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginReceiveRequest (timeout, callback, state);
+               }
+
+               public virtual IAsyncResult BeginTryReceiveRequest (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginTryReceiveRequest (timeout, callback, state);
+               }
+
+               public virtual IAsyncResult BeginWaitForRequest (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginWaitForRequest (timeout, callback, state);
+               }
+
+               public virtual RequestContext EndReceiveRequest (IAsyncResult result)
+               {
+                       return inner.EndReceiveRequest (result);
+               }
+
+               public virtual bool EndTryReceiveRequest (IAsyncResult result, out RequestContext context)
+               {
+                       return inner.EndTryReceiveRequest (result, out context);
+               }
+
+               public virtual bool EndWaitForRequest (IAsyncResult result)
+               {
+                       return inner.EndWaitForRequest (result);
+               }
+
+               public virtual RequestContext ReceiveRequest ()
+               {
+                       return ReceiveRequest (Listener.DefaultReceiveTimeout);
+               }
+
+               public virtual RequestContext  ReceiveRequest (TimeSpan timeout)
+               {
+                       return inner.ReceiveRequest (timeout);
+               }
+
+               public virtual bool TryReceiveRequest (TimeSpan timeout, out RequestContext context)
+               {
+                       return inner.TryReceiveRequest (timeout, out context);
+               }
+
+               public virtual bool WaitForRequest (TimeSpan timeout)
+               {
+                       return inner.WaitForRequest (timeout);
+               }
+
+               // IChannel
+
+               public virtual T GetProperty<T> () where T : class
+               {
+                       return inner.GetProperty<T> ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredRequestChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/LayeredRequestChannel.cs
new file mode 100644 (file)
index 0000000..42b730c
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// LayeredRequestChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       internal abstract class LayeredRequestChannel : LayeredCommunicationObject, IRequestChannel
+       {
+               IRequestChannel inner;
+
+               public LayeredRequestChannel (IRequestChannel source)
+                       : base (source)
+               {
+                       inner = source;
+               }
+
+               public abstract ChannelFactoryBase Factory { get; }
+
+               public override ChannelManagerBase ChannelManager {
+                       get { return Factory; }
+               }
+
+               // IRequestChannel
+               public virtual EndpointAddress RemoteAddress {
+                       get { return inner.RemoteAddress; }
+               }
+
+               public IAsyncResult BeginRequest (Message message, AsyncCallback callback, object state)
+               {
+                       // FIXME: send + receive?
+                       return BeginRequest (message, Factory.DefaultSendTimeout, callback, state);
+               }
+
+               public virtual IAsyncResult BeginRequest (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       ThrowIfNotOpen ();
+                       return OnBeginRequest (message, timeout, callback, state);
+               }
+
+               protected virtual IAsyncResult OnBeginRequest (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginRequest (message, timeout, callback, state);
+               }
+
+               public Message EndRequest (IAsyncResult result)
+               {
+                       return OnEndRequest (result);
+               }
+
+               protected virtual Message OnEndRequest (IAsyncResult result)
+               {
+                       return inner.EndRequest (result);
+               }
+
+               public Message Request (Message message)
+               {
+                       // FIXME: send + receive?
+                       return Request (message, Factory.DefaultSendTimeout);
+               }
+
+               public Message Request (Message message, TimeSpan timeout)
+               {
+                       ThrowIfNotOpen ();
+                       return OnRequest (message, timeout);
+               }
+
+               protected virtual Message OnRequest (Message message, TimeSpan timeout)
+               {
+                       return inner.Request (message, timeout);
+               }
+
+               public virtual Uri Via {
+                       get { return inner.Via; }
+               }
+
+               // IChannel
+
+               public virtual T GetProperty<T> () where T : class
+               {
+                       return inner.GetProperty<T> ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/LocalClientSecuritySettings.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/LocalClientSecuritySettings.cs
new file mode 100644 (file)
index 0000000..fec4a34
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// LocalClientSecuritySettings.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public sealed class LocalClientSecuritySettings
+       {
+               bool cache_cookies = true;
+               int cookie_renewal = 60;
+               bool detect_replays = true;
+               IdentityVerifier verifier = IdentityVerifier.CreateDefault ();
+               TimeSpan max_clock_skew = TimeSpan.FromMinutes (5);
+               TimeSpan max_cookie_cache_time = TimeSpan.MaxValue;
+               bool reconnect = true;
+               int replay_cache_size = 900000;
+               TimeSpan replay_window = TimeSpan.FromMinutes (5);
+               TimeSpan renewal_interval = TimeSpan.FromHours (10);
+               TimeSpan rollover_interval = TimeSpan.FromMinutes (5);
+               TimeSpan validity_duration = TimeSpan.FromMinutes (5);
+
+               public LocalClientSecuritySettings ()
+               {
+               }
+
+               public bool CacheCookies {
+                       get { return cache_cookies; }
+                       set { cache_cookies = value; }
+               }
+               public int CookieRenewalThresholdPercentage {
+                       get { return cookie_renewal; }
+                       set { cookie_renewal = value; }
+               }
+               public bool DetectReplays {
+                       get { return detect_replays; }
+                       set { detect_replays = value; }
+               }
+               public IdentityVerifier IdentityVerifier {
+                       get { return verifier; }
+                       set { verifier = value; }
+               }
+               public TimeSpan MaxClockSkew {
+                       get { return max_clock_skew; }
+                       set { max_clock_skew = value; }
+               }
+               public TimeSpan MaxCookieCachingTime {
+                       get { return max_cookie_cache_time; }
+                       set { max_cookie_cache_time = value; }
+               }
+               public bool ReconnectTransportOnFailure {
+                       get { return reconnect; }
+                       set { reconnect = value; }
+               }
+               public int ReplayCacheSize {
+                       get { return replay_cache_size; }
+                       set { replay_cache_size = value; }
+               }
+               public TimeSpan ReplayWindow {
+                       get { return replay_window; }
+                       set { replay_window = value; }
+               }
+               public TimeSpan SessionKeyRenewalInterval {
+                       get { return renewal_interval; }
+                       set { renewal_interval = value; }
+               }
+               public TimeSpan SessionKeyRolloverInterval {
+                       get { return rollover_interval; }
+                       set { rollover_interval = value; }
+               }
+
+               public TimeSpan TimestampValidityDuration {
+                       get { return validity_duration; }
+                       set { validity_duration = value; }
+               }
+
+               [MonoTODO ("What happens to IdentityVerifier?")]
+               public LocalClientSecuritySettings Clone ()
+               {
+                       return (LocalClientSecuritySettings) MemberwiseClone ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs
new file mode 100644 (file)
index 0000000..7eb05ca
--- /dev/null
@@ -0,0 +1,426 @@
+//
+// Message.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Xml;
+using System.Xml.Schema;
+using Mono.Xml.XPath;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class Message : IDisposable
+       {
+               bool disposed;
+               string body_id;
+
+               protected Message () {
+                       State = MessageState.Created;
+               }
+
+               public abstract MessageHeaders Headers { get; }
+
+               internal string BodyId {
+                       get { return body_id; }
+                       set { body_id = value; }
+               }
+
+               public virtual bool IsEmpty {
+                       get { return false; }
+               }
+
+               public virtual bool IsFault {
+                       get { return false; }
+               }
+
+               public abstract MessageProperties Properties { get; }
+
+               MessageState ___state;
+               public MessageState State {
+                       get { return ___state; }
+                       private set { ___state = value; }
+               }
+
+               public abstract MessageVersion Version { get; }
+
+               protected bool IsDisposed {
+                       get { return disposed; }
+               }
+
+               public void Close ()
+               {
+                       if (!disposed)
+                               OnClose ();
+                       State = MessageState.Closed;
+                       disposed = true;
+               }
+
+               public MessageBuffer CreateBufferedCopy (int maxBufferSize)
+               {
+                       if (State != MessageState.Created)
+                               throw new InvalidOperationException (String.Format ("The message is already at {0} state", State));
+                       try {
+                               return OnCreateBufferedCopy (maxBufferSize);
+                       } finally {
+                               State = MessageState.Copied;
+                       }
+               }
+
+               void IDisposable.Dispose ()
+               {
+                       Close ();
+               }
+
+               public T GetBody<T> ()
+               {
+                       return GetBody<T> (new DataContractSerializer (typeof (T)));
+               }
+
+               public T GetBody<T> (XmlObjectSerializer xmlFormatter)
+               {
+                       return (T) xmlFormatter.ReadObject (GetReaderAtBodyContents ());
+               }
+
+               public string GetBodyAttribute (string localName, string ns)
+               {
+                       return OnGetBodyAttribute (localName, ns);
+               }
+
+               public XmlDictionaryReader GetReaderAtBodyContents ()
+               {
+                       return OnGetReaderAtBodyContents ();
+               }
+
+               public override string ToString ()
+               {
+                       MessageState tempState = State;
+                       try {
+
+                               StringWriter sw = new StringWriter ();
+                               XmlWriterSettings settings = new XmlWriterSettings ();
+                               settings.Indent = true;
+                               settings.OmitXmlDeclaration = true;
+                               using (XmlWriter w = XmlWriter.Create (sw, settings)) {
+                                       WriteMessage (w);
+                               }
+                               return sw.ToString ();
+                       }
+                       finally {
+                               State = tempState;
+                       }
+               }
+
+               void WriteXsiNil (XmlDictionaryWriter writer)
+               {
+                       writer.WriteStartElement ("z", "anyType", Constants.MSSerialization);
+                       writer.WriteAttributeString ("i", "nil", XmlSchema.InstanceNamespace, "true");
+                       writer.WriteEndElement ();
+               }
+
+               public void WriteBody (XmlDictionaryWriter writer)
+               {
+                       if (Version.Envelope != EnvelopeVersion.None)
+                               WriteStartBody (writer);
+                       WriteBodyContents (writer);
+                       if (Version.Envelope != EnvelopeVersion.None)
+                               writer.WriteEndElement ();
+               }
+
+               public void WriteBody (XmlWriter writer)
+               {
+                       WriteBody (XmlDictionaryWriter.CreateDictionaryWriter (writer));
+               }
+
+               public void WriteBodyContents (XmlDictionaryWriter writer)
+               {
+                       if (!IsEmpty)
+                               OnWriteBodyContents (writer);
+                       else if (Version.Envelope == EnvelopeVersion.None)
+                               WriteXsiNil (writer);
+               }
+
+               public void WriteMessage (XmlDictionaryWriter writer)
+               {
+                       if (State != MessageState.Created)
+                               throw new InvalidOperationException (String.Format ("The message is already at {0} state", State));
+                       State = MessageState.Written;
+
+                       OnWriteMessage (writer);
+               }
+
+               public void WriteMessage (XmlWriter writer)
+               {
+                       WriteMessage (XmlDictionaryWriter.CreateDictionaryWriter (writer));
+               }
+
+               public void WriteStartBody (XmlDictionaryWriter writer)
+               {
+                       if (State != MessageState.Created && State != MessageState.Written)
+                               throw new InvalidOperationException (String.Format ("The message is already at {0} state", State));
+                       State = MessageState.Written;
+
+                       OnWriteStartBody (writer);
+               }
+
+               public void WriteStartBody (XmlWriter writer)
+               {
+                       WriteStartBody (
+                               XmlDictionaryWriter.CreateDictionaryWriter (writer));
+               }
+
+               public void WriteStartEnvelope (XmlDictionaryWriter writer)
+               {
+                       if (State != MessageState.Created && State != MessageState.Written)
+                               throw new InvalidOperationException (String.Format ("The message is already at {0} state", State));
+                       State = MessageState.Written;
+
+                       OnWriteStartEnvelope (writer);
+               }
+
+               [MonoTODO]
+               protected virtual void OnBodyToString (
+                       XmlDictionaryWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected virtual void OnClose ()
+               {
+               }
+
+               [MonoTODO]
+               protected virtual MessageBuffer OnCreateBufferedCopy (
+                       int maxBufferSize)
+               {
+                       DTMXPathDocumentWriter2 pw = new DTMXPathDocumentWriter2 (new NameTable (), 100);
+                       XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter (pw);
+                       WriteMessage (w);
+                       return new XPathMessageBuffer (pw.CreateDocument (), Version, Headers.Count, this.Properties);
+               }
+
+               protected virtual string OnGetBodyAttribute (
+                       string localName, string ns)
+               {
+                       // other than XmlReaderMessage it cannot return anything
+                       return null;
+               }
+
+               [MonoTODO]
+               protected virtual XmlDictionaryReader OnGetReaderAtBodyContents ()
+               {
+                       XmlDictionaryWriter writer = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (TextWriter.Null));
+                       if (Version.Envelope != EnvelopeVersion.None) {
+                               WriteStartEnvelope (writer);
+                               OnWriteStartHeaders (writer);
+                               for (int i = 0, count = Headers.Count; i < count; i++)
+                                       Headers.WriteHeader (i, writer);
+                               writer.WriteEndElement ();
+                               WriteStartBody (writer);
+                       }
+
+                       StringWriter sw = new StringWriter ();
+                       using (XmlDictionaryWriter body = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (sw))) {
+                               WriteBodyContents (body);
+                       }
+
+                       if (Version.Envelope != EnvelopeVersion.None) {
+                               writer.WriteEndElement ();
+                               writer.WriteEndElement ();
+                       }
+
+                       return XmlDictionaryReader.CreateDictionaryReader (XmlReader.Create (new StringReader (sw.ToString ())));
+               }
+
+               protected abstract void OnWriteBodyContents (
+                       XmlDictionaryWriter writer);
+
+               protected virtual void OnWriteMessage (
+                       XmlDictionaryWriter writer)
+               {
+                       if (Version.Envelope != EnvelopeVersion.None) {
+                               WriteStartEnvelope (writer);
+                               OnWriteStartHeaders (writer);
+                               for (int i = 0, count = Headers.Count; i < count; i++)
+                                       Headers.WriteHeader (i, writer);
+                               writer.WriteEndElement ();
+                       }
+                       WriteBody (writer);
+                       if (Version.Envelope != EnvelopeVersion.None)
+                               writer.WriteEndElement ();
+               }
+
+               [MonoTODO]
+               protected virtual void OnWriteStartBody (
+                       XmlDictionaryWriter writer)
+               {
+                       writer.WriteStartElement ("s", "Body", Version.Envelope.Namespace);
+                       if (BodyId != null)
+                               writer.WriteAttributeString ("u", "Id", Constants.WsuNamespace, BodyId);
+               }
+
+               protected virtual void OnWriteStartEnvelope (
+                       XmlDictionaryWriter writer)
+               {
+                       writer.WriteStartElement ("s", "Envelope", Version.Envelope.Namespace);
+                       if (Headers.Action != null && Version.Addressing.Namespace != MessageVersion.None.Addressing.Namespace)
+                               writer.WriteXmlnsAttribute ("a", Version.Addressing.Namespace);
+                       foreach (MessageHeaderInfo h in Headers)
+                               if (h.Id != null) {
+                                       writer.WriteXmlnsAttribute ("u", Constants.WsuNamespace);
+                                       break;
+                               }
+               }
+
+               protected virtual void OnWriteStartHeaders (
+                       XmlDictionaryWriter writer)
+               {
+                       writer.WriteStartElement ("s", "Header", Version.Envelope.Namespace);
+               }
+
+               #region factory methods
+
+               //  1) fault -> 4
+               //  2) action -> 5
+               //  3) fault, action -> 10
+               //  4) version, fault -> 10
+               //  5) version, action -> EmptyMessage
+               //  6) action, body -> 12
+               //  7) action, xmlReader -> 8
+               //  8) action, reader -> 16
+               // 10) version, fault, action -> 20
+               // 11) version, action, body -> 14
+               // 12) action, body, formatter -> 14
+               // 13) version, action, body -> 14
+               // 14) version, action, body, formatter -> 20
+               // 15) version, action, xmlReader -> 16
+               // 16) version, action, reader -> 20
+               // 17) xmlReader, maxSizeOfHeaders, version -> 18
+               // 18) reader, maxSizeOfHeaders, version -> ForwardingMessage
+               // 19) action, bodyWriter -> 20
+               // 20) version, action, bodyWriter -> SimpleMessage
+
+               public static Message CreateMessage (MessageVersion version,
+                       FaultCode code, string reason, string action)
+               {
+                       MessageFault fault = MessageFault.CreateFault (code, reason);
+                       return CreateMessage (version, fault, action);
+               }
+
+               public static Message CreateMessage (MessageVersion version,
+                       FaultCode code, string reason, object detail,
+                       string action)
+               {
+                       MessageFault fault = MessageFault.CreateFault (
+                               code, new FaultReason (reason), detail);
+                       return CreateMessage (version, fault, action);
+               }
+
+               public static Message CreateMessage (MessageVersion version,
+                       MessageFault fault, string action)
+               {
+                       return new SimpleMessage (version, action,
+                               new MessageFaultBodyWriter (fault, version), true);
+               }
+
+               public static Message CreateMessage (MessageVersion version,
+                       string action, object body)
+               {
+                       return body == null ?
+                               CreateMessage (version, action) :
+                               CreateMessage (version, action, body, new DataContractSerializer (body.GetType ()));
+               }
+
+               public static Message CreateMessage (MessageVersion version,
+                       string action, object body, XmlObjectSerializer xmlFormatter)
+               {
+                       return body == null ?
+                               CreateMessage (version, action) :
+                               CreateMessage (
+                                       version, action,
+                                       new XmlObjectSerializerBodyWriter (body, xmlFormatter));
+               }
+
+               public static Message CreateMessage (MessageVersion version,
+                       string action, XmlReader body)
+               {
+                       return CreateMessage (version, action,
+                               XmlDictionaryReader.CreateDictionaryReader (body));
+               }
+
+               public static Message CreateMessage (MessageVersion version,
+                       string action, XmlDictionaryReader body)
+               {
+                       return CreateMessage (version, action,
+                               new XmlReaderBodyWriter (body));
+               }
+
+               public static Message CreateMessage (XmlReader envelopeReader,
+                       int maxSizeOfHeaders, MessageVersion version)
+               {
+                       return CreateMessage (
+                               XmlDictionaryReader.CreateDictionaryReader (envelopeReader),
+                               maxSizeOfHeaders,
+                               version);
+               }
+
+               // Core implementations of CreateMessage.
+
+               public static Message CreateMessage (MessageVersion version,
+                       string action, BodyWriter body)
+               {
+                       if (version == null)
+                               throw new ArgumentNullException ("version");
+                       if (body == null)
+                               throw new ArgumentNullException ("body");
+                       return new SimpleMessage (version, action, body, false);
+               }
+
+               public static Message CreateMessage (MessageVersion version,
+                       string action)
+               {
+                       if (version == null)
+                               throw new ArgumentNullException ("version");
+                       return new EmptyMessage (version, action);
+               }
+
+               public static Message CreateMessage (
+                       XmlDictionaryReader envelopeReader,
+                       int maxSizeOfHeaders,
+                       MessageVersion version)
+               {
+                       if (envelopeReader == null)
+                               throw new ArgumentNullException ("envelopeReader");
+                       if (version == null)
+                               throw new ArgumentNullException ("version");
+                       return new XmlReaderMessage (version,
+                               envelopeReader, maxSizeOfHeaders);
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageBuffer.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageBuffer.cs
new file mode 100644 (file)
index 0000000..ecbf261
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// System.ServiceModel.MessageBuffer.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Xml;
+using System.Xml.XPath;
+using Mono.Xml.XPath;
+
+namespace System.ServiceModel.Channels {
+
+       public abstract class MessageBuffer : IXPathNavigable, IDisposable
+       {
+               XPathNavigator nav_cache;
+
+               protected MessageBuffer () {}
+
+               public abstract void Close ();
+               public abstract Message CreateMessage ();
+
+               public XPathNavigator CreateNavigator ()
+               {
+                       return CreateNavigator (XmlSpace.Default);
+               }
+
+               public XPathNavigator CreateNavigator (int node_quota)
+               {
+                       return CreateNavigator (node_quota, XmlSpace.Default);
+               }
+
+               [MonoTODO ("supply proper quota")]
+               public XPathNavigator CreateNavigator (XmlSpace space)
+               {
+                       // FIXME: I never counted expected quota value.
+                       return CreateNavigator (1000, XmlSpace.Default);
+               }
+
+               [MonoTODO ("Handle node_quota and xmlspace")]
+               public XPathNavigator CreateNavigator (int node_quota, XmlSpace space)
+               {
+                       if (nav_cache == null) {
+                               DTMXPathDocumentWriter2 pw = new DTMXPathDocumentWriter2 (new NameTable (), node_quota);
+                               XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter (pw);
+                               CreateMessage ().WriteMessage (w);
+                               nav_cache = pw.CreateDocument ().CreateNavigator ();
+                       }
+                       return nav_cache.Clone ();
+               }
+
+               void IDisposable.Dispose ()
+               {
+                       this.Close ();
+               }
+
+               public virtual void WriteMessage (Stream stream)
+               {
+                       if (stream == null)
+                               throw new ArgumentNullException ("stream is null");
+                       
+                       XmlDictionaryWriter w = XmlDictionaryWriter.CreateBinaryWriter (stream);
+                       Message m = CreateMessage ();
+
+                       m.WriteMessage (w);
+                       w.Close ();
+               }
+
+               public abstract int BufferSize { get; }
+
+               public virtual string MessageContentType {
+                       get { return "application/soap+msbin1"; }
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageBufferImpl.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageBufferImpl.cs
new file mode 100644 (file)
index 0000000..05c97a6
--- /dev/null
@@ -0,0 +1,117 @@
+//
+// MessageBufferImpl.cs
+//
+// Author:
+//     Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Runtime.Serialization;
+using System.Xml;
+using System.Xml.XPath;
+
+namespace System.ServiceModel.Channels
+{
+       internal class DefaultMessageBuffer : MessageBuffer
+       {
+               MessageHeaders headers;
+               MessageProperties properties;
+               BodyWriter body;
+               bool closed, is_fault;
+               
+               internal DefaultMessageBuffer (MessageHeaders headers, MessageProperties properties)
+                       : this (headers, properties, null, false)
+               {
+               }
+
+               internal DefaultMessageBuffer (MessageHeaders headers, MessageProperties properties, BodyWriter body, bool isFault)
+               {
+                       this.headers = headers;
+                       this.body = body;
+                       this.closed = false;
+                       this.is_fault = isFault;
+                       this.properties = properties;
+               }
+
+               public override void Close ()
+               {
+                       if (closed) 
+                               return;
+                       
+                       headers = null;
+                       body = null;
+                       closed = true;
+               }
+               
+
+               public override Message CreateMessage ()
+               {
+                       if (closed)
+                               throw new ObjectDisposedException ("The message buffer has already been closed.");
+                       Message msg;
+                       if (body == null)
+                               msg = new EmptyMessage (headers.MessageVersion, headers.Action);
+                       else
+                               msg = new SimpleMessage (headers.MessageVersion, headers.Action, body, is_fault);
+                       msg.Properties.CopyProperties (properties);
+                       return msg;
+               }
+
+               public override int BufferSize {
+                       get { return 0; }
+               }
+       }
+
+       internal class XPathMessageBuffer : MessageBuffer
+       {
+               IXPathNavigable source;
+               MessageVersion version;
+               int max_header_size;
+               MessageProperties properties;
+
+               public XPathMessageBuffer (IXPathNavigable source, MessageVersion version, int maxSizeOfHeaders, MessageProperties properties)
+               {
+                       this.source = source;
+                       this.version = version;
+                       this.max_header_size = maxSizeOfHeaders;
+                       this.properties = properties;
+               }
+
+               public override void Close ()
+               {
+               }
+
+               public override Message CreateMessage ()
+               {
+                       XmlDictionaryReader r = XmlDictionaryReader.CreateDictionaryReader (source.CreateNavigator ().ReadSubtree ());
+                       Message msg = new XmlReaderMessage (version, r, max_header_size);
+                       msg.Properties.CopyProperties (properties);
+                       return msg;
+               }
+
+               public override int BufferSize {
+                       // FIXME: implement
+                       get { return 0; }
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncoder.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncoder.cs
new file mode 100644 (file)
index 0000000..c27470d
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// MessageEncoder.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class MessageEncoder
+       {
+               protected MessageEncoder ()
+               {
+               }
+
+               public abstract string ContentType { get; }
+
+               public abstract string MediaType { get; }
+
+               public abstract MessageVersion MessageVersion { get; }
+
+               [MonoTODO]
+               public virtual T GetProperty<T> () where T : class
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public virtual bool IsContentTypeSupported (string contentType)
+               {
+                       return contentType == ContentType;
+               }
+
+               public Message ReadMessage (ArraySegment<byte> buffer,
+                       BufferManager bufferManager)
+               {
+                       return ReadMessage (buffer, bufferManager, ContentType);
+               }
+
+               public abstract Message ReadMessage (ArraySegment<byte> buffer,
+                       BufferManager bufferManager, string contentType);
+
+               public Message ReadMessage (Stream stream, int maxSizeOfHeaders)
+               {
+                       return ReadMessage (stream, maxSizeOfHeaders, ContentType);
+               }
+
+               public abstract Message ReadMessage (Stream stream,
+                       int maxSizeOfHeaders, string contentType);
+
+               public abstract void WriteMessage (Message message, Stream stream);
+
+               public ArraySegment<byte> WriteMessage (Message message,
+                       int maxMessageSize, BufferManager bufferManager)
+               {
+                       return WriteMessage (message, maxMessageSize, bufferManager, 0);
+               }
+
+               public abstract ArraySegment<byte> WriteMessage (
+                       Message message, int maxMessageSize,
+                       BufferManager bufferManager, int messageOffset);
+
+               public override string ToString ()
+               {
+                       return ContentType;
+               }
+
+               internal void VerifyMessageVersion (Message message)
+               {
+                       if (!message.Version.Equals (MessageVersion))
+                               throw new ProtocolException (String.Format ("Message version mismatch. Expected {0} but was {1}.", MessageVersion, message.Version));
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncoderFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncoderFactory.cs
new file mode 100644 (file)
index 0000000..5aecfcb
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// MessageEncoderFactory.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class MessageEncoderFactory
+       {
+               protected MessageEncoderFactory ()
+               {
+               }
+
+               public abstract MessageEncoder Encoder { get; }
+
+               public abstract MessageVersion MessageVersion { get; }
+
+               [MonoTODO]
+               public virtual MessageEncoder CreateSessionEncoder ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncodingBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncodingBindingElement.cs
new file mode 100644 (file)
index 0000000..32db32d
--- /dev/null
@@ -0,0 +1,62 @@
+//
+// MessageEncodingBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class MessageEncodingBindingElement : BindingElement
+       {
+               public MessageEncodingBindingElement ()
+               {
+               }
+
+               [MonoTODO]
+               public MessageEncodingBindingElement (MessageEncodingBindingElement source)
+               {
+                       MessageVersion = source.MessageVersion;
+               }
+
+               public abstract MessageEncoderFactory
+                       CreateMessageEncoderFactory ();
+
+               public abstract MessageVersion MessageVersion { get; set; }
+
+               [MonoTODO]
+               protected virtual void OnImportPolicy (XmlElement assertion,
+                       MessageVersion messageVersion,
+                       MetadataImporter exporter,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncodingBindingElementImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageEncodingBindingElementImporter.cs
new file mode 100644 (file)
index 0000000..4f12e2d
--- /dev/null
@@ -0,0 +1,69 @@
+//
+// MessageEncodingBindingElementImporter.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Web.Services.Description;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public class MessageEncodingBindingElementImporter
+               : IWsdlImportExtension, IPolicyImportExtension
+       {
+               void IWsdlImportExtension.BeforeImport (
+                       ServiceDescriptionCollection wsdlDocuments,
+                       XmlSchemaSet xmlSchemas,
+                       ICollection<XmlElement> policy)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IWsdlImportExtension.ImportContract (WsdlImporter importer,
+                       WsdlContractConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IWsdlImportExtension.ImportEndpoint (WsdlImporter importer,
+                       WsdlEndpointConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IPolicyImportExtension.ImportPolicy (MetadataImporter importer,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageFault.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageFault.cs
new file mode 100644 (file)
index 0000000..7e94fdc
--- /dev/null
@@ -0,0 +1,430 @@
+//
+// MessageFault.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class MessageFault
+       {
+               // type members
+
+               public static MessageFault CreateFault (Message message, int maxBufferSize)
+               {
+                       if (message.Version.Envelope == EnvelopeVersion.Soap11)
+                               return CreateFault11 (message, maxBufferSize);
+                       else if (message.Version.Envelope == EnvelopeVersion.Soap12)
+                               return CreateFault12 (message, maxBufferSize);
+                       throw new InvalidOperationException ("The input message is not a SOAP envelope.");
+               }
+
+               static MessageFault CreateFault11 (Message message, int maxBufferSize)
+               {
+                       FaultCode fc = null;
+                       FaultReason fr = null;
+                       object details = null;
+                       XmlDictionaryReader r = message.GetReaderAtBodyContents ();
+                       r.ReadStartElement ("Fault", message.Version.Envelope.Namespace);
+                       r.MoveToContent ();
+
+                       while (r.NodeType != XmlNodeType.EndElement) {
+                               switch (r.LocalName) {
+                               case "faultcode":
+                                       fc = ReadFaultCode11 (r);
+                                       break;
+                               case "faultstring":
+                                       fr = new FaultReason (r.ReadElementContentAsString());
+                                       break;
+                               case "detail":
+                                       //BUGBUG: Handle children of type other than ExceptionDetail, in order to comply with 
+                                       //        FaultContractAttribute.
+                                       r.ReadStartElement ();
+                                       r.MoveToContent();
+                                       details = new DataContractSerializer (typeof (ExceptionDetail)).ReadObject (r);
+                                       break;
+                               case "faultactor":
+                               default:
+                                       throw new NotImplementedException ();
+                               }
+                               r.MoveToContent ();
+                       }
+                       r.ReadEndElement ();
+
+                       if (details == null)
+                               return CreateFault (fc, fr);
+                       return CreateFault (fc, fr, details);
+               }
+
+               static MessageFault CreateFault12 (Message message, int maxBufferSize)
+               {
+                       FaultCode fc = null;
+                       FaultReason fr = null;
+                       XmlDictionaryReader r = message.GetReaderAtBodyContents ();
+                       r.ReadStartElement ("Fault", message.Version.Envelope.Namespace);
+                       r.MoveToContent ();
+
+                       while (r.NodeType != XmlNodeType.EndElement) {
+                               switch (r.LocalName) {
+                               case "Code":
+                                       fc = ReadFaultCode12 (r, message.Version.Envelope.Namespace);
+                                       break;
+                               case "Reason":
+                                       fr = ReadFaultReason12 (r, message.Version.Envelope.Namespace);
+                                       break;
+                               default:
+                                       throw new NotImplementedException ();
+                               }
+                       }
+
+                       r.ReadEndElement ();
+
+                       return CreateFault (fc, fr);
+               }
+
+               static FaultCode ReadFaultCode11 (XmlDictionaryReader r)
+               {
+                       FaultCode subcode = null;
+                       XmlQualifiedName value = XmlQualifiedName.Empty;
+
+                       if (r.IsEmptyElement)
+                               throw new ArgumentException ("Fault Code is mandatory in SOAP fault message.");
+
+                       r.ReadStartElement ("faultcode");
+                       r.MoveToContent ();
+                       while (r.NodeType != XmlNodeType.EndElement) {
+                               if (r.NodeType == XmlNodeType.Element)
+                                       subcode = ReadFaultCode11 (r);
+                               else
+                                       value = (XmlQualifiedName) r.ReadContentAs (typeof (XmlQualifiedName), r as IXmlNamespaceResolver);
+                               r.MoveToContent ();
+                       }
+                       r.ReadEndElement ();
+
+                       return new FaultCode (value.Name, value.Namespace, subcode);
+               }
+
+               static FaultCode ReadFaultCode12 (XmlDictionaryReader r, string ns)
+               {
+                       FaultCode subcode = null;
+                       XmlQualifiedName value = XmlQualifiedName.Empty;
+
+                       if (r.IsEmptyElement)
+                               throw new ArgumentException ("Value element is mandatory in SOAP fault code.");
+
+                       r.ReadStartElement ("Code", ns);
+                       r.MoveToContent ();
+                       while (r.NodeType != XmlNodeType.EndElement) {
+                               switch (r.LocalName) {
+                               case "Subcode":
+                                       subcode = ReadFaultCode12 (r, ns);
+                                       break;
+                               case "Value":
+                                       value = (XmlQualifiedName) r.ReadElementContentAs (typeof (XmlQualifiedName), r as IXmlNamespaceResolver, "Value", ns);
+                                       break;
+                               default:
+                                       throw new ArgumentException ();
+                               }
+                               r.MoveToContent ();
+                       }
+                       r.ReadEndElement ();
+
+                       return new FaultCode (value.Name, value.Namespace, subcode);
+               }
+
+               static FaultReason ReadFaultReason12 (XmlDictionaryReader r, string ns)
+               {
+                       List<FaultReasonText> l = new List<FaultReasonText> ();
+                       if (r.IsEmptyElement)
+                               throw new ArgumentException ("One or more Text element is mandatory in SOAP fault reason text.");
+
+                       r.ReadStartElement ("Code", ns);
+                       for (r.MoveToContent ();
+                            r.NodeType != XmlNodeType.EndElement;
+                            r.MoveToContent ()) {
+                               string lang = r.GetAttribute ("lang", "http://www.w3.org/XML/1998/namespace");
+                               l.Add (new FaultReasonText (r.ReadElementContentAsString ("Text", ns), lang));
+                       }
+                       return new FaultReason (l);
+               }
+
+               public static MessageFault CreateFault (FaultCode code,
+                       string reason)
+               {
+                       return CreateFault (code, new FaultReason (reason));
+               }
+
+               public static MessageFault CreateFault (FaultCode code,
+                       FaultReason reason)
+               {
+                       return new SimpleMessageFault (code, reason,
+                                false, null, null, null, null);
+               }
+
+               public static MessageFault CreateFault (FaultCode code,
+                       FaultReason reason, object detail)
+               {
+                       return new SimpleMessageFault (code, reason,
+                               true, detail, new DataContractSerializer (detail.GetType ()), null, null);
+               }
+
+               public static MessageFault CreateFault (FaultCode code,
+                       FaultReason reason, object detail,
+                       XmlObjectSerializer formatter)
+               {
+                       return new SimpleMessageFault (code, reason, true,
+                               detail, formatter, String.Empty, String.Empty);
+               }
+
+               public static MessageFault CreateFault (FaultCode code,
+                       FaultReason reason, object detail,
+                       XmlObjectSerializer formatter, string actor)
+               {
+                       return new SimpleMessageFault (code, reason,
+                               true, detail, formatter, actor, String.Empty);
+               }
+
+               public static MessageFault CreateFault (FaultCode code,
+                       FaultReason reason, object detail,
+                       XmlObjectSerializer formatter, string actor, string node)
+               {
+                       return new SimpleMessageFault (code, reason,
+                               true, detail, formatter, actor, node);
+               }
+
+               // pretty simple implementation class
+               internal class SimpleMessageFault : MessageFault
+               {
+                       bool has_detail;
+                       string actor, node;
+                       FaultCode code;
+                       FaultReason reason;
+                       object detail;
+                       XmlObjectSerializer formatter;
+
+                       public SimpleMessageFault (FaultCode code,
+                               FaultReason reason, bool has_detail,
+                               object detail, XmlObjectSerializer formatter,
+                               string actor, string node)
+                               : this (code, reason, detail, formatter, actor, node)
+                       {
+                               this.has_detail = has_detail;
+                       }
+
+                       public SimpleMessageFault (FaultCode code,
+                               FaultReason reason,
+                               object detail, XmlObjectSerializer formatter,
+                               string actor, string node)
+                       {
+                               if (code == null)
+                                       throw new ArgumentNullException ("code");
+                               if (reason == null)
+                                       throw new ArgumentNullException ("reason");
+
+                               this.code = code;
+                               this.reason = reason;
+                               this.detail = detail;
+                               this.formatter = formatter;
+                               this.actor = actor;
+                               this.node = node;
+                       }
+
+                       public override string Actor {
+                               get { return actor; }
+                       }
+
+                       public override FaultCode Code {
+                               get { return code; }
+                       }
+
+                       public override bool HasDetail {
+                               // it is not simply "detail != null" since
+                               // null detail could become <ms:anyType xsi:nil="true" />
+                               get { return has_detail; }
+                       }
+
+                       public override string Node {
+                               get { return node; }
+                       }
+
+                       public override FaultReason Reason {
+                               get { return reason; }
+                       }
+
+                       protected override XmlDictionaryReader OnGetReaderAtDetailContents ()
+                       {
+                               // FIXME: use XmlObjectSerializer
+                               return base.OnGetReaderAtDetailContents ();
+                       }
+
+                       protected override void OnWriteDetailContents (XmlDictionaryWriter writer)
+                       {
+                               formatter.WriteObject (writer, detail);
+                       }
+
+                       public object Detail {
+                               get { return detail; }
+                       }
+               }
+
+               // instance members
+
+               protected MessageFault ()
+               {
+               }
+
+               [MonoTODO ("is this true?")]
+               public virtual string Actor {
+                       get { return String.Empty; }
+               }
+
+               public abstract FaultCode Code { get; }
+
+               public abstract bool HasDetail { get; }
+
+               [MonoTODO ("is this true?")]
+               public virtual string Node {
+                       get { return String.Empty; }
+               }
+
+               public abstract FaultReason Reason { get; }
+
+               public T GetDetail<T> ()
+               {
+                       return GetDetail<T> (new DataContractSerializer (typeof (T)));
+               }
+
+               public T GetDetail<T> (XmlObjectSerializer formatter)
+               {
+                       if (!HasDetail)
+                               throw new InvalidOperationException ("This message does not have details.");
+
+                       return (T) formatter.ReadObject (GetReaderAtDetailContents ());
+               }
+
+               public XmlDictionaryReader GetReaderAtDetailContents ()
+               {
+                       return OnGetReaderAtDetailContents ();
+               }
+
+               public void WriteTo (XmlDictionaryWriter writer,
+                       EnvelopeVersion version)
+               {
+                       writer.WriteStartElement ("Fault", version.Namespace);
+                       WriteFaultCode (writer, version, Code);
+                       WriteReason (writer, version);
+                       if (HasDetail)
+                               OnWriteDetail (writer, version);
+                       writer.WriteEndElement ();
+               }
+
+               private void WriteFaultCode (XmlDictionaryWriter writer, 
+                       EnvelopeVersion version, FaultCode code)
+               {
+                       if (version == EnvelopeVersion.Soap11) {
+                               writer.WriteStartElement ("", "faultcode", version.Namespace);
+                               if (code.Namespace.Length > 0)
+                                       writer.WriteXmlnsAttribute ("a", code.Namespace);
+                               writer.WriteQualifiedName (code.Name, code.Namespace);
+                               writer.WriteEndElement ();
+                       } else { // Soap12
+                               writer.WriteStartElement ("Code", version.Namespace);
+                               writer.WriteStartElement ("Value", version.Namespace);
+                               if (code.Namespace.Length > 0)
+                                       writer.WriteXmlnsAttribute ("a", code.Namespace);
+                               writer.WriteQualifiedName (code.Name, code.Namespace);
+                               if (code.SubCode != null)
+                                       WriteFaultCode (writer, version, code.SubCode);
+                               writer.WriteEndElement ();
+                               writer.WriteEndElement ();
+                       }
+               }
+
+               private void WriteReason (XmlDictionaryWriter writer, 
+                       EnvelopeVersion version)
+               {
+                       if (version == EnvelopeVersion.Soap11) {
+                               foreach (FaultReasonText t in Reason.Translations) {
+                                       writer.WriteStartElement ("", "faultstring", version.Namespace);
+                                       if (t.XmlLang != null)
+                                               writer.WriteAttributeString ("xml", "lang", null, t.XmlLang);
+                                       writer.WriteString (t.Text);
+                                       writer.WriteEndElement ();
+                               }
+                       } else { // Soap12
+                               writer.WriteStartElement ("Reason", version.Namespace);
+                               foreach (FaultReasonText t in Reason.Translations) {
+                                       writer.WriteStartElement ("Text", version.Namespace);
+                                       if (t.XmlLang != null)
+                                               writer.WriteAttributeString ("xml", "lang", null, t.XmlLang);
+                                       writer.WriteString (t.Text);
+                                       writer.WriteEndElement ();
+                               }
+                               writer.WriteEndElement ();
+                       }
+               }
+
+               public void WriteTo (XmlWriter writer, EnvelopeVersion version)
+               {
+                       WriteTo (XmlDictionaryWriter.CreateDictionaryWriter (
+                               writer), version);
+               }
+
+               protected virtual XmlDictionaryReader OnGetReaderAtDetailContents ()
+               {
+                       MemoryStream ms = new MemoryStream ();
+                       using (XmlDictionaryWriter dw =
+                               XmlDictionaryWriter.CreateDictionaryWriter (
+                                       XmlWriter.Create (ms))) {
+                               OnWriteDetailContents (dw);
+                       }
+                       ms.Seek (0, SeekOrigin.Begin);
+                       return XmlDictionaryReader.CreateDictionaryReader (
+                               XmlReader.Create (ms));
+               }
+
+               protected virtual void OnWriteDetail (XmlDictionaryWriter writer, EnvelopeVersion version)
+               {
+                       OnWriteStartDetail (writer, version);
+                       OnWriteDetailContents (writer);
+                       writer.WriteEndElement ();
+               }
+
+               protected virtual void OnWriteStartDetail (XmlDictionaryWriter writer, EnvelopeVersion version)
+               {
+                       if (version == EnvelopeVersion.Soap11)
+                               writer.WriteStartElement ("detail", String.Empty);
+                       else // Soap12
+                               writer.WriteStartElement ("Detail", version.Namespace);
+               }
+
+               protected abstract void OnWriteDetailContents (XmlDictionaryWriter writer);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageFaultBodyWriter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageFaultBodyWriter.cs
new file mode 100644 (file)
index 0000000..dbb829f
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// MessageFaultBodyWriter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO ("Check how isBuffered works.")]
+       internal class MessageFaultBodyWriter : BodyWriter
+       {
+               MessageFault fault;
+               MessageVersion version;
+
+               public MessageFaultBodyWriter (MessageFault fault, MessageVersion version)
+                       : base (true)
+               {
+                       this.fault = fault;
+                       this.version = version;
+               }
+
+               protected override BodyWriter OnCreateBufferedCopy (
+                       int maxBufferSize)
+               {
+                       return new MessageFaultBodyWriter (fault, version);
+               }
+
+               protected override void OnWriteBodyContents (
+                       XmlDictionaryWriter writer)
+               {
+                       fault.WriteTo (writer, version.Envelope);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeader.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeader.cs
new file mode 100644 (file)
index 0000000..1de0db4
--- /dev/null
@@ -0,0 +1,296 @@
+//
+// System.ServiceModel.MessageHeader.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//        Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class MessageHeader : MessageHeaderInfo
+       {
+               static readonly XmlWriterSettings writer_settings;
+
+               static MessageHeader ()
+               {
+                       writer_settings = new XmlWriterSettings ();
+                       writer_settings.OmitXmlDeclaration = true;
+                       writer_settings.Indent = true;
+               }
+
+               protected MessageHeader () {}
+
+               static string default_actor = String.Empty;
+               static bool default_is_ref = false;
+               static bool default_must_understand = false;
+               static bool default_relay = false;
+               static Type [] knownTypes = new Type [1] {typeof (EndpointAddress10)};
+
+               internal static MessageHeader CreateInternalHeader (XmlElement el, string soap_ns)
+               {
+                       return new RawMessageHeader (el, soap_ns);
+               }
+
+               public static MessageHeader CreateHeader (string name, string ns, object value)
+               {
+                       return CreateHeader (name, ns, value, default_must_understand);
+               }
+
+               public static MessageHeader CreateHeader (string name, string ns, object value, bool must_understand)
+               {
+                       return CreateHeader (name, ns, value, must_understand, default_actor);
+               }
+
+               public static MessageHeader CreateHeader (string name, string ns, object value, XmlObjectSerializer formatter)
+               {
+                       return CreateHeader (name, ns, value, formatter, default_must_understand, 
+                                            default_actor, default_relay);
+               }
+
+               public static MessageHeader CreateHeader (string name, string ns, object value, 
+                                                  bool must_understand, string actor)
+               {
+                       return CreateHeader (name, ns, value, must_understand, actor, default_relay);
+               }
+
+               public static MessageHeader CreateHeader (string name, string ns, object value, XmlObjectSerializer formatter, 
+                                                  bool must_understand)
+               {
+                       return CreateHeader (name, ns, value, formatter, must_understand, default_actor, default_relay);
+               }
+               
+               public static MessageHeader CreateHeader (string name, string ns, object value, 
+                                                  bool must_understand, string actor, bool relay)
+               {
+                       return CreateHeader (name, ns, value, new DataContractSerializer (value.GetType (), knownTypes),
+                                       must_understand, actor, relay);
+               }
+
+               public static MessageHeader CreateHeader (string name, string ns, object value, XmlObjectSerializer formatter,
+                                                  bool must_understand, string actor)
+               {
+                       return CreateHeader (name, ns, value, formatter, must_understand, actor, default_relay);
+               }
+               
+               public static MessageHeader CreateHeader (string name, string ns, object value, XmlObjectSerializer formatter,
+                                                  bool must_understand, string actor, bool relay)
+               {
+                       // FIXME: how to get IsReferenceParameter ?
+                       return new DefaultMessageHeader (name, ns, value, formatter, default_is_ref, must_understand, actor, relay);
+               }
+
+               public virtual bool IsMessageVersionSupported (MessageVersion version)
+               {
+                       if (version.Envelope == EnvelopeVersion.Soap12)
+                               if (Actor == EnvelopeVersion.Soap11.NextDestinationActorValue)
+                                       return false;
+
+                       if (version.Envelope == EnvelopeVersion.Soap11)
+                               if (Actor == EnvelopeVersion.Soap12.NextDestinationActorValue ||
+                                   Actor == EnvelopeVersion.Soap12UltimateReceiver)
+                                       return false;
+
+                       // by default, it's always supported
+                       return true;
+               }
+
+               protected abstract void OnWriteHeaderContents (XmlDictionaryWriter writer, MessageVersion version);
+
+               protected virtual void OnWriteStartHeader (XmlDictionaryWriter writer, MessageVersion version)
+               {
+                       writer.WriteStartElement (this.Name, this.Namespace);
+                       WriteHeaderAttributes (writer, version);
+               }
+
+               public override string ToString ()
+               {
+                       StringBuilder sb = new StringBuilder ();
+
+                       XmlWriter w = XmlWriter.Create (sb, writer_settings);
+
+                       WriteHeader (w, MessageVersion.Default);
+                       w.Close ();
+
+                       return sb.ToString ();
+               }
+
+               public void WriteHeader (XmlDictionaryWriter writer, MessageVersion version)
+               {
+                       if (writer == null)
+                               throw new ArgumentNullException ("writer is null.");
+
+                       if (version == null)
+                               throw new ArgumentNullException ("version is null.");
+
+                       if (version.Envelope == EnvelopeVersion.None)
+                               return;
+
+                       WriteStartHeader (writer, version);
+                       WriteHeaderContents (writer, version);
+
+                       writer.WriteEndElement ();
+               }
+
+               public void WriteHeader (XmlWriter writer, MessageVersion version)
+               {
+                       WriteHeader (XmlDictionaryWriter.CreateDictionaryWriter (writer), version);
+               }
+
+               protected void WriteHeaderAttributes (XmlDictionaryWriter writer, MessageVersion version)
+               {
+                       if (Id != null)
+                               writer.WriteAttributeString ("u", "Id", Constants.WsuNamespace, Id);
+                       if (Actor != String.Empty) {
+                               if (version.Envelope == EnvelopeVersion.Soap11) 
+                                       writer.WriteAttributeString ("s", "actor", version.Envelope.Namespace, Actor);
+
+                               if (version.Envelope == EnvelopeVersion.Soap12) 
+                                       writer.WriteAttributeString ("s", "role", version.Envelope.Namespace, Actor);
+                       }
+
+                       // mustUnderstand is the same across SOAP 1.1 and 1.2
+                       if (MustUnderstand == true)
+                               writer.WriteAttributeString ("s", "mustUnderstand", version.Envelope.Namespace, "1");
+
+                       // relay is only available on SOAP 1.2
+                       if (Relay == true && version.Envelope == EnvelopeVersion.Soap12)
+                               writer.WriteAttributeString ("s", "relay", version.Envelope.Namespace, "true");
+               }
+
+               public void WriteHeaderContents (XmlDictionaryWriter writer, MessageVersion version)
+               {
+                       this.OnWriteHeaderContents (writer, version);
+               }
+
+               public void WriteStartHeader (XmlDictionaryWriter writer, MessageVersion version)
+               {
+                       this.OnWriteStartHeader (writer, version);
+               }
+
+               public override string Actor { get { return default_actor; }}
+
+               public override bool IsReferenceParameter { get { return default_is_ref; }}
+
+               public override bool MustUnderstand { get { return default_must_understand; }}
+
+               public override bool Relay { get { return default_relay; }}
+
+               internal class RawMessageHeader : MessageHeader
+               {
+                       XmlElement source;
+                       string soap_ns;
+                       bool is_ref, must_understand, relay;
+                       string actor;
+
+                       public RawMessageHeader (XmlElement source, string soap_ns)
+                       {
+                               this.source = source;
+
+                               Id = source.HasAttribute ("Id", Constants.WsuNamespace) ?
+                                       source.GetAttribute ("Id", Constants.WsuNamespace) :
+                                       null;
+
+                               // FIXME: fill is_ref
+                               string s = source.GetAttribute ("relay", soap_ns);
+                               relay = s.Length > 0 ? XmlConvert.ToBoolean (s) : false;
+                               s = source.GetAttribute ("mustUnderstand", soap_ns);
+                               must_understand = s.Length > 0 ? XmlConvert.ToBoolean (s) : false;
+                               actor = source.GetAttribute ("actor", soap_ns);
+                       }
+
+                       public XmlReader CreateReader ()
+                       {
+                               return new XmlNodeReader (source);
+                       }
+
+                       protected override void OnWriteHeaderContents (
+                               XmlDictionaryWriter writer, MessageVersion version)
+                       {
+                               source.WriteContentTo (writer);
+                       }
+
+                       public override string Actor { get { return actor; }}
+
+                       public override bool IsReferenceParameter { get { return is_ref; }}
+
+                       public override bool MustUnderstand { get { return must_understand; }}
+
+                       public override string Name { get { return source.LocalName; }}
+
+                       public override string Namespace { get { return source.NamespaceURI; }}
+
+                       public override bool Relay { get { return relay; }}
+               }
+
+               internal class DefaultMessageHeader : MessageHeader
+               {
+                       string actor, name, ns;
+                       object value;
+                       XmlObjectSerializer formatter;
+                       bool is_ref, must_understand, relay;
+                       
+                       internal DefaultMessageHeader (string name, string ns, object value, XmlObjectSerializer formatter, 
+                                                      bool isReferenceParameter,
+                                                      bool mustUnderstand, string actor, bool relay)
+                       {
+                               this.name = name;
+                               this.ns = ns;
+                               this.value = value;
+                               this.formatter = formatter;
+                               this.is_ref = isReferenceParameter;
+                               this.must_understand = mustUnderstand;
+                               this.actor = actor;
+                               this.relay = relay;
+                       }
+
+                       protected override void OnWriteHeaderContents (XmlDictionaryWriter writer,
+                                                                      MessageVersion version)
+                       {
+                               if (value is EndpointAddress)
+                                       ((EndpointAddress) value).WriteTo (version.Addressing, writer, name, ns);
+                               else
+                                       this.formatter.WriteObjectContent (writer, value);
+                       }
+
+                       public override string Actor { get { return actor; }}
+
+                       public override bool IsReferenceParameter { get { return is_ref; }}
+
+                       public override bool MustUnderstand { get { return must_understand; }}
+
+                       public override string Name { get { return name; }}
+
+                       public override string Namespace { get { return ns; }}
+
+                       public override bool Relay { get { return relay; }}
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeaderInfo.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeaderInfo.cs
new file mode 100644 (file)
index 0000000..4deafbe
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// System.ServiceModel.MessageHeaderInfo.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Channels
+{
+
+       public abstract class MessageHeaderInfo
+       {
+               public abstract string Actor { get; }
+               public abstract bool IsReferenceParameter { get; }
+               public abstract bool MustUnderstand { get; }
+               public abstract string Name { get; }
+               public abstract string Namespace { get; }
+               public abstract bool Relay { get; }
+
+               string id;
+               internal string Id {
+                       get { return id; }
+                       set { id = value; }
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeaders.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeaders.cs
new file mode 100644 (file)
index 0000000..e6179bb
--- /dev/null
@@ -0,0 +1,434 @@
+//
+// System.ServiceModel.MessageHeader.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class MessageHeaders : IEnumerable<MessageHeaderInfo>, IEnumerable
+       {
+               static string [] empty_strings = new string [0];
+
+               static readonly XmlReaderSettings reader_settings;
+
+               static MessageHeaders ()
+               {
+                       reader_settings = new XmlReaderSettings ();
+                       reader_settings.ConformanceLevel = ConformanceLevel.Fragment;
+               }
+
+               List<MessageHeaderInfo> l;
+               Dictionary<Type, XmlObjectSerializer> serializers =
+                       new Dictionary<Type, XmlObjectSerializer> ();
+               MessageVersion version;
+
+               public MessageHeaders (MessageHeaders headers)
+                       : this (headers.MessageVersion)
+               {
+                       CopyHeadersFrom (headers);
+               }
+
+               public MessageHeaders (MessageVersion version)
+                       : this (version, 10) // let's say 10 is the initial size
+               {
+               }
+
+               public MessageHeaders (MessageVersion version, int capacity)
+               {
+                       this.version = version;
+                       l = new List<MessageHeaderInfo> (capacity);
+               }
+               
+               public void Add (MessageHeader header)
+               {
+                       l.Add (header);
+               }
+
+               public void CopyHeaderFrom (Message m, int index)
+               {
+                       CopyHeaderFrom (m.Headers, index);
+               }
+
+               public void Clear ()
+               {
+                       l.Clear ();
+               }
+
+               public void CopyHeaderFrom (MessageHeaders headers, int index)
+               {
+                       l.Add (headers [index]);
+               }
+
+               public void CopyHeadersFrom (Message m)
+               {
+                       CopyHeadersFrom (m.Headers);
+               }
+
+               public void CopyHeadersFrom (MessageHeaders headers)
+               {
+                       foreach (MessageHeaderInfo h in headers)
+                               l.Add (h);
+               }
+
+               public void CopyTo (MessageHeaderInfo [] dst, int index)
+               {
+                       l.CopyTo (dst, index);
+               }
+
+               public int FindHeader (string name, string ns)
+               {
+                       return FindHeader (name, ns, null);
+               }
+
+               bool HasActor (string actor, string [] candidates)
+               {
+                       foreach (string c in candidates)
+                               if (c == actor)
+                                       return true;
+                       return false;
+               }
+
+               public int FindHeader (string name, string ns, params string [] actors)
+               {
+                       int found = 0;
+                       int retval = -1;
+                       
+                       for (int i = 0; i < l.Count; i++) {
+                               MessageHeaderInfo info = l [i];
+
+                               if (info.Name == name && info.Namespace == ns) {
+                                       if (found > 1)
+                                               throw new ArgumentException ("Found multiple matching headers.");
+                                       // When no actors are passed, it never
+                                       // matches such header that has an
+                                       // Actor.
+                                       if (actors == null && info.Actor == String.Empty ||
+                                           actors != null && HasActor (info.Actor, actors)) {
+                                               retval = i;
+                                               found++;
+                                       }
+                               }
+                       }
+
+                       return retval;
+               }
+
+               public IEnumerator<MessageHeaderInfo> GetEnumerator ()
+               {
+                       return l.GetEnumerator ();
+               }
+
+               XmlObjectSerializer GetSerializer<T> ()
+               {
+                       if (!serializers.ContainsKey (typeof (T)))
+                               serializers [typeof (T)] = new DataContractSerializer (typeof (T));
+                       return serializers [typeof (T)];
+               }
+
+               public T GetHeader<T> (int index)
+               {
+                       if (typeof (T) == typeof (EndpointAddress)) {
+                               XmlDictionaryReader r = GetReaderAtHeader (index);
+                               return (T) (object) new EndpointAddress (r.ReadElementContentAsString ());
+                       }
+                       else
+                               return GetHeader<T> (index, GetSerializer<T> ());
+               }
+
+               public T GetHeader<T> (int index, XmlObjectSerializer serializer)
+               {
+                       if (serializer == null)
+                               throw new ArgumentNullException ("serializer");
+                       XmlDictionaryReader r = GetReaderAtHeader (index);
+                       return (T) serializer.ReadObject (r, false);
+               }
+
+               public T GetHeader<T> (string name, string ns)
+               {
+                       return GetHeader<T> (name, ns, empty_strings);
+               }
+
+               public T GetHeader<T> (string name, string ns, params string [] actors)
+               {
+                       int idx = FindHeader (name, ns, actors);
+
+                       if (idx == -1)
+                               throw new MessageHeaderException (String.Format ("Header '{0}:{1}' was not found for the argument actors: {2}", ns, name, String.Join (",", actors)));
+
+                       return GetHeader<T> (idx);
+               }
+
+               public T GetHeader<T> (string name, string ns, XmlObjectSerializer serializer)
+               {
+                       if (serializer == null)
+                               throw new ArgumentNullException ("serializer");
+                       int idx = FindHeader (name, ns);
+
+                       if (idx < 0)
+                               throw new MessageHeaderException (String.Format ("Header '{0}:{1}' was not found", ns, name));
+
+                       return GetHeader<T> (idx, serializer);
+               }
+
+               public XmlDictionaryReader GetReaderAtHeader (int index)
+               {
+                       if (index >= l.Count)
+                               throw new ArgumentOutOfRangeException (String.Format ("Index is out of range. Current header count is {0}", index));
+                       MessageHeader item = (MessageHeader) l [index];
+
+                       XmlReader reader =
+                               item is MessageHeader.RawMessageHeader ?
+                               ((MessageHeader.RawMessageHeader) item).CreateReader () :
+                               XmlReader.Create (
+                                       new StringReader (item.ToString ()),
+                                       reader_settings);
+                       reader.MoveToContent ();
+                       XmlDictionaryReader dr = XmlDictionaryReader.CreateDictionaryReader (reader);
+                       dr.MoveToContent ();
+                       return dr;
+               }
+
+               public bool HaveMandatoryHeadersBeenUnderstood ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool HaveMandatoryHeadersBeenUnderstood (params string [] actors)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void Insert (int index, MessageHeader header)
+               {
+                       l.Insert (index, header);
+               }
+
+               public void RemoveAll (string name, string ns)
+               {
+                       l.RemoveAll (delegate (MessageHeaderInfo info) {
+                                               return info.Name == name && info.Namespace == ns;
+                                       });
+               }
+
+               public void RemoveAt (int index)
+               {
+                       l.RemoveAt (index);
+               }
+
+               IEnumerator IEnumerable.GetEnumerator ()
+               {
+                       return ((IEnumerable) l).GetEnumerator ();
+               }
+
+               public void WriteHeader (int index, XmlDictionaryWriter writer)
+               {
+                       if (version.Envelope == EnvelopeVersion.None)
+                               return;
+
+                       // For AddressingVersion.None, don't output the item.
+                       //
+                       // FIXME: It should even ignore Action, but for now
+                       // service dispatcher won't work without it.
+                       if (version.Addressing == AddressingVersion.None &&
+                           l [index].Name != "Action")
+                               return;
+
+                       WriteStartHeader (index, writer);
+                       WriteHeaderContents (index, writer);
+                       writer.WriteEndElement ();
+               }
+
+               public void WriteHeader (int index, XmlWriter writer)
+               {
+                       WriteHeader (index, XmlDictionaryWriter.CreateDictionaryWriter (writer));
+               }
+
+               public void WriteHeaderContents (int index, XmlDictionaryWriter writer)
+               {
+                       if (index > l.Count)
+                               throw new ArgumentOutOfRangeException ("There is no header at position " + index + ".");
+                       
+                       MessageHeader h = l [index] as MessageHeader;
+
+                       h.WriteHeaderContents (writer, version);
+               }
+
+               public void WriteHeaderContents (int index, XmlWriter writer)
+               {
+                       WriteHeaderContents (index, XmlDictionaryWriter.CreateDictionaryWriter (writer));
+               }
+
+               public void WriteStartHeader (int index, XmlDictionaryWriter writer)
+               {
+                       if (index > l.Count)
+                               throw new ArgumentOutOfRangeException ("There is no header at position " + index + ".");
+
+                       MessageHeader h = l [index] as MessageHeader;
+                       
+                       h.WriteStartHeader (writer, version);
+               }
+
+               public void WriteStartHeader (int index, XmlWriter writer)
+               {
+                       WriteStartHeader (index, XmlDictionaryWriter.CreateDictionaryWriter (writer));
+               }
+
+               public string Action {
+                       get {
+                               int idx = FindHeader ("Action", version.Addressing.Namespace);
+                               return idx < 0 ? null : GetHeader<string> (idx);
+                       }
+                       set {
+                               RemoveAll ("Action", version.Addressing.Namespace);
+                               Add (MessageHeader.CreateHeader ("Action", version.Addressing.Namespace, value, true));
+                       }
+               }
+
+               public int Count {
+                       get { return l.Count; }
+               }
+
+               public EndpointAddress FaultTo {
+                       get {
+                               int idx = FindHeader ("FaultTo", Constants.WSA1);
+                               return idx < 0 ? null : GetHeader<EndpointAddress> (idx);
+                       }
+                       set {
+                               if (version.Addressing == AddressingVersion.None)
+                                       throw new InvalidOperationException ("WS-Addressing header is not allowed for AddressingVersion.None");
+
+                               RemoveAll ("FaultTo", Constants.WSA1);
+                               Add (MessageHeader.CreateHeader (
+                                               "FaultTo", 
+                                               Constants.WSA1,
+                                               EndpointAddress10.FromEndpointAddress (value)));
+                       }
+               }
+
+               public EndpointAddress From {
+                       get {
+                               int idx = FindHeader ("From", version.Addressing.Namespace);
+                               return idx < 0 ? null : GetHeader<EndpointAddress> (idx);
+                       }
+                       set { 
+                               if (version.Addressing == AddressingVersion.None)
+                                       throw new InvalidOperationException ("WS-Addressing header is not allowed for AddressingVersion.None");
+
+                               RemoveAll ("From", Constants.WSA1);
+                               Add (MessageHeader.CreateHeader (
+                                               "From", 
+                                               Constants.WSA1,
+                                               EndpointAddress10.FromEndpointAddress (value)));
+                       }
+               }
+
+               public MessageHeaderInfo this [int index] {
+                       get { return l [index]; }
+               }
+
+               public UniqueId MessageId {
+                       get { 
+                               int idx = FindHeader ("MessageID", Constants.WSA1);
+                               return idx < 0 ? null : new UniqueId (GetHeader<string> (idx));
+                       }
+                       set {
+                               if (version.Addressing == AddressingVersion.None)
+                                       throw new InvalidOperationException ("WS-Addressing header is not allowed for AddressingVersion.None");
+
+                               RemoveAll ("MessageID", Constants.WSA1);
+                               Add (MessageHeader.CreateHeader (
+                                               "MessageID", 
+                                               Constants.WSA1,
+                                               value.ToString ()));
+                       }
+               }
+
+               public MessageVersion MessageVersion { get { return version; } }
+
+               public UniqueId RelatesTo {
+                       get { 
+                               int idx = FindHeader ("RelatesTo", Constants.WSA1);
+                               return idx < 0 ? null : new UniqueId (GetHeader<string> (idx));
+                       }
+                       set {
+                               if (version.Addressing == AddressingVersion.None)
+                                       throw new InvalidOperationException ("WS-Addressing header is not allowed for AddressingVersion.None");
+
+                               RemoveAll ("MessageID", Constants.WSA1);
+                               Add (MessageHeader.CreateHeader (
+                                               "RelatesTo", 
+                                               Constants.WSA1,
+                                               value.ToString ()));
+                       }
+
+               }
+
+               public EndpointAddress ReplyTo {
+                       get {
+                               int idx = FindHeader ("ReplyTo", Constants.WSA1);
+                               return idx < 0 ? null : GetHeader<EndpointAddress> (idx);
+                       }
+                       set {
+                               if (version.Addressing == AddressingVersion.None)
+                                       throw new InvalidOperationException ("WS-Addressing header is not allowed for AddressingVersion.None");
+
+                               RemoveAll ("ReplyTo", Constants.WSA1);
+                               Add (MessageHeader.CreateHeader (
+                                               "ReplyTo", 
+                                               Constants.WSA1,
+                                               EndpointAddress10.FromEndpointAddress (value)));
+                       }
+               }
+
+               public Uri To {
+                       get {
+                               int idx = FindHeader ("To", version.Addressing.Namespace);
+                               //FIXME: return idx < 0 ? null : GetHeader<Uri> (idx);
+                               return idx < 0 ? null : new Uri (GetHeader<string> (idx));
+                       }
+                       set { 
+                               RemoveAll ("To", version.Addressing.Namespace);
+                               Add (MessageHeader.CreateHeader (
+                                               "To", 
+                                               version.Addressing.Namespace, 
+                                               value.AbsoluteUri,
+                                               true));
+                       }
+               }
+
+               [MonoTODO]
+               public UnderstoodHeaders UnderstoodHeaders {
+                       get { throw new NotImplementedException (); }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageImpl.cs
new file mode 100644 (file)
index 0000000..c79a462
--- /dev/null
@@ -0,0 +1,269 @@
+//
+// MessageImpl.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Runtime.Serialization;
+using System.Xml;
+using System.IO;
+
+namespace System.ServiceModel.Channels
+{
+       // Apparently Microsoft should have split Message class into
+       // two diffferent public classes such as IncomingMessage and
+       // OutgoingMessage.
+       internal class XmlReaderMessage : Message
+       {
+               MessageVersion version;
+               XmlDictionaryReader reader;
+               MessageHeaders headers;
+               MessageProperties properties = new MessageProperties ();
+               bool is_empty, is_fault, body_started, body_consumed;
+               int max_headers;
+
+               string body;
+
+               public XmlReaderMessage (MessageVersion version, XmlDictionaryReader reader, int maxSizeOfHeaders)
+               {
+                       this.version = version;
+                       this.reader = reader;
+                       this.max_headers = maxSizeOfHeaders;
+
+                       ReadEnvelopeStart ();
+                       // Headers and IsEmpty are consumed at this stage.
+                       // Body content is not.
+                       ReadBodyStart ();
+
+                       StringWriter sw = new StringWriter ();
+                       using (XmlDictionaryWriter bodyXml = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (sw))) {
+                               while (!reader.EOF && reader.NodeType != XmlNodeType.EndElement)
+                                       bodyXml.WriteNode (reader, false);
+                       }
+                       this.body = sw.ToString ();
+               }
+
+               public override MessageHeaders Headers {
+                       get {
+                               if (headers == null)
+                                       ReadHeaders ();
+                               return headers;
+                       }
+               }
+
+               public override bool IsEmpty {
+                       get {
+                               if (!body_started)
+                                       ReadBodyStart ();
+                               return is_empty;
+                       }
+               }
+
+               public override bool IsFault {
+                       get {
+                               if (!body_started)
+                                       ReadBodyStart ();
+                               return is_fault;
+                       }
+               }
+
+               public override MessageProperties Properties {
+                       get { return properties; }
+               }
+
+               public override MessageVersion Version {
+                       get { return version; }
+               }
+
+               protected override string OnGetBodyAttribute (
+                       string localName, string ns)
+               {
+                       if (headers == null)
+                               ReadHeaders ();
+                       return reader.GetAttribute (localName, ns);
+               }
+
+               protected override XmlDictionaryReader OnGetReaderAtBodyContents ()
+               {
+                       XmlDictionaryReader newReader = XmlDictionaryReader.CreateDictionaryReader (XmlReader.Create (new StringReader (this.body)));
+                       newReader.MoveToContent();
+                       return newReader;
+               }
+
+               protected override void OnWriteBodyContents (
+                       XmlDictionaryWriter writer)
+               {
+                       XmlDictionaryReader reader = GetReaderAtBodyContents ();
+                       while (!reader.EOF && reader.NodeType != XmlNodeType.EndElement)
+                               writer.WriteNode (reader, false);
+               }
+
+               static readonly char [] whitespaceChars = new char [] {' ', '\t', '\r', '\n'};
+
+               void ReadEnvelopeStart ()
+               {
+                       reader.MoveToContent ();
+                       if (reader.IsEmptyElement)
+                               throw new ArgumentException ("Missing message content XML.");
+                       reader.ReadStartElement ("Envelope", Version.Envelope.Namespace);
+
+                       // SOAP Header
+                       reader.MoveToContent ();
+               }
+
+               void ReadHeaders ()
+               {
+                       if (headers != null)
+                               throw new InvalidOperationException ("XmlReader at headers is already consumed.");
+
+                       string envNS = Version.Envelope.Namespace;
+
+                       headers = new MessageHeaders (version, max_headers);
+                       if (reader.LocalName != "Header" || reader.NamespaceURI != envNS)
+                               return;
+
+                       bool isEmptyHeader = reader.IsEmptyElement;
+                       reader.ReadStartElement ("Header", envNS);
+                       reader.MoveToContent ();
+                       if (isEmptyHeader)
+                               return;
+
+                       XmlDocument doc = null;
+                       while (!reader.EOF && reader.NodeType != XmlNodeType.EndElement) {
+                               if (doc == null)
+                                       doc = new XmlDocument ();
+                               XmlElement el = doc.ReadNode (reader) as XmlElement;
+                               if (el != null)
+                                       headers.Add (MessageHeader.CreateInternalHeader (el, envNS));
+                               // FIXME: handle UnderstoodHeaders as well.
+                               reader.MoveToContent ();
+                       }
+                       reader.ReadEndElement ();
+                       reader.MoveToContent ();
+               }
+
+               void ReadBodyStart ()
+               {
+                       // read headers in advance.
+                       if (headers == null)
+                               ReadHeaders ();
+
+                       // SOAP Body
+                       body_started = true;
+                       is_empty = reader.IsEmptyElement;
+                       if (reader.MoveToAttribute ("Id", Constants.WsuNamespace)) {
+                               BodyId = reader.Value;
+                               reader.MoveToElement ();
+                       }
+                       reader.ReadStartElement ("Body", Version.Envelope.Namespace);
+                       if (reader.NodeType == XmlNodeType.EndElement) {
+                               is_empty = true;
+                               reader.Read ();
+                       } else {
+                               reader.MoveToContent ();
+                               if (reader.NodeType == XmlNodeType.Element &&
+                                   reader.LocalName == "Fault" &&
+                                   reader.NamespaceURI == Version.Envelope.Namespace)
+                                       is_fault = true;
+                       }
+               }
+       }
+
+       internal abstract class MessageImplBase : Message
+       {
+               MessageHeaders headers;
+               MessageProperties properties = new MessageProperties ();
+
+               public MessageImplBase (MessageVersion version, string action)
+               {
+                       headers = new MessageHeaders (version);
+                       if (action != null)
+                               headers.Action = action;
+               }
+
+               public override MessageHeaders Headers {
+                       get { return headers; }
+               }
+
+               public override MessageProperties Properties {
+                       get { return properties; }
+               }
+
+               public override MessageVersion Version {
+                       get { return Headers.MessageVersion; }
+               }
+       }
+
+       internal class EmptyMessage : MessageImplBase
+       {
+               public EmptyMessage (MessageVersion version, string action)
+                       : base (version, action)
+               {
+               }
+
+               public override bool IsEmpty {
+                       get { return true; }
+               }
+
+               protected override void OnWriteBodyContents (
+                       XmlDictionaryWriter writer)
+               {
+               }
+
+               protected override MessageBuffer OnCreateBufferedCopy (
+                       int maxBufferSize)
+               {
+                       return new DefaultMessageBuffer (Headers, Properties);
+               }
+       }
+
+       internal class SimpleMessage : MessageImplBase
+       {
+               BodyWriter body;
+               bool is_fault;
+
+               public SimpleMessage (MessageVersion version,
+                       string action, BodyWriter body, bool isFault)
+                       : base (version, action)
+               {
+                       this.body = body;
+                       this.is_fault = isFault;
+               }
+
+               public override bool IsEmpty {
+                       get { return false; }
+               }
+
+               public override bool IsFault {
+                       get { return is_fault; }
+               }
+
+               protected override void OnWriteBodyContents (
+                       XmlDictionaryWriter writer)
+               {
+                       body.WriteBodyContents (writer);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageProperties.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageProperties.cs
new file mode 100644 (file)
index 0000000..8531605
--- /dev/null
@@ -0,0 +1,317 @@
+//
+// MessageProperties.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+
+using Pair = System.Collections.Generic.KeyValuePair<string, object>;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO ("it's untested")]
+       public sealed class MessageProperties : IDictionary<string, object>, 
+               ICollection<Pair>, IEnumerable<Pair>, IEnumerable, IDisposable
+       {
+               bool allow_output_batch;
+               MessageEncoder encoder;
+               Uri via;
+               List<Pair> list;
+
+               public MessageProperties ()
+               {
+                       list = new List<Pair> ();
+               }
+
+               public MessageProperties (MessageProperties properties)
+               {
+                       properties.CopyProperties (this);
+               }
+
+               [MonoTODO ("This should actually be internal of a property.")]
+               public bool AllowOutputBatching {
+                       get { return allow_output_batch; }
+                       set { allow_output_batch = value; }
+               }
+
+               public int Count {
+                       get { return list.Count; }
+               }
+
+               [MonoTODO ("This should actually be internal of a property.")]
+               public MessageEncoder Encoder {
+                       get { return encoder; }
+                       set { encoder = value; }
+               }
+
+               public bool IsFixedSize {
+                       get { return false; }
+               }
+
+               public bool IsReadOnly {
+                       get { return false; }
+               }
+
+               public ICollection<string> Keys {
+                       get { return new ParameterKeyCollection (list); }
+               }
+
+               public object this [string name] {
+                       get {
+                               for (int i = 0; i < list.Count; i++)
+                                       if (list [i].Key == name)
+                                               return list [i].Value;
+                               return null;
+                       }
+                       set {
+                               for (int i = 0; i < list.Count; i++)
+                                       if (list [i].Key == name) {
+                                               list [i] = new Pair (name, value);
+                                               return;
+                                       }
+                               list.Add (new Pair (name, value));
+                       }
+               }
+
+               public SecurityMessageProperty Security {
+                       get { return (SecurityMessageProperty) this ["Security"]; }
+                       set { this ["Security"] = value; }
+               }
+
+               public ICollection<object> Values {
+                       get { return new ParameterValueCollection (list); }
+               }
+
+               [MonoTODO ("This should actually be internal of a property.")]
+               public Uri Via {
+                       get { return via; }
+                       set { via = value; }
+               }
+
+               public void Add (string name, object property)
+               {
+                       list.Add (new Pair (name, property));
+               }
+
+               public void Clear ()
+               {
+                       list.Clear ();
+               }
+
+               public bool ContainsKey (string name)
+               {
+                       for (int i = 0; i < list.Count; i++)
+                               if (list [i].Key == name)
+                                       return true;
+                       return false;
+               }
+
+               public void CopyProperties (MessageProperties properties)
+               {
+                       list = new List<Pair> (properties.list);
+                       allow_output_batch = properties.allow_output_batch;
+                       encoder = properties.encoder;
+                       via = properties.via;
+               }
+
+               public void Dispose ()
+               {
+               }
+
+               public bool Remove (string name)
+               {
+                       for (int i = 0; i < list.Count; i++)
+                               if (list [i].Key == name) {
+                                       list.RemoveAt (i);
+                                       return true;
+                               }
+                       return false;
+               }
+
+               public bool TryGetValue (string name, out object value)
+               {
+                       for (int i = 0; i < list.Count; i++)
+                               if (list [i].Key == name) {
+                                       value = list [i].Value;
+                                       return true;
+                               }
+                       value = null;
+                       return false;
+               }
+
+               void ICollection<Pair>.Add (Pair pair)
+               {
+                       list.Add (pair);
+               }
+
+               bool ICollection<Pair>.Contains (Pair pair)
+               {
+                       return list.Contains (pair);
+               }
+
+               void ICollection<Pair>.CopyTo (Pair [] array, int index)
+               {
+                       list.CopyTo (array, index);
+               }
+
+               bool ICollection<Pair>.Remove (Pair pair)
+               {
+                       return list.Remove (pair);
+               }
+
+               IEnumerator<Pair> IEnumerable<Pair>.GetEnumerator ()
+               {
+                       return list.GetEnumerator ();
+               }
+
+               IEnumerator IEnumerable.GetEnumerator ()
+               {
+                       return (IEnumerator) ((IEnumerable<Pair>) this).GetEnumerator ();
+               }
+
+               class ParameterKeyCollection : ICollection<string>
+               {
+                       List<Pair> source;
+
+                       public ParameterKeyCollection (List<Pair> source)
+                       {
+                               this.source = source;
+                       }
+
+                       public int Count {
+                               get { return source.Count; }
+                       }
+
+                       public bool IsReadOnly {
+                               get { return true; }
+                       }
+
+                       public void Add (string item)
+                       {
+                               throw new InvalidOperationException ();
+                       }
+
+                       public void Clear ()
+                       {
+                               throw new InvalidOperationException ();
+                       }
+
+                       public bool Contains (string item)
+                       {
+                               for (int i = 0; i < source.Count; i++)
+                                       if (source [i].Key == item)
+                                               return true;
+                               return false;
+                       }
+
+                       public void CopyTo (string [] array, int index)
+                       {
+                               for (int i = 0; i < source.Count; i++)
+                                       array [index + i] = source [i].Key;
+                       }
+
+                       public IEnumerator<string> GetEnumerator ()
+                       {
+                               foreach (Pair p in source)
+                                       yield return p.Key;
+                       }
+
+                       IEnumerator IEnumerable.GetEnumerator ()
+                       {
+                               foreach (Pair p in source)
+                                       yield return p.Key;
+                       }
+
+                       public bool Remove (string item)
+                       {
+                               throw new InvalidOperationException ();
+                       }
+               }
+
+               class ParameterValueCollection : ICollection<object>
+               {
+                       List<Pair> source;
+
+                       public ParameterValueCollection (List<Pair> source)
+                       {
+                               this.source = source;
+                       }
+
+                       public int Count {
+                               get { return source.Count; }
+                       }
+
+                       public bool IsReadOnly {
+                               get { return true; }
+                       }
+
+                       public void Add (object item)
+                       {
+                               throw new InvalidOperationException ();
+                       }
+
+                       public void Clear ()
+                       {
+                               throw new InvalidOperationException ();
+                       }
+
+                       public bool Contains (object item)
+                       {
+                               for (int i = 0; i < source.Count; i++)
+                                       if (source [i].Value == item)
+                                               return true;
+                               return false;
+                       }
+
+                       public void CopyTo (object [] array, int index)
+                       {
+                               for (int i = 0; i < source.Count; i++)
+                                       array [index + i] = source [i].Value;
+                       }
+
+                       public IEnumerator<object> GetEnumerator ()
+                       {
+                               foreach (Pair p in source)
+                                       yield return p.Value;
+                       }
+
+                       IEnumerator IEnumerable.GetEnumerator ()
+                       {
+                               foreach (Pair p in source)
+                                       yield return p.Key;
+                       }
+
+                       public bool Remove (object item)
+                       {
+                               throw new InvalidOperationException ();
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageSecurityBindingSupport.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageSecurityBindingSupport.cs
new file mode 100644 (file)
index 0000000..089b608
--- /dev/null
@@ -0,0 +1,605 @@
+//
+// MessageSecurityBindingSupport.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Net.Security;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Channels
+{
+       internal class SupportingTokenInfo
+       {
+               public SupportingTokenInfo (SecurityToken token,
+                       SecurityTokenAttachmentMode mode,
+                       bool isOptional)
+               {
+                       Token = token;
+                       Mode = mode;
+                       IsOptional = isOptional;
+               }
+
+               public SecurityToken Token;
+               public SecurityTokenAttachmentMode Mode;
+               public bool IsOptional;
+               public EncryptedData Encrypted;
+       }
+
+       internal class SupportingTokenInfoCollection : Collection<SupportingTokenInfo>
+       {
+               protected override void InsertItem (int index, SupportingTokenInfo item)
+               {
+                       foreach (SupportingTokenInfo i in this)
+                               if (i.Token.GetType () == item.Token.GetType ())
+                                       throw new ArgumentException (String.Format ("Supporting tokens do not allow multiple SecurityTokens of the same type: {0}", i.Token.GetType ()));
+                       base.InsertItem (index, item);
+               }
+       }
+
+       internal abstract class MessageSecurityBindingSupport
+       {
+               SecurityTokenManager manager;
+               ChannelProtectionRequirements requirements;
+               SecurityTokenSerializer serializer;
+               SecurityCapabilities element_support;
+
+               // only filled at prepared state.
+               SecurityTokenAuthenticator authenticator;
+               SecurityTokenResolver auth_token_resolver;
+
+               protected MessageSecurityBindingSupport (
+                       SecurityCapabilities elementSupport,
+                       SecurityTokenManager manager,
+                       ChannelProtectionRequirements requirements)
+               {
+                       element_support = elementSupport;
+                       Initialize (manager, requirements);
+               }
+
+               public void Initialize (SecurityTokenManager manager,
+                       ChannelProtectionRequirements requirements)
+               {
+                       this.manager = manager;
+                       if (requirements == null)
+                               requirements = new ChannelProtectionRequirements ();
+                       this.requirements = requirements;
+               }
+
+               public abstract IDefaultCommunicationTimeouts Timeouts { get; }
+
+               public ChannelProtectionRequirements ChannelRequirements {
+                       get { return requirements; }
+               }
+
+               public SecurityTokenManager SecurityTokenManager {
+                       get { return manager; }
+               }
+
+               public SecurityTokenSerializer TokenSerializer {
+                       get {
+                               if (serializer == null)
+                                       serializer = manager.CreateSecurityTokenSerializer (Element.MessageSecurityVersion.SecurityTokenVersion);
+                               return serializer;
+                       }
+               }
+
+               public SecurityTokenAuthenticator TokenAuthenticator {
+                       get { return authenticator; }
+               }
+
+               public SecurityTokenResolver OutOfBandTokenResolver {
+                       get { return auth_token_resolver; }
+               }
+
+               public abstract SecurityToken EncryptionToken { get; }
+
+               public abstract SecurityToken SigningToken { get; }
+
+               #region element_support
+
+               public SecurityBindingElement Element {
+                       get { return element_support.Element; }
+               }
+
+               public bool AllowSerializedSigningTokenOnReply {
+                       get { return element_support.AllowSerializedSigningTokenOnReply; }
+               }
+
+               public MessageProtectionOrder MessageProtectionOrder { 
+                       get { return element_support.MessageProtectionOrder; }
+               }
+
+               public SecurityTokenParameters InitiatorParameters { 
+                       get { return element_support.InitiatorParameters; }
+               }
+
+               public SecurityTokenParameters RecipientParameters { 
+                       get { return element_support.RecipientParameters; }
+               }
+
+               public bool RequireSignatureConfirmation {
+                       get { return element_support.RequireSignatureConfirmation; }
+               }
+
+               public string DefaultSignatureAlgorithm {
+                       get { return element_support.DefaultSignatureAlgorithm; }
+               }
+
+               public string DefaultKeyWrapAlgorithm {
+                       get { return element_support.DefaultKeyWrapAlgorithm; }
+               }
+
+               #endregion
+
+               public SecurityTokenProvider CreateTokenProvider (SecurityTokenRequirement requirement)
+               {
+                       return manager.CreateSecurityTokenProvider (requirement);
+               }
+
+               public abstract SecurityTokenAuthenticator CreateTokenAuthenticator (SecurityTokenParameters p, out SecurityTokenResolver resolver);
+
+               protected void PrepareAuthenticator ()
+               {
+                       authenticator = CreateTokenAuthenticator (RecipientParameters, out auth_token_resolver);
+               }
+
+               protected void InitializeRequirement (SecurityTokenParameters p, SecurityTokenRequirement r)
+               {
+                       p.CallInitializeSecurityTokenRequirement (r);
+
+                       // r.Properties [ChannelParametersCollectionProperty] =
+                       // r.Properties [ReqType.EndpointFilterTableProperty] =
+                       // r.Properties [ReqType.HttpAuthenticationSchemeProperty] =
+                       // r.Properties [ReqType.IsOutOfBandTokenProperty] =
+                       // r.Properties [ReqType.IssuerAddressProperty] =
+                       // r.Properties [ReqType.MessageDirectionProperty] = 
+                       r.Properties [ReqType.MessageSecurityVersionProperty] = Element.MessageSecurityVersion.SecurityTokenVersion;
+                       r.Properties [ReqType.SecurityAlgorithmSuiteProperty] = Element.DefaultAlgorithmSuite;
+                       r.Properties [ReqType.SecurityBindingElementProperty] = Element;
+                       // r.Properties [ReqType.SupportingTokenAttachmentModeProperty] =
+                       // r.TransportScheme =
+               }
+
+               public void Release ()
+               {
+                       ReleaseCore ();
+
+                       authenticator = null;
+               }
+
+               protected abstract void ReleaseCore ();
+
+               public SupportingTokenInfoCollection CollectSupportingTokens (string action)
+               {
+                       SupportingTokenInfoCollection tokens =
+                               new SupportingTokenInfoCollection ();
+
+                       SupportingTokenParameters supp;
+
+                       CollectSupportingTokensCore (tokens, Element.EndpointSupportingTokenParameters, true);
+                       if (Element.OperationSupportingTokenParameters.TryGetValue (action, out supp))
+                               CollectSupportingTokensCore (tokens, supp, true);
+                       CollectSupportingTokensCore (tokens, Element.OptionalEndpointSupportingTokenParameters, false);
+                       if (Element.OptionalOperationSupportingTokenParameters.TryGetValue (action, out supp))
+                               CollectSupportingTokensCore (tokens, supp, false);
+
+                       return tokens;
+               }
+
+               void CollectSupportingTokensCore (
+                       SupportingTokenInfoCollection l,
+                       SupportingTokenParameters s,
+                       bool required)
+               {
+                       foreach (SecurityTokenParameters p in s.Signed)
+                               l.Add (new SupportingTokenInfo (GetSigningToken (p), SecurityTokenAttachmentMode.Signed, required));
+                       foreach (SecurityTokenParameters p in s.Endorsing)
+                               l.Add (new SupportingTokenInfo (GetSigningToken (p), SecurityTokenAttachmentMode.Endorsing, required));
+                       foreach (SecurityTokenParameters p in s.SignedEndorsing)
+                               l.Add (new SupportingTokenInfo (GetSigningToken (p), SecurityTokenAttachmentMode.SignedEndorsing, required));
+                       foreach (SecurityTokenParameters p in s.SignedEncrypted)
+                               l.Add (new SupportingTokenInfo (GetSigningToken (p), SecurityTokenAttachmentMode.SignedEncrypted, required));
+               }
+
+               SecurityToken GetSigningToken (SecurityTokenParameters p)
+               {
+                       return GetToken (CreateRequirement (), p, SecurityKeyUsage.Signature);
+               }
+
+               SecurityToken GetExchangeToken (SecurityTokenParameters p)
+               {
+                       return GetToken (CreateRequirement (), p, SecurityKeyUsage.Exchange);
+               }
+
+               public SecurityToken GetToken (SecurityTokenRequirement requirement, SecurityTokenParameters targetParams, SecurityKeyUsage usage)
+               {
+                       requirement.KeyUsage = usage;
+                       requirement.Properties [ReqType.SecurityBindingElementProperty] = Element;
+                       requirement.Properties [ReqType.MessageSecurityVersionProperty] =
+                               Element.MessageSecurityVersion.SecurityTokenVersion;
+
+                       InitializeRequirement (targetParams, requirement);
+
+                       SecurityTokenProvider provider =
+                               CreateTokenProvider (requirement);
+                       ICommunicationObject obj = provider as ICommunicationObject;
+                       try {
+                               if (obj != null)
+                                       obj.Open (Timeouts.OpenTimeout);
+                               return provider.GetToken (Timeouts.SendTimeout);
+                       } finally {
+                               if (obj != null && obj.State == CommunicationState.Opened)
+                                       obj.Close ();
+                       }
+               }
+               
+               public abstract SecurityTokenRequirement CreateRequirement ();
+       }
+
+       internal class InitiatorMessageSecurityBindingSupport : MessageSecurityBindingSupport
+       {
+               ChannelFactoryBase factory;
+               EndpointAddress message_to;
+               SecurityToken encryption_token;
+               SecurityToken signing_token;
+
+               public InitiatorMessageSecurityBindingSupport (
+                       SecurityCapabilities elementSupport,
+                       SecurityTokenManager manager,
+                       ChannelProtectionRequirements requirements)
+                       : base (elementSupport, manager, requirements)
+               {
+               }
+
+               public override IDefaultCommunicationTimeouts Timeouts {
+                       get { return factory; }
+               }
+
+               public void Prepare (ChannelFactoryBase factory, EndpointAddress address)
+               {
+                       this.factory = factory;
+                       this.message_to = address;
+
+                       PrepareAuthenticator ();
+
+                       // This check is almost extra, though it is needed
+                       // to check correct signing token existence.
+                       if (EncryptionToken == null)
+                               throw new Exception ("INTERNAL ERROR");
+               }
+
+               public override SecurityToken EncryptionToken {
+                       get {
+                               if (encryption_token == null) {
+                                       SecurityTokenRequirement r = CreateRequirement ();
+                                       r.Properties [ReqType.MessageDirectionProperty] = MessageDirection.Input;
+                                       InitializeRequirement (RecipientParameters, r);
+                                       encryption_token = GetToken (r, RecipientParameters, SecurityKeyUsage.Exchange);
+                               }
+                               return encryption_token;
+                       }
+               }
+
+               public override SecurityToken SigningToken {
+                       get {
+                               if (signing_token == null) {
+                                       SecurityTokenRequirement r = CreateRequirement ();
+                                       r.Properties [ReqType.MessageDirectionProperty] = MessageDirection.Input;
+                                       InitializeRequirement (InitiatorParameters, r);
+                                       signing_token = GetToken (r, InitiatorParameters, SecurityKeyUsage.Signature);
+                               }
+                               return signing_token;
+                       }
+               }
+
+               protected override void ReleaseCore ()
+               {
+                       this.factory = null;
+                       this.message_to = null;
+
+                       IDisposable disposable = signing_token as IDisposable;
+                       if (disposable != null)
+                               disposable.Dispose ();
+                       signing_token = null;
+
+                       disposable = encryption_token as IDisposable;
+                       if (disposable != null)
+                               disposable.Dispose ();
+                       encryption_token = null;
+               }
+
+               public override SecurityTokenRequirement CreateRequirement ()
+               {
+                       SecurityTokenRequirement r = new InitiatorServiceModelSecurityTokenRequirement ();
+//                     r.Properties [ReqType.IssuerAddressProperty] = message_to;
+                       r.Properties [ReqType.TargetAddressProperty] = message_to;
+                       // FIXME: set Via
+                       return r;
+               }
+
+               public override SecurityTokenAuthenticator CreateTokenAuthenticator (SecurityTokenParameters p, out SecurityTokenResolver resolver)
+               {
+                       resolver = null;
+                       // This check might be almost extra, though it is
+                       // needed to check correct signing token existence.
+                       //
+                       // Not sure if it is limited to this condition, but
+                       // Ssl parameters do not support token provider and
+                       // still do not fail. X509 parameters do fail.
+                       if (!InitiatorParameters.InternalSupportsClientAuthentication)
+                               return null;
+
+                       SecurityTokenRequirement r = CreateRequirement ();
+                       r.Properties [ReqType.MessageDirectionProperty] = MessageDirection.Output;
+                       InitializeRequirement (p, r);
+                       return SecurityTokenManager.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+       }
+
+       class RecipientMessageSecurityBindingSupport : MessageSecurityBindingSupport
+       {
+               ChannelListenerBase listener;
+               SecurityToken encryption_token;
+               SecurityToken signing_token;
+
+               public RecipientMessageSecurityBindingSupport (
+                       SecurityCapabilities elementSupport,
+                       SecurityTokenManager manager,
+                       ChannelProtectionRequirements requirements)
+                       : base (elementSupport, manager, requirements)
+               {
+               }
+
+               public override IDefaultCommunicationTimeouts Timeouts {
+                       get { return listener; }
+               }
+
+               public void Prepare (ChannelListenerBase listener)
+               {
+                       this.listener = listener;
+
+                       PrepareAuthenticator ();
+
+                       // This check is almost extra, though it is needed
+                       // to check correct signing token existence.
+                       //
+                       // Not sure if it is limited to this condition, but
+                       // Ssl parameters do not support token provider and
+                       // still do not fail. X509 parameters do fail.
+                       //
+                       // FIXME: as AsymmetricSecurityBindingElementTest
+                       // .ServiceRecipientHasNoKeys() implies, it should be
+                       // the recipient's parameters that is used. However
+                       // such changes will break some of existing tests...
+                       if (InitiatorParameters.InternalHasAsymmetricKey &&
+                           EncryptionToken == null)
+                               throw new Exception ("INTERNAL ERROR");
+               }
+
+               public override SecurityToken EncryptionToken {
+                       get {
+                               if (encryption_token == null) {
+                                       SecurityTokenRequirement r = CreateRequirement ();
+                                       r.Properties [ReqType.MessageDirectionProperty] = MessageDirection.Output;
+                                       encryption_token = GetToken (r, InitiatorParameters, SecurityKeyUsage.Exchange);
+                               }
+                               return encryption_token;
+                       }
+               }
+
+               public override SecurityToken SigningToken {
+                       get {
+                               if (signing_token == null) {
+                                       SecurityTokenRequirement r = CreateRequirement ();
+                                       r.Properties [ReqType.MessageDirectionProperty] = MessageDirection.Input;
+                                       InitializeRequirement (RecipientParameters, r);
+                                       signing_token = GetToken (r, RecipientParameters, SecurityKeyUsage.Signature);
+                               }
+                               return signing_token;
+                       }
+               }
+
+               protected override void ReleaseCore ()
+               {
+                       this.listener = null;
+
+                       IDisposable disposable = signing_token as IDisposable;
+                       if (disposable != null)
+                               disposable.Dispose ();
+                       signing_token = null;
+
+                       disposable = encryption_token as IDisposable;
+                       if (disposable != null)
+                               disposable.Dispose ();
+                       encryption_token = null;
+               }
+
+               public override SecurityTokenRequirement CreateRequirement ()
+               {
+                       SecurityTokenRequirement requirement =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       requirement.Properties [ReqType.ListenUriProperty] = listener.Uri;
+                       return requirement;
+               }
+
+               public override SecurityTokenAuthenticator CreateTokenAuthenticator (SecurityTokenParameters p, out SecurityTokenResolver resolver)
+               {
+                       resolver = null;
+                       // This check might be almost extra, though it is
+                       // needed to check correct signing token existence.
+                       //
+                       // Not sure if it is limited to this condition, but
+                       // Ssl parameters do not support token provider and
+                       // still do not fail. X509 parameters do fail.
+                       if (!RecipientParameters.InternalSupportsServerAuthentication)
+                               return null;
+
+                       SecurityTokenRequirement r = CreateRequirement ();
+                       r.Properties [ReqType.MessageDirectionProperty] = MessageDirection.Input;
+                       InitializeRequirement (p, r);
+                       return SecurityTokenManager.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+       }
+
+       internal abstract class SecurityCapabilities
+               : ISecurityCapabilities
+       {
+               public abstract SecurityBindingElement Element { get; }
+
+               public abstract bool AllowSerializedSigningTokenOnReply { get; }
+
+               public abstract MessageProtectionOrder MessageProtectionOrder { get; }
+
+               public abstract SecurityTokenParameters InitiatorParameters { get; }
+
+               public abstract SecurityTokenParameters RecipientParameters { get; }
+
+               public abstract bool RequireSignatureConfirmation { get; }
+
+               public abstract string DefaultKeyWrapAlgorithm { get; }
+
+               public abstract string DefaultSignatureAlgorithm { get; }
+
+
+               // ISecurityCapabilities
+               // FIXME: implement correctly
+               public ProtectionLevel SupportedRequestProtectionLevel {
+                       get { return ProtectionLevel.EncryptAndSign; }
+               }
+
+               public ProtectionLevel SupportedResponseProtectionLevel {
+                       get { return ProtectionLevel.EncryptAndSign; }
+               }
+
+               public bool SupportsClientAuthentication {
+                       get { return InitiatorParameters != null ? InitiatorParameters.InternalSupportsClientAuthentication : false; }
+               }
+
+               public bool SupportsClientWindowsIdentity {
+                       get { return InitiatorParameters != null ? InitiatorParameters.InternalSupportsClientWindowsIdentity : false; }
+               }
+
+               public bool SupportsServerAuthentication {
+                       get { return RecipientParameters != null ? RecipientParameters.InternalSupportsServerAuthentication : false; }
+               }
+       }
+
+       internal class SymmetricSecurityCapabilities : SecurityCapabilities
+       {
+               SymmetricSecurityBindingElement element;
+
+               public SymmetricSecurityCapabilities (
+                       SymmetricSecurityBindingElement element)
+               {
+                       this.element = element;
+               }
+
+               public override SecurityBindingElement Element {
+                       get { return element; }
+               }
+
+               // FIXME: const true or false
+               public override bool AllowSerializedSigningTokenOnReply {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public override MessageProtectionOrder MessageProtectionOrder {
+                       get { return element.MessageProtectionOrder; }
+               }
+
+               public override SecurityTokenParameters InitiatorParameters {
+                       get { return element.ProtectionTokenParameters; }
+               }
+
+               public override SecurityTokenParameters RecipientParameters {
+                       get { return element.ProtectionTokenParameters; }
+               }
+
+               public override bool RequireSignatureConfirmation {
+                       get { return element.RequireSignatureConfirmation; }
+               }
+
+               public override string DefaultSignatureAlgorithm {
+                       get { return element.DefaultAlgorithmSuite.DefaultSymmetricSignatureAlgorithm; }
+               }
+
+               public override string DefaultKeyWrapAlgorithm {
+                       get { return element.DefaultAlgorithmSuite.DefaultSymmetricKeyWrapAlgorithm; }
+               }
+       }
+
+       internal class AsymmetricSecurityCapabilities : SecurityCapabilities
+       {
+               AsymmetricSecurityBindingElement element;
+
+               public AsymmetricSecurityCapabilities (
+                       AsymmetricSecurityBindingElement element)
+               {
+                       this.element = element;
+               }
+
+               public override bool AllowSerializedSigningTokenOnReply {
+                       get { return element.AllowSerializedSigningTokenOnReply; }
+               }
+
+               public override SecurityBindingElement Element {
+                       get { return element; }
+               }
+
+               public override MessageProtectionOrder MessageProtectionOrder {
+                       get { return element.MessageProtectionOrder; }
+               }
+
+               public override SecurityTokenParameters InitiatorParameters {
+                       get { return element.InitiatorTokenParameters; }
+               }
+
+               public override SecurityTokenParameters RecipientParameters {
+                       get { return element.RecipientTokenParameters; }
+               }
+
+               public override bool RequireSignatureConfirmation {
+                       get { return element.RequireSignatureConfirmation; }
+               }
+
+               public override string DefaultSignatureAlgorithm {
+                       get { return element.DefaultAlgorithmSuite.DefaultAsymmetricSignatureAlgorithm; }
+               }
+
+               public override string DefaultKeyWrapAlgorithm {
+                       get { return element.DefaultAlgorithmSuite.DefaultAsymmetricKeyWrapAlgorithm; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageVersion.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageVersion.cs
new file mode 100644 (file)
index 0000000..9a3bc36
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// System.ServiceModel.MessageVersion.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels {
+
+       public sealed class MessageVersion
+       {
+               EnvelopeVersion envelope;
+               AddressingVersion addressing;
+
+               MessageVersion (EnvelopeVersion envelope, AddressingVersion addressing)
+               {
+                       this.envelope = envelope;
+                       this.addressing = addressing;
+               }
+               
+               public static MessageVersion CreateVersion (EnvelopeVersion envelope_version)
+               {
+                       return CreateVersion (envelope_version,
+                               AddressingVersion.WSAddressing10);
+               }
+
+               public static MessageVersion CreateVersion (EnvelopeVersion envelope_version,
+                                                           AddressingVersion addressing_version)
+               {
+                       return new MessageVersion (envelope_version, addressing_version);
+               }
+
+               public override bool Equals (object value)
+               {
+                       MessageVersion other = value as MessageVersion;
+
+                       if (other == null)
+                               return false;
+
+                       return (other.Addressing == this.Addressing) && (other.Envelope == this.Envelope);
+               }
+
+               public override int GetHashCode ()
+               {
+                       return addressing.GetHashCode () + envelope.GetHashCode ();
+               }
+
+               public override string ToString ()
+               {
+                       return envelope.ToString () + " " +  addressing.ToString ();
+               }
+
+               public AddressingVersion Addressing { 
+                       get { return addressing; }
+               }
+
+               public static MessageVersion Default { 
+                       get { return CreateVersion (EnvelopeVersion.Soap12); }
+               }
+
+               public EnvelopeVersion Envelope {
+                       get { return envelope; }
+               }
+
+               public static MessageVersion None { 
+                       get { return CreateVersion (EnvelopeVersion.None, AddressingVersion.None); }
+               }
+
+               public static MessageVersion Soap11 {
+                       get { return CreateVersion (EnvelopeVersion.Soap11, AddressingVersion.None); }
+               }
+
+               public static MessageVersion Soap12 {
+                       get { return CreateVersion (EnvelopeVersion.Soap12, AddressingVersion.None); }
+               }
+
+               public static MessageVersion Soap11WSAddressing10 {
+                       get { return CreateVersion (EnvelopeVersion.Soap11, AddressingVersion.WSAddressing10); }
+               }
+
+               public static MessageVersion Soap11WSAddressingAugust2004 {
+                       get { return CreateVersion (EnvelopeVersion.Soap11, AddressingVersion.WSAddressingAugust2004); }
+               }
+
+               public static MessageVersion Soap12WSAddressing10 {
+                       get { return CreateVersion (EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10); }
+               }
+
+               public static MessageVersion Soap12WSAddressingAugust2004 {
+                       get { return CreateVersion (EnvelopeVersion.Soap12, AddressingVersion.WSAddressingAugust2004); }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqBindingElementBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqBindingElementBase.cs
new file mode 100644 (file)
index 0000000..5503c1a
--- /dev/null
@@ -0,0 +1,140 @@
+//
+// MsmqBindingElementBase.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class MsmqBindingElementBase : TransportBindingElement,
+               ITransactedBindingElement, IPolicyExportExtension, IWsdlExportExtension
+       {
+               Uri custom_dead_letter_queue;
+               DeadLetterQueue dead_letter_queue = DeadLetterQueue.System;
+               bool durable = true, exactly_once = true, tx_enabled, use_msmq_trace, use_source_journal;
+               int max_retry_cycles = 2, receive_retry_count = 5;
+               ReceiveErrorHandling receive_error_handling;
+               TimeSpan retry_cycle_delay = TimeSpan.FromMinutes (30), ttl = TimeSpan.FromDays (1);
+               MsmqTransportSecurity transport_security =
+                       new MsmqTransportSecurity ();
+
+               internal MsmqBindingElementBase ()
+               {
+               }
+
+               public Uri CustomDeadLetterQueue {
+                       get { return custom_dead_letter_queue; }
+                       set { custom_dead_letter_queue = value; }
+               }
+
+               public DeadLetterQueue DeadLetterQueue {
+                       get { return dead_letter_queue; }
+                       set { dead_letter_queue = value; }
+               }
+
+               public bool Durable {
+                       get { return durable; }
+                       set { durable = value; }
+               }
+
+               public bool ExactlyOnce {
+                       get { return exactly_once; }
+                       set { exactly_once = value; }
+               }
+
+               public int MaxRetryCycles {
+                       get { return max_retry_cycles; }
+                       set { max_retry_cycles = value; }
+               }
+
+               public MsmqTransportSecurity MsmqTransportSecurity {
+                       get { return transport_security; }
+               }
+
+               public ReceiveErrorHandling ReceiveErrorHandling {
+                       get { return receive_error_handling; }
+                       set { receive_error_handling = value; }
+               }
+
+               public int ReceiveRetryCount {
+                       get { return receive_retry_count; }
+                       set { receive_retry_count = value; }
+               }
+
+               public TimeSpan RetryCycleDelay {
+                       get { return retry_cycle_delay; }
+                       set { retry_cycle_delay = value; }
+               }
+
+               public TimeSpan TimeToLive {
+                       get { return ttl; }
+                       set { ttl = value; }
+               }
+
+               public bool TransactedReceiveEnabled {
+                       get { return tx_enabled; }
+               }
+
+               public bool UseMsmqTracing {
+                       get { return use_msmq_trace; }
+                       set { use_msmq_trace = value; }
+               }
+
+               public bool UseSourceJournal {
+                       get { return use_source_journal; }
+                       set { use_source_journal = value; }
+               }
+
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       if (typeof (T) is IBindingDeliveryCapabilities)
+                               throw new NotImplementedException ();
+                       if (typeof (T) is ISecurityCapabilities)
+                               throw new NotImplementedException ();
+                       return base.GetProperty<T> (context);
+               }
+
+               [MonoTODO]
+               void IPolicyExportExtension.ExportPolicy (MetadataExporter exporter, PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IWsdlExportExtension.ExportContract (WsdlExporter exporter, WsdlContractConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IWsdlExportExtension.ExportEndpoint (WsdlExporter exporter, WsdlEndpointConversionContext endpointContext)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqChannelFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqChannelFactory.cs
new file mode 100644 (file)
index 0000000..9b964a1
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// MsmqChannelFactory.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.Text;
+
+namespace System.ServiceModel.Channels
+{
+       internal class MsmqChannelFactory<TChannel> : ChannelFactoryBase<TChannel>
+       {
+               // not sure if they are required.
+               MsmqTransportBindingElement source;
+               MessageEncoder encoder;
+
+               public MsmqChannelFactory (MsmqTransportBindingElement source, BindingContext ctx)
+               {
+                       this.source = source;
+                       foreach (BindingElement be in ctx.RemainingBindingElements) {
+                               MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
+                               if (mbe != null) {
+                                       encoder = mbe.CreateMessageEncoderFactory ().Encoder;
+                                       break;
+                               }
+                       }
+                       if (encoder == null)
+                               encoder = new BinaryMessageEncoder ();
+               }
+
+               public MessageEncoder MessageEncoder {
+                       get { return encoder; }
+               }
+
+               protected override TChannel OnCreateChannel (
+                       EndpointAddress address, Uri via)
+               {
+                       ThrowIfDisposedOrNotOpen ();
+
+                       if (source.Scheme != address.Uri.Scheme)
+                               throw new ArgumentException (String.Format ("Argument EndpointAddress has unsupported URI scheme: {0}", address.Uri.Scheme));
+
+                       Type t = typeof (TChannel);
+                       if (t == typeof (IOutputChannel))
+                               return (TChannel) (object) new MsmqOutputChannel ((MsmqChannelFactory<IOutputChannel>) (object) this, address, via);
+                       else if (t == typeof (IOutputSessionChannel))
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       throw new InvalidOperationException (String.Format ("channel type {0} is not supported.", typeof (TChannel).Name));
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqChannelListener.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqChannelListener.cs
new file mode 100644 (file)
index 0000000..f6ac287
--- /dev/null
@@ -0,0 +1,179 @@
+//
+// MsmqChannelListener.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Messaging;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.Text;
+
+namespace System.ServiceModel.Channels
+{
+       internal class MsmqChannelListener<TChannel> : ChannelListenerBase<TChannel>
+               where TChannel : class, IChannel
+       {
+               MsmqTransportBindingElement source;
+               BindingContext context;
+               Uri listen_uri;
+               MessageQueue queue;
+               List<IChannel> channels = new List<IChannel> ();
+               MessageEncoder encoder;
+
+               public MsmqChannelListener (MsmqTransportBindingElement source,
+                       BindingContext context)
+                       : base (context.Binding)
+               {
+                       if (context.ListenUriMode == ListenUriMode.Explicit)
+                               listen_uri = new Uri (context.ListenUriBaseAddress, context.ListenUriRelativeAddress);
+                       else
+                               // FIXME: consider ListenUriMode.Unique
+                               throw new NotImplementedException ();
+
+                       foreach (BindingElement be in context.RemainingBindingElements) {
+                               MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
+                               if (mbe != null) {
+                                       encoder = mbe.CreateMessageEncoderFactory ().Encoder;
+                                       break;
+                               }
+                       }
+                       if (encoder == null)
+                               encoder = new BinaryMessageEncoder ();
+               }
+
+               public MessageQueue Queue {
+                       get { return queue; }
+               }
+
+               public MessageEncoder MessageEncoder {
+                       get { return encoder; }
+               }
+
+               public override Uri Uri {
+                       get { return listen_uri; }
+               }
+
+               protected override TChannel OnAcceptChannel (TimeSpan timeout)
+               {
+                       TChannel ch = PopulateChannel (timeout);
+                       channels.Add (ch);
+                       return ch;
+               }
+
+               TChannel PopulateChannel (TimeSpan timeout)
+               {
+                       if (typeof (TChannel) == typeof (IInputChannel)) {
+                               return (TChannel) (object) new MsmqInputChannel (
+                                       (MsmqChannelListener<IInputChannel>) (object) this, timeout);
+                       }
+
+                       // FIXME: implement more
+
+                       throw new NotImplementedException ();
+               }
+
+               protected override IAsyncResult OnBeginAcceptChannel (
+                       TimeSpan timeout, AsyncCallback callback,
+                       object asyncState)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override TChannel OnEndAcceptChannel (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override IAsyncResult OnBeginWaitForChannel (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override bool OnEndWaitForChannel (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override bool OnWaitForChannel (TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               void StartListening (TimeSpan timeout)
+               {
+                       if (queue != null)
+                               throw new InvalidOperationException ("This listener is already waiting for connection.");
+
+                       queue = new MessageQueue (listen_uri.GetLeftPart (UriPartial.Scheme));
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       StartListening (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       // FIXME: somewhere to use timeout?
+                       if (queue == null)
+                               return;
+                       queue.Dispose ();
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO ("find out what to do here.")]
+               protected override void OnAbort ()
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqInputChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqInputChannel.cs
new file mode 100644 (file)
index 0000000..bc19c50
--- /dev/null
@@ -0,0 +1,132 @@
+//
+// MsmqInputChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Messaging;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       internal class MsmqInputChannel : InputChannelBase
+       {
+               MsmqChannelListener<IInputChannel> listener;
+               EndpointAddress local_address;
+
+               // FIXME: handle timeout
+               public MsmqInputChannel (MsmqChannelListener<IInputChannel> listener, TimeSpan timeout)
+                       : base (listener)
+               {
+                       this.listener = listener;
+               }
+
+               // FIXME: how is it set?
+               public override EndpointAddress LocalAddress {
+                       get { return local_address; }
+               }
+
+               public override IAsyncResult BeginReceive (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override IAsyncResult BeginTryReceive (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override IAsyncResult BeginWaitForMessage (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override Message EndReceive (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool EndTryReceive (IAsyncResult result, out Message message)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool EndWaitForMessage (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override Message Receive (TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool TryReceive (TimeSpan timeout, out Message message)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool WaitForMessage (TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               // ChannelBase
+
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       // nothing to do
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object sender)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object sender)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqMessageProperty.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqMessageProperty.cs
new file mode 100644 (file)
index 0000000..c49cd10
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// MsmqMessageProperty.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class MsmqMessageProperty
+       {
+               public const string Name = "MsmqMessageProperty";
+
+               [MonoTODO]
+               public static MsmqMessageProperty Get (Message message)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               int abort_count, move_count;
+               DeliveryFailure? failure;
+               DeliveryStatus? delivery_status;
+
+               internal MsmqMessageProperty ()
+               {
+               }
+
+               public int AbortCount {
+                       get { return abort_count; }
+               }
+
+               public int MoveCount {
+                       get { return move_count; }
+               }
+
+               public DeliveryFailure? DeliveryFailure {
+                       get { return failure; }
+               }
+
+               public DeliveryStatus? DeliveryStatus {
+                       get { return delivery_status; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqOutputChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqOutputChannel.cs
new file mode 100644 (file)
index 0000000..cc0173e
--- /dev/null
@@ -0,0 +1,200 @@
+//
+// MsmqOutputChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Messaging;
+using System.ServiceModel;
+using System.Threading;
+
+namespace System.ServiceModel.Channels
+{
+       internal class MsmqOutputChannel : OutputChannelBase
+       {
+               MsmqChannelFactory<IOutputChannel> source;
+               EndpointAddress address;
+               Uri via;
+               MessageQueue queue;
+
+               public MsmqOutputChannel (MsmqChannelFactory<IOutputChannel> factory,
+                       EndpointAddress address, Uri via)
+                       : base (factory)
+               {
+                       this.source = factory;
+                       this.address = address;
+                       this.via = via;
+               }
+
+               // IOutputChannel
+               public override EndpointAddress RemoteAddress {
+                       get { return address; }
+               }
+
+               public override Uri Via {
+                       get { return via; }
+               }
+
+               // Send
+
+               public override IAsyncResult BeginSend (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       ThrowIfDisposedOrNotOpen ();
+
+                       return new MsmqChannelOutputAsyncResult (this, message, timeout, callback, state);
+               }
+
+               public override void EndSend (IAsyncResult result)
+               {
+                       if (result == null)
+                               throw new ArgumentNullException ("result");
+                       MsmqChannelOutputAsyncResult r = result as MsmqChannelOutputAsyncResult;
+                       if (r == null)
+                               throw new InvalidOperationException ("Wrong IAsyncResult");
+                       r.WaitEnd ();
+               }
+
+               public override void Send (Message message, TimeSpan timeout)
+               {
+                       ThrowIfDisposedOrNotOpen ();
+
+                       MemoryStream ms = new MemoryStream ();
+                       source.MessageEncoder.WriteMessage (message, ms);
+
+                       queue.Send (ms);
+
+                       //throw new NotImplementedException ();
+               }
+
+               // Abort
+
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               // Close
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       if (queue != null)
+                               queue.Close ();
+                       queue = null;
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               // Open
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       // FIXME: is distination really like this?
+                       Uri destination = Via != null ? Via : RemoteAddress.Uri;
+
+                       queue = new MessageQueue (destination.GetLeftPart (UriPartial.Scheme));
+                       // FIXME: setup queue
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               class MsmqChannelOutputAsyncResult : IAsyncResult
+               {
+                       MsmqOutputChannel channel;
+                       Message message;
+                       TimeSpan timeout;
+                       AsyncCallback callback;
+                       object state;
+                       AutoResetEvent wait;
+                       bool done, waiting;
+                       Exception error;
+
+                       public MsmqChannelOutputAsyncResult (MsmqOutputChannel channel, Message message, TimeSpan timeout, AsyncCallback callback, object state)
+                       {
+                               this.channel = channel;
+                               this.message = message;
+                               this.timeout = timeout;
+                               this.callback = callback;
+                               this.state = state;
+
+                               wait = new AutoResetEvent (false);
+                               Thread t = new Thread (delegate () {
+                                       try {
+                                               channel.Send (message, timeout);
+                                               if (callback != null)
+                                                       callback (this);
+                                       } catch (Exception ex) {
+                                               error = ex;
+                                       } finally {
+                                               done = true;
+                                               wait.Set ();
+                                       }
+                               });
+                               t.Start ();
+                       }
+
+                       public WaitHandle AsyncWaitHandle {
+                               get { return wait; }
+                       }
+
+                       public object AsyncState {
+                               get { return state; }
+                       }
+
+                       public bool CompletedSynchronously {
+                               get { return done && !waiting; }
+                       }
+
+                       public bool IsCompleted {
+                               get { return done; }
+                       }
+
+                       public void WaitEnd ()
+                       {
+                               if (!done) {
+                                       waiting = true;
+                                       wait.WaitOne (timeout, true);
+                               }
+                               if (error != null)
+                                       throw error;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqTransportBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MsmqTransportBindingElement.cs
new file mode 100644 (file)
index 0000000..f8b0be4
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// ITransactedBindingElement.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class MsmqTransportBindingElement : MsmqBindingElementBase
+       {
+               int max_pool_size = 8;
+               QueueTransferProtocol queue_tr_protocol;
+               bool use_ad;
+
+               public MsmqTransportBindingElement ()
+               {
+               }
+
+               public int MaxPoolSize {
+                       get { return max_pool_size; }
+                       set { max_pool_size = value; }
+               }
+
+               public QueueTransferProtocol QueueTransferProtocol {
+                       get { return queue_tr_protocol; }
+                       set { queue_tr_protocol = value; }
+               }
+
+               public override string Scheme {
+                       get { return "net.msmq"; }
+               }
+
+               [MonoLimitation ("ActiveDirectory is windows-only solution")]
+               public bool UseActiveDirectory {
+                       get { return use_ad; }
+                       set { use_ad = value; }
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return (MsmqTransportBindingElement) MemberwiseClone ();
+               }
+
+               public override bool CanBuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       return  typeof (TChannel) == typeof (IOutputChannel) ||
+                               typeof (TChannel) == typeof (IOutputSessionChannel);
+               }
+
+               [MonoTODO]
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       if (typeof (TChannel) == typeof (IOutputChannel))
+                               return (IChannelFactory<TChannel>) new MsmqChannelFactory<IOutputChannel> (this, context);
+                       if (typeof (TChannel) == typeof (IOutputSessionChannel))
+                               return (IChannelFactory<TChannel>) new MsmqChannelFactory<IOutputChannel> (this, context);
+                       return base.BuildChannelFactory<TChannel> (context);
+               }
+
+               public override bool CanBuildChannelListener<TChannel> (BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       return  typeof (TChannel) == typeof (IInputChannel) ||
+                               typeof (TChannel) == typeof (IInputSessionChannel);
+               }
+
+               [MonoTODO]
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MtomMessageEncoder.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MtomMessageEncoder.cs
new file mode 100644 (file)
index 0000000..dd86e6c
--- /dev/null
@@ -0,0 +1,103 @@
+//
+// MtomMessageEncoder.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       internal class MtomMessageEncoder : MessageEncoder
+       {
+               Encoding encoding;
+               MessageVersion version;
+
+               public MtomMessageEncoder (MtomMessageEncoderFactory owner)
+               {
+                       version = owner.MessageVersion;
+                       encoding = owner.Owner.WriteEncoding;
+               }
+
+               public override string ContentType {
+                       get { return "multipart/related; type=application/xop+xml"; }
+               }
+
+               public override string MediaType {
+                       get { return "multipart/related"; }
+               }
+
+               public override MessageVersion MessageVersion {
+                       get { return version; }
+               }
+
+               [MonoTODO]
+               public override Message ReadMessage (ArraySegment<byte> buffer,
+                       BufferManager bufferManager, string contentType)
+               {
+                       // FIXME: where should bufferManager be used?
+                       // FIXME: no way to take maxSizeOfHeaders
+                       // FIXME: create proper quotas
+                       return Message.CreateMessage (
+                               XmlDictionaryReader.CreateMtomReader (buffer.Array, buffer.Offset, buffer.Count, encoding, new XmlDictionaryReaderQuotas ()),
+                               int.MaxValue,
+                               MessageVersion);
+               }
+
+               [MonoTODO]
+               public override Message ReadMessage (Stream stream,
+                       int maxSizeOfHeaders, string contentType)
+               {
+                       // FIXME: create proper quotas
+                       return Message.CreateMessage (
+                               XmlDictionaryReader.CreateMtomReader (
+                                       stream, encoding, new XmlDictionaryReaderQuotas ()),
+                               maxSizeOfHeaders,
+                               MessageVersion);
+               }
+
+               [MonoTODO]
+               public override void WriteMessage (Message message, Stream stream)
+               {
+                       VerifyMessageVersion (message);
+
+                       // FIXME: no way to acquire maxSizeInBytes and startInfo?
+                       message.WriteMessage (XmlDictionaryWriter.CreateMtomWriter (stream, encoding, int.MaxValue, null));
+               }
+
+               [MonoTODO]
+               public override ArraySegment<byte> WriteMessage (
+                       Message message, int maxMessageSize,
+                       BufferManager bufferManager, int messageOffset)
+               {
+                       VerifyMessageVersion (message);
+
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MtomMessageEncoderFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MtomMessageEncoderFactory.cs
new file mode 100644 (file)
index 0000000..38e4e03
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// MtomMessageEncoderFactory.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Text;
+
+namespace System.ServiceModel.Channels
+{
+       internal class MtomMessageEncoderFactory : MessageEncoderFactory
+       {
+               MtomMessageEncodingBindingElement owner;
+               MtomMessageEncoder encoder;
+
+               public MtomMessageEncoderFactory (
+                       MtomMessageEncodingBindingElement owner)
+               {
+                       this.owner = owner;
+                       encoder = new MtomMessageEncoder (this);
+               }
+
+               public MtomMessageEncodingBindingElement Owner {
+                       get { return owner; }
+               }
+
+               public override MessageEncoder Encoder {
+                       get { return encoder; }
+               }
+
+               public override MessageVersion MessageVersion {
+                       get { return owner.MessageVersion; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MtomMessageEncodingBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MtomMessageEncodingBindingElement.cs
new file mode 100644 (file)
index 0000000..657c0c1
--- /dev/null
@@ -0,0 +1,140 @@
+//
+// MtomMessageEncodingBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public sealed class MtomMessageEncodingBindingElement
+               : MessageEncodingBindingElement,
+                 IWsdlExportExtension, IPolicyExportExtension
+       {
+               MessageVersion version;
+               Encoding encoding;
+
+               public MtomMessageEncodingBindingElement ()
+                       : this (MessageVersion.Default, Encoding.UTF8)
+               {
+               }
+
+               public MtomMessageEncodingBindingElement (
+                       MessageVersion version, Encoding encoding)
+               {
+                       this.version = version;
+                       this.encoding = encoding;
+               }
+
+               public override MessageVersion MessageVersion {
+                       get { return version; }
+                       set { version = value; }
+               }
+
+               public Encoding WriteEncoding {
+                       get { return encoding; }
+                       set { encoding = value; }
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       context.RemainingBindingElements.Add (this);
+                       return base.BuildChannelFactory<TChannel> (context);
+               }
+
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       context.RemainingBindingElements.Add (this);
+                       return base.BuildChannelListener<TChannel> (context);
+               }
+
+               public override bool CanBuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       return context.CanBuildInnerChannelListener<TChannel> ();
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new MtomMessageEncodingBindingElement (
+                               version, encoding);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override MessageEncoderFactory
+                       CreateMessageEncoderFactory ()
+               {
+                       return new MtomMessageEncoderFactory (this);
+               }
+
+               [MonoTODO]
+               protected override void OnImportPolicy (XmlElement assertion,
+                       MessageVersion messageVersion,
+                       MetadataImporter exporter,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IWsdlExportExtension.ExportContract (WsdlExporter exporter,
+                       WsdlContractConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IWsdlExportExtension.ExportEndpoint (WsdlExporter exporter,
+                       WsdlEndpointConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void ExportPolicy (MetadataExporter exporter,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/NamedPipeConnectionPoolSettings.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/NamedPipeConnectionPoolSettings.cs
new file mode 100644 (file)
index 0000000..ea7c19b
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// NamedPipeConnectionPoolSettings.cs
+//
+// Authors:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2008 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class NamedPipeConnectionPoolSettings
+       {
+               internal NamedPipeConnectionPoolSettings ()
+               {
+               }
+
+               string group_name = "default";
+               TimeSpan idle_timeout = TimeSpan.FromSeconds (120);
+               int max_conn = 10;
+
+               internal void CopyPropertiesFrom (NamedPipeConnectionPoolSettings other)
+               {
+                       group_name = other.group_name;
+                       idle_timeout = other.idle_timeout;
+                       max_conn = other.max_conn;
+               }
+
+               [MonoTODO]
+               public string GroupName {
+                       get { return group_name; }
+                       set { group_name = value; }
+               }
+
+               [MonoTODO]
+               public TimeSpan IdleTimeout {
+                       get { return idle_timeout; }
+                       set { idle_timeout = value; }
+               }
+
+               [MonoTODO]
+               public int MaxOutboundConnectionsPerEndpoint {
+                       get { return max_conn; }
+                       set { max_conn = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/NamedPipetransportBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/NamedPipetransportBindingElement.cs
new file mode 100644 (file)
index 0000000..81644d3
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// NamedPipeTransportBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public class NamedPipeTransportBindingElement
+               : ConnectionOrientedTransportBindingElement
+       {
+               public NamedPipeTransportBindingElement ()
+               {
+               }
+
+               protected NamedPipeTransportBindingElement (
+                       NamedPipeTransportBindingElement other)
+                       : base (other)
+               {
+                       pool.CopyPropertiesFrom (other.pool);
+               }
+
+               NamedPipeConnectionPoolSettings pool = new NamedPipeConnectionPoolSettings ();
+
+               public NamedPipeConnectionPoolSettings ConnectionPoolSettings {
+                       get { return pool; }
+               }
+
+               public override string Scheme {
+                       get { return "net.pipe"; }
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new NamedPipeTransportBindingElement (this);
+               }
+
+               // FIXME: IT should not be required, but gmcs borks here.
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/OneWayBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/OneWayBindingElement.cs
new file mode 100644 (file)
index 0000000..ea747e1
--- /dev/null
@@ -0,0 +1,225 @@
+//
+// OneWayBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class OneWayBindingElement : BindingElement
+       {
+               public OneWayBindingElement ()
+               {
+                       pool = new ChannelPoolSettings ();
+               }
+
+               OneWayBindingElement (OneWayBindingElement other)
+               {
+                       pool = new ChannelPoolSettings (other.pool);
+               }
+
+               ChannelPoolSettings pool;
+
+               public ChannelPoolSettings ChannelPoolSettings {
+                       get { return pool; }
+               }
+
+               [MonoTODO ("It generates just pass-thru factory")]
+               public override IChannelFactory<TChannel>
+                       BuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       if (typeof (TChannel) == typeof (IOutputSessionChannel) ||
+                           typeof (TChannel) == typeof (IOutputChannel))
+                               return new OneWayChannelFactory<TChannel> (context.BuildInnerChannelFactory<TChannel> ());
+                       throw new ArgumentException (String.Format ("The requested channel type '{0}' is not supported by this binding element", typeof (TChannel)));
+               }
+
+               [MonoTODO ("It generates just pass-thru listener")]
+               public override IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       if (typeof (TChannel) == typeof (IInputSessionChannel) ||
+                           typeof (TChannel) == typeof (IInputChannel))
+                               return new OneWayChannelListener<TChannel> (context.BuildInnerChannelListener<TChannel> ());
+                       throw new ArgumentException (String.Format ("The requested channel type '{0}' is not supported by this binding element", typeof (TChannel)));
+               }
+
+               public override bool CanBuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       return typeof (TChannel) == typeof (IOutputSessionChannel) ||
+                               typeof (TChannel) == typeof (IOutputChannel);
+               }
+
+               public override bool CanBuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       return typeof (TChannel) == typeof (IInputSessionChannel) ||
+                               typeof (TChannel) == typeof (IInputChannel);
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new OneWayBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
+       class OneWayChannelFactory<TChannel> : ChannelFactoryBase<TChannel>
+       {
+               IChannelFactory<TChannel> inner;
+
+               public OneWayChannelFactory (IChannelFactory<TChannel> inner)
+               {
+                       this.inner = inner;
+               }
+
+               protected override TChannel OnCreateChannel (EndpointAddress address, Uri via)
+               {
+                       return inner.CreateChannel (address, via);
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       inner.Open (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginOpen (timeout, callback, state);
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       inner.EndOpen (result);
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       inner.Close (timeout);
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginClose (timeout, callback, state);
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       inner.EndClose (result);
+               }
+       }
+
+       class OneWayChannelListener<TChannel> : ChannelListenerBase<TChannel>
+               where TChannel : class, IChannel
+       {
+               IChannelListener<TChannel> inner;
+
+               public OneWayChannelListener (IChannelListener<TChannel> inner)
+               {
+                       this.inner = inner;
+               }
+
+               public override Uri Uri {
+                       get { return inner.Uri; }
+               }
+
+               protected override void OnAbort ()
+               {
+                       inner.Abort ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       inner.Open (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginOpen (timeout, callback, state);
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       inner.EndOpen (result);
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       inner.Close (timeout);
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginClose (timeout, callback, state);
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       inner.EndClose (result);
+               }
+
+               protected override bool OnWaitForChannel (TimeSpan timeout)
+               {
+                       return inner.WaitForChannel (timeout);
+               }
+
+               protected override IAsyncResult OnBeginWaitForChannel (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginWaitForChannel (timeout, callback, state);
+               }
+
+               protected override bool OnEndWaitForChannel (IAsyncResult result)
+               {
+                       return inner.EndWaitForChannel (result);
+               }
+
+               protected override TChannel OnAcceptChannel (TimeSpan timeout)
+               {
+                       return inner.AcceptChannel (timeout);
+               }
+
+               protected override IAsyncResult OnBeginAcceptChannel (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginAcceptChannel (timeout, callback, state);
+               }
+
+               protected override TChannel OnEndAcceptChannel (IAsyncResult result)
+               {
+                       return inner.EndAcceptChannel (result);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/OneWayBindingElementImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/OneWayBindingElementImporter.cs
new file mode 100644 (file)
index 0000000..1ff9c25
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// OneWayBindingElementImporter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class OneWayBindingElementImporter
+               : IPolicyImportExtension
+       {
+               [MonoTODO]
+               void IPolicyImportExtension.ImportPolicy (MetadataImporter importer, PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/OutputChannelBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/OutputChannelBase.cs
new file mode 100644 (file)
index 0000000..011db54
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// OutputChannelBase.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       internal abstract class OutputChannelBase : ChannelBase, IOutputChannel
+       {
+               ChannelFactoryBase channel_factory;
+
+               public OutputChannelBase (ChannelFactoryBase factory)
+                       : base (factory)
+               {
+                       this.channel_factory = factory;
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return channel_factory.DefaultCloseTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return channel_factory.DefaultOpenTimeout; }
+               }
+
+               // IOutputChannel
+               public abstract EndpointAddress RemoteAddress { get; }
+
+               public abstract Uri Via { get; }
+
+               public IAsyncResult BeginSend (Message message, AsyncCallback callback, object state)
+               {
+                       return BeginSend (message, channel_factory.DefaultSendTimeout, callback, state);
+               }
+
+               public abstract IAsyncResult BeginSend (Message message, TimeSpan timeout, AsyncCallback callback, object state);
+
+               public abstract void EndSend (IAsyncResult result);
+
+               public void Send (Message message)
+               {
+                       Send (message, channel_factory.DefaultSendTimeout);
+               }
+
+               public abstract void Send (Message message, TimeSpan timeout);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/PeerResolverBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/PeerResolverBindingElement.cs
new file mode 100644 (file)
index 0000000..aedb39a
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// PeerResolverBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+
+// LAMESPEC: This class resides in System.ServiceModel.Description but it does not
+// make sense.
+namespace System.ServiceModel.Channels
+{
+       public abstract class PeerResolverBindingElement : BindingElement
+       {
+               protected PeerResolverBindingElement ()
+               {
+               }
+
+               protected PeerResolverBindingElement (PeerResolverBindingElement other)
+               {
+               }
+
+               public abstract PeerResolver CreatePeerResolver ();
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/PeerTransportBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/PeerTransportBindingElement.cs
new file mode 100644 (file)
index 0000000..94ed837
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// PeerTransportBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public sealed class PeerTransportBindingElement
+               : TransportBindingElement, ISecurityCapabilities
+       {
+               string listen_ip_addr;
+               long max_recv_message_size;
+               bool auth_msg;
+               int port;
+
+               public PeerTransportBindingElement ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               private PeerTransportBindingElement (
+                       PeerTransportBindingElement other)
+                       : base (other)
+               {
+               }
+
+               public string ListenIPAddress {
+                       get { return listen_ip_addr; }
+                       set { listen_ip_addr = value; }
+               }
+
+               public override long MaxReceivedMessageSize {
+                       get { return max_recv_message_size; }
+                       set { max_recv_message_size = value; }
+               }
+
+               public bool MessageAuthentication {
+                       get { return auth_msg; }
+                       set { auth_msg = value; }
+               }
+
+               public int Port {
+                       get { return port; }
+                       set { port = value; }
+               }
+
+               public override string Scheme {
+                       get { return "net.p2p"; }
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new PeerTransportBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               ProtectionLevel ISecurityCapabilities.SupportedRequestProtectionLevel {
+                       get { throw new NotImplementedException (); }
+               }
+
+               ProtectionLevel ISecurityCapabilities.SupportedResponseProtectionLevel {
+                       get { throw new NotImplementedException (); }
+               }
+
+               bool ISecurityCapabilities.SupportsClientAuthentication {
+                       get { throw new NotImplementedException (); }
+               }
+
+               bool ISecurityCapabilities.SupportsClientWindowsIdentity {
+                       get { throw new NotImplementedException (); }
+               }
+
+               bool ISecurityCapabilities.SupportsServerAuthentication {
+                       get { throw new NotImplementedException (); }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/PnrpPeerResolverBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/PnrpPeerResolverBindingElement.cs
new file mode 100644 (file)
index 0000000..ba102ab
--- /dev/null
@@ -0,0 +1,85 @@
+//
+// PnrpPeerResolverBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public class PnrpPeerResolverBindingElement : PeerResolverBindingElement
+       {
+               public PnrpPeerResolverBindingElement ()
+               {
+               }
+
+               private PnrpPeerResolverBindingElement (
+                       PnrpPeerResolverBindingElement other)
+                       : base (other)
+               {
+               }
+
+               [MonoTODO]
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override BindingElement Clone ()
+               {
+                       return new PnrpPeerResolverBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override PeerResolver CreatePeerResolver ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReliableSessionBindingElementImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReliableSessionBindingElementImporter.cs
new file mode 100644 (file)
index 0000000..7f0f3d1
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// ReliableSessionBindingElementImporter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class ReliableSessionBindingElementImporter
+               : IPolicyImportExtension
+       {
+               [MonoTODO]
+               void IPolicyImportExtension.ImportPolicy (MetadataImporter importer,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReplyChannelBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ReplyChannelBase.cs
new file mode 100644 (file)
index 0000000..3a2603e
--- /dev/null
@@ -0,0 +1,120 @@
+//
+// ReplyChannelBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Channels
+{
+       internal abstract class ReplyChannelBase : ChannelBase, IReplyChannel
+       {
+               ChannelListenerBase channel_listener;
+
+               public ReplyChannelBase (ChannelListenerBase listener)
+                       : base (listener)
+               {
+                       this.channel_listener = listener;
+               }
+
+               public abstract EndpointAddress LocalAddress { get; }
+
+               public virtual bool TryReceiveRequest ()
+               {
+                       RequestContext dummy;
+                       return TryReceiveRequest (channel_listener.DefaultReceiveTimeout, out dummy);
+               }
+
+               public abstract bool TryReceiveRequest (TimeSpan timeout, out RequestContext context);
+
+               public abstract IAsyncResult BeginTryReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state);
+
+               public virtual bool EndTryReceiveRequest (IAsyncResult result)
+               {
+                       RequestContext dummy;
+                       return EndTryReceiveRequest (result, out dummy);
+               }
+
+               public abstract bool EndTryReceiveRequest (IAsyncResult result, out RequestContext context);
+
+               public virtual bool WaitForRequest ()
+               {
+                       return WaitForRequest (channel_listener.DefaultReceiveTimeout);
+               }
+
+               public abstract bool WaitForRequest (TimeSpan timeout);
+
+               public abstract IAsyncResult BeginWaitForRequest (TimeSpan timeout, AsyncCallback callback, object state);
+
+               public abstract bool EndWaitForRequest (IAsyncResult result);
+
+               public virtual RequestContext ReceiveRequest ()
+               {
+                       return ReceiveRequest (channel_listener.DefaultReceiveTimeout);
+               }
+
+               public abstract RequestContext ReceiveRequest (TimeSpan timeout);
+
+               public virtual IAsyncResult BeginReceiveRequest (AsyncCallback callback, object state)
+               {
+                       return BeginReceiveRequest (channel_listener.DefaultReceiveTimeout, callback, state);
+               }
+
+               public abstract IAsyncResult BeginReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state);
+
+               public abstract RequestContext EndReceiveRequest (IAsyncResult result);
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/RequestChannelBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/RequestChannelBase.cs
new file mode 100644 (file)
index 0000000..ea6979f
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// RequestChannelBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Channels
+{
+       internal abstract class RequestChannelBase : ChannelBase, IRequestChannel
+       {
+               ChannelFactoryBase channel_factory;
+
+               public RequestChannelBase (ChannelFactoryBase factory)
+                       : base (factory)
+               {
+                       this.channel_factory = factory;
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return channel_factory.DefaultCloseTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return channel_factory.DefaultOpenTimeout; }
+               }
+
+               public abstract EndpointAddress RemoteAddress { get; }
+
+               public abstract Uri Via { get; }
+
+               // Request
+
+               public Message Request (Message message)
+               {
+                       return Request (message, DefaultSendTimeout);
+               }
+
+               public abstract Message Request (Message message, TimeSpan timeout);
+
+               public IAsyncResult BeginRequest (Message message, AsyncCallback callback, object state)
+               {
+                       return BeginRequest (message, DefaultSendTimeout, callback, state);
+               }
+
+               public abstract IAsyncResult BeginRequest (Message message, TimeSpan timeout, AsyncCallback callback, object state);
+
+               public abstract Message EndRequest (IAsyncResult result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/RequestContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/RequestContext.cs
new file mode 100644 (file)
index 0000000..27cdf4b
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// RequestContext.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class RequestContext : IDisposable
+       {
+               public abstract Message RequestMessage { get; }
+               public abstract void Abort ();
+               public abstract IAsyncResult BeginReply (Message message, AsyncCallback callback, object state);
+               public abstract IAsyncResult BeginReply (Message message, TimeSpan timeout, AsyncCallback callback, object state);
+               public abstract void Close ();
+               public abstract void Close (TimeSpan timeout);
+               public abstract void EndReply (IAsyncResult result);
+               public abstract void Reply (Message message);
+               public abstract void Reply (Message message, TimeSpan timeout);
+
+               public void Dispose ()
+               {
+                       Close ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageDecryptor.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageDecryptor.cs
new file mode 100644 (file)
index 0000000..bff5c0c
--- /dev/null
@@ -0,0 +1,449 @@
+//
+// SecureMessageDecryptor.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Runtime.Serialization;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Text;
+using System.Xml;
+using System.Xml.XPath;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Channels
+{
+       internal class RecipientSecureMessageDecryptor : SecureMessageDecryptor
+       {
+               RecipientMessageSecurityBindingSupport security;
+
+               public RecipientSecureMessageDecryptor (
+                       Message source, RecipientMessageSecurityBindingSupport security)
+                       : base (source, security)
+               {
+                       this.security = security;
+               }
+
+               public override MessageDirection Direction {
+                       get { return MessageDirection.Input; }
+               }
+
+               public override SecurityMessageProperty RequestSecurity {
+                       get { return null; }
+               }
+
+               public override SecurityTokenParameters Parameters {
+                       get { return security.RecipientParameters; }
+               }
+
+               public override SecurityTokenParameters CounterParameters {
+                       get { return security.InitiatorParameters; }
+               }
+       }
+
+       internal class InitiatorSecureMessageDecryptor : SecureMessageDecryptor
+       {
+               InitiatorMessageSecurityBindingSupport security;
+               SecurityMessageProperty request_security;
+
+               public InitiatorSecureMessageDecryptor (
+                       Message source, SecurityMessageProperty secprop, InitiatorMessageSecurityBindingSupport security)
+                       : base (source, security)
+               {
+                       this.security = security;
+                       request_security = secprop;
+               }
+
+               public override SecurityMessageProperty RequestSecurity {
+                       get { return request_security; }
+               }
+
+               public override MessageDirection Direction {
+                       get { return MessageDirection.Output; }
+               }
+
+               public override SecurityTokenParameters Parameters {
+                       get { return security.InitiatorParameters; }
+               }
+
+               public override SecurityTokenParameters CounterParameters {
+                       get { return security.RecipientParameters; }
+               }
+       }
+
+       internal abstract class SecureMessageDecryptor
+       {
+               Message source_message;
+               MessageBuffer buf;
+               MessageSecurityBindingSupport security;
+
+               XmlDocument doc;
+               XmlNamespaceManager nsmgr; // for XPath query
+
+               SecurityMessageProperty sec_prop =
+                       new SecurityMessageProperty ();
+               WSSecurityMessageHeader wss_header = null;
+               WSSecurityMessageHeaderReader wss_header_reader;
+               List<MessageHeaderInfo> headers = new List<MessageHeaderInfo> ();
+               SecurityTokenResolver token_resolver;
+               List<SecurityToken> tokens;
+
+               protected SecureMessageDecryptor (
+                       Message source, MessageSecurityBindingSupport security)
+               {
+                       source_message = source;
+                       this.security = security;
+
+                       // FIXME: use proper max buffer
+                       buf = source.CreateBufferedCopy (int.MaxValue);
+
+                       doc = new XmlDocument ();
+                       doc.PreserveWhitespace = true;
+
+                       nsmgr = new XmlNamespaceManager (doc.NameTable);
+                       nsmgr.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
+                       nsmgr.AddNamespace ("c", Constants.WsscNamespace);
+                       nsmgr.AddNamespace ("o", Constants.WssNamespace);
+                       nsmgr.AddNamespace ("e", EncryptedXml.XmlEncNamespaceUrl);
+                       nsmgr.AddNamespace ("u", Constants.WsuNamespace);
+                       nsmgr.AddNamespace ("dsig", SignedXml.XmlDsigNamespaceUrl);
+
+               }
+
+               public abstract MessageDirection Direction { get; }
+               public abstract SecurityTokenParameters Parameters { get; }
+               public abstract SecurityTokenParameters CounterParameters { get; }
+               public abstract SecurityMessageProperty RequestSecurity { get; }
+
+               public SecurityTokenResolver TokenResolver {
+                       get { return token_resolver; }
+               }
+
+               public Message DecryptMessage ()
+               {
+                       Message srcmsg = buf.CreateMessage ();
+                       if (srcmsg.Version.Envelope == EnvelopeVersion.None)
+                               throw new ArgumentException ("The message to decrypt is not an expected SOAP envelope.");
+
+                       string action = GetAction ();
+                       if (action == null)
+                               throw new ArgumentException ("SOAP action could not be retrieved from the message to decrypt.");
+
+                       XPathNavigator nav = doc.CreateNavigator ();
+                       using (XmlWriter writer = nav.AppendChild ()) {
+                               buf.CreateMessage ().WriteMessage (writer);
+                       }
+/*
+doc.PreserveWhitespace = false;
+doc.Save (Console.Out);
+doc.PreserveWhitespace = true;
+*/
+
+                       // read and store headers, wsse:Security and setup in-band resolver.
+                       ReadHeaders (srcmsg);
+
+                       ExtractSecurity ();
+
+                       Message msg = Message.CreateMessage (new XmlNodeReader (doc), srcmsg.Headers.Count, srcmsg.Version);
+                       for (int i = 0; i < srcmsg.Headers.Count; i++) {
+                               MessageHeaderInfo header = srcmsg.Headers [i];
+                               if (header == wss_header)
+                                       msg.Headers.Add (wss_header);
+                               else
+                                       msg.Headers.CopyHeaderFrom (srcmsg, i);
+                       }
+
+                       // FIXME: when Local[Client|Service]SecuritySettings.DetectReplays
+                       // is true, reject such messages which don't have <wsu:Timestamp>
+
+                       msg.Properties.Add ("Security", sec_prop);
+                       return msg;
+               }
+
+               void ReadHeaders (Message srcmsg)
+               {
+                       SecurityTokenSerializer serializer =
+                               security.TokenSerializer;
+
+                       tokens = new List<SecurityToken> ();
+                       token_resolver = SecurityTokenResolver.CreateDefaultSecurityTokenResolver (
+                               new ReadOnlyCollection <SecurityToken> (tokens),
+                               true);
+                       token_resolver = new UnionSecurityTokenResolver (token_resolver, security.OutOfBandTokenResolver);
+
+                       // Add relevant protection token and supporting tokens.
+                       tokens.Add (security.EncryptionToken);
+                       // FIXME: this is just a workaround for symmetric binding to not require extra client certificate.
+                       if (security.Element is AsymmetricSecurityBindingElement)
+                               tokens.Add (security.SigningToken);
+                       if (RequestSecurity != null && RequestSecurity.ProtectionToken != null)
+                               tokens.Add (RequestSecurity.ProtectionToken.SecurityToken);
+                       // FIXME: handle supporting tokens
+
+                       for (int i = 0; i < srcmsg.Headers.Count; i++) {
+                               MessageHeaderInfo header = srcmsg.Headers [i];
+                               // FIXME: check SOAP Actor.
+                               // MessageHeaderDescription.Actor needs to be accessible from here.
+                               if (header.Namespace == Constants.WssNamespace &&
+                                   header.Name == "Security") {
+                                       wss_header = new WSSecurityMessageHeader (null);
+                                       wss_header_reader = new WSSecurityMessageHeaderReader (wss_header, serializer, token_resolver, doc, nsmgr, tokens);
+                                       wss_header_reader.ReadContents (srcmsg.Headers.GetReaderAtHeader (i));
+                                       headers.Add (wss_header);
+                               }
+                               else
+                                       headers.Add (header);
+                       }
+                       if (wss_header == null)
+                               throw new InvalidOperationException ("In this service contract, a WS-Security header is required in the Message, but was not found.");
+               }
+
+               void ExtractSecurity ()
+               {
+                       if (security.MessageProtectionOrder == MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature &&
+                           wss_header.Find<SignedXml> () != null)
+                               throw new MessageSecurityException ("The security binding element expects that the message signature is encrypted, while it isn't.");
+
+                       WrappedKeySecurityToken wk = wss_header.Find<WrappedKeySecurityToken> ();
+                       DerivedKeySecurityToken dk = wss_header.Find<DerivedKeySecurityToken> ();
+                       if (wk != null) {
+                               if (Parameters.RequireDerivedKeys && dk == null)
+                                       throw new MessageSecurityException ("DerivedKeyToken is required in this contract, but was not found in the message");
+                       }
+                       else
+                               // FIXME: this is kind of hack for symmetric reply processing.
+                               wk = RequestSecurity.ProtectionToken != null ? RequestSecurity.ProtectionToken.SecurityToken as WrappedKeySecurityToken : null;
+
+                       SymmetricSecurityKey wkkey = wk != null ? wk.SecurityKeys [0] as SymmetricSecurityKey : null;
+
+                       wss_header_reader.DecryptSecurity (this, wkkey, RequestSecurity != null ? RequestSecurity.EncryptionKey : null);
+
+                       // signature confirmation
+                       WSSignedXml sxml = wss_header.Find<WSSignedXml> ();
+                       if (sxml == null)
+                               throw new MessageSecurityException ("The the message signature is expected but not found.");
+
+                       bool confirmed = false;
+
+                       SecurityKeyIdentifierClause sigClause = null;
+                       foreach (KeyInfoClause kic in sxml.KeyInfo) {
+                               SecurityTokenReferenceKeyInfo r = kic as SecurityTokenReferenceKeyInfo;
+                               if (r != null)
+                                       sigClause = r.Clause;
+                       }
+                       if (sigClause == null)
+                               throw new MessageSecurityException ("SecurityTokenReference was not found in dsig:Signature KeyInfo.");
+
+                       SecurityToken signToken;
+                       SecurityKey signKey;
+
+                       signToken = TokenResolver.ResolveToken (sigClause);
+                       signKey = signToken.ResolveKeyIdentifierClause (sigClause);
+                       SymmetricSecurityKey symkey = signKey as SymmetricSecurityKey;
+                       if (symkey != null) {
+                               confirmed = sxml.CheckSignature (new HMACSHA1 (symkey.GetSymmetricKey ()));
+                               if (wk != null)
+                                       // FIXME: authenticate token
+                                       sec_prop.ProtectionToken = new SecurityTokenSpecification (wk, null);
+                       } else {
+                               AsymmetricAlgorithm alg = ((AsymmetricSecurityKey) signKey).GetAsymmetricAlgorithm (security.DefaultSignatureAlgorithm, false);
+                               confirmed = sxml.CheckSignature (alg);
+                               sec_prop.InitiatorToken = new SecurityTokenSpecification (
+                                       signToken,
+                                       security.TokenAuthenticator.ValidateToken (signToken));
+                       }
+                       if (!confirmed)
+                               throw new MessageSecurityException ("Message signature is invalid.");
+
+                       // token authentication
+                       // FIXME: it might not be limited to recipient
+                       if (Direction == MessageDirection.Input)
+                               ProcessSupportingTokens (sxml);
+
+                       sec_prop.EncryptionKey = ((SymmetricSecurityKey) wk.SecurityKeys [0]).GetSymmetricKey ();
+                       sec_prop.ConfirmedSignatures.Add (Convert.ToBase64String (sxml.SignatureValue));
+               }
+
+               #region supporting token processing
+
+               // authenticate and map supporting tokens to proper SupportingTokenSpecification list.
+               void ProcessSupportingTokens (SignedXml sxml)
+               {
+                       List<SupportingTokenInfo> tokens = new List<SupportingTokenInfo> ();
+               
+                       // First, categorize those tokens in the Security
+                       // header:
+                       // - Endorsing          signing
+                       // - Signed                     signed
+                       // - SignedEncrypted            signed  encrypted
+                       // - SignedEndorsing    signing signed
+
+                       foreach (object obj in wss_header.Contents) {
+                               SecurityToken token = obj as SecurityToken;
+                               if (token == null)
+                                       continue;
+                               bool signed = false, endorsing = false, encrypted = false;
+                               // signed
+                               foreach (Reference r in sxml.SignedInfo.References)
+                                       if (r.Uri.Substring (1) == token.Id) {
+                                               signed = true;
+                                               break;
+                                       }
+                               // FIXME: how to get 'encrypted' state?
+                               // FIXME: endorsing
+
+                               SecurityTokenAttachmentMode mode =
+                                       signed ? encrypted ? SecurityTokenAttachmentMode.SignedEncrypted :
+                                       endorsing ? SecurityTokenAttachmentMode.SignedEndorsing :
+                                       SecurityTokenAttachmentMode.Signed :
+                                       SecurityTokenAttachmentMode.Endorsing;
+                               tokens.Add (new SupportingTokenInfo (token, mode, false));
+                       }
+
+                       // then,
+                       // 1. validate every mandatory supporting token
+                       // parameters (Endpoint-, Operation-). To do that,
+                       // iterate all tokens in the header against every
+                       // parameter in the mandatory list.
+                       // 2. validate every token that is not validated.
+                       // To do that, iterate all supporting token parameters
+                       // and check if any of them can validate it.
+                       SupportingTokenParameters supp;
+                       string action = GetAction ();
+                       ValidateTokensByParameters (security.Element.EndpointSupportingTokenParameters, tokens, false);
+                       if (security.Element.OperationSupportingTokenParameters.TryGetValue (action, out supp))
+                               ValidateTokensByParameters (supp, tokens, false);
+                       ValidateTokensByParameters (security.Element.OptionalEndpointSupportingTokenParameters, tokens, true);
+                       if (security.Element.OptionalOperationSupportingTokenParameters.TryGetValue (action, out supp))
+                               ValidateTokensByParameters (supp, tokens, true);
+               }
+
+               void ValidateTokensByParameters (SupportingTokenParameters supp, List<SupportingTokenInfo> tokens, bool optional)
+               {
+                       ValidateTokensByParameters (supp.Endorsing, tokens, optional, SecurityTokenAttachmentMode.Endorsing);
+                       ValidateTokensByParameters (supp.Signed, tokens, optional, SecurityTokenAttachmentMode.Signed);
+                       ValidateTokensByParameters (supp.SignedEndorsing, tokens, optional, SecurityTokenAttachmentMode.SignedEndorsing);
+                       ValidateTokensByParameters (supp.SignedEncrypted, tokens, optional, SecurityTokenAttachmentMode.SignedEncrypted);
+               }
+
+               void ValidateTokensByParameters (IEnumerable<SecurityTokenParameters> plist, List<SupportingTokenInfo> tokens, bool optional, SecurityTokenAttachmentMode attachMode)
+               {
+                       foreach (SecurityTokenParameters p in plist) {
+                               SecurityTokenResolver r;
+                               SecurityTokenAuthenticator a =
+                                       security.CreateTokenAuthenticator (p, out r);
+                               SupportingTokenSpecification spec = ValidateTokensByParameters (a, r, tokens);
+                               if (spec == null) {
+                                       if (optional)
+                                               continue;
+                                       else
+                                               throw new MessageSecurityException (String.Format ("No security token could be validated for authenticator '{0}' which is indicated by the '{1}' supporting token parameters", a, attachMode));
+                               } else {
+                                       // For endorsing tokens, verify corresponding signatures.
+                                       switch (attachMode) {
+                                       case SecurityTokenAttachmentMode.Endorsing:
+                                       case SecurityTokenAttachmentMode.SignedEndorsing:
+                                               WSSignedXml esxml = GetSignatureForToken (spec.SecurityToken);
+                                               if (esxml == null)
+                                                       throw new MessageSecurityException (String.Format ("The '{1}' token '{0}' is expected to endorse the primary signature but no corresponding signature is found.", spec.SecurityToken, attachMode));
+
+                                               bool confirmed;
+                                               SecurityAlgorithmSuite suite = security.Element.DefaultAlgorithmSuite;
+                                               foreach (SecurityTokenReferenceKeyInfo kic in esxml.KeyInfo) {
+                                                       SecurityKey signKey = spec.SecurityToken.ResolveKeyIdentifierClause (kic.Clause);
+                                                       SymmetricSecurityKey symkey = signKey as SymmetricSecurityKey;
+                                                       if (symkey != null) {
+                                                               confirmed = esxml.CheckSignature (symkey.GetKeyedHashAlgorithm (suite.DefaultSymmetricSignatureAlgorithm));
+                                                       } else {
+                                                               AsymmetricAlgorithm alg = ((AsymmetricSecurityKey) signKey).GetAsymmetricAlgorithm (suite.DefaultAsymmetricSignatureAlgorithm, false);
+                                                               confirmed = esxml.CheckSignature (alg);
+                                                       }
+                                                       if (!confirmed)
+                                                               throw new MessageSecurityException (String.Format ("Signature for '{1}' token '{0}' is invalid.", spec.SecurityToken, attachMode));
+                                                       break;
+                                               }
+
+                                               sec_prop.ConfirmedSignatures.Insert (0, Convert.ToBase64String (esxml.SignatureValue));
+                                               break;
+                                       }
+                               }
+
+                               sec_prop.IncomingSupportingTokens.Add (spec);
+                       }
+               }
+
+               WSSignedXml GetSignatureForToken (SecurityToken token)
+               {
+                       int count = 0;
+                       foreach (WSSignedXml sxml in wss_header.FindAll<WSSignedXml> ()) {
+                               if (count++ == 0)
+                                       continue; // primary signature
+                               foreach (SecurityTokenReferenceKeyInfo r in sxml.KeyInfo)
+                                       if (token.MatchesKeyIdentifierClause (r.Clause))
+                                               return sxml;
+                       }
+                       return null;
+               }
+
+               SupportingTokenSpecification ValidateTokensByParameters (SecurityTokenAuthenticator a, SecurityTokenResolver r, List<SupportingTokenInfo> tokens)
+               {
+                       foreach (SupportingTokenInfo info in tokens)
+                               if (a.CanValidateToken (info.Token))
+                                       return new SupportingTokenSpecification (
+                                               info.Token,
+                                               a.ValidateToken (info.Token),
+                                               info.Mode);
+                       return null;
+               }
+
+               #endregion
+
+               string GetAction ()
+               {
+                       string ret = source_message.Headers.Action;
+                       if (ret == null) {
+                               HttpRequestMessageProperty reqprop =
+                                       source_message.Properties ["Action"] as HttpRequestMessageProperty;
+                               if (reqprop != null)
+                                       ret = reqprop.Headers ["Action"];
+                       }
+                       return ret;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecureMessageGenerator.cs
new file mode 100644 (file)
index 0000000..23e6043
--- /dev/null
@@ -0,0 +1,711 @@
+//
+// MessageSecurityGenerator.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Runtime.Serialization;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Text;
+using System.Xml;
+using System.Xml.XPath;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Channels
+{
+       internal class InitiatorMessageSecurityGenerator : MessageSecurityGenerator
+       {
+               EndpointAddress message_to;
+               InitiatorMessageSecurityBindingSupport security;
+
+               public InitiatorMessageSecurityGenerator (
+                       Message msg,
+                       InitiatorMessageSecurityBindingSupport security,
+                       EndpointAddress messageTo)
+                       : base (msg, security)
+               {
+                       // FIXME: I believe it should be done at channel
+                       // creation phase, but WinFX does not.
+//                     if (!security.InitiatorParameters.InternalHasAsymmetricKey)
+//                             throw new InvalidOperationException ("Wrong security token parameters: it must have an asymmetric key (HasAsymmetricKey). There is likely a misconfiguration in the custom security binding element.");
+
+                       this.security = security;
+                       this.message_to = messageTo;
+               }
+
+               public override SecurityRequestContext RequestContext {
+                       get { return null; }
+               }
+
+               public override UniqueId RelatesTo {
+                       get { return null; }
+               }
+
+               public override SecurityTokenParameters Parameters {
+                       get { return security.InitiatorParameters; }
+               }
+
+               public override SecurityTokenParameters CounterParameters {
+                       get { return security.RecipientParameters; }
+               }
+
+               public override MessageDirection Direction {
+                       get { return MessageDirection.Input; }
+               }
+
+               public override EndpointAddress MessageTo {
+                       get { return message_to; }
+               }
+
+               public override bool ShouldIncludeToken (SecurityTokenInclusionMode mode, bool isInitialized)
+               {
+                       switch (mode) {
+                       case SecurityTokenInclusionMode.Never:
+                       case SecurityTokenInclusionMode.AlwaysToInitiator:
+                               return false;
+                       case SecurityTokenInclusionMode.AlwaysToRecipient:
+                               return true;
+                       case SecurityTokenInclusionMode.Once:
+                               return !isInitialized;
+                       }
+                       throw new Exception ("Internal Error: should not happen.");
+               }
+
+               public override ScopedMessagePartSpecification SignatureParts { 
+                       get { return Security.ChannelRequirements.IncomingSignatureParts; }
+               }
+
+               public override ScopedMessagePartSpecification EncryptionParts { 
+                       get { return Security.ChannelRequirements.IncomingEncryptionParts; }
+               }
+       }
+
+       internal class RecipientMessageSecurityGenerator : MessageSecurityGenerator
+       {
+               RecipientMessageSecurityBindingSupport security;
+               SecurityRequestContext req_ctx;
+
+               public RecipientMessageSecurityGenerator (
+                       Message msg,
+                       SecurityRequestContext requestContext,
+                       RecipientMessageSecurityBindingSupport security)
+                       : base (msg, security)
+               {
+                       this.security = security;
+                       req_ctx = requestContext;
+                       SecurityMessageProperty secprop =
+                               (SecurityMessageProperty) req_ctx.RequestMessage.Properties.Security.CreateCopy ();
+                       msg.Properties.Security = secprop;
+               }
+
+               public override SecurityRequestContext RequestContext {
+                       get { return req_ctx; }
+               }
+
+               public override UniqueId RelatesTo {
+                       get { return req_ctx.RequestMessage.Headers.MessageId; }
+               }
+
+               public override SecurityTokenParameters Parameters {
+                       get { return security.RecipientParameters; }
+               }
+
+               public override SecurityTokenParameters CounterParameters {
+                       get { return security.InitiatorParameters; }
+               }
+
+               public override MessageDirection Direction {
+                       get { return MessageDirection.Output; }
+               }
+
+               public override EndpointAddress MessageTo {
+                       get { return null; }
+               }
+
+               public override bool ShouldIncludeToken (SecurityTokenInclusionMode mode, bool isInitialized)
+               {
+                       switch (mode) {
+                       case SecurityTokenInclusionMode.Never:
+                       case SecurityTokenInclusionMode.AlwaysToRecipient:
+                               return false;
+                       case SecurityTokenInclusionMode.AlwaysToInitiator:
+                               return true;
+                       case SecurityTokenInclusionMode.Once:
+                               return !isInitialized;
+                       }
+                       throw new Exception ("Internal Error: should not happen.");
+               }
+
+               public override ScopedMessagePartSpecification SignatureParts { 
+                       get { return Security.ChannelRequirements.OutgoingSignatureParts; }
+               }
+
+               public override ScopedMessagePartSpecification EncryptionParts { 
+                       get { return Security.ChannelRequirements.OutgoingEncryptionParts; }
+               }
+       }
+
+       internal abstract class MessageSecurityGenerator
+       {
+               Message msg;
+               SecurityMessageProperty secprop;
+               MessageSecurityBindingSupport security;
+               int idbase;
+
+               public MessageSecurityGenerator (Message msg, 
+                       MessageSecurityBindingSupport security)
+               {
+                       this.msg = msg;
+                       this.security = security;
+               }
+
+               public Message Message {
+                       get { return msg; }
+               }
+
+               public MessageSecurityBindingSupport Security {
+                       get { return security; }
+               }
+
+               public abstract SecurityTokenParameters Parameters { get; }
+
+               public abstract SecurityTokenParameters CounterParameters { get; }
+
+               public abstract MessageDirection Direction { get; }
+
+               public abstract EndpointAddress MessageTo { get; }
+
+               public abstract ScopedMessagePartSpecification SignatureParts { get; }
+
+               public abstract ScopedMessagePartSpecification EncryptionParts { get; }
+
+               public MessagePartSpecification SignaturePart {
+                       get {
+                               MessagePartSpecification spec;
+                               if (!SignatureParts.TryGetParts (GetAction (), false, out spec))
+                                       spec = SignatureParts.ChannelParts;
+                               return spec;
+                       }
+               }
+
+               public MessagePartSpecification EncryptionPart {
+                       get {
+                               MessagePartSpecification spec;
+                               if (!EncryptionParts.TryGetParts (GetAction (), false, out spec))
+                                       spec = EncryptionParts.ChannelParts;
+                               return spec;
+                       }
+               }
+
+               public abstract bool ShouldIncludeToken (SecurityTokenInclusionMode mode, bool isInitialized);
+
+               public bool ShouldOutputEncryptedKey {
+                       get { return RequestContext == null || RequestContext.RequestMessage.Properties.Security.ProtectionToken == null; } //security.Element is AsymmetricSecurityBindingElement; }
+               }
+
+               public abstract UniqueId RelatesTo { get; }
+
+               public abstract SecurityRequestContext RequestContext { get; }
+
+               public Message SecureMessage ()
+               {
+                       secprop = Message.Properties.Security ?? new SecurityMessageProperty ();
+
+                       SecurityToken encToken =
+                               secprop.InitiatorToken != null ? secprop.InitiatorToken.SecurityToken : security.EncryptionToken;
+                       // FIXME: it might be still incorrect.
+                       SecurityToken signToken =
+                               Parameters == CounterParameters ? null :
+                               security.SigningToken;
+                       MessageProtectionOrder protectionOrder =
+                               security.MessageProtectionOrder;
+                       SecurityTokenSerializer serializer =
+                               security.TokenSerializer;
+                       SecurityBindingElement element =
+                               security.Element;
+                       SecurityAlgorithmSuite suite = element.DefaultAlgorithmSuite;
+
+// FIXME: remove this hack
+if (!ShouldOutputEncryptedKey)
+       encToken = new BinarySecretSecurityToken (secprop.EncryptionKey);
+
+                       string messageId = "uuid-" + Guid.NewGuid ();
+                       int identForMessageId = 1;
+                       XmlDocument doc = new XmlDocument ();
+                       doc.PreserveWhitespace = true;
+
+                       UniqueId relatesTo = RelatesTo;
+                       if (relatesTo != null)
+                               msg.Headers.RelatesTo = relatesTo;
+                       else // FIXME: probably it is always added when it is stateful ?
+                               msg.Headers.MessageId = new UniqueId ("urn:" + messageId);
+
+                       // FIXME: get correct ReplyTo value
+                       if (Direction == MessageDirection.Input)
+                               msg.Headers.Add (MessageHeader.CreateHeader ("ReplyTo", msg.Version.Addressing.Namespace, EndpointAddress10.FromEndpointAddress (new EndpointAddress (Constants.WsaAnonymousUri))));
+
+                       if (MessageTo != null)
+                               msg.Headers.Add (MessageHeader.CreateHeader ("To", msg.Version.Addressing.Namespace, MessageTo.Uri.AbsoluteUri, true));
+
+                       // wss:Security
+                       WSSecurityMessageHeader header =
+                               new WSSecurityMessageHeader (serializer);
+                       msg.Headers.Add (header);
+                       // 1. [Timestamp]
+                       if (element.IncludeTimestamp) {
+                               WsuTimestamp timestamp = new WsuTimestamp ();
+                               timestamp.Id = messageId + "-" + identForMessageId++;
+                               timestamp.Created = DateTime.Now;
+                               // FIXME: on service side, use element.LocalServiceSettings.TimestampValidityDuration
+                               timestamp.Expires = timestamp.Created.Add (element.LocalClientSettings.TimestampValidityDuration);
+                               header.AddContent (timestamp);
+                       }
+
+                       XmlNamespaceManager nsmgr = new XmlNamespaceManager (doc.NameTable);
+                       nsmgr.AddNamespace ("s", msg.Version.Envelope.Namespace);
+                       nsmgr.AddNamespace ("o", Constants.WssNamespace);
+                       nsmgr.AddNamespace ("u", Constants.WsuNamespace);
+                       nsmgr.AddNamespace ("o11", Constants.Wss11Namespace);
+
+                       /*WrappedKey*/SecurityToken primaryToken = null;
+                       DerivedKeySecurityToken dkeyToken = null;
+                       SecurityToken actualToken = null;
+                       SecurityKeyIdentifierClause actualClause = null;
+                       Signature sig = null;
+
+                       List<DerivedKeySecurityToken> derivedKeys =
+                               new List<DerivedKeySecurityToken> ();
+
+                       SymmetricAlgorithm masterKey = new RijndaelManaged ();
+                       masterKey.KeySize = suite.DefaultSymmetricKeyLength;
+                       masterKey.Mode = CipherMode.CBC;
+                       masterKey.Padding = PaddingMode.ISO10126;
+                       SymmetricAlgorithm actualKey = masterKey;
+
+                       // 2. [Encryption Token]
+
+                       // SecurityTokenInclusionMode
+                       // - Initiator or Recipient
+                       // - done or notyet. FIXME: not implemented yet
+                       // It also affects on key reference output
+
+                       bool includeEncToken = // /* FIXME: remove this hack */Parameters is SslSecurityTokenParameters ? false :
+                                               ShouldIncludeToken (
+                               Security.RecipientParameters.InclusionMode, false);
+                       bool includeSigToken = // /* FIXME: remove this hack */ Parameters is SslSecurityTokenParameters ? false :
+                                               ShouldIncludeToken (
+                               Security.InitiatorParameters.InclusionMode, false);
+
+                       SecurityKeyIdentifierClause encClause = ShouldOutputEncryptedKey ?
+                               CounterParameters.CallCreateKeyIdentifierClause (encToken, !ShouldOutputEncryptedKey ? SecurityTokenReferenceStyle.Internal : includeEncToken ? Parameters.ReferenceStyle : SecurityTokenReferenceStyle.External) : null;
+
+                       MessagePartSpecification sigSpec = SignaturePart;
+                       MessagePartSpecification encSpec = EncryptionPart;
+
+                       // encryption key (possibly also used for signing)
+                       // FIXME: get correct SymmetricAlgorithm according to the algorithm suite
+                       if (secprop.EncryptionKey != null)
+                               actualKey.Key = secprop.EncryptionKey;
+
+// FIXME: remove thid hack
+if (!ShouldOutputEncryptedKey)
+primaryToken = RequestContext.RequestMessage.Properties.Security.ProtectionToken.SecurityToken as WrappedKeySecurityToken;
+else
+                       primaryToken =
+                               // FIXME: remove this hack?
+                               encToken is SecurityContextSecurityToken ? encToken :
+                               new WrappedKeySecurityToken (messageId + "-" + identForMessageId++,
+                               actualKey.Key,
+                               // security.DefaultKeyWrapAlgorithm,
+                               Parameters.InternalHasAsymmetricKey ?
+                                       suite.DefaultAsymmetricKeyWrapAlgorithm :
+                                       suite.DefaultSymmetricKeyWrapAlgorithm,
+                               encToken,
+                               encClause != null ? new SecurityKeyIdentifier (encClause) : null);
+
+                       // If it reuses request's encryption key, do not output.
+                       if (ShouldOutputEncryptedKey)
+                               header.AddContent (primaryToken);
+
+                       actualToken = primaryToken;
+
+                       // FIXME: I doubt it is correct...
+                       WrappedKeySecurityToken requestEncKey = ShouldOutputEncryptedKey ? null : primaryToken as WrappedKeySecurityToken;
+                       actualClause = requestEncKey == null ? (SecurityKeyIdentifierClause)
+                               new LocalIdKeyIdentifierClause (actualToken.Id, typeof (WrappedKeySecurityToken)) :
+                               new InternalEncryptedKeyIdentifierClause (SHA1.Create ().ComputeHash (requestEncKey.GetWrappedKey ()));
+
+                       // generate derived key if needed
+                       if (CounterParameters.RequireDerivedKeys) {
+                               RijndaelManaged deriv = new RijndaelManaged ();
+                               deriv.KeySize = suite.DefaultEncryptionKeyDerivationLength;
+                               deriv.Mode = CipherMode.CBC;
+                               deriv.Padding = PaddingMode.ISO10126;
+                               deriv.GenerateKey ();
+                               dkeyToken = new DerivedKeySecurityToken (
+                                       GenerateId (doc),
+                                       null, // algorithm
+                                       actualClause,
+                                       new InMemorySymmetricSecurityKey (actualKey.Key),
+                                       null, // name
+                                       null, // generation
+                                       null, // offset
+                                       deriv.Key.Length,
+                                       null, // label
+                                       deriv.Key);
+                               derivedKeys.Add (dkeyToken);
+                               actualToken = dkeyToken;
+                               actualKey.Key = ((SymmetricSecurityKey) dkeyToken.SecurityKeys [0]).GetSymmetricKey ();
+                               actualClause = new LocalIdKeyIdentifierClause (dkeyToken.Id);
+                               header.AddContent (dkeyToken);
+                       }
+
+                       ReferenceList refList = new ReferenceList ();
+                       // When encrypted with DerivedKeyToken, put references
+                       // immediately after the derived token (not inside the
+                       // primary token).
+                       // Similarly, when we do not output EncryptedKey,
+                       // output ReferenceList in the same way.
+                       if (CounterParameters.RequireDerivedKeys ||
+                           !ShouldOutputEncryptedKey)
+                               header.AddContent (refList);
+                       else
+                               ((WrappedKeySecurityToken) primaryToken).ReferenceList = refList;
+
+                       // [Signature Confirmation]
+                       if (security.RequireSignatureConfirmation && secprop.ConfirmedSignatures.Count > 0)
+                               foreach (string value in secprop.ConfirmedSignatures)
+                                       header.AddContent (new Wss11SignatureConfirmation (GenerateId (doc), value));
+
+                       SupportingTokenInfoCollection tokenInfos =
+                               Direction == MessageDirection.Input ?
+                               security.CollectSupportingTokens (GetAction ()) :
+                               new SupportingTokenInfoCollection (); // empty
+
+                       foreach (SupportingTokenInfo tinfo in tokenInfos)
+                               header.AddContent (tinfo.Token);
+
+                       // populate DOM to sign.
+                       XPathNavigator nav = doc.CreateNavigator ();
+                       using (XmlWriter w = nav.AppendChild ()) {
+                               msg.WriteMessage (w);
+                       }
+
+                       XmlElement body = doc.SelectSingleNode ("/s:Envelope/s:Body/*", nsmgr) as XmlElement;
+                       string bodyId = null;
+                       XmlElement secElem = null;
+                       Collection<WSSignedXml> endorsedSignatures =
+                               new Collection<WSSignedXml> ();
+                       bool signatureProtection = (protectionOrder == MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature);
+
+                       // Below are o:Security contents that are not signed...
+                       if (includeSigToken && signToken != null)
+                               header.AddContent (signToken);
+
+                       switch (protectionOrder) {
+                       case MessageProtectionOrder.EncryptBeforeSign:
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       case MessageProtectionOrder.SignBeforeEncrypt:
+                       case MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature:
+
+                               // sign
+                               // see clause 8 of WS-SecurityPolicy C.2.2
+                               WSSignedXml sxml = new WSSignedXml (doc);
+                               SecurityTokenReferenceKeyInfo sigKeyInfo;
+
+                               sig = sxml.Signature;
+                               sig.SignedInfo.CanonicalizationMethod =
+                                       suite.DefaultCanonicalizationAlgorithm;
+                               foreach (XmlElement elem in doc.SelectNodes ("/s:Envelope/s:Header/o:Security/u:Timestamp", nsmgr))
+                                       CreateReference (sig, elem, elem.GetAttribute ("Id", Constants.WsuNamespace));
+                               foreach (XmlElement elem in doc.SelectNodes ("/s:Envelope/s:Header/o:Security/o11:SignatureConfirmation", nsmgr))
+                                       CreateReference (sig, elem, elem.GetAttribute ("Id", Constants.WsuNamespace));
+                               foreach (SupportingTokenInfo tinfo in tokenInfos)
+                                       if (tinfo.Mode != SecurityTokenAttachmentMode.Endorsing) {
+                                               XmlElement el = sxml.GetIdElement (doc, tinfo.Token.Id);
+                                               CreateReference (sig, el, el.GetAttribute ("Id", Constants.WsuNamespace));
+                                       }
+                               XmlNodeList nodes = doc.SelectNodes ("/s:Envelope/s:Header/*", nsmgr);
+                               for (int i = 0; i < msg.Headers.Count; i++) {
+                                       MessageHeaderInfo h = msg.Headers [i];
+                                       if (h.Name == "Security" && h.Namespace == Constants.WssNamespace)
+                                               secElem = nodes [i] as XmlElement;
+                                       else if (sigSpec.HeaderTypes.Count == 0 ||
+                                           sigSpec.HeaderTypes.Contains (new XmlQualifiedName (h.Name, h.Namespace))) {
+                                               string id = GenerateId (doc);
+                                               h.Id = id;
+                                               CreateReference (sig, nodes [i] as XmlElement, id);
+                                       }
+                               }
+                               if (sigSpec.IsBodyIncluded) {
+                                       bodyId = GenerateId (doc);
+                                       CreateReference (sig, body.ParentNode as XmlElement, bodyId);
+                               }
+
+                               if (security.DefaultSignatureAlgorithm == SignedXml.XmlDsigHMACSHA1Url) {
+                                       // FIXME: use appropriate hash algorithm
+                                       sxml.ComputeSignature (new HMACSHA1 (actualKey.Key));
+                                       sigKeyInfo = new SecurityTokenReferenceKeyInfo (actualClause, serializer, doc);
+                               }
+                               else {
+                                       SecurityKeyIdentifierClause signClause =
+                                               CounterParameters.CallCreateKeyIdentifierClause (signToken, includeSigToken ? CounterParameters.ReferenceStyle : SecurityTokenReferenceStyle.External);
+                                       AsymmetricSecurityKey signKey = (AsymmetricSecurityKey) signToken.ResolveKeyIdentifierClause (signClause);
+                                       sxml.SigningKey = signKey.GetAsymmetricAlgorithm (security.DefaultSignatureAlgorithm, true);
+                                       sxml.ComputeSignature ();
+                                       sigKeyInfo = new SecurityTokenReferenceKeyInfo (signClause, serializer, doc);
+                               }
+
+                               sxml.KeyInfo = new KeyInfo ();
+                               sxml.KeyInfo.AddClause (sigKeyInfo);
+
+                               if (!signatureProtection)
+                                       header.AddContent (sig);
+
+                               // endorse the signature with (signed)endorsing
+                               // supporting tokens.
+
+                               foreach (SupportingTokenInfo tinfo in tokenInfos) {
+                                       switch (tinfo.Mode) {
+                                       case SecurityTokenAttachmentMode.Endorsing:
+                                       case SecurityTokenAttachmentMode.SignedEndorsing:
+                                               if (sxml.Signature.Id == null) {
+                                                       sig.Id = GenerateId (doc);
+                                                       secElem.AppendChild (sxml.GetXml ());
+                                               }
+                                               WSSignedXml ssxml = new WSSignedXml (doc);
+                                               ssxml.Signature.SignedInfo.CanonicalizationMethod = suite.DefaultCanonicalizationAlgorithm;
+                                               CreateReference (ssxml.Signature, doc, sig.Id);
+                                               SecurityToken sst = tinfo.Token;
+                                               SecurityKey ssk = sst.SecurityKeys [0]; // FIXME: could be different?
+                                               SecurityKeyIdentifierClause tclause = new LocalIdKeyIdentifierClause (sst.Id); // FIXME: could be different?
+                                               if (ssk is SymmetricSecurityKey) {
+                                                       SymmetricSecurityKey signKey = (SymmetricSecurityKey) ssk;
+                                                       ssxml.ComputeSignature (signKey.GetKeyedHashAlgorithm (suite.DefaultSymmetricSignatureAlgorithm));
+                                               } else {
+                                                       AsymmetricSecurityKey signKey = (AsymmetricSecurityKey) ssk;
+                                                       ssxml.SigningKey = signKey.GetAsymmetricAlgorithm (suite.DefaultAsymmetricSignatureAlgorithm, true);
+                                                       ssxml.ComputeSignature ();
+                                               }
+                                               ssxml.KeyInfo.AddClause (new SecurityTokenReferenceKeyInfo (tclause, serializer, doc));
+                                               if (!signatureProtection)
+                                                       header.AddContent (ssxml.Signature);
+                                               endorsedSignatures.Add (ssxml);
+
+                                               break;
+                                       }
+                               }
+
+                               // encrypt
+
+                               WSEncryptedXml exml = new WSEncryptedXml (doc);
+
+                               EncryptedData edata = Encrypt (body, actualKey, actualToken.Id, refList, actualClause, exml, doc);
+                               EncryptedXml.ReplaceElement (body, edata, false);
+
+                               // encrypt signature
+                               if (signatureProtection) {
+                                       XmlElement sigxml = sig.GetXml ();
+                                       edata = Encrypt (sigxml, actualKey, actualToken.Id, refList, actualClause, exml, doc);
+                                       header.AddContent (edata);
+
+                                       foreach (WSSignedXml ssxml in endorsedSignatures) {
+                                               sigxml = ssxml.GetXml ();
+                                               edata = Encrypt (sigxml, actualKey, actualToken.Id, refList, actualClause, exml, doc);
+                                               header.AddContent (edata);
+                                       }
+
+                                       if (security.RequireSignatureConfirmation) {
+                                               Collection<Wss11SignatureConfirmation> confs = header.FindAll<Wss11SignatureConfirmation> ();
+                                               int count = 0;
+                                               foreach (XmlElement elem in doc.SelectNodes ("/s:Envelope/s:Header/o:Security/o11:SignatureConfirmation", nsmgr)) {
+                                                       edata = Encrypt (elem, actualKey, confs [count].Id, refList, actualClause, exml, doc);
+                                                       EncryptedXml.ReplaceElement (elem, edata, false);
+                                                       header.Contents.Insert (header.Contents.IndexOf (confs [count]), edata);
+                                                       header.Contents.Remove (confs [count++]);
+                                               }
+                                       }
+                               }
+
+                               // encrypt Encrypted supporting tokens
+                               foreach (SupportingTokenInfo tinfo in tokenInfos) {
+                                       if (tinfo.Mode == SecurityTokenAttachmentMode.SignedEncrypted) {
+                                               XmlElement el = exml.GetIdElement (doc, tinfo.Token.Id);
+                                               tinfo.Encrypted = Encrypt (el, actualKey, actualToken.Id, refList, actualClause, exml, doc);
+                                               EncryptedXml.ReplaceElement (el, tinfo.Encrypted, false);
+                                               header.Contents.Insert (header.Contents.IndexOf (tinfo.Token), tinfo.Encrypted);
+                                               header.Contents.Remove (tinfo.Token);
+                                       }
+                               }
+                               break;
+                       }
+
+                       Message ret = Message.CreateMessage (msg.Version, msg.Headers.Action, new XmlNodeReader (doc.SelectSingleNode ("/s:Envelope/s:Body/*", nsmgr) as XmlElement));
+                       ret.Properties.Security = (SecurityMessageProperty) secprop.CreateCopy ();
+                       ret.Properties.Security.EncryptionKey = masterKey.Key;
+                       ret.BodyId = bodyId;
+
+                       // FIXME: can we support TransportToken here?
+                       if (element is AsymmetricSecurityBindingElement) {
+                               ret.Properties.Security.InitiatorToken = new SecurityTokenSpecification (encToken, null); // FIXME: second argument
+                               ret.Properties.Security.InitiatorToken = new SecurityTokenSpecification (signToken, null); // FIXME: second argument
+                       }
+                       else
+                               ret.Properties.Security.ProtectionToken = new SecurityTokenSpecification (primaryToken, null);
+
+                       ret.Headers.Clear ();
+                       ret.Headers.CopyHeadersFrom (msg);
+
+                       // Header contents are:
+                       //      - Timestamp
+                       //      - SignatureConfirmation if required
+                       //      - EncryptionToken if included
+                       //      - derived key token for EncryptionToken
+                       //      - ReferenceList for encrypted items
+                       //      - signed supporting tokens
+                       //      - signed endorsing supporting tokens
+                       //      (i.e. Signed/SignedEncrypted/SignedEndorsing)
+                       //      - Signature Token if different from enc token.
+                       //      - derived key token for sig token if different
+                       //      - Signature for:
+                       //              - Timestamp
+                       //              - supporting tokens (regardless of
+                       //                its inclusion)
+                       //              - message parts in SignedParts
+                       //              - SignatureToken if TokenProtection
+                       //                (regardless of its inclusion)
+                       //      - Signatures for the main signature (above),
+                       //        for every endorsing token and signed
+                       //        endorsing token.
+                       //      
+
+//MessageBuffer zzz = ret.CreateBufferedCopy (100000);
+//ret = zzz.CreateMessage ();
+//Console.WriteLine (zzz.CreateMessage ());
+                       return ret;
+               }
+
+               void CreateReference (Signature sig, XmlElement el, string id)
+               {
+                       CreateReference (sig, el.OwnerDocument, id);
+
+                       if (el.GetAttribute ("Id", Constants.WsuNamespace) != id) {
+                               XmlAttribute a = el.SetAttributeNode ("Id", Constants.WsuNamespace);
+                               a.Prefix = "u";
+                               a.Value = id;
+                       }
+               }
+
+               void CreateReference (Signature sig, XmlDocument doc, string id)
+               {
+                       SecurityAlgorithmSuite suite = security.Element.DefaultAlgorithmSuite;
+                       if (id == String.Empty)
+                               id = GenerateId (doc);
+                       Reference r = new Reference ("#" + id);
+                       r.AddTransform (CreateTransform (suite.DefaultCanonicalizationAlgorithm));
+                       r.DigestMethod = suite.DefaultDigestAlgorithm;
+                       sig.SignedInfo.AddReference (r);
+               }
+
+               Transform CreateTransform (string url)
+               {
+                       switch (url) {
+                       case SignedXml.XmlDsigC14NTransformUrl:
+                               return new XmlDsigC14NTransform ();
+                       case SignedXml.XmlDsigC14NWithCommentsTransformUrl:
+                               return new XmlDsigC14NWithCommentsTransform ();
+                       case SignedXml.XmlDsigExcC14NTransformUrl:
+                               return new XmlDsigExcC14NTransform ();
+                       case SignedXml.XmlDsigExcC14NWithCommentsTransformUrl:
+                               return new XmlDsigExcC14NWithCommentsTransform ();
+                       }
+                       throw new Exception (String.Format ("INTERNAL ERROR: Invalid canonicalization URL: {0}", url));
+               }
+
+               EncryptedData Encrypt (XmlElement target, SymmetricAlgorithm actualKey, string ekeyId, ReferenceList refList, SecurityKeyIdentifierClause encClause, EncryptedXml exml, XmlDocument doc)
+               {
+                       SecurityAlgorithmSuite suite = security.Element.DefaultAlgorithmSuite;
+                       SecurityTokenSerializer serializer = security.TokenSerializer;
+
+                       byte [] encrypted = exml.EncryptData (target, actualKey, false);
+                       EncryptedData edata = new EncryptedData ();
+                       edata.Id = GenerateId (doc);
+                       edata.Type = EncryptedXml.XmlEncElementContentUrl;
+                       edata.EncryptionMethod = new EncryptionMethod (suite.DefaultEncryptionAlgorithm);
+                       // FIXME: here wsse:DigestMethod should be embedded 
+                       // inside EncryptionMethod. Since it is not possible 
+                       // with S.S.C.Xml.EncryptionMethod, we will have to
+                       // build our own XML encryption classes.
+
+                       edata.CipherData.CipherValue = encrypted;
+
+                       DataReference dr = new DataReference ();
+                       dr.Uri = "#" + edata.Id;
+                       refList.Add (dr);
+
+                       if (ShouldOutputEncryptedKey && !CounterParameters.RequireDerivedKeys)
+                               edata.KeyInfo = null;
+                       else {
+                               edata.KeyInfo = new KeyInfo ();
+                               edata.KeyInfo.AddClause (new SecurityTokenReferenceKeyInfo (encClause, serializer, doc));
+                       }
+
+                       return edata;
+               }
+
+               string GenerateId (XmlDocument doc)
+               {
+                       idbase++;
+                       return secprop.SenderIdPrefix + idbase;
+               }
+
+               public string GetAction ()
+               {
+                       string ret = msg.Headers.Action;
+                       if (ret == null) {
+                               HttpRequestMessageProperty reqprop =
+                                       msg.Properties ["Action"] as HttpRequestMessageProperty;
+                               if (reqprop != null)
+                                       ret = reqprop.Headers ["Action"];
+                       }
+                       return ret;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityBindingElement.cs
new file mode 100644 (file)
index 0000000..463803a
--- /dev/null
@@ -0,0 +1,458 @@
+//
+// SecurityBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Description;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class SecurityBindingElement : BindingElement
+       {
+               internal SecurityBindingElement ()
+               {
+                       DefaultAlgorithmSuite = SecurityAlgorithmSuite.Default;
+                       MessageSecurityVersion = MessageSecurityVersion.Default;
+                       IncludeTimestamp = true;
+                       KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
+                       endpoint = new SupportingTokenParameters ();
+                       operation = new Dictionary<string,SupportingTokenParameters> ();
+                       opt_endpoint = new SupportingTokenParameters ();
+                       opt_operation = new Dictionary<string,SupportingTokenParameters> ();
+                       client_settings = new LocalClientSecuritySettings ();
+                       service_settings = new LocalServiceSecuritySettings ();
+               }
+
+               internal SecurityBindingElement (SecurityBindingElement other)
+               {
+                       alg_suite = other.alg_suite;
+                       include_timestamp = other.include_timestamp;
+                       key_entropy_mode = other.key_entropy_mode;
+                       security_header_layout = other.security_header_layout;
+                       msg_security_version = other.msg_security_version;
+                       endpoint = other.endpoint.Clone ();
+                       opt_endpoint = other.opt_endpoint.Clone ();
+                       operation = new Dictionary<string,SupportingTokenParameters> ();
+                       foreach (KeyValuePair<string,SupportingTokenParameters> p in other.operation)
+                               operation.Add (p.Key, p.Value.Clone ());
+                       opt_operation = new Dictionary<string,SupportingTokenParameters> ();
+                       foreach (KeyValuePair<string,SupportingTokenParameters> p in other.opt_operation)
+                               opt_operation.Add (p.Key, p.Value.Clone ());
+                       client_settings = other.client_settings.Clone ();
+                       service_settings = other.service_settings.Clone ();
+               }
+
+               SecurityAlgorithmSuite alg_suite;
+               bool include_timestamp;
+               SecurityKeyEntropyMode key_entropy_mode;
+               SecurityHeaderLayout security_header_layout;
+               MessageSecurityVersion msg_security_version;
+               SupportingTokenParameters endpoint, opt_endpoint;
+               IDictionary<string,SupportingTokenParameters> operation, opt_operation;
+               LocalClientSecuritySettings client_settings;
+               LocalServiceSecuritySettings service_settings;
+
+               public SecurityAlgorithmSuite DefaultAlgorithmSuite {
+                       get { return alg_suite; }
+                       set { alg_suite = value; }
+               }
+
+               public bool IncludeTimestamp {
+                       get { return include_timestamp; }
+                       set { include_timestamp = value; }
+               }
+
+               public SecurityKeyEntropyMode KeyEntropyMode {
+                       get { return key_entropy_mode; }
+                       set { key_entropy_mode = value; }
+               }
+
+               public LocalClientSecuritySettings LocalClientSettings {
+                       get { return client_settings; }
+               }
+
+               public LocalServiceSecuritySettings LocalServiceSettings {
+                       get { return service_settings; }
+               }
+
+               public SecurityHeaderLayout SecurityHeaderLayout {
+                       get { return security_header_layout; }
+                       set { security_header_layout = value; }
+               }
+
+               public MessageSecurityVersion MessageSecurityVersion {
+                       get { return msg_security_version; }
+                       set { msg_security_version = value; }
+               }
+
+               public SupportingTokenParameters EndpointSupportingTokenParameters {
+                       get { return endpoint; }
+               }
+
+               public IDictionary<string,SupportingTokenParameters> OperationSupportingTokenParameters {
+                       get { return operation; }
+               }
+
+               public SupportingTokenParameters OptionalEndpointSupportingTokenParameters {
+                       get { return opt_endpoint; }
+               }
+
+               public IDictionary<string,SupportingTokenParameters> OptionalOperationSupportingTokenParameters {
+                       get { return opt_operation; }
+               }
+
+               [MonoTODO ("It supports only IRequestSessionChannel")]
+               public override bool CanBuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       return context.CanBuildInnerChannelFactory<TChannel> ();
+               }
+
+               [MonoTODO ("It probably supports only IReplySessionChannel")]
+               public override bool CanBuildChannelListener<TChannel> (BindingContext context)
+               {
+                       return context.CanBuildInnerChannelListener<TChannel> ();
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       return BuildChannelFactoryCore<TChannel> (context);
+               }
+
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       return BuildChannelListenerCore<TChannel> (context);
+               }
+
+               public virtual void SetKeyDerivation (bool requireDerivedKeys)
+               {
+                       endpoint.SetKeyDerivation (requireDerivedKeys);
+                       opt_endpoint.SetKeyDerivation (requireDerivedKeys);
+                       foreach (SupportingTokenParameters p in operation.Values)
+                               p.SetKeyDerivation (requireDerivedKeys);
+                       foreach (SupportingTokenParameters p in opt_operation.Values)
+                               p.SetKeyDerivation (requireDerivedKeys);
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+
+               protected abstract IChannelFactory<TChannel>
+                       BuildChannelFactoryCore<TChannel> (BindingContext context);
+
+               protected abstract IChannelListener<TChannel> 
+                       BuildChannelListenerCore<TChannel> (BindingContext context)
+                       where TChannel : class, IChannel;
+
+               #region Factory methods
+               public static SymmetricSecurityBindingElement 
+                       CreateAnonymousForCertificateBindingElement ()
+               {
+                       SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
+                       be.RequireSignatureConfirmation = true;
+                       be.ProtectionTokenParameters = CreateProtectionTokenParameters (true);
+                       return be;
+               }
+
+               public static TransportSecurityBindingElement 
+                       CreateCertificateOverTransportBindingElement ()
+               {
+                       return CreateCertificateOverTransportBindingElement (MessageSecurityVersion.Default);
+               }
+
+               [MonoTODO]
+               public static TransportSecurityBindingElement 
+                       CreateCertificateOverTransportBindingElement (MessageSecurityVersion version)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static AsymmetricSecurityBindingElement 
+                       CreateCertificateSignatureBindingElement  ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static SymmetricSecurityBindingElement 
+                       CreateIssuedTokenBindingElement  (
+                       IssuedSecurityTokenParameters issuedTokenParameters)
+               {
+                       SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
+                       be.ProtectionTokenParameters = issuedTokenParameters;
+                       return be;
+               }
+
+               public static SymmetricSecurityBindingElement
+                       CreateIssuedTokenForCertificateBindingElement (
+                       IssuedSecurityTokenParameters issuedTokenParameters)
+               {
+                       SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
+                       be.RequireSignatureConfirmation = true;
+                       be.ProtectionTokenParameters = CreateProtectionTokenParameters (true);
+                       be.EndpointSupportingTokenParameters.Endorsing.Add (
+                               issuedTokenParameters);
+                       return be;
+               }
+
+               [MonoTODO]
+               public static SymmetricSecurityBindingElement 
+                       CreateIssuedTokenForSslBindingElement (
+                       IssuedSecurityTokenParameters issuedTokenParameters)
+               {
+                       return CreateIssuedTokenForSslBindingElement (
+                               issuedTokenParameters, false);
+               }
+
+               [MonoTODO]
+               public static SymmetricSecurityBindingElement 
+                       CreateIssuedTokenForSslBindingElement (
+                       IssuedSecurityTokenParameters issuedTokenParameters,
+                       bool requireCancellation)
+               {
+                       SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
+                       be.RequireSignatureConfirmation = true;
+                       be.ProtectionTokenParameters = CreateProtectionTokenParameters (false);
+                       be.EndpointSupportingTokenParameters.Endorsing.Add (
+                               issuedTokenParameters);
+                       return be;
+               }
+
+               [MonoTODO]
+               public static TransportSecurityBindingElement 
+                       CreateIssuedTokenOverTransportBindingElement (
+                       IssuedSecurityTokenParameters issuedTokenParameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static SymmetricSecurityBindingElement CreateKerberosBindingElement ()
+               {
+                       SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
+                       be.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic128;
+                       be.ProtectionTokenParameters = CreateProtectionTokenParameters (false);
+                       be.ProtectionTokenParameters.InclusionMode =
+                               SecurityTokenInclusionMode.Once;
+                       return be;
+               }
+
+               [MonoTODO]
+               public static TransportSecurityBindingElement 
+                       CreateKerberosOverTransportBindingElement ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static SecurityBindingElement 
+                       CreateMutualCertificateBindingElement ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static SecurityBindingElement 
+                       CreateMutualCertificateBindingElement (MessageSecurityVersion version)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static SecurityBindingElement 
+                       CreateMutualCertificateBindingElement (
+                       MessageSecurityVersion version,
+                       bool allowSerializedSigningTokenOnReply)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static AsymmetricSecurityBindingElement 
+                       CreateMutualCertificateDuplexBindingElement ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static AsymmetricSecurityBindingElement 
+                       CreateMutualCertificateDuplexBindingElement (
+                       MessageSecurityVersion version)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static SecurityBindingElement 
+                       CreateSecureConversationBindingElement (SecurityBindingElement binding)
+               {
+                       return CreateSecureConversationBindingElement (binding, false);
+               }
+
+               public static SecurityBindingElement 
+                       CreateSecureConversationBindingElement (
+                       SecurityBindingElement binding, bool requireCancellation)
+               {
+                       return CreateSecureConversationBindingElement (binding, requireCancellation, null);
+               }
+
+               [MonoTODO]
+               public static SecurityBindingElement 
+                       CreateSecureConversationBindingElement (
+                       SecurityBindingElement binding, bool requireCancellation,
+                       ChannelProtectionRequirements protectionRequirements)
+               {
+                       SymmetricSecurityBindingElement be =
+                               new SymmetricSecurityBindingElement ();
+                       be.ProtectionTokenParameters =
+                               new SecureConversationSecurityTokenParameters (
+                                       binding, requireCancellation, protectionRequirements);
+                       return be;
+               }
+
+               [MonoTODO]
+               public static SymmetricSecurityBindingElement 
+                       CreateSslNegotiationBindingElement (bool requireClientCertificate)
+               {
+                       return CreateSslNegotiationBindingElement (
+                               requireClientCertificate, false);
+               }
+
+               [MonoTODO]
+               public static SymmetricSecurityBindingElement 
+                       CreateSslNegotiationBindingElement (
+                       bool requireClientCertificate,
+                       bool requireCancellation)
+               {
+                       SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
+                       be.ProtectionTokenParameters = new SslSecurityTokenParameters (requireClientCertificate, requireCancellation);
+                       return be;
+               }
+
+               [MonoTODO]
+               public static SymmetricSecurityBindingElement 
+                       CreateSspiNegotiationBindingElement ()
+               {
+                       return CreateSspiNegotiationBindingElement (true);
+               }
+
+               [MonoTODO]
+               public static SymmetricSecurityBindingElement 
+                       CreateSspiNegotiationBindingElement (bool requireCancellation)
+               {
+                       SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
+                       be.ProtectionTokenParameters = CreateProtectionTokenParameters (false);
+                       return be;
+               }
+
+               public static TransportSecurityBindingElement 
+                       CreateSspiNegotiationOverTransportBindingElement ()
+               {
+                       return CreateSspiNegotiationOverTransportBindingElement (false);
+               }
+
+               [MonoTODO]
+               public static TransportSecurityBindingElement 
+                       CreateSspiNegotiationOverTransportBindingElement (bool requireCancellation)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               static X509SecurityTokenParameters CreateProtectionTokenParameters (bool cert)
+               {
+                       X509SecurityTokenParameters p =
+                               new X509SecurityTokenParameters ();
+                       p.X509ReferenceStyle = X509KeyIdentifierClauseType.Thumbprint;
+                       if (cert)
+                               p.InclusionMode = SecurityTokenInclusionMode.Never;
+                       return p;
+               }
+
+               [MonoTODO]
+               public static SymmetricSecurityBindingElement 
+                       CreateUserNameForCertificateBindingElement ()
+               {
+                       SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
+                       be.ProtectionTokenParameters = CreateProtectionTokenParameters (true);
+                       UserNameSecurityTokenParameters utp =
+                               new UserNameSecurityTokenParameters ();
+                       be.EndpointSupportingTokenParameters.SignedEncrypted.Add (utp);
+                       return be;
+               }
+
+               [MonoTODO]
+               public static SymmetricSecurityBindingElement 
+                       CreateUserNameForSslBindingElement ()
+               {
+                       return CreateUserNameForSslBindingElement (false);
+               }
+
+               [MonoTODO]
+               public static SymmetricSecurityBindingElement 
+                       CreateUserNameForSslBindingElement (bool requireCancellation)
+               {
+                       SymmetricSecurityBindingElement be = new SymmetricSecurityBindingElement ();
+                       be.ProtectionTokenParameters = CreateProtectionTokenParameters (false);
+                       UserNameSecurityTokenParameters utp =
+                               new UserNameSecurityTokenParameters ();
+                       be.EndpointSupportingTokenParameters.SignedEncrypted.Add (utp);
+                       return be;
+               }
+
+               [MonoTODO]
+               public static TransportSecurityBindingElement 
+                       CreateUserNameOverTransportBindingElement ()
+               {
+                       throw new NotImplementedException ();
+               }
+               #endregion
+
+               // It seems almost internal, hardcoded like this (I tried
+               // custom parameters that sets IssuedTokenSecurityTokenParameters
+               // like below ones, but that didn't trigger this method).
+               protected static void SetIssuerBindingContextIfRequired (
+                       SecurityTokenParameters parameters,
+                       BindingContext issuerBindingContext)
+               {
+                       if (parameters is IssuedSecurityTokenParameters ||
+                           parameters is SecureConversationSecurityTokenParameters ||
+                           parameters is SslSecurityTokenParameters ||
+                           parameters is SspiSecurityTokenParameters) {
+                               parameters.IssuerBindingContext = issuerBindingContext;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityBindingElementImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityBindingElementImporter.cs
new file mode 100644 (file)
index 0000000..fa38443
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// SecurityBindingElementImporter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public class SecurityBindingElementImporter : IPolicyImportExtension
+       {
+               [MonoTODO]
+               public int MaxPolicyRedirections {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               void IPolicyImportExtension.ImportPolicy (MetadataImporter importer,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityChannelFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityChannelFactory.cs
new file mode 100644 (file)
index 0000000..f85a47e
--- /dev/null
@@ -0,0 +1,99 @@
+//
+// SecurityChannelFactory.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Runtime.Serialization;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using System.Xml.XPath;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Channels
+{
+       internal class SecurityChannelFactory<TChannel> : ChannelFactoryBase<TChannel>
+       {
+               IChannelFactory<TChannel> inner;
+               InitiatorMessageSecurityBindingSupport security;
+
+               public SecurityChannelFactory (
+                       IChannelFactory<TChannel> innerFactory, 
+                       InitiatorMessageSecurityBindingSupport security)
+               {
+                       this.inner = innerFactory;
+                       this.security = security;
+               }
+
+               public InitiatorMessageSecurityBindingSupport SecuritySupport {
+                       get { return security; }
+               }
+
+               protected override TChannel OnCreateChannel (
+                       EndpointAddress remoteAddress, Uri via)
+               {
+                       TChannel src = inner.CreateChannel (remoteAddress, via);
+
+                       if (typeof (TChannel) == typeof (IRequestChannel))
+                               return (TChannel) (object) new SecurityRequestChannel ((IRequestChannel) (object) src, (SecurityChannelFactory<IRequestChannel>) (object) this);
+                       if (typeof (TChannel) == typeof (IOutputChannel))
+                               return (TChannel) (object) new SecurityOutputChannel ((IOutputChannel) (object) src, (SecurityChannelFactory<IOutputChannel>) (object) this);
+                       if (typeof (TChannel) == typeof (IRequestSessionChannel))
+                               return (TChannel) (object) new SecurityRequestSessionChannel ((IRequestSessionChannel) (object) src, (SecurityChannelFactory<IRequestSessionChannel>) (object) this);
+                       if (typeof (TChannel) == typeof (IOutputSessionChannel))
+                               return (TChannel) (object) new SecurityOutputSessionChannel ((IOutputSessionChannel) (object) src, (SecurityChannelFactory<IOutputSessionChannel>) (object) this);
+
+                       throw new NotSupportedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       inner.Open (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginOpen (timeout, callback, state);
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       inner.EndOpen (result);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityChannelListener.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityChannelListener.cs
new file mode 100644 (file)
index 0000000..05c52ef
--- /dev/null
@@ -0,0 +1,225 @@
+//
+// SecurityChannelListener.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Channels
+{
+       internal class SecurityChannelListener<TChannel> : ChannelListenerBase<TChannel>
+                 where TChannel : class, IChannel
+       {
+               IChannelListener<TChannel> inner;
+               RecipientMessageSecurityBindingSupport security;
+
+               public SecurityChannelListener (
+                       IChannelListener<TChannel> innerListener, 
+                       RecipientMessageSecurityBindingSupport security)
+               {
+                       inner = innerListener;
+                       this.security = security;
+               }
+
+               public RecipientMessageSecurityBindingSupport SecuritySupport {
+                       get { return security; }
+               }
+
+               public override T GetProperty<T> ()
+               {
+                       if (typeof (T) == typeof (MessageSecurityBindingSupport))
+                               return (T) (object) security;
+                       return base.GetProperty<T> ();
+               }
+
+               TChannel CreateSecurityWrapper (TChannel src)
+               {
+                       if (typeof (TChannel) == typeof (IReplyChannel))
+                               return (TChannel) (object) new SecurityReplyChannel ((SecurityChannelListener<IReplyChannel>) (object) this, (IReplyChannel) (object) src);
+                       throw new NotImplementedException ();
+               }
+
+               void AcquireTokens ()
+               {
+                       security.Prepare (this);
+               }
+
+               void ReleaseTokens ()
+               {
+                       security.Release ();
+               }
+
+               // ChannelListenerBase
+
+               protected override TChannel OnAcceptChannel (TimeSpan timeout)
+               {
+                       return CreateSecurityWrapper (inner.AcceptChannel (timeout));
+               }
+
+               protected override IAsyncResult OnBeginAcceptChannel (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginAcceptChannel (timeout, callback, state);
+               }
+
+               protected override TChannel OnEndAcceptChannel (IAsyncResult result)
+               {
+                       return CreateSecurityWrapper (inner.EndAcceptChannel (result));
+               }
+
+               protected override bool OnWaitForChannel (TimeSpan timeout)
+               {
+                       return inner.WaitForChannel (timeout);
+               }
+
+               protected override IAsyncResult OnBeginWaitForChannel (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginWaitForChannel (timeout, callback, state);
+               }
+
+               protected override bool OnEndWaitForChannel (IAsyncResult result)
+               {
+                       return inner.EndWaitForChannel (result);
+               }
+
+               public override Uri Uri {
+                       get { return inner.Uri; }
+               }
+
+               // CommunicationObject
+               protected override void OnAbort ()
+               {
+                       inner.Abort ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       ReleaseTokens ();
+                       inner.Close (timeout);
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       ReleaseTokens ();
+                       return inner.BeginClose (timeout, callback, state);
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       inner.EndClose (result);
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       AcquireTokens ();
+                       inner.Open (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       AcquireTokens ();
+                       return inner.BeginOpen (timeout, callback, state);
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       inner.EndOpen (result);
+               }
+       }
+
+       internal class SecurityReplyChannel : LayeredReplyChannel
+       {
+               SecurityChannelListener<IReplyChannel> source;
+
+               public SecurityReplyChannel (
+                       SecurityChannelListener<IReplyChannel> source,
+                       IReplyChannel innerChannel)
+                       : base (innerChannel)
+               {
+                       this.source = source;
+               }
+
+               public override ChannelListenerBase Listener {
+                       get { return source; }
+               }
+
+               public SecurityChannelListener<IReplyChannel> Source {
+                       get { return source; }
+               }
+
+               // IReplyChannel
+
+               public override IAsyncResult BeginReceiveRequest (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override IAsyncResult BeginTryReceiveRequest (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override RequestContext EndReceiveRequest (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool EndTryReceiveRequest (IAsyncResult result, out RequestContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override RequestContext  ReceiveRequest (TimeSpan timeout)
+               {
+                       return new SecurityRequestContext (this, base.ReceiveRequest (timeout));
+               }
+
+               public override bool TryReceiveRequest (TimeSpan timeout, out RequestContext context)
+               {
+                       if (!base.TryReceiveRequest (timeout, out context))
+                               return false;
+                       context = new SecurityRequestContext (this, context);
+                       return true;
+               }
+
+               // IChannel
+
+               public override T GetProperty<T> ()
+               {
+                       // FIXME: implement
+                       return base.GetProperty<T> ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityOutputChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityOutputChannel.cs
new file mode 100644 (file)
index 0000000..18d652f
--- /dev/null
@@ -0,0 +1,131 @@
+//
+// SecurityRequestChannel.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Runtime.Serialization;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using System.Xml.XPath;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Channels
+{
+       class SecurityOutputChannel : SecurityOutputChannelBase
+       {
+               SecurityChannelFactory<IOutputChannel> source;
+
+               public SecurityOutputChannel (IOutputChannel innerChannel, SecurityChannelFactory<IOutputChannel> source)
+                       : base (innerChannel)
+               {
+                       this.source = source;
+                       InitializeSecurityFunctionality (source.SecuritySupport);
+               }
+
+               public override ChannelFactoryBase Factory {
+                       get { return source; }
+               }
+       }
+
+       class SecurityOutputSessionChannel : SecurityOutputChannelBase
+       {
+               SecurityChannelFactory<IOutputSessionChannel> source;
+
+               public SecurityOutputSessionChannel (IOutputSessionChannel innerChannel, SecurityChannelFactory<IOutputSessionChannel> source)
+                       : base (innerChannel)
+               {
+                       this.source = source;
+                       InitializeSecurityFunctionality (source.SecuritySupport);
+               }
+
+               public override ChannelFactoryBase Factory {
+                       get { return source; }
+               }
+       }
+
+       abstract class SecurityOutputChannelBase : LayeredOutputChannel
+       {
+               InitiatorMessageSecurityBindingSupport security;
+
+               protected SecurityOutputChannelBase (IOutputChannel innerChannel)
+                       : base (innerChannel)
+               {
+                       Opened += new EventHandler (AcquireSecurityKey);
+                       Closing += new EventHandler (ReleaseSecurityKey);
+               }
+
+               protected void InitializeSecurityFunctionality (InitiatorMessageSecurityBindingSupport security)
+               {
+                       this.security = security;
+               }
+
+               protected override IAsyncResult OnBeginSend (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       Message secure = SecureMessage (message);
+                       return base.BeginSend (secure, timeout, callback, state);
+               }
+
+               protected override void OnEndSend (IAsyncResult result)
+               {
+                       // FIXME: it must be also asynchronized.
+                       base.EndSend (result);
+               }
+
+               protected override void OnSend (Message message, TimeSpan timeout)
+               {
+                       Message secure = SecureMessage (message);
+                       base.OnSend (secure, timeout);
+               }
+
+               Message SecureMessage (Message msg)
+               {
+                       return new InitiatorMessageSecurityGenerator (msg, security, RemoteAddress).SecureMessage ();
+               }
+
+               void AcquireSecurityKey (object o, EventArgs e)
+               {
+                       security.Prepare (Factory, RemoteAddress);
+               }
+
+               void ReleaseSecurityKey (object o, EventArgs e)
+               {
+                       security.Release ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityRequestChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityRequestChannel.cs
new file mode 100644 (file)
index 0000000..3a94b59
--- /dev/null
@@ -0,0 +1,148 @@
+//
+// SecurityRequestChannel.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Runtime.Serialization;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using System.Xml.XPath;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Channels
+{
+       interface ISecurityChannelSource
+       {
+               MessageSecurityBindingSupport Support { get; }
+       }
+
+       class SecurityRequestChannel : SecurityRequestChannelBase
+       {
+               SecurityChannelFactory<IRequestChannel> source;
+
+               public SecurityRequestChannel (IRequestChannel innerChannel, SecurityChannelFactory<IRequestChannel> source)
+                       : base (innerChannel)
+               {
+                       this.source = source;
+                       InitializeSecurityFunctionality (source.SecuritySupport);
+               }
+
+               public override ChannelFactoryBase Factory {
+                       get { return source; }
+               }
+       }
+
+       class SecurityRequestSessionChannel : SecurityRequestChannelBase
+       {
+               SecurityChannelFactory<IRequestSessionChannel> source;
+
+               public SecurityRequestSessionChannel (IRequestSessionChannel innerChannel, SecurityChannelFactory<IRequestSessionChannel> source)
+                       : base (innerChannel)
+               {
+                       this.source = source;
+                       InitializeSecurityFunctionality (source.SecuritySupport);
+               }
+
+               public override ChannelFactoryBase Factory {
+                       get { return source; }
+               }
+       }
+
+       abstract class SecurityRequestChannelBase : LayeredRequestChannel
+       {
+               InitiatorMessageSecurityBindingSupport security;
+
+               protected SecurityRequestChannelBase (IRequestChannel innerChannel)
+                       : base (innerChannel)
+               {
+                       Opened += new EventHandler (AcquireSecurityKey);
+                       Closing += new EventHandler (ReleaseSecurityKey);
+               }
+
+               protected void InitializeSecurityFunctionality (InitiatorMessageSecurityBindingSupport security)
+               {
+                       this.security = security;
+               }
+
+               SecurityMessageProperty secprop;
+
+               protected override IAsyncResult OnBeginRequest (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       // FIXME: make it really async
+                       Message secure = SecureMessage (message);
+                       secprop = secure.Properties.Security;
+                       return base.BeginRequest (secure, timeout, callback, state);
+               }
+
+               protected override Message OnEndRequest (IAsyncResult result)
+               {
+                       // FIXME: it must be also asynchronized.
+                       Message raw = base.EndRequest (result);
+                       return ProcessReply (raw, secprop);
+               }
+
+               protected override Message OnRequest (Message message, TimeSpan timeout)
+               {
+                       Message secure = SecureMessage (message);
+                       Message raw = base.OnRequest (secure, timeout);
+                       return ProcessReply (raw, secure.Properties.Security);
+               }
+
+               Message SecureMessage (Message msg)
+               {
+                       return new InitiatorMessageSecurityGenerator (msg, security, RemoteAddress).SecureMessage ();
+               }
+
+               Message ProcessReply (Message message, SecurityMessageProperty secprop)
+               {
+                       // FIXME: provide correct parameters
+                       return new InitiatorSecureMessageDecryptor (message, secprop, security).DecryptMessage ();
+               }
+
+               void AcquireSecurityKey (object o, EventArgs e)
+               {
+                       security.Prepare (Factory, RemoteAddress);
+               }
+
+               void ReleaseSecurityKey (object o, EventArgs e)
+               {
+                       security.Release ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityRequestContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SecurityRequestContext.cs
new file mode 100644 (file)
index 0000000..774d800
--- /dev/null
@@ -0,0 +1,148 @@
+//
+// SecurityRequestContext.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using System.Xml.XPath;
+
+namespace System.ServiceModel.Channels
+{
+       internal class SecurityRequestContext : RequestContext
+       {
+               RecipientMessageSecurityBindingSupport security;
+               SecurityReplyChannel channel;
+               RequestContext source;
+               Message msg;
+               MessageBuffer source_request;
+
+               public SecurityRequestContext (SecurityReplyChannel channel, RequestContext source)
+               {
+                       this.source = source;
+                       this.channel = channel;
+
+                       security = channel.Source.SecuritySupport;
+               }
+
+               MessageBuffer SourceBuffer {
+                       get {
+                               if (source_request == null)
+                                       source_request = source.RequestMessage.CreateBufferedCopy (0x10000);
+                               return source_request;
+                       }
+               }
+
+               public override Message RequestMessage {
+                       get {
+                               if (msg == null) {
+                                       msg = SourceBuffer.CreateMessage (); // default
+                                       switch (msg.Headers.Action) {
+                                       case Constants.WstIssueAction:
+                                       case Constants.WstIssueReplyAction:
+                                       case Constants.WstRenewAction:
+                                       case Constants.WstCancelAction:
+                                       case Constants.WstValidateAction:
+                                               break;
+                                       default:
+                                               msg = new RecipientSecureMessageDecryptor (msg, security).DecryptMessage ();
+                                               break;
+                                       }
+                               }
+                               return msg;
+                       }
+               }
+
+               public override void Abort ()
+               {
+                       source.Abort ();
+               }
+
+               public override IAsyncResult BeginReply (Message message, AsyncCallback callback, object state)
+               {
+                       return BeginReply (message, channel.Listener.DefaultSendTimeout, callback, state);
+               }
+
+               public override IAsyncResult BeginReply (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               public override void Close ()
+               {
+                       Close (channel.Listener.DefaultCloseTimeout);
+               }
+
+               public override void Close (TimeSpan timeout)
+               {
+                       source.Close (timeout);
+               }
+
+               public override void EndReply (IAsyncResult result)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               public override void Reply (Message message)
+               {
+                       Reply (message, channel.Listener.DefaultSendTimeout);
+               }
+
+               public override void Reply (Message message, TimeSpan timeout)
+               {
+                       try {
+                               if (!message.IsFault && message.Headers.Action != Constants.WstIssueReplyAction)
+                                       message = SecureMessage (message);
+                               source.Reply (message, timeout);
+                       } catch (Exception ex) {
+                               FaultConverter fc = FaultConverter.GetDefaultFaultConverter (msg.Version);
+                               Message fault;
+                               if (fc.TryCreateFaultMessage (ex, out fault))
+                                       source.Reply (fault, timeout);
+                               else
+                                       throw;
+                       }
+               }
+
+               Message SecureMessage (Message input)
+               {
+                       return new RecipientMessageSecurityGenerator (input, this, security).SecureMessage ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ServiceHostParser.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ServiceHostParser.cs
new file mode 100644 (file)
index 0000000..c91ef5e
--- /dev/null
@@ -0,0 +1,219 @@
+//
+// ServiceHostParser.cs
+//
+// Author:
+//     Ankit Jain      (jankit@novell.com)
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections;
+using System.Collections.Specialized;
+using System.IO;
+using System.Text;
+using System.Web;
+using System.Web.Caching;
+using System.Web.Configuration;
+
+namespace System.ServiceModel.Channels {
+
+       class ServiceHostParser
+       {
+               string file;
+               string url;
+               string type_name;
+               string language;
+               string factory;
+               bool debug;
+               bool got_default_directive;
+               string program; // If program == null, we have to get the requested 'type_name' from the assemblies in bin
+               ArrayList assemblies;
+               HttpContext context;
+
+               public ServiceHostParser (string file, string url, HttpContext context)
+               {
+                       this.file = file;
+                       this.url = url;
+                       assemblies = new ArrayList ();
+                       assemblies.Add ("System.ServiceModel");
+                       this.context = context;
+                       CompilationSection section = (CompilationSection) context.GetSection ("system.web/compilation");
+                       language = section.DefaultLanguage;
+               }
+
+               public HttpContext Context {
+                       get { return context; }
+               }
+
+               public string Filename {
+                       get { return file; }
+               }
+
+               public string TypeName {
+                       get { return type_name; }
+               }
+
+               public bool Debug {
+                       get { return debug; }
+               }
+
+               public string Program {
+                       get { return program; }
+               }
+
+               public ArrayList Assemblies {
+                       get { return assemblies; }
+               }
+
+               public string Factory {
+                       get { return factory; }
+               }
+
+               public string Language {
+                       get { return language; }
+               }
+
+               public void Parse ()
+               {
+                       using (StreamReader reader = new StreamReader (file)) {
+                               string line;
+                               bool directive_found = false;
+                               StringBuilder content = new StringBuilder ();
+                                       
+                               while ((line = reader.ReadLine ()) != null) {
+                                       string trimmed = line.Trim ();
+                                       if (!directive_found && trimmed == String.Empty)
+                                               continue;
+                                       
+                                       if (trimmed.StartsWith ("<%@")) {
+                                               ParseDirective (trimmed);
+                                               directive_found = true;
+                                               continue;
+                                       }
+
+                                       content.Append (line + "\n");
+                                       content.Append (reader.ReadToEnd ());
+                               }
+                               
+                               if (!got_default_directive)
+                                       throw new Exception ("No @ServiceHost directive found");
+
+                               this.program = content.ToString ().Trim ();
+                               if (this.program.Trim () == "")
+                                       this.program = null;
+                       }
+
+                       if (String.IsNullOrEmpty (Language))
+                               throw new Exception ("Language not specified.");
+               }
+
+               void ParseDirective (string line)
+               {
+                       StringDictionary attributes = Split (line);
+
+                       //Directive
+                       if (String.Compare (attributes ["directive"], "ServiceHost", true) == 0) {
+                               got_default_directive = true;
+
+                               if (!attributes.ContainsKey ("SERVICE"))
+                                       throw new Exception ("Service attribute not present in @ServiceHost directive.");
+                               else
+                                       type_name = attributes ["SERVICE"];
+
+                               if (attributes.ContainsKey ("LANGUAGE"))
+                                       language = attributes ["LANGUAGE"];
+
+                               if (attributes.ContainsKey ("FACTORY"))
+                                       factory = attributes ["FACTORY"];
+
+                               if (attributes.ContainsKey ("DEBUG")) {
+                                       if (String.Compare (attributes ["DEBUG"], "TRUE", true) == 0)
+                                               debug = true;
+                                       else if (String.Compare (attributes ["DEBUG"], "FALSE", true) == 0)
+                                               debug = false;
+                                       else
+                                               throw new Exception (String.Format (
+                                                       "Invalid value for debug attribute : '{0}'", attributes ["DEBUG"]));
+                               }
+
+
+                               //FIXME: Other attributes, 
+                               return;
+                       }
+                       //FIXME: Other directives? Documentation doesn't mention any other
+
+                       throw new Exception (String.Format ("Cannot handle directive : '{0}'", attributes ["directive"]));
+               }
+
+               StringDictionary Split (string line)
+               {
+                       line.Trim ();
+                       int end_pos = line.LastIndexOf ("%>");
+                       if (end_pos < 0)
+                               throw new Exception ("Directive must end with '%>'");
+
+                       StringDictionary table = new StringDictionary ();
+                       string content = line.Substring (3, end_pos - 3).Trim ();
+                       if (content.Length == 0)
+                               throw new Exception ("No directive found");
+
+                       int len = content.Length;
+                       int pos = 0;
+                       
+                       while (pos < len && content [pos] != ' ')
+                               pos ++;
+
+                       if (pos >= len) {
+                               table ["directive"] = content;
+                               return table;
+                       }
+
+                       table ["directive"] = content.Substring (0, pos);
+
+                       content = content.Substring (pos);
+
+                       len = content.Length;
+                       pos = 0;
+                       while (pos < len) {
+                               //skip spaces   
+                               while (content [pos] == ' ' && pos < len)
+                                       pos ++;
+
+                               int eq_pos = content.IndexOf ('=', pos);
+                               string key = content.Substring (pos, eq_pos - pos).Trim ();
+
+                               pos = eq_pos + 1;
+                               int start_quote = content.IndexOf ('"', pos);
+                               int end_quote = content.IndexOf ('"', start_quote + 1);
+
+                               string val = content.Substring (start_quote + 1, end_quote - start_quote - 1).Trim ();
+
+                               pos = end_quote + 1;
+                               table [key.ToUpper ()] = val;
+                       }
+
+                       return table;
+               }
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SslStreamSecurityBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SslStreamSecurityBindingElement.cs
new file mode 100644 (file)
index 0000000..e9f1456
--- /dev/null
@@ -0,0 +1,139 @@
+//
+// SslStreamSecurityBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public class SslStreamSecurityBindingElement
+               : BindingElement, ITransportTokenAssertionProvider, IPolicyExportExtension
+       {
+               public SslStreamSecurityBindingElement ()
+               {
+                       verifier = IdentityVerifier.CreateDefault ();
+               }
+
+               IdentityVerifier verifier;
+               bool require_client_certificate;
+
+               public IdentityVerifier IdentityVerifier {
+                       get { return verifier; }
+                       set { verifier = value; }
+               }
+
+               public bool RequireClientCertificate {
+                       get { return require_client_certificate; }
+                       set { require_client_certificate = value; }
+               }
+
+               private SslStreamSecurityBindingElement (
+                       SslStreamSecurityBindingElement other)
+                       : base (other)
+               {
+                       verifier = other.verifier;
+                       require_client_certificate = other.require_client_certificate;
+               }
+
+               [MonoTODO]
+               public StreamUpgradeProvider BuildClientStreamUpgradeProvider (BindingContext context)
+               {
+                       return new SslStreamSecurityUpgradeProvider (this);
+               }
+
+               [MonoTODO]
+               public StreamUpgradeProvider BuildServerStreamUpgradeProvider (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public XmlElement GetTransportTokenAssertion ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override IChannelFactory<TChannel>
+                       BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override bool CanBuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override bool CanBuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new SslStreamSecurityBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               #region explicit interface implementations
+               [MonoTODO]
+               void IPolicyExportExtension.ExportPolicy (
+                       MetadataExporter exporter,
+                       PolicyConversionContext policyContext)
+               {
+                       throw new NotImplementedException ();
+               }
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SslStreamSecurityUpgradeAcceptor.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SslStreamSecurityUpgradeAcceptor.cs
new file mode 100644 (file)
index 0000000..fed306a
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// SslStreamSecurityUpgradeAcceptor.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       class SslStreamSecurityUpgradeAcceptor : StreamSecurityUpgradeAcceptor
+       {
+               SslStreamSecurityUpgradeProvider source;
+               public SslStreamSecurityUpgradeAcceptor (SslStreamSecurityUpgradeProvider source)
+               {
+                       this.source = source;
+               }
+
+               public override SecurityMessageProperty GetRemoteSecurity()
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               public override bool CanUpgrade (string contentType)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               public override IAsyncResult BeginAcceptUpgrade (
+                       Stream stream, AsyncCallback callback, object state)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               public override Stream EndAcceptUpgrade(IAsyncResult result)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SslStreamSecurityUpgradeProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SslStreamSecurityUpgradeProvider.cs
new file mode 100644 (file)
index 0000000..fdcddc8
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// SslStreamSecurityUpgradeProvider.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       class SslStreamSecurityUpgradeProvider : StreamSecurityUpgradeProvider
+       {
+               SslStreamSecurityBindingElement source;
+
+               public SslStreamSecurityUpgradeProvider (SslStreamSecurityBindingElement source)
+               {
+                       this.source = source;
+               }
+
+               // FIXME: implement
+               public override EndpointIdentity Identity {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public override StreamUpgradeAcceptor CreateUpgradeAcceptor ()
+               {
+                       return new SslStreamSecurityUpgradeAcceptor (this);
+               }
+
+               public override StreamUpgradeInitiator CreateUpgradeInitiator (EndpointAddress remoteAddress, Uri via)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               // CommunicationObject
+
+               protected override void OnAbort ()
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StandardBindingImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StandardBindingImporter.cs
new file mode 100644 (file)
index 0000000..2147439
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// StandardBindingImporter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Description;
+using System.Web.Services.Description;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public class StandardBindingImporter : IWsdlImportExtension
+       {
+               [MonoTODO]
+               void IWsdlImportExtension.BeforeImport (
+                       ServiceDescriptionCollection wsdlDocuments,
+                       XmlSchemaSet xmlSchemas,
+                       ICollection<XmlElement> policy)
+               {
+               }
+
+               [MonoTODO]
+               void IWsdlImportExtension.ImportContract (WsdlImporter importer,
+                       WsdlContractConversionContext context)
+               {
+               }
+
+               [MonoTODO]
+               void IWsdlImportExtension.ImportEndpoint (WsdlImporter importer,
+                       WsdlEndpointConversionContext context)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamSecurityUpgradeAcceptor.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamSecurityUpgradeAcceptor.cs
new file mode 100644 (file)
index 0000000..01007bf
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// StreamSecurityUpgradeAcceptor.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class StreamSecurityUpgradeAcceptor
+               : StreamUpgradeAcceptor
+       {
+               protected StreamSecurityUpgradeAcceptor ()
+               {
+               }
+
+               public abstract SecurityMessageProperty GetRemoteSecurity ();
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamSecurityUpgradeInitiator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamSecurityUpgradeInitiator.cs
new file mode 100644 (file)
index 0000000..27d76ba
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// StreamSecurityUpgradeInitiator.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class StreamSecurityUpgradeInitiator
+               : StreamUpgradeInitiator
+       {
+               protected StreamSecurityUpgradeInitiator ()
+               {
+               }
+
+               public abstract SecurityMessageProperty GetRemoteSecurity ();
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamSecurityUpgradeProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamSecurityUpgradeProvider.cs
new file mode 100644 (file)
index 0000000..6d0c12e
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// StreamSecurityUpgradeProvider.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class StreamSecurityUpgradeProvider
+               : StreamUpgradeProvider
+       {
+               protected StreamSecurityUpgradeProvider ()
+                       : base ()
+               {
+               }
+
+               protected StreamSecurityUpgradeProvider (IDefaultCommunicationTimeouts timeouts)
+                       : base (timeouts)
+               {
+               }
+
+               public abstract EndpointIdentity Identity { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeAcceptor.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeAcceptor.cs
new file mode 100644 (file)
index 0000000..35f4f7e
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// StreamUpgradeAcceptor.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class StreamUpgradeAcceptor
+       {
+               protected StreamUpgradeAcceptor ()
+               {
+               }
+
+               public virtual Stream AcceptUpgrade (Stream stream)
+               {
+                       return EndAcceptUpgrade (BeginAcceptUpgrade (stream, null, null));
+               }
+
+               public abstract IAsyncResult BeginAcceptUpgrade (Stream stream,
+                       AsyncCallback callback, object state);
+
+               public abstract bool CanUpgrade (string contentType);
+
+               public abstract Stream EndAcceptUpgrade (IAsyncResult result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeBindingElement.cs
new file mode 100644 (file)
index 0000000..0a5fa43
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// StreamUpgradeBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class StreamUpgradeBindingElement : BindingElement
+       {
+               protected StreamUpgradeBindingElement ()
+               {
+               }
+
+               protected StreamUpgradeBindingElement (StreamUpgradeBindingElement other)
+               {
+               }
+
+               public abstract StreamUpgradeProvider 
+                       BuildClientStreamUpgradeProvider (BindingContext context);
+               public abstract StreamUpgradeProvider
+                       BuildServerStreamUpgradeProvider (BindingContext context);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeInitiator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeInitiator.cs
new file mode 100644 (file)
index 0000000..cd28ff5
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// StreamUpgradeInitiator.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class StreamUpgradeInitiator
+       {
+               protected StreamUpgradeInitiator ()
+               {
+               }
+
+               public abstract Stream InitiateUpgrade (Stream stream);
+
+               public abstract IAsyncResult BeginInitiateUpgrade (Stream stream,
+                       AsyncCallback callback, object state);
+
+               public abstract string GetNextUpgrade ();
+
+               public abstract Stream EndInitiateUpgrade (IAsyncResult result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/StreamUpgradeProvider.cs
new file mode 100644 (file)
index 0000000..afc6f81
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// StreamUpgradeProvider.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class StreamUpgradeProvider : CommunicationObject
+       {
+               protected StreamUpgradeProvider ()
+                       : this (DefaultCommunicationTimeouts.Instance)
+               {
+               }
+
+               protected StreamUpgradeProvider (IDefaultCommunicationTimeouts timeouts)
+               {
+                       if (timeouts == null)
+                               throw new ArgumentNullException ("timeouts");
+                       default_open_timeout = timeouts.OpenTimeout;
+                       default_close_timeout = timeouts.CloseTimeout;
+               }
+
+               TimeSpan default_open_timeout, default_close_timeout;
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return default_close_timeout; }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return default_open_timeout; }
+               }
+
+               public abstract StreamUpgradeAcceptor CreateUpgradeAcceptor ();
+
+               public abstract StreamUpgradeInitiator CreateUpgradeInitiator (
+                       EndpointAddress remoteAddress, Uri via);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs
new file mode 100644 (file)
index 0000000..fdaadb9
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// SvcHttpHandler.cs
+//
+// Author:
+//     Ankit Jain  <jankit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Web;
+using System.Threading;
+
+using System.ServiceModel;
+using System.ServiceModel.Activation;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels {
+
+       internal class SvcHttpHandler : IHttpHandler
+       {
+               Type type;
+               Type factory_type;
+               internal string path;
+               Uri request_url;
+               ServiceHostBase host;
+
+               AspNetReplyChannel reply_channel;
+               AutoResetEvent wait = new AutoResetEvent (false);
+               AutoResetEvent listening = new AutoResetEvent (false);
+
+               public SvcHttpHandler (Type type, Type factoryType, string path)
+               {
+                       this.type = type;
+                       this.factory_type = factoryType;
+                       this.path = path;
+               }
+
+               public bool IsReusable 
+               {
+                       get { return true; }
+               }
+
+               public bool WaitForRequest (AspNetReplyChannel reply_channel, TimeSpan timeout)
+               {
+                       this.reply_channel = reply_channel;
+                       listening.Set ();
+
+                       return wait.WaitOne (timeout, false);
+               }
+
+               public void ProcessRequest (HttpContext context)
+               {
+                       request_url = context.Request.Url;
+                       EnsureServiceHost ();
+
+                       reply_channel.Context = context;
+                       wait.Set ();
+
+                       listening.WaitOne ();
+                       reply_channel.Context = null;
+               }
+
+               public void Close ()
+               {
+                       host.Close ();
+                       host = null;
+               }
+
+               void ApplyConfiguration (ServiceHost host)
+               {
+                       foreach (ServiceElement service in ConfigUtil.ServicesSection.Services) {
+                               foreach (ServiceEndpointElement endpoint in service.Endpoints) {
+                                       // FIXME: consider BindingName as well
+                                       ServiceEndpoint se = host.AddServiceEndpoint (
+                                               endpoint.Contract,
+                                               ConfigUtil.CreateBinding (endpoint.Binding, endpoint.BindingConfiguration),
+                                               new Uri (path));
+                               }
+                               // behaviors
+                               ServiceBehaviorElement behavior = ConfigUtil.BehaviorsSection.ServiceBehaviors.Find (service.BehaviorConfiguration);
+                               if (behavior != null) {
+                                       foreach (BehaviorExtensionElement bxel in behavior) {
+                                               IServiceBehavior b = null;
+                                               ServiceMetadataPublishingElement meta = bxel as ServiceMetadataPublishingElement;
+                                               if (meta != null) {
+                                                       ServiceMetadataBehavior smb = meta.CreateBehavior () as ServiceMetadataBehavior;
+                                                       smb.HttpGetUrl = request_url;
+                                                       // FIXME: HTTPS as well
+                                                       b = smb;
+                                               }
+                                               if (b != null)
+                                                       host.Description.Behaviors.Add (b);
+                                       }
+                               }
+                       }
+               }
+
+               void EnsureServiceHost ()
+               {
+                       if (reply_channel != null)
+                               return;
+
+                       //ServiceHost for this not created yet
+                       if (factory_type != null)
+                               host = ((ServiceHostFactory) Activator.CreateInstance (factory_type)).CreateServiceHost (type, new Uri [0]);
+                       else
+                               host = new ServiceHost (type);
+
+#if true
+                       //FIXME: Binding: Get from web.config.
+                       host.AddServiceEndpoint (ContractDescription.GetContract (type).Name,
+                               new BasicHttpBinding (), new Uri (path));
+#else
+                       ApplyConfiguration (host);
+#endif
+
+                       host.Open ();
+
+                       listening.WaitOne ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandlerFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandlerFactory.cs
new file mode 100644 (file)
index 0000000..d80b04e
--- /dev/null
@@ -0,0 +1,169 @@
+//
+// SvcHttpHandlerFactory.cs
+//
+// Author:
+//     Ankit Jain  <jankit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.IO;
+using System.Reflection;
+using System.ServiceModel;
+using System.Web;
+using System.Web.Caching;
+
+namespace System.ServiceModel.Channels {
+
+       internal class SvcHttpHandlerFactory : IHttpHandlerFactory
+       {
+               static Dictionary<string, SvcHttpHandler> handlers = new Dictionary<string, SvcHttpHandler> ();
+               string privateBinPath;
+               Type service_type, factory_type;
+
+               public SvcHttpHandlerFactory ()
+               {
+                       ServiceHostingEnvironment.InAspNet = true;
+               }
+
+               public IHttpHandler GetHandler (HttpContext context, string requestType, string url, string pathTranslated)
+               {
+                       if (handlers.ContainsKey (url))
+                               return handlers [url];
+                       
+                       LoadTypeFromSvc (pathTranslated, url, context);
+                       if (service_type == null)
+                               throw new Exception (String.Format (
+                                       "Could not find service for url : '{0}'", url));
+                       
+                       SvcHttpHandler handler = new SvcHttpHandler (service_type, factory_type, url);
+                       handlers [url] = handler;
+
+                       return handler;
+               }
+
+               [MonoTODO]
+               public void ReleaseHandler (IHttpHandler handler)
+               {
+                       return;
+               }
+
+               internal static SvcHttpHandler GetHandler (string path)
+               {
+                       return handlers [path];
+               }
+
+               void LoadTypeFromSvc (string path, string url, HttpContext context)
+               {
+                       if (CachingCompiler.GetTypeFromCache (path) != null)
+                               return;
+                       
+                       ServiceHostParser parser = new ServiceHostParser (path, url, context);
+                       
+                       parser.Parse ();
+                       if (parser.Program == null) {
+                               //FIXME: Not caching, as parser.TypeName could be
+                               //just typename or fully qualified name
+                               service_type = GetTypeFromBin (parser.TypeName);
+                               /*CachingCompiler.InsertType (
+                                       service_type, service_type.Assembly.Location, url, 
+                                       new CacheItemRemovedCallback (RemovedCallback));*/
+                       } else {
+                               service_type = CachingCompiler.CompileAndGetType (
+                                       parser, url,
+                                       new CacheItemRemovedCallback (RemovedCallback));
+                       }
+
+                       if (parser.Factory != null) {
+                               factory_type = GetTypeFromBin (parser.Factory);
+                               /*CachingCompiler.InsertType (
+                                       factory_type, factory_type.Assembly.Location, url, 
+                                       new CacheItemRemovedCallback (RemovedCallback));*/
+                       }
+               }
+               
+               string PrivateBinPath {
+                       get {
+                               if (privateBinPath != null)
+                                       return privateBinPath;
+
+                               AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
+                               privateBinPath = setup.PrivateBinPath;
+                                       
+                               if (!Path.IsPathRooted (privateBinPath)) {
+                                       string appbase = setup.ApplicationBase;
+                                       if (appbase.StartsWith ("file://")) {
+                                               appbase = appbase.Substring (7);
+                                               if (Path.DirectorySeparatorChar != '/')
+                                                       appbase = appbase.Replace ('/', Path.DirectorySeparatorChar);
+                                       }
+                                       privateBinPath = Path.Combine (appbase, privateBinPath);
+                               }
+
+                               return privateBinPath;
+                       }
+               }
+
+               //FIXME: Service="TypeName,TypeNamespace" not handled
+               Type GetTypeFromBin (string typeName)
+               {
+                       if (!Directory.Exists (PrivateBinPath))
+                               throw new HttpException (String.Format ("Type {0} not found.", typeName));
+
+                       string [] binDlls = Directory.GetFiles (PrivateBinPath, "*.dll");
+                       Type result = null;
+                       foreach (string dll in binDlls) {
+                               Assembly assembly = Assembly.LoadFrom (dll);
+                               Type type = assembly.GetType (typeName, false);
+                               if (type != null) {
+                                       if (result != null) 
+                                               throw new HttpException (String.Format ("Type {0} is not unique.", typeName));
+
+                                       result = type;
+                               } 
+                       }
+
+                       if (result == null)
+                               throw new HttpException (String.Format ("Type {0} not found.", typeName));
+
+                       return result;
+               }
+
+               public static void RemovedCallback (string key, object value, CacheItemRemovedReason reason)
+               {
+                       if (key.StartsWith (CachingCompiler.cacheTypePrefix)) {
+                               string path = key.Remove (0, CachingCompiler.cacheTypePrefix.Length);
+
+                               SvcHttpHandler handler;
+                               if (!handlers.TryGetValue (path, out handler))
+                                       return;
+                               handler.Close ();
+
+                               handlers.Remove (path);
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SymmetricSecurityBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SymmetricSecurityBindingElement.cs
new file mode 100644 (file)
index 0000000..0bd3274
--- /dev/null
@@ -0,0 +1,178 @@
+//
+// SymmetricSecurityBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class SymmetricSecurityBindingElement
+               : SecurityBindingElement, IPolicyExportExtension
+       {
+               public SymmetricSecurityBindingElement ()
+                       : this ((SecurityTokenParameters) null)
+               {
+               }
+
+               public SymmetricSecurityBindingElement (
+                       SecurityTokenParameters protectionTokenParameters)
+               {
+                       ProtectionTokenParameters = protectionTokenParameters;
+               }
+
+               private SymmetricSecurityBindingElement (
+                       SymmetricSecurityBindingElement other)
+                       : base (other)
+               {
+                       msg_protection_order = other.msg_protection_order;
+                       require_sig_confirm = other.require_sig_confirm;
+                       if (other.protection_token_params != null)
+                               protection_token_params = other.protection_token_params.Clone ();
+               }
+
+               MessageProtectionOrder msg_protection_order =
+                       MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature;
+               SecurityTokenParameters protection_token_params;
+               bool require_sig_confirm;
+               // make sure that they are also cloned.
+
+               [MonoTODO]
+               public MessageProtectionOrder MessageProtectionOrder {
+                       get { return msg_protection_order; }
+                       set { msg_protection_order = value; }
+               }
+
+               public SecurityTokenParameters ProtectionTokenParameters {
+                       get { return protection_token_params; }
+                       set { protection_token_params = value; }
+               }
+
+               [MonoTODO]
+               public bool RequireSignatureConfirmation {
+                       get { return require_sig_confirm; }
+                       set { require_sig_confirm = value; }
+               }
+
+               public override void SetKeyDerivation (bool requireDerivedKeys)
+               {
+                       base.SetKeyDerivation (requireDerivedKeys);
+                       if (ProtectionTokenParameters != null)
+                               ProtectionTokenParameters.RequireDerivedKeys = requireDerivedKeys;
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+
+               [MonoTODO]
+               protected override IChannelFactory<TChannel>
+                       BuildChannelFactoryCore<TChannel> (
+                       BindingContext context)
+               {
+                       if (ProtectionTokenParameters == null)
+                               throw new InvalidOperationException ("Protection token parameters must be set before building channel factory.");
+
+                       SetIssuerBindingContextIfRequired (ProtectionTokenParameters, context);
+
+                       ClientCredentials cred = context.BindingParameters.Find<ClientCredentials> ();
+                       if (cred == null)
+                               // it happens when there is no ChannelFactory<T>.
+                               cred = new ClientCredentials ();
+                       SecurityTokenManager manager = cred.CreateSecurityTokenManager ();
+                       ChannelProtectionRequirements requirements =
+                               context.BindingParameters.Find<ChannelProtectionRequirements> ();
+
+                       return new SecurityChannelFactory<TChannel> (
+                               context.BuildInnerChannelFactory<TChannel> (), new InitiatorMessageSecurityBindingSupport (GetCapabilities (), manager, requirements));
+               }
+
+               [MonoTODO]
+               protected override IChannelListener<TChannel>
+                       BuildChannelListenerCore<TChannel> (
+                       BindingContext context)
+               {
+                       if (ProtectionTokenParameters == null)
+                               throw new InvalidOperationException ("Protection token parameters must be set before building channel factory.");
+
+                       SetIssuerBindingContextIfRequired (ProtectionTokenParameters, context);
+
+                       ServiceCredentials cred = context.BindingParameters.Find<ServiceCredentials> ();
+                       if (cred == null)
+                               // it happens when there is no ChannelFactory<T>.
+                               cred = new ServiceCredentials ();
+                       ServiceCredentialsSecurityTokenManager manager = (ServiceCredentialsSecurityTokenManager) cred.CreateSecurityTokenManager ();
+                       ChannelProtectionRequirements requirements =
+                               context.BindingParameters.Find<ChannelProtectionRequirements> ();
+
+                       return new SecurityChannelListener<TChannel> (
+                               context.BuildInnerChannelListener<TChannel> (), new RecipientMessageSecurityBindingSupport (GetCapabilities (), manager, requirements));
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new SymmetricSecurityBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       if (typeof (T) == typeof (ISecurityCapabilities))
+                               return (T) (object) GetCapabilities ();
+                       if (typeof (T) == typeof (IdentityVerifier))
+                               throw new NotImplementedException ();
+                       return context.GetInnerProperty<T> ();
+               }
+
+               SymmetricSecurityCapabilities GetCapabilities ()
+               {
+                       return new SymmetricSecurityCapabilities (this);
+               }
+
+               #region explicit interface implementations
+               [MonoTODO]
+               void IPolicyExportExtension.ExportPolicy (
+                       MetadataExporter exporter,
+                       PolicyConversionContext policyContext)
+               {
+                       throw new NotImplementedException ();
+               }
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpChannelFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpChannelFactory.cs
new file mode 100644 (file)
index 0000000..9bc4d79
--- /dev/null
@@ -0,0 +1,96 @@
+// 
+// TcpChannelFactory.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.Text;
+
+namespace System.ServiceModel.Channels
+{
+       internal class TcpChannelInfo
+       {
+               public TcpChannelInfo (TcpTransportBindingElement element, MessageEncoder encoder)
+               {
+                       this.element = element;
+                       this.encoder = encoder;
+               }
+
+               TcpTransportBindingElement element;
+               MessageEncoder encoder;
+
+               public TcpTransportBindingElement BindingElement {
+                       get { return element; }
+               }
+
+               public MessageEncoder MessageEncoder {
+                       get { return encoder; }
+               }
+       }
+
+       internal class TcpChannelFactory<TChannel> : ChannelFactoryBase<TChannel>
+       {
+               TcpChannelInfo info;
+
+               [MonoTODO]
+               public TcpChannelFactory (TcpTransportBindingElement source, BindingContext ctx)
+               {
+                       MessageEncoder encoder = null;
+                       foreach (BindingElement be in ctx.RemainingBindingElements) {
+                               MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
+                               if (mbe != null) {
+                                       encoder = mbe.CreateMessageEncoderFactory ().Encoder;
+                                       break;
+                               }
+                       }
+                       if (encoder == null)
+                               encoder = new BinaryMessageEncoder ();
+                       info = new TcpChannelInfo (source, encoder);
+               }
+
+               [MonoTODO]
+               protected override TChannel OnCreateChannel (
+                       EndpointAddress address, Uri via)
+               {                       
+                       ThrowIfDisposedOrNotOpen ();
+
+                       if (info.BindingElement.Scheme != address.Uri.Scheme)
+                               throw new ArgumentException (String.Format ("Argument EndpointAddress has unsupported URI scheme: {0}", address.Uri.Scheme));
+
+                       Type t = typeof (TChannel);
+                       
+                       if (t == typeof (IDuplexSessionChannel))
+                               return (TChannel) (object) new TcpDuplexSessionChannel (this, info, address, via);
+                       
+                       throw new InvalidOperationException (String.Format ("Channel type {0} is not supported.", typeof (TChannel).Name));
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnOpen (TimeSpan timeout)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpChannelListener.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpChannelListener.cs
new file mode 100644 (file)
index 0000000..c1636e7
--- /dev/null
@@ -0,0 +1,167 @@
+// 
+// TcpChannelListener.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.ServiceModel.Description;
+using System.Text;
+
+namespace System.ServiceModel.Channels
+{
+       internal class TcpChannelListener<TChannel> : ChannelListenerBase<TChannel> 
+               where TChannel : class, IChannel
+       {
+               List<IChannel> channels = new List<IChannel> ();
+               BindingContext context;
+               TcpChannelInfo info;
+               IDuplexSession session;
+               Uri listen_uri;
+               TcpListener tcp_listener;
+               
+               [MonoTODO]
+               public TcpChannelListener (TcpTransportBindingElement source, 
+                                          BindingContext context) : base (context.Binding)
+               {
+                       MessageEncoder encoder = null;
+                       if (context.ListenUriMode == ListenUriMode.Explicit)
+                               listen_uri =
+                                       context.ListenUriRelativeAddress != null ?
+                                       new Uri (context.ListenUriBaseAddress, context.ListenUriRelativeAddress) :
+                                       context.ListenUriBaseAddress;
+                       else
+                               throw new NotImplementedException ();
+                       
+                       foreach (BindingElement be in context.RemainingBindingElements) {
+                               MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
+                               if (mbe != null) {
+                                       encoder = mbe.CreateMessageEncoderFactory ().Encoder;
+                                       break;
+                               }
+                       }
+                       
+                       if (encoder == null)
+                               encoder = new BinaryMessageEncoder ();
+
+                       info = new TcpChannelInfo (source, encoder);
+               }
+               
+               public override Uri Uri {
+                       get { return listen_uri; }
+               }
+               
+               [MonoTODO]
+               protected override TChannel OnAcceptChannel (TimeSpan timeout)
+               {
+                       TChannel channel = PopulateChannel (timeout);
+                       channels.Add (channel);
+                       return channel;
+               }
+               
+               TChannel PopulateChannel (TimeSpan timeout)
+               {
+                       TcpClient cli = tcp_listener.AcceptTcpClient ();
+
+                       // FIXME: pass delegate or something to remove the channel instance from "channels" when it is closed.
+                       if (typeof (TChannel) == typeof (IDuplexSessionChannel))
+                               return (TChannel) (object) new TcpDuplexSessionChannel (this, info, cli, timeout);
+
+                       // FIXME: To implement more.
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginAcceptChannel (TimeSpan timeout,
+                       AsyncCallback callback, object asyncState)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override TChannel OnEndAcceptChannel (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               protected override IAsyncResult OnBeginWaitForChannel (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override bool OnEndWaitForChannel (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override bool OnWaitForChannel (TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               // CommunicationObject
+               
+               [MonoTODO]
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       tcp_listener.Stop ();
+                       tcp_listener = null;
+               }
+               
+               [MonoTODO]
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       IPHostEntry entry = Dns.GetHostEntry (listen_uri.Host);
+                       
+                       if (entry.AddressList.Length ==0)
+                               throw new ArgumentException (String.Format ("Invalid listen URI: {0}", listen_uri));
+                       
+                       int explicitPort = listen_uri.Port;
+                       tcp_listener = new TcpListener (entry.AddressList [0], explicitPort <= 0 ? TcpTransportBindingElement.DefaultPort : explicitPort);
+                       tcp_listener.Start ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpConnectionPoolSettings.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpConnectionPoolSettings.cs
new file mode 100644 (file)
index 0000000..842dcc0
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// TcpConnectionPoolSettings.cs
+//
+// Authors:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2008 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class TcpConnectionPoolSettings
+       {
+               internal TcpConnectionPoolSettings ()
+               {
+               }
+
+               string group_name = "default";
+               TimeSpan idle_timeout = TimeSpan.FromSeconds (120);
+               TimeSpan lease_timeout = TimeSpan.FromSeconds (300);
+               int max_conn = 10;
+
+               internal void CopyPropertiesFrom (TcpConnectionPoolSettings other)
+               {
+                       group_name = other.group_name;
+                       idle_timeout = other.idle_timeout;
+                       lease_timeout = other.lease_timeout;
+                       max_conn = other.max_conn;
+               }
+
+               [MonoTODO]
+               public string GroupName {
+                       get { return group_name; }
+                       set { group_name = value; }
+               }
+
+               [MonoTODO]
+               public TimeSpan IdleTimeout {
+                       get { return idle_timeout; }
+                       set { idle_timeout = value; }
+               }
+
+               [MonoTODO]
+               public TimeSpan LeaseTimeout {
+                       get { return lease_timeout; }
+                       set { lease_timeout = value; }
+               }
+
+               [MonoTODO]
+               public int MaxOutboundConnectionsPerEndpoint {
+                       get { return max_conn; }
+                       set { max_conn = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpDuplexSessionChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpDuplexSessionChannel.cs
new file mode 100644 (file)
index 0000000..82af898
--- /dev/null
@@ -0,0 +1,334 @@
+// 
+// TcpDuplexSessionChannel.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.ServiceModel.Channels;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       internal class TcpDuplexSessionChannel : DuplexChannelBase, IDuplexSessionChannel
+       {
+
+               TcpChannelInfo info;
+               TcpClient client;
+               bool is_service_side;
+               EndpointAddress local_address;
+               EndpointAddress remote_address;
+               TcpListener tcp_listener;
+               TimeSpan timeout;
+               Uri via;
+               
+               public TcpDuplexSessionChannel (ChannelFactoryBase factory, TcpChannelInfo info, EndpointAddress address, Uri via)
+                       : base (factory)
+               {
+                       is_service_side = false;
+                       this.info = info;
+                       remote_address = address;
+                       this.via = via;
+               }
+               
+               public TcpDuplexSessionChannel (ChannelListenerBase listener, TcpChannelInfo info, TcpClient acceptedRequest, TimeSpan timeout)
+                       : base (listener)
+               {
+                       is_service_side = true;
+                       this.info = info;
+                       this.client = acceptedRequest;
+                       this.timeout = timeout;
+
+                       Stream s = client.GetStream ();
+
+                       //while (s.CanRead)
+                       //      Console.Write ("{0:X02} ", s.ReadByte ());
+                       
+                       for (int i = 0; i < 6; i++)
+                               s.ReadByte ();
+                       
+                       int size = s.ReadByte ();
+                       
+                       for (int i = 0; i < size; i++)
+                               s.ReadByte (); // URI
+                       
+                       s.ReadByte ();
+                       s.ReadByte ();
+                       s.ReadByte ();
+                       s.WriteByte (0x0B);
+               }
+               
+               public MessageEncoder Encoder {
+                       get { return info.MessageEncoder; }
+               }
+
+               public override EndpointAddress LocalAddress {
+                       get { return local_address; }
+               }
+               
+               public override EndpointAddress RemoteAddress {
+                       get { return remote_address; }
+               }
+               
+               // FIXME: implement
+               public IDuplexSession Session {
+                       get { throw new NotImplementedException (); }
+               }
+               
+               public override Uri Via {
+                       get { return via; }
+               }
+               
+               [MonoTODO]
+               public override IAsyncResult BeginSend (Message message, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override IAsyncResult BeginSend (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override void EndSend (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override void Send (Message message)
+               {
+                       MemoryStream ms = new MemoryStream ();
+                       BinaryFormatter bf = new BinaryFormatter ();
+                       
+                       try
+                       {
+                               NetworkStream stream = client.GetStream ();
+                               MyBinaryWriter bw = new MyBinaryWriter (stream);
+                               bw.Write ((byte) 6);
+                               Encoder.WriteMessage (message, ms);
+                               bw.WriteBytes (ms.ToArray ());
+                               bw.Write ((byte) 7);
+                               bw.Flush ();
+
+                               stream.ReadByte (); // 7
+                       }
+                       catch (Exception e)
+                       {
+                               throw e;
+                       }
+               }
+               
+               [MonoTODO]
+               public override void Send (Message message, TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override IAsyncResult BeginReceive (AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override IAsyncResult BeginReceive (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override IAsyncResult BeginTryReceive (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override IAsyncResult BeginWaitForMessage (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override Message EndReceive (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override bool EndTryReceive (IAsyncResult result, out Message message)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override bool EndWaitForMessage (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override Message Receive ()
+               {
+                       Stream s = client.GetStream ();
+                       s.ReadByte (); // 6
+                       MyBinaryReader br = new MyBinaryReader (s);
+//                     string msg = br.ReadString ();
+//                     br.Read7BitEncodedInt ();
+                       byte [] buffer = new byte [65536];
+                       buffer = br.ReadBytes ();
+                       MemoryStream ms = new MemoryStream ();
+                       ms.Write (buffer, 0, buffer.Length);
+                       ms.Seek (0, SeekOrigin.Begin);
+                       
+//                     while (s.CanRead)
+//                             Console.Write ("{0:X02} ", s.ReadByte ());
+                       
+                       Message msg = null;
+                       // FIXME: To supply maxSizeOfHeaders.
+                       msg = Encoder.ReadMessage (ms, 0x10000);
+                       s.ReadByte (); // 7
+//                     Console.WriteLine (msg);
+                       s.WriteByte (7);
+                       s.Flush ();
+
+                       return msg;
+               }
+               
+               [MonoTODO]
+               public override Message Receive (TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override bool TryReceive (TimeSpan timeout, out Message message)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public override bool WaitForMessage (TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               // CommunicationObject
+               
+               [MonoTODO]
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       client.Close ();
+               }
+               
+               [MonoTODO]
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       if (! is_service_side) {
+                               int explicitPort = RemoteAddress.Uri.Port;
+                               client = new TcpClient (RemoteAddress.Uri.Host, explicitPort <= 0 ? TcpTransportBindingElement.DefaultPort : explicitPort);
+                                                       //RemoteAddress.Uri.Port);
+                               
+                               NetworkStream ns = client.GetStream ();
+                               ns.WriteByte (0);
+                               ns.WriteByte (1);
+                               ns.WriteByte (0);
+                               ns.WriteByte (1);
+                               ns.WriteByte (2);
+                               ns.WriteByte (2);
+                               byte [] bytes = System.Text.Encoding.UTF8.GetBytes (RemoteAddress.Uri.ToString ());
+                               ns.WriteByte ((byte) bytes.Length);
+                               ns.Write (bytes, 0, bytes.Length);
+                               ns.WriteByte (3);
+                               ns.WriteByte (3);
+                               ns.WriteByte (0xC);
+                               int hoge = ns.ReadByte ();
+                               //while (ns.CanRead)
+                               //      Console.Write ("{0:X02} ", ns.ReadByte ());
+                       }
+                       // Service side.
+                       /*
+                       else
+                               Console.WriteLine ("Server side.");
+                       */
+               }
+               
+               // FIXME: To look for other way to do this.
+               class MyBinaryReader : BinaryReader
+               {
+                       public MyBinaryReader (Stream s)
+                               : base (s)
+                       {
+                       }
+                       
+                       public byte [] ReadBytes ()
+                       {
+                               byte [] buffer = new byte [65536];
+                               int length = Read7BitEncodedInt ();
+                               
+                               if (length > 65536)
+                                       throw new InvalidOperationException ("The message is too large.");
+                               
+                               Read (buffer, 0, length);
+                               
+                               return buffer;
+                       }
+               }
+               
+               class MyBinaryWriter : BinaryWriter
+               {
+                       public MyBinaryWriter (Stream s)
+                               : base (s)
+                       {
+                       }
+                       
+                       public void WriteBytes (byte [] bytes)
+                       {
+                               Write7BitEncodedInt (bytes.Length);
+                               Write (bytes);
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpTransportBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpTransportBindingElement.cs
new file mode 100644 (file)
index 0000000..6233b80
--- /dev/null
@@ -0,0 +1,113 @@
+//
+// TcpTransportBindingElement.cs
+//
+// Authors:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//      Marcos Cobena (marcoscobena@gmail.com)
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public class TcpTransportBindingElement
+               : ConnectionOrientedTransportBindingElement
+       {
+               internal const int DefaultPort = 808;
+
+               int listen_backlog = 10;
+               bool port_sharing_enabled = false;
+               bool teredo_enabled = false;
+               TcpConnectionPoolSettings pool = new TcpConnectionPoolSettings ();
+
+               public TcpTransportBindingElement ()
+               {
+               }
+
+               protected TcpTransportBindingElement (
+                       TcpTransportBindingElement other)
+                       : base (other)
+               {
+                       listen_backlog = other.listen_backlog;
+                       port_sharing_enabled = other.port_sharing_enabled;
+                       pool.CopyPropertiesFrom (other.pool);
+               }
+               
+               public TcpConnectionPoolSettings ConnectionPoolSettings {
+                       get { return pool; }
+               }
+
+               public int ListenBacklog {
+                       get { return listen_backlog; }
+                       set { listen_backlog = value; }
+               }
+
+               public bool PortSharingEnabled {
+                       get { return port_sharing_enabled; }
+                       set { port_sharing_enabled = value; }
+               }
+
+               public override string Scheme {
+                       get { return "net.tcp"; }
+               }
+               
+               // As MSDN exposes, this' only available on Windows XP SP2 and Windows Server 2003
+               public bool TeredoEnabled {
+                       get { return teredo_enabled; }
+                       set { teredo_enabled = value; }
+               }
+
+               [MonoTODO]
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       return new TcpChannelFactory<TChannel> (this, context);
+               }
+
+               [MonoTODO]
+               public override IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       return new TcpChannelListener<TChannel> (this, context);
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new TcpTransportBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       // FIXME: ... or return ISecurityCapabilities?
+                       return context.GetInnerProperty<T> ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoder.cs
new file mode 100644 (file)
index 0000000..ce396ff
--- /dev/null
@@ -0,0 +1,121 @@
+//
+// TextMessageEncoder.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       internal class TextMessageEncoder : MessageEncoder
+       {
+               Encoding encoding;
+               MessageVersion version;
+
+               public TextMessageEncoder (MessageVersion version, Encoding encoding)
+               {
+                       this.version = version;
+                       this.encoding = encoding;
+               }
+
+               public override string ContentType {
+                       get { return String.Concat (MediaType, "; charset=", encoding.WebName); }
+               }
+
+               public override string MediaType {
+                       get { return version.Envelope == EnvelopeVersion.Soap12 ? "application/soap+xml" : "text/xml";  }
+               }
+
+               public override MessageVersion MessageVersion {
+                       get { return version; }
+               }
+
+               [MonoTODO]
+               public override Message ReadMessage (ArraySegment<byte> buffer,
+                       BufferManager bufferManager, string contentType)
+               {
+                       return Message.CreateMessage (
+                               XmlDictionaryReader.CreateDictionaryReader (
+                                       XmlReader.Create (new StreamReader (
+                                               new MemoryStream (
+                                               buffer.Array, buffer.Offset,
+                                               buffer.Count), encoding))),
+                               // FIXME: supply max header size
+                               int.MaxValue,
+                               version);
+               }
+
+               [MonoTODO]
+               public override Message ReadMessage (Stream stream,
+                       int maxSizeOfHeaders, string contentType)
+               {
+                       return Message.CreateMessage (
+                               XmlDictionaryReader.CreateDictionaryReader (
+                                       XmlReader.Create (new StreamReader (stream, encoding))),
+                               maxSizeOfHeaders,
+                               version);
+               }
+
+               public override void WriteMessage (Message message, Stream stream)
+               {
+                       if (message == null)
+                               throw new ArgumentNullException ("message");
+                       if (stream == null)
+                               throw new ArgumentNullException ("stream");
+                       VerifyMessageVersion (message);
+
+                       XmlWriterSettings s = new XmlWriterSettings ();
+                       s.Encoding = encoding;
+                       using (XmlWriter w = XmlWriter.Create (stream, s)) {
+                               message.WriteMessage (
+                                       XmlDictionaryWriter.CreateDictionaryWriter (w));
+                       }
+               }
+
+               [MonoTODO]
+               public override ArraySegment<byte> WriteMessage (
+                       Message message, int maxMessageSize,
+                       BufferManager bufferManager, int messageOffset)
+               {
+                       VerifyMessageVersion (message);
+
+                       ArraySegment<byte> seg = new ArraySegment<byte> (
+                               bufferManager.TakeBuffer (maxMessageSize),
+                               messageOffset, maxMessageSize);
+                       XmlWriterSettings s = new XmlWriterSettings ();
+                       s.Encoding = encoding;
+                       using (XmlWriter w = XmlWriter.Create (
+                               new MemoryStream (seg.Array, seg.Offset, seg.Count), s)) {
+                               message.WriteMessage (
+                                       XmlDictionaryWriter.CreateDictionaryWriter (w));
+                       }
+                       return seg;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoderFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncoderFactory.cs
new file mode 100644 (file)
index 0000000..a616253
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// TextMessageEncoderFactory.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Text;
+
+namespace System.ServiceModel.Channels
+{
+       internal class TextMessageEncoderFactory : MessageEncoderFactory
+       {
+               TextMessageEncodingBindingElement owner;
+               TextMessageEncoder encoder;
+
+               public TextMessageEncoderFactory (
+                       TextMessageEncodingBindingElement owner)
+               {
+                       this.owner = owner;
+                       encoder = new TextMessageEncoder (
+                               MessageVersion, owner.WriteEncoding);
+               }
+
+               public override MessageEncoder Encoder {
+                       get { return encoder; }
+               }
+
+               public override MessageVersion MessageVersion {
+                       get { return owner.MessageVersion; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncodingBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TextMessageEncodingBindingElement.cs
new file mode 100644 (file)
index 0000000..50b2590
--- /dev/null
@@ -0,0 +1,171 @@
+//
+// TextMessageEncodingBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public sealed class TextMessageEncodingBindingElement
+               : MessageEncodingBindingElement,
+                 IWsdlExportExtension, IPolicyExportExtension
+       {
+               // FIXME: they might be configurable.
+               MessageVersion version = MessageVersion.Default;
+               int max_read_pool_size = 64;
+               int max_write_pool_size = 16;
+               XmlDictionaryReaderQuotas quotas =
+                       new XmlDictionaryReaderQuotas ();
+               Encoding encoding;
+
+               public TextMessageEncodingBindingElement ()
+                       : this (MessageVersion.Default, Encoding.UTF8)
+               {
+               }
+
+               public TextMessageEncodingBindingElement (
+                       MessageVersion messageVersion,
+                       Encoding writeEncoding)
+               {
+                       version = messageVersion;
+                       encoding = writeEncoding;
+               }
+
+               private TextMessageEncodingBindingElement (
+                       TextMessageEncodingBindingElement source)
+               {
+                       version = source.version;
+                       max_read_pool_size = source.max_read_pool_size;
+                       max_write_pool_size = source.max_write_pool_size;
+                       encoding = source.encoding;
+
+                       quotas = new XmlDictionaryReaderQuotas ();
+                       source.quotas.CopyTo (quotas);
+               }
+
+               public override MessageVersion MessageVersion {
+                       get { return version; }
+                       set { version = value; }
+               }
+
+               public int MaxReadPoolSize {
+                       get { return max_read_pool_size; }
+                       set { max_read_pool_size = value; }
+               }
+
+               public int MaxWritePoolSize {
+                       get { return max_write_pool_size; }
+                       set { max_write_pool_size = value; }
+               }
+
+               public XmlDictionaryReaderQuotas ReaderQuotas {
+                       get { return quotas; }
+               }
+
+               public Encoding WriteEncoding {
+                       get { return encoding; }
+                       set { encoding = value; }
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       context.RemainingBindingElements.Add (this);
+                       return base.BuildChannelFactory<TChannel> (context);
+               }
+
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       context.RemainingBindingElements.Add (this);
+                       return base.BuildChannelListener<TChannel> (context);
+               }
+
+               public override bool CanBuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       if (context == null)
+                               throw new ArgumentNullException ("context");
+                       return context.CanBuildInnerChannelListener<TChannel> ();
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new TextMessageEncodingBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       return context.GetInnerProperty<T> ();
+               }
+
+               public override MessageEncoderFactory
+                       CreateMessageEncoderFactory ()
+               {
+                       return new TextMessageEncoderFactory (this);
+               }
+
+               [MonoTODO]
+               protected override void OnImportPolicy (XmlElement assertion,
+                       MessageVersion messageVersion,
+                       MetadataImporter exporter,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IWsdlExportExtension.ExportContract (WsdlExporter exporter,
+                       WsdlContractConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IWsdlExportExtension.ExportEndpoint (WsdlExporter exporter,
+                       WsdlEndpointConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IPolicyExportExtension.ExportPolicy (MetadataExporter exporter,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionFlowBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionFlowBindingElement.cs
new file mode 100644 (file)
index 0000000..9324471
--- /dev/null
@@ -0,0 +1,237 @@
+//
+// TransactionFlowBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Channels;
+using System.Transactions;
+
+namespace System.ServiceModel.Channels
+{
+       public class TransactionFlowBindingElement : BindingElement
+       {
+               TransactionProtocol protocol;
+
+               // Funny, but since it uses OLE TX, Mono will never support this constructor.
+               [MonoTODO]
+               public TransactionFlowBindingElement ()
+                       : this (TransactionProtocol.Default)
+               {
+               }
+
+               public TransactionFlowBindingElement (TransactionProtocol protocol)
+               {
+                       this.protocol = protocol;
+               }
+
+               public TransactionProtocol TransactionProtocol {
+                       get { return protocol; }
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new TransactionFlowBindingElement (protocol);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool CanBuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       return context.CanBuildInnerChannelFactory<TChannel> ();
+               }
+
+               [MonoTODO]
+               public override bool CanBuildChannelListener<TChannel> (BindingContext context)
+               {
+                       return context.CanBuildInnerChannelListener<TChannel> ();
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       if (protocol == null)
+                               throw new InvalidOperationException ("Set transaction protocol in prior to build a channel factory.");
+                       if (protocol == TransactionProtocol.Default)
+                               throw new NotSupportedException ("Mono does not support DTC.");
+                       if (!CanBuildChannelFactory<TChannel> (context.Clone ()))
+                               throw new ArgumentException (String.Format ("The channel type '{0}' is not supported", typeof (TChannel)));
+                       return new TransactionChannelFactory<TChannel> (context.BuildInnerChannelFactory<TChannel> (), protocol);
+               }
+
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (BindingContext context)
+               {
+                       if (protocol == null)
+                               throw new InvalidOperationException ("Set transaction protocol in prior to build a channel listener.");
+                       if (protocol == TransactionProtocol.Default)
+                               throw new NotSupportedException ("Mono does not support DTC.");
+                       if (!CanBuildChannelListener<TChannel> (context.Clone ()))
+                               throw new ArgumentException (String.Format ("The channel type '{0}' is not supported", typeof (TChannel)));
+                       return new TransactionChannelListener<TChannel> (
+                               context.BuildInnerChannelListener<TChannel> (),
+                               protocol);
+               }
+       }
+
+       internal class TransactionChannelFactory<TChannel> : ChannelFactoryBase<TChannel>
+       {
+               IChannelFactory<TChannel> inner_factory;
+               TransactionScope txscope;
+               TransactionProtocol protocol;
+
+               public TransactionChannelFactory (IChannelFactory<TChannel> innerFactory, TransactionProtocol protocol)
+               {
+                       this.inner_factory = innerFactory;
+                       this.protocol = protocol;
+               }
+
+               void ProcessOpen ()
+               {
+                       CommittableTransaction tx = new CommittableTransaction ();
+                       txscope = new TransactionScope (tx);
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       ProcessOpen ();
+                       inner_factory.Open (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       ProcessOpen ();
+                       return inner_factory.BeginOpen (timeout, callback, state);
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       inner_factory.EndOpen (result);
+               }
+
+               protected override TChannel OnCreateChannel (
+                       EndpointAddress remoteAddress, Uri via)
+               {
+                       return inner_factory.CreateChannel (remoteAddress, via);
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       inner_factory.Close (timeout);
+                       txscope.Complete ();
+               }
+       }
+
+       internal class TransactionChannelListener<TChannel> : ChannelListenerBase<TChannel> where TChannel : class, IChannel
+       {
+               IChannelListener<TChannel> inner_listener;
+               TransactionScope txscope;
+               TransactionProtocol protocol;
+
+               public TransactionChannelListener (IChannelListener<TChannel> innerListener, TransactionProtocol protocol)
+               {
+                       this.inner_listener = innerListener;
+                       this.protocol = protocol;
+               }
+
+               public override Uri Uri {
+                       get { return inner_listener.Uri; }
+               }
+
+               protected override void OnAbort ()
+               {
+                       inner_listener.Abort ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       CommittableTransaction tx = new CommittableTransaction ();
+                       txscope = new TransactionScope (tx);
+                       inner_listener.Open (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner_listener.BeginOpen (timeout, callback, state);
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       inner_listener.EndOpen (result);
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       inner_listener.Close (timeout);
+                       txscope.Complete ();
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner_listener.BeginClose (timeout, callback, state);
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       inner_listener.EndClose (result);
+               }
+
+               protected override bool OnWaitForChannel (TimeSpan timeout)
+               {
+                       return inner_listener.WaitForChannel (timeout);
+               }
+
+               protected override IAsyncResult OnBeginWaitForChannel (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner_listener.BeginWaitForChannel (timeout, callback, state);
+               }
+
+               protected override bool OnEndWaitForChannel (IAsyncResult result)
+               {
+                       return inner_listener.EndWaitForChannel (result);
+               }
+
+               protected override TChannel OnAcceptChannel (TimeSpan timeout)
+               {
+                       return inner_listener.AcceptChannel (timeout);
+               }
+
+               protected override IAsyncResult OnBeginAcceptChannel (TimeSpan timeout,
+                       AsyncCallback callback, object asyncState)
+               {
+                       return inner_listener.BeginAcceptChannel (timeout, callback, asyncState);
+               }
+
+               protected override TChannel OnEndAcceptChannel (IAsyncResult result)
+               {
+                       return inner_listener.EndAcceptChannel (result);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionFlowBindingElementImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionFlowBindingElementImporter.cs
new file mode 100644 (file)
index 0000000..4e52c5e
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// TransactionFlowBindingElementImporter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.Transactions;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class TransactionFlowBindingElementImporter
+               : IPolicyImportExtension
+       {
+               [MonoTODO]
+               public XmlElement GetAssertion (XmlDocument doc,
+                       TransactionFlowOption option,
+                       string prefix, string name, string ns)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void ExportPolicy (MetadataExporter exporter,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IPolicyImportExtension.ImportPolicy (MetadataImporter importer,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionMessageProperty.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionMessageProperty.cs
new file mode 100644 (file)
index 0000000..7fc83b9
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// TransactionMessageProperty.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.Transactions;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       internal class TransactionMessageProperty
+       {
+               Transaction tx;
+               Message msg;
+
+               public TransactionMessageProperty (Transaction tx, Message msg)
+               {
+                       this.tx = tx;
+                       this.msg = msg;
+               }
+
+               public Transaction Transaction {
+                       get { return tx; }
+               }
+
+               [MonoTODO]
+               public static void Set (Transaction tx, Message msg)
+               {
+                       msg.Properties.Add ("Transaction", new TransactionMessageProperty (tx, msg));
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransportBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransportBindingElement.cs
new file mode 100644 (file)
index 0000000..1c08f40
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// TransportBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005, 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       public abstract class TransportBindingElement : BindingElement
+       {
+               bool manual_addressing;
+               long max_buffer_pool_size = 0x80000;
+               long max_recv_message_size = 0x10000;
+
+               protected TransportBindingElement ()
+               {
+               }
+
+               protected TransportBindingElement (
+                       TransportBindingElement other)
+                       : base (other)
+               {
+                       manual_addressing = other.manual_addressing;
+                       max_buffer_pool_size = other.max_buffer_pool_size;
+                       max_recv_message_size = other.max_recv_message_size;
+               }
+
+               public bool ManualAddressing {
+                       get { return manual_addressing; }
+                       set { manual_addressing = value; }
+               }
+
+               public long MaxBufferPoolSize {
+                       get { return max_buffer_pool_size; }
+                       set { max_buffer_pool_size = value; }
+               }
+
+               public virtual long MaxReceivedMessageSize {
+                       get { return max_recv_message_size; }
+                       set { max_recv_message_size = value; }
+               }
+
+               public abstract string Scheme { get; }
+
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       T ret = context.GetInnerProperty<T> ();
+                       if (ret != default (T))
+                               return ret;
+                       if (typeof (T) == typeof (XmlDictionaryReaderQuotas)) {
+                               XmlDictionaryReaderQuotas q =
+                                       new XmlDictionaryReaderQuotas ();
+                               q.MaxStringContentLength = (int) MaxReceivedMessageSize;
+                               return (T) (object) q;
+                       }
+                       if (typeof (T) == typeof (ChannelProtectionRequirements))
+                               // blank one, basically it should not be used
+                               // for any secure channels (
+                               return (T) (object) new ChannelProtectionRequirements ();
+                       if (typeof (T) == typeof (MessageVersion))
+                               return (T) (object) MessageVersion.Default;
+                       return null;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransportBindingElementImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransportBindingElementImporter.cs
new file mode 100644 (file)
index 0000000..f323cca
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// TransportBindingElementImporter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.Web.Services.Description;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public class TransportBindingElementImporter
+               : IWsdlImportExtension, IPolicyImportExtension
+       {
+               public TransportBindingElementImporter ()
+               {
+               }
+
+               void IWsdlImportExtension.BeforeImport (ServiceDescriptionCollection wsdlDocuments,
+                       XmlSchemaSet xmlSchemas, ICollection<XmlElement> policy)
+               {
+               }
+
+               void IWsdlImportExtension.ImportContract (WsdlImporter importer,
+                       WsdlContractConversionContext context)
+               {
+               }
+
+               void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer,
+                       WsdlEndpointConversionContext context)
+               {
+                       for (int i = 0; i < context.WsdlBinding.Extensions.Count; i ++) {
+                               if (context.WsdlBinding.Extensions [i] is SoapBinding) {
+                                       SoapBinding transport = context.WsdlBinding.Extensions [i] as SoapBinding;
+                                       if (transport.Transport != SoapBinding.HttpTransport)
+                                               //FIXME: not http
+                                               return;
+
+                                       if (! (context.Endpoint.Binding is CustomBinding))
+                                               //FIXME: 
+                                               throw new Exception ();
+
+                                       ((CustomBinding) context.Endpoint.Binding).Elements.Add (new HttpTransportBindingElement ());
+                                       //((CustomBinding) context.Endpoint.Binding).Scheme = "http";
+
+                                       for (int j = 0; j < context.WsdlPort.Extensions.Count; j ++) {
+                                               SoapAddressBinding address = context.WsdlPort.Extensions [j] as SoapAddressBinding;
+                                               if (address == null)
+                                                       continue;
+
+                                               context.Endpoint.Address = new EndpointAddress (address.Location);
+                                               context.Endpoint.ListenUri = new Uri (address.Location);
+                                       }
+
+                                       break;
+                               }
+                       }
+               }
+
+               void IPolicyImportExtension.ImportPolicy (MetadataImporter importer,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransportSecurityBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransportSecurityBindingElement.cs
new file mode 100644 (file)
index 0000000..2088624
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// TransportSecurityBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class TransportSecurityBindingElement
+               : SecurityBindingElement,
+                 ISecurityCapabilities, IPolicyExportExtension
+       {
+               public TransportSecurityBindingElement ()
+               {
+               }
+
+               private TransportSecurityBindingElement (
+                       TransportSecurityBindingElement other)
+                       : base (other)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override IChannelFactory<TChannel>
+                       BuildChannelFactoryCore<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override IChannelListener<TChannel>
+                       BuildChannelListenerCore<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override BindingElement Clone ()
+               {
+                       return new TransportSecurityBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               #region explicit interface implementations
+               [MonoTODO]
+               ProtectionLevel ISecurityCapabilities.SupportedRequestProtectionLevel {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               ProtectionLevel ISecurityCapabilities.SupportedResponseProtectionLevel {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               bool ISecurityCapabilities.SupportsClientAuthentication {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               bool ISecurityCapabilities.SupportsClientWindowsIdentity {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               bool ISecurityCapabilities.SupportsServerAuthentication {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               void IPolicyExportExtension.ExportPolicy (
+                       MetadataExporter exporter,
+                       PolicyConversionContext policyContext)
+               {
+                       throw new NotImplementedException ();
+               }
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/UnderstoodHeaders.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/UnderstoodHeaders.cs
new file mode 100644 (file)
index 0000000..cea0354
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// System.ServiceModel.UnderstoodHeaders.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Channels
+{
+       public sealed class UnderstoodHeaders : IEnumerable<MessageHeaderInfo>, IEnumerable
+       {
+               List <MessageHeaderInfo> headers;
+               
+               internal UnderstoodHeaders ()
+               {
+                       headers = new List<MessageHeaderInfo> ();
+               }
+               public void Add (MessageHeaderInfo header)
+               {
+                       headers.Add (header);
+               }
+
+               public bool Contains (MessageHeaderInfo header)
+               {
+                       return headers.Contains (header);
+               }
+
+               public IEnumerator<MessageHeaderInfo> GetEnumerator ()
+               {
+                       return headers.GetEnumerator ();
+               }
+
+               public void Remove (MessageHeaderInfo header)
+               {
+                       headers.Remove (header);
+               }
+
+               IEnumerator IEnumerable.GetEnumerator ()
+               {
+                       return headers.GetEnumerator ();
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/UseManagedPresentationBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/UseManagedPresentationBindingElement.cs
new file mode 100644 (file)
index 0000000..f47f1b5
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// UseManagedPresentationBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public sealed class UseManagedPresentationBindingElement
+               : BindingElement, IPolicyExportExtension
+       {
+               public UseManagedPresentationBindingElement ()
+               {
+               }
+
+               [MonoTODO]
+               public override BindingElement Clone ()
+               {
+                       return new UseManagedPresentationBindingElement ();
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IPolicyExportExtension.ExportPolicy (
+                       MetadataExporter exporter,
+                       PolicyConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/WSEncryptedXml.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/WSEncryptedXml.cs
new file mode 100644 (file)
index 0000000..4986354
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// WSEncryptedXml.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       // See http://blogs.msdn.com/shawnfa/archive/2004/04/05/108098.aspx :)
+       class WSEncryptedXml : EncryptedXml
+       {
+               public WSEncryptedXml ()
+               {
+               }
+
+               public WSEncryptedXml (XmlDocument doc)
+                       : base (doc)
+               {
+               }
+
+               public override XmlElement GetIdElement (XmlDocument doc, string id)
+               {
+                       return SearchChildren (doc, id);
+               }
+
+               XmlElement SearchChildren (XmlNode node, string id)
+               {
+                       for (XmlNode n = node.FirstChild; n != null; n = n.NextSibling) {
+                               XmlElement el = n as XmlElement;
+                               if (el == null)
+                                       continue;
+                               if (el.GetAttribute ("Id", Constants.WsuNamespace) == id || el.GetAttribute ("Id") == id)
+                                       return el;
+                               XmlElement el2 = SearchChildren (el, id);
+                               if (el2 != null)
+                                       return el2;
+                       }
+                       return null;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/WSSecurityMessageHeader.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/WSSecurityMessageHeader.cs
new file mode 100644 (file)
index 0000000..fc02db8
--- /dev/null
@@ -0,0 +1,548 @@
+//
+// WSSecurityMessageHeader.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2006-2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.IO;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Runtime.Serialization;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       internal class WSSecurityMessageHeaderReader
+       {
+               public WSSecurityMessageHeaderReader (WSSecurityMessageHeader header, SecurityTokenSerializer serializer, SecurityTokenResolver resolver, XmlDocument doc, XmlNamespaceManager nsmgr, List<SecurityToken> tokens)
+               {
+                       this.header = header;
+                       this.serializer = serializer;
+                       this.resolver = resolver;
+                       this.doc = doc;
+                       this.nsmgr = nsmgr;
+                       this.tokens = tokens;
+               }
+
+               WSSecurityMessageHeader header;
+               SecurityTokenSerializer serializer;
+               SecurityTokenResolver resolver;
+               XmlDocument doc;
+               XmlNamespaceManager nsmgr;
+               List<SecurityToken> tokens;
+               Dictionary<string, EncryptedData> encryptedDataList =
+                       new Dictionary<string, EncryptedData> ();
+
+               public void ReadContents (XmlReader reader)
+               {
+                       DerivedKeySecurityToken currentToken = null;
+
+                       reader.MoveToContent ();
+                       reader.ReadStartElement ("Security", Constants.WssNamespace);
+                       do {
+                               reader.MoveToContent ();
+                               if (reader.NodeType == XmlNodeType.EndElement)
+                                       break;
+                               object o = ReadContent (reader);
+                               if (o is EncryptedData) {
+                                       EncryptedData ed = (EncryptedData) o;
+                                       encryptedDataList [ed.Id] = ed;
+                               }
+                               else if (o is ReferenceList && currentToken != null)
+                                       currentToken.ReferenceList = (ReferenceList) o;
+                               else if (o is SecurityToken) {
+                                       if (o is DerivedKeySecurityToken)
+                                               currentToken = o as DerivedKeySecurityToken;
+                                       tokens.Add ((SecurityToken) o);
+                               }
+                               header.Contents.Add (o);
+                       } while (true);
+                       reader.ReadEndElement ();
+               }
+
+               object ReadContent (XmlReader reader)
+               {
+                       reader.MoveToContent ();
+                       if (reader.NodeType != XmlNodeType.Element)
+                               throw new XmlException (String.Format ("Node type {0} is not expected as a WS-Security message header content.", reader.NodeType));
+                       switch (reader.NamespaceURI) {
+                       case Constants.WsuNamespace:
+                               switch (reader.LocalName) {
+                               case "Timestamp":
+                                       return ReadTimestamp (reader);
+                               }
+                               break;
+                       //case Constants.WstNamespace:
+                       case Constants.Wss11Namespace:
+                               if (reader.LocalName == "SignatureConfirmation") {
+                                       return ReadSignatureConfirmation (reader, doc);
+                               }
+                               break;
+                       case SignedXml.XmlDsigNamespaceUrl:
+                               switch (reader.LocalName) {
+                               case "Signature":
+                                       WSSignedXml sxml = new WSSignedXml (doc);
+                                       sxml.Signature.LoadXml ((XmlElement) doc.ReadNode (reader));
+                                       UpdateSignatureKeyInfo (sxml.Signature, doc, serializer);
+                                       return sxml;
+                               }
+                               break;
+                       case EncryptedXml.XmlEncNamespaceUrl:
+                               switch (reader.LocalName) {
+                               case "EncryptedData":
+                                       XmlElement el = (XmlElement) doc.ReadNode (reader);
+                                       return CreateEncryptedData (el);
+                               case "ReferenceList":
+                                       ReferenceList rl = new ReferenceList ();
+                                       reader.Read ();
+                                       for (reader.MoveToContent ();
+                                            reader.NodeType != XmlNodeType.EndElement;
+                                            reader.MoveToContent ()) {
+                                               switch (reader.LocalName) {
+                                               case "DataReference":
+                                                       DataReference dref = new DataReference ();
+                                                       dref.LoadXml ((XmlElement) doc.ReadNode (reader));
+                                                       rl.Add (dref);
+                                                       continue;
+                                               case "KeyReference":
+                                                       KeyReference kref = new KeyReference ();
+                                                       kref.LoadXml ((XmlElement) doc.ReadNode (reader));
+                                                       rl.Add (kref);
+                                                       continue;
+                                               }
+                                               throw new XmlException (String.Format ("Unexpected {2} node '{0}' in namespace '{1}' in ReferenceList.", reader.Name, reader.NamespaceURI, reader.NodeType));
+                                       }
+                                       reader.ReadEndElement ();
+                                       return rl;
+                               }
+                               break;
+                       }
+                       // SecurityTokenReference will be handled here.
+                       // This order (Token->KeyIdentifierClause) is
+                       // important because WrappedKey could be read
+                       // in both context (but must be a token here).
+                       if (serializer.CanReadToken (reader))
+                               return serializer.ReadToken (reader, resolver);
+                       else if (serializer.CanReadKeyIdentifierClause (reader))
+                               return serializer.ReadKeyIdentifierClause (reader);
+                       else
+                               throw new XmlException (String.Format ("Unexpected element '{0}' in namespace '{1}' as a WS-Security message header content.", reader.Name, reader.NamespaceURI));
+               }
+
+               void UpdateSignatureKeyInfo (Signature sig, XmlDocument doc, SecurityTokenSerializer serializer)
+               {
+                       KeyInfo ki = new KeyInfo ();
+                       ki.Id = sig.KeyInfo.Id;
+                       foreach (KeyInfoClause kic in sig.KeyInfo) {
+                               SecurityTokenReferenceKeyInfo r = new SecurityTokenReferenceKeyInfo (serializer, doc);
+                               r.LoadXml (kic.GetXml ());
+                               ki.AddClause (r);
+                       }
+                       sig.KeyInfo = ki;
+               }
+
+               #region Decryption
+
+               // returns the protection token
+               public void DecryptSecurity (SecureMessageDecryptor decryptor, SymmetricSecurityKey sym, byte [] dummyEncKey)
+               {
+                       WSEncryptedXml encXml = new WSEncryptedXml (doc);
+
+                       // default, unless overriden by the default DerivedKeyToken.
+                       Rijndael aes = RijndaelManaged.Create (); // it is reused with every key
+                       aes.Mode = CipherMode.CBC;
+
+                       if (sym == null)
+                               throw new MessageSecurityException ("Cannot find the encryption key in this message and context");
+
+                       // decrypt the body with the decrypted key
+                       Collection<string> references = new Collection<string> ();
+
+                       foreach (ReferenceList rlist in header.FindAll<ReferenceList> ())
+                               foreach (EncryptedReference encref in rlist)
+                                       references.Add (StripUri (encref.Uri));
+
+                       foreach (WrappedKeySecurityToken wk in header.FindAll<WrappedKeySecurityToken> ())
+                               foreach (EncryptedReference er in wk.ReferenceList)
+                                       references.Add (StripUri (er.Uri));
+
+                       Collection<XmlElement> list = new Collection<XmlElement> ();
+                       foreach (string uri in references) {
+                               XmlElement el = encXml.GetIdElement (doc, uri);
+                               if (el != null)
+                                       list.Add (el);
+                               else
+                                       throw new MessageSecurityException (String.Format ("On decryption, EncryptedData with Id '{0}', referenced by ReferenceData, was not found.", uri));
+                       }
+
+                       foreach (XmlElement el in list) {
+                               EncryptedData ed2 = CreateEncryptedData (el);
+                               byte [] key = GetEncryptionKeyForData (ed2, encXml, dummyEncKey);
+                               aes.Key = key != null ? key : sym.GetSymmetricKey ();
+                               byte [] decrypted = DecryptData (encXml, ed2, aes);
+                               encXml.ReplaceData (el, decrypted);
+                               EncryptedData existing;
+                               // if it was a header content, replace 
+                               // corresponding one.
+                               if (encryptedDataList.TryGetValue (ed2.Id, out existing)) {
+                                       // FIXME: it is kind of extraneous and could be replaced by XmlNodeReader
+//Console.WriteLine ("DECRYPTED EncryptedData:");
+//Console.WriteLine (Encoding.UTF8.GetString (decrypted));
+                                       object o = ReadContent (XmlReader.Create (new MemoryStream (decrypted)));
+                                       header.Contents.Remove (existing);
+                                       header.Contents.Add (o);
+                               }
+                       }
+/*
+Console.WriteLine ("======== Decrypted Document ========");
+doc.PreserveWhitespace = false;
+doc.Save (Console.Out);
+doc.PreserveWhitespace = true;
+*/
+               }
+
+               EncryptedData CreateEncryptedData (XmlElement el)
+               {
+                       EncryptedData ed = new EncryptedData ();
+                       ed.LoadXml (el);
+                       if (ed.Id == null)
+                               ed.Id = el.GetAttribute ("Id", Constants.WsuNamespace);
+                       return ed;
+               }
+
+               byte [] GetEncryptionKeyForData (EncryptedData ed2, EncryptedXml encXml, byte [] dummyEncKey)
+               {
+                       // Since ReferenceList could be embedded directly in wss_header without
+                       // key indication, it must iterate all the derived keys to find out
+                       // appropriate one.
+                       foreach (DerivedKeySecurityToken dk in header.FindAll<DerivedKeySecurityToken> ()) {
+                               if (dk.ReferenceList == null)
+                                       continue;
+                               foreach (DataReference dr in dk.ReferenceList)
+                                       if (StripUri (dr.Uri) == ed2.Id)
+                                               return ((SymmetricSecurityKey) dk.SecurityKeys [0]).GetSymmetricKey ();
+                       }
+                       foreach (WrappedKeySecurityToken wk in header.FindAll<WrappedKeySecurityToken> ()) {
+                               if (wk.ReferenceList == null)
+                                       continue;
+                               foreach (DataReference dr in wk.ReferenceList)
+                                       if (StripUri (dr.Uri) == ed2.Id)
+                                               return ((SymmetricSecurityKey) wk.SecurityKeys [0]).GetSymmetricKey ();
+                       }
+
+                       if (ed2.KeyInfo == null)
+                               return null;
+                       foreach (KeyInfoClause kic in ed2.KeyInfo) {
+                               SecurityKeyIdentifierClause skic = serializer.ReadKeyIdentifierClause (new XmlNodeReader (kic.GetXml ()));
+
+                               SecurityKey skey = null;
+                               if (!resolver.TryResolveSecurityKey (skic, out skey))
+                                       throw new MessageSecurityException (String.Format ("The signing key could not be resolved from {0}", skic));
+                               SymmetricSecurityKey ssk = skey as SymmetricSecurityKey;
+                               if (ssk != null)
+                                       return ssk.GetSymmetricKey ();
+                       }
+                       return null; // no applicable key info clause.
+               }
+
+               // Probably it is a bug in .NET, but sometimes it does not contain
+               // proper padding bytes. For such cases, use PaddingMode.None
+               // instead. It must not be done in EncryptedXml class as it
+               // correctly rejects improper ISO10126 padding.
+               byte [] DecryptData (EncryptedXml encXml, EncryptedData ed, SymmetricAlgorithm symAlg)
+               {
+                       PaddingMode bak = symAlg.Padding;
+                       try {
+                               byte [] bytes = ed.CipherData.CipherValue;
+
+                               if (encXml.Padding != PaddingMode.None &&
+                                   encXml.Padding != PaddingMode.Zeros &&
+                                   bytes [bytes.Length - 1] > symAlg.BlockSize / 8)
+                                       symAlg.Padding = PaddingMode.None;
+                               return encXml.DecryptData (ed, symAlg);
+                       } finally {
+                               symAlg.Padding = bak;
+                       }
+               }
+
+               string StripUri (string src)
+               {
+                       if (src == null || src.Length == 0)
+                               return String.Empty;
+                       if (src [0] != '#')
+                               throw new NotSupportedException (String.Format ("Non-fragment URI in DataReference and KeyReference is not supported: '{0}'", src));
+                       return src.Substring (1);
+               }
+               #endregion
+
+               static Wss11SignatureConfirmation ReadSignatureConfirmation (XmlReader reader, XmlDocument doc)
+               {
+                       string id = reader.GetAttribute ("Id", Constants.WsuNamespace);
+                       string value = reader.GetAttribute ("Value");
+                       reader.Skip ();
+                       return new Wss11SignatureConfirmation (id, value);
+               }
+
+               static WsuTimestamp ReadTimestamp (XmlReader reader)
+               {
+                       WsuTimestamp ret = new WsuTimestamp ();
+                       ret.Id = reader.GetAttribute ("Id", Constants.WsuNamespace);
+                       reader.ReadStartElement ();
+                       do {
+                               reader.MoveToContent ();
+                               if (reader.NodeType == XmlNodeType.EndElement)
+                                       break;
+                               if (reader.NodeType != XmlNodeType.Element)
+                                       throw new XmlException (String.Format ("Node type {0} is not expected as a WS-Security 'Timestamp' content.", reader.NodeType));
+                               switch (reader.NamespaceURI) {
+                               case Constants.WsuNamespace:
+                                       switch (reader.LocalName) {
+                                       case "Created":
+                                               ret.Created = (DateTime) reader.ReadElementContentAs (typeof (DateTime), null);
+                                               continue;
+                                       case "Expires":
+                                               ret.Expires = (DateTime) reader.ReadElementContentAs (typeof (DateTime), null);
+                                               continue;
+                                       }
+                                       break;
+                               }
+                               throw new XmlException (String.Format ("Unexpected element '{0}' in namespace '{1}' as a WS-Security message header content.", reader.Name, reader.NamespaceURI));
+                       } while (true);
+
+                       reader.ReadEndElement (); // </u:Timestamp>
+                       return ret;
+               }
+       }
+
+       internal class WSSecurityMessageHeader : MessageHeader
+       {
+               public WSSecurityMessageHeader (SecurityTokenSerializer serializer)
+               {
+                       this.serializer = serializer;
+               }
+
+               SecurityTokenSerializer serializer;
+               Collection<object> contents = new Collection<object> ();
+
+               // Timestamp, BinarySecurityToken, EncryptedKey,
+               // [DerivedKeyToken]*, ReferenceList, EncryptedData
+               public Collection<object> Contents {
+                       get { return contents; }
+               }
+
+               public override bool MustUnderstand {
+                       get { return true; }
+               }
+
+               public override string Name {
+                       get { return "Security"; }
+               }
+
+               public override string Namespace {
+                       get { return Constants.WssNamespace; }
+               }
+
+               public void AddContent (object obj)
+               {
+                       if (obj == null)
+                               throw new ArgumentNullException ("obj");
+                       Contents.Add (obj);
+               }
+
+               public T Find<T> ()
+               {
+                       foreach (object o in Contents)
+                               if (typeof (T).IsAssignableFrom (o.GetType ()))
+                                       return (T) o;
+                       return default (T);
+               }
+
+               public Collection<T> FindAll<T> ()
+               {
+                       Collection<T> c = new Collection<T> ();
+                       foreach (object o in Contents)
+                               if (typeof (T).IsAssignableFrom (o.GetType ()))
+                                       c.Add ((T) o);
+                       return c;
+               }
+
+               protected override void OnWriteStartHeader (XmlDictionaryWriter writer, MessageVersion version)
+               {
+                       writer.WriteStartElement ("o", this.Name, this.Namespace);
+                       WriteHeaderAttributes (writer, version);
+               }
+
+               protected override void OnWriteHeaderContents (XmlDictionaryWriter writer, MessageVersion version)
+               {
+                       foreach (object obj in Contents) {
+                               if (obj is WsuTimestamp) {
+                                       WsuTimestamp ts = (WsuTimestamp) obj;
+                                       ts.WriteTo (writer);
+                               } else if (obj is SecurityToken) {
+                                       serializer.WriteToken (writer, (SecurityToken) obj);
+                               } else if (obj is EncryptedKey) {
+                                       ((EncryptedKey) obj).GetXml ().WriteTo (writer);
+                               } else if (obj is ReferenceList) {
+                                       writer.WriteStartElement ("ReferenceList", EncryptedXml.XmlEncNamespaceUrl);
+                                       foreach (EncryptedReference er in (ReferenceList) obj)
+                                               er.GetXml ().WriteTo (writer);
+                                       writer.WriteEndElement ();
+                               } else if (obj is EncryptedData) {
+                                       ((EncryptedData) obj).GetXml ().WriteTo (writer);
+                               } else if (obj is Signature) {
+                                       ((Signature) obj).GetXml ().WriteTo (writer);
+                               } else if (obj is Wss11SignatureConfirmation) {
+                                       Wss11SignatureConfirmation sc = (Wss11SignatureConfirmation) obj;
+                                       writer.WriteStartElement ("k", "SignatureConfirmation", Constants.Wss11Namespace);
+                                       writer.WriteAttributeString ("u", "Id", Constants.WsuNamespace, sc.Id);
+                                       writer.WriteAttributeString ("Value", sc.Value);
+                                       writer.WriteEndElement ();
+                               }
+                               else
+                                       throw new ArgumentException (String.Format ("Unrecognized header item {0}", obj ?? "(null)"));
+                       }
+               }
+       }
+
+       internal class WsuTimestamp
+       {
+               string id;
+               DateTime created, expires;
+
+               public string Id {
+                       get { return id; }
+                       set { id = value; }
+               }
+
+               public DateTime Created {
+                       get { return created; }
+                       set { created = value; }
+               }
+
+               public DateTime Expires {
+                       get { return expires; }
+                       set { expires = value; }
+               }
+
+               public void WriteTo (XmlWriter writer)
+               {
+                       writer.WriteStartElement ("u", "Timestamp", Constants.WsuNamespace);
+                       writer.WriteAttributeString ("u", "Id", Constants.WsuNamespace, Id);
+                       writer.WriteStartElement ("u", "Created", Constants.WsuNamespace);
+                       writer.WriteValue (FormatAsUtc (Created));
+                       writer.WriteEndElement ();
+                       writer.WriteStartElement ("u", "Expires", Constants.WsuNamespace);
+                       writer.WriteValue (FormatAsUtc (Expires));
+                       writer.WriteEndElement ();
+                       writer.WriteEndElement ();
+               }
+
+               string FormatAsUtc (DateTime date)
+               {
+                       return date.ToUniversalTime ().ToString (
+                               "yyyy-MM-dd'T'HH:mm:ss.fff'Z'",
+                               CultureInfo.InvariantCulture);
+               }
+       }
+
+       internal class SecurityTokenReferenceKeyInfo : KeyInfoClause
+       {
+               SecurityKeyIdentifierClause clause;
+               SecurityTokenSerializer serializer;
+               XmlDocument doc;
+
+               // for LoadXml()
+               public SecurityTokenReferenceKeyInfo (
+                       SecurityTokenSerializer serializer,
+                       XmlDocument doc)
+                       : this (null, serializer, doc)
+               {
+               }
+
+               // for GetXml()
+               public SecurityTokenReferenceKeyInfo (
+                       SecurityKeyIdentifierClause clause,
+                       SecurityTokenSerializer serializer,
+                       XmlDocument doc)
+               {
+                       this.clause = clause;
+                       this.serializer = serializer;
+                       if (doc == null)
+                               doc = new XmlDocument ();
+                       this.doc = doc;
+               }
+
+               public SecurityKeyIdentifierClause Clause {
+                       get { return clause; }
+               }
+
+               public override XmlElement GetXml ()
+               {
+                       XmlDocumentFragment df = doc.CreateDocumentFragment ();
+                       XmlWriter w = df.CreateNavigator ().AppendChild ();
+                       serializer.WriteKeyIdentifierClause (w, clause);
+                       w.Close ();
+                       return (XmlElement) df.FirstChild;
+               }
+
+               public override void LoadXml (XmlElement element)
+               {
+                       clause = serializer.ReadKeyIdentifierClause (new XmlNodeReader (element));
+               }
+       }
+
+       internal class Wss11SignatureConfirmation
+       {
+               string id, value;
+
+               public Wss11SignatureConfirmation (string id, string value)
+               {
+                       this.id = id;
+                       this.value = value;
+               }
+
+               public string Id {
+                       get { return id; }
+                       set { id = value; }
+               }
+
+               public string Value {
+                       get { return value; }
+                       set { this.value = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/WSSignedXml.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/WSSignedXml.cs
new file mode 100644 (file)
index 0000000..4724023
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// WSSignedXml.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       // See http://blogs.msdn.com/shawnfa/archive/2004/04/05/108098.aspx :)
+       class WSSignedXml : SignedXml
+       {
+               public WSSignedXml ()
+               {
+               }
+
+               public WSSignedXml (XmlDocument doc)
+                       : base (doc)
+               {
+               }
+
+               public override XmlElement GetIdElement (XmlDocument doc, string id)
+               {
+                       return SearchChildren (doc, id);
+               }
+
+               XmlElement SearchChildren (XmlNode node, string id)
+               {
+                       for (XmlNode n = node.FirstChild; n != null; n = n.NextSibling) {
+                               XmlElement el = n as XmlElement;
+                               if (el == null)
+                                       continue;
+                               if (el.GetAttribute ("Id", Constants.WsuNamespace) == id || el.GetAttribute ("Id") == id)
+                                       return el;
+                               XmlElement el2 = SearchChildren (el, id);
+                               if (el2 != null)
+                                       return el2;
+                       }
+                       return null;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/WindowsStreamSecurityBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/WindowsStreamSecurityBindingElement.cs
new file mode 100644 (file)
index 0000000..6c3a22b
--- /dev/null
@@ -0,0 +1,132 @@
+//
+// WindowsStreamSecurityBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public class WindowsStreamSecurityBindingElement
+               : BindingElement, ISecurityCapabilities, IPolicyExportExtension
+       {
+               [MonoTODO]
+               public WindowsStreamSecurityBindingElement ()
+               {
+               }
+
+               [MonoTODO]
+               private WindowsStreamSecurityBindingElement (
+                       WindowsStreamSecurityBindingElement other)
+                       : base (other)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override IChannelFactory<TChannel>
+                       BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override IChannelListener<TChannel>
+                       BuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override bool CanBuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override bool CanBuildChannelListener<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override BindingElement Clone ()
+               {
+                       return new WindowsStreamSecurityBindingElement (this);
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               #region explicit interface implementations
+               [MonoTODO]
+               ProtectionLevel ISecurityCapabilities.SupportedRequestProtectionLevel {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               ProtectionLevel ISecurityCapabilities.SupportedResponseProtectionLevel {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               bool ISecurityCapabilities.SupportsClientAuthentication {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               bool ISecurityCapabilities.SupportsClientWindowsIdentity {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               bool ISecurityCapabilities.SupportsServerAuthentication {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               void IPolicyExportExtension.ExportPolicy (
+                       MetadataExporter exporter,
+                       PolicyConversionContext policyContext)
+               {
+                       throw new NotImplementedException ();
+               }
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/XmlObjectSerializerBodyWriter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/XmlObjectSerializerBodyWriter.cs
new file mode 100644 (file)
index 0000000..43d2416
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// XmlObjectSerializerBodyWriter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO ("Check how isBuffered works.")]
+       internal class XmlObjectSerializerBodyWriter : BodyWriter
+       {
+               object body;
+               XmlObjectSerializer formatter;
+
+               public XmlObjectSerializerBodyWriter (
+                       object body, XmlObjectSerializer formatter)
+                       : base (true)
+               {
+                       this.body = body;
+                       this.formatter = formatter;
+               }
+
+               protected override BodyWriter OnCreateBufferedCopy (
+                       int maxBufferSize)
+               {
+                       return new XmlObjectSerializerBodyWriter (body, formatter);
+               }
+
+               protected override void OnWriteBodyContents (
+                       XmlDictionaryWriter writer)
+               {
+                       formatter.WriteObject (writer, body);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/XmlReaderBodyWriter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/XmlReaderBodyWriter.cs
new file mode 100644 (file)
index 0000000..f7173c7
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// XmlReaderBodyWriter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.Xml;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO ("Check if isBuffered works or not (I think it shouldn't).")]
+       internal class XmlReaderBodyWriter : BodyWriter
+       {
+               XmlDictionaryReader reader;
+
+               public XmlReaderBodyWriter (XmlDictionaryReader reader)
+                       : base (false)
+               {
+                       reader.MoveToContent ();
+                       this.reader = reader;
+               }
+
+               [MonoTODO]
+               protected override BodyWriter OnCreateBufferedCopy (
+                       int maxBufferSize)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               protected override void OnWriteBodyContents (
+                       XmlDictionaryWriter writer)
+               {
+                       writer.WriteNode (reader, false);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.ComIntegration/Dummy.cs b/mcs/class/System.ServiceModel/System.ServiceModel.ComIntegration/Dummy.cs
new file mode 100644 (file)
index 0000000..df56d3e
--- /dev/null
@@ -0,0 +1,9 @@
+namespace System.ServiceModel.ComIntegration
+{
+       public interface IChannelCredentials { }
+       public interface IMoniker { }
+       public interface IServiceSurrogate { }
+       public class ComPlusListenerInitializationException { }
+       public class DllHostInitializer { }
+       public class ServiceMoniker { }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AddressHeaderCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AddressHeaderCollectionElement.cs
new file mode 100644 (file)
index 0000000..060b799
--- /dev/null
@@ -0,0 +1,131 @@
+//
+// AddressHeaderCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class AddressHeaderCollectionElement
+                : ConfigurationElement
+       {
+               AddressHeaderCollection _headers;
+
+               // Properties
+
+               [ConfigurationProperty ("headers",
+                        DefaultValue = null,
+                        Options = ConfigurationPropertyOptions.None)]
+               public AddressHeaderCollection Headers {
+                       get { return _headers; }
+                       set { _headers = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+               
+               protected override void DeserializeElement (
+                       XmlReader reader, bool serializeCollectionKey) {
+                       reader.MoveToContent ();
+                       _headers = new AddressHeaderCollection (DeserializeAddressHeaders (reader));
+               }
+
+               static IEnumerable<AddressHeader> DeserializeAddressHeaders (XmlReader reader) {
+                       while (true) {
+                               do {
+                                       reader.Read ();
+                               } while (reader.NodeType == XmlNodeType.Whitespace);
+
+                               if (reader.NodeType == XmlNodeType.EndElement)
+                                       yield break;
+
+                               if (reader.NodeType != XmlNodeType.Element)
+                                       throw new ConfigurationErrorsException ("invalid node type.");
+
+                               yield return new ConfiguredAddressHeader (reader.LocalName, reader.NamespaceURI, reader.ReadOuterXml ());
+                       }
+               }
+
+               [MonoTODO]
+               protected override bool SerializeToXmlElement (
+                       XmlWriter writer, string elementName) {
+                       throw new NotImplementedException ();
+               }
+
+               class ConfiguredAddressHeader : AddressHeader {
+
+                       readonly string _name;
+                       readonly string _namespace;
+                       readonly string _outerXml;
+
+                       public ConfiguredAddressHeader (string name, string @namespace, string outerXml) {
+                               _name = name;
+                               _namespace = @namespace;
+                               _outerXml = outerXml;
+                       }
+
+                       [MonoTODO]
+                       protected override void OnWriteAddressHeaderContents (XmlDictionaryWriter writer) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public override string Name {
+                               get { return _name; }
+                       }
+
+                       public override string Namespace {
+                               get { return _namespace; }
+                       }
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AllowedAudienceUriElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AllowedAudienceUriElement.cs
new file mode 100644 (file)
index 0000000..96bbc28
--- /dev/null
@@ -0,0 +1,61 @@
+//\r
+// AllowedAudienceUriElement.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Configuration;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       public sealed class AllowedAudienceUriElement : ConfigurationElement\r
+       {\r
+               ConfigurationPropertyCollection _properties;\r
+\r
+               public AllowedAudienceUriElement () {\r
+               }\r
+\r
+               [StringValidator (MinLength = 1)]\r
+               [ConfigurationProperty ("allowedAudienceUri",\r
+                       Options = ConfigurationPropertyOptions.IsKey)]\r
+               public string AllowedAudienceUri {\r
+                       get { return (string) this ["allowedAudienceUri"]; }\r
+                       set { this ["allowedAudienceUri"] = value; }\r
+               }\r
+\r
+               protected override ConfigurationPropertyCollection Properties {\r
+                       get {\r
+                               if (_properties == null) {\r
+                                       _properties = new ConfigurationPropertyCollection ();\r
+                                       _properties.Add (new ConfigurationProperty ("allowedAudienceUri", typeof (string), null, null, new StringValidator (1), ConfigurationPropertyOptions.IsKey));\r
+                               }\r
+                               return _properties;\r
+                       }\r
+               }\r
+       }\r
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AllowedAudienceUriElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AllowedAudienceUriElementCollection.cs
new file mode 100644 (file)
index 0000000..a72db78
--- /dev/null
@@ -0,0 +1,56 @@
+//\r
+// AllowedAudienceUriElementCollection.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Configuration;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       [ConfigurationCollection (typeof (AllowedAudienceUriElement), CollectionType = ConfigurationElementCollectionType.BasicMap)]\r
+       public sealed class AllowedAudienceUriElementCollection : ServiceModelConfigurationElementCollection<AllowedAudienceUriElement>\r
+       {\r
+               public AllowedAudienceUriElementCollection () {\r
+               }\r
+\r
+               protected override bool ThrowOnDuplicate {\r
+                       get {\r
+                               return base.ThrowOnDuplicate;\r
+                       }\r
+               }\r
+\r
+               protected override System.Configuration.ConfigurationElement CreateNewElement () {\r
+                       return new AllowedAudienceUriElement ();\r
+               }\r
+\r
+               protected override object GetElementKey (ConfigurationElement element) {\r
+                       return ((AllowedAudienceUriElement) element).AllowedAudienceUri;\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AuthenticationMode.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AuthenticationMode.cs
new file mode 100644 (file)
index 0000000..786b50a
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// AuthenticationMode.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Configuration
+{
+       public enum AuthenticationMode
+       {
+               AnonymousForCertificate,
+               AnonymousForSslNegotiated,
+               CertificateOverTransport,
+               IssuedToken,
+               IssuedTokenForCertificate,
+               IssuedTokenForSslNegotiated,
+               IssuedTokenOverTransport,
+               Kerberos,
+               KerberosOverTransport,
+               MutualCertificate,
+               MutualCertificateDuplex,
+               MutualSslNegotiated,
+               SecureConversation,
+               SspiNegotiated,
+               UserNameForCertificate,
+               UserNameForSslNegotiated,
+               UserNameOverTransport,
+               SspiNegotiatedOverTransport,
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AuthorizationPolicyTypeElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AuthorizationPolicyTypeElement.cs
new file mode 100644 (file)
index 0000000..fcabe0a
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// AuthorizationPolicyTypeElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class AuthorizationPolicyTypeElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty policy_type;
+
+               static AuthorizationPolicyTypeElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       policy_type = new ConfigurationProperty ("policyType",
+                               typeof (string), null, null, new StringValidator (1, int.MaxValue), 
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       properties.Add (policy_type);
+               }
+
+               public AuthorizationPolicyTypeElement ()
+               {
+               }
+               
+               public AuthorizationPolicyTypeElement (string policyType) {
+                       if (policyType == null)
+                               throw new ArgumentNullException ("policyType");
+
+                       PolicyType = policyType;
+               }
+
+
+               // Properties
+
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("policyType",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               public string PolicyType {
+                       get { return (string) base [policy_type]; }
+                       set { base [policy_type] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AuthorizationPolicyTypeElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/AuthorizationPolicyTypeElementCollection.cs
new file mode 100644 (file)
index 0000000..9dbc832
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// AuthorizationPolicyTypeElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (AuthorizationPolicyTypeElement),
+                AddItemName = "add",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       public sealed class AuthorizationPolicyTypeElementCollection
+                : ServiceModelConfigurationElementCollection<AuthorizationPolicyTypeElement>,  ICollection,  IEnumerable
+       {
+               // Properties
+               protected override object GetElementKey (ConfigurationElement element) {
+                       return ((AuthorizationPolicyTypeElement) element).PolicyType;
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BaseAddressElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BaseAddressElement.cs
new file mode 100644 (file)
index 0000000..c452bfa
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// BaseAddressElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class BaseAddressElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty base_address;
+
+               static BaseAddressElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       base_address = new ConfigurationProperty ("baseAddress",
+                               typeof (string), null, new StringConverter (), new StringValidator (1, int.MaxValue, null),
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       properties.Add (base_address);
+               }
+
+               public BaseAddressElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("baseAddress",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string BaseAddress {
+                       get { return (string) base [base_address]; }
+                       set { base [base_address] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BaseAddressElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BaseAddressElementCollection.cs
new file mode 100644 (file)
index 0000000..af37d8e
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// BaseAddressElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (BaseAddressElement),
+                AddItemName = "add",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.BasicMap)]
+       public sealed class BaseAddressElementCollection
+                : ServiceModelConfigurationElementCollection<BaseAddressElement>,  ICollection,  IEnumerable
+       {
+               protected override object GetElementKey (ConfigurationElement element) {
+                       return ((BaseAddressElement) element).BaseAddress;
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..431a273
--- /dev/null
@@ -0,0 +1,62 @@
+//
+// BasicHttpBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public partial class BasicHttpBindingCollectionElement
+                : StandardBindingCollectionElement<BasicHttpBinding, BasicHttpBindingElement>
+       {
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpBindingElement.cs
new file mode 100644 (file)
index 0000000..20e2d39
--- /dev/null
@@ -0,0 +1,231 @@
+//
+// BasicHttpBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class BasicHttpBindingElement
+                : StandardBindingElement,  IBindingConfigurationElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public BasicHttpBindingElement ()
+               {
+               }
+
+               public BasicHttpBindingElement (string name) : base (name) { }
+
+               // Properties
+
+               [ConfigurationProperty ("allowCookies",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool AllowCookies {
+                       get { return (bool) this ["allowCookies"]; }
+                       set { this ["allowCookies"] = value; }
+               }
+
+               protected override Type BindingElementType {
+                       get { return typeof (BasicHttpBinding); }
+               }
+
+               [ConfigurationProperty ("bypassProxyOnLocal",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool BypassProxyOnLocal {
+                       get { return (bool) this ["bypassProxyOnLocal"]; }
+                       set { this ["bypassProxyOnLocal"] = value; }
+               }
+
+               [ConfigurationProperty ("hostNameComparisonMode",
+                        DefaultValue = "StrongWildcard",
+                        Options = ConfigurationPropertyOptions.None)]
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return (HostNameComparisonMode) this ["hostNameComparisonMode"]; }
+                       set { this ["hostNameComparisonMode"] = value; }
+               }
+
+               [LongValidator ( MinValue = 0,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxBufferPoolSize",
+                        DefaultValue = "524288",
+                        Options = ConfigurationPropertyOptions.None)]
+               public long MaxBufferPoolSize {
+                       get { return (long) this ["maxBufferPoolSize"]; }
+                       set { this ["maxBufferPoolSize"] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxBufferSize",
+                        DefaultValue = "65536",
+                        Options = ConfigurationPropertyOptions.None)]
+               public int MaxBufferSize {
+                       get { return (int) this ["maxBufferSize"]; }
+                       set { this ["maxBufferSize"] = value; }
+               }
+
+               [LongValidator ( MinValue = 1,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxReceivedMessageSize",
+                        DefaultValue = "65536",
+                        Options = ConfigurationPropertyOptions.None)]
+               public long MaxReceivedMessageSize {
+                       get { return (long) this ["maxReceivedMessageSize"]; }
+                       set { this ["maxReceivedMessageSize"] = value; }
+               }
+
+               [ConfigurationProperty ("messageEncoding",
+                        DefaultValue = "Text",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSMessageEncoding MessageEncoding {
+                       get { return (WSMessageEncoding) this ["messageEncoding"]; }
+                       set { this ["messageEncoding"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("allowCookies", typeof (bool), "false", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("bypassProxyOnLocal", typeof (bool), "false", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("hostNameComparisonMode", typeof (HostNameComparisonMode), "StrongWildcard", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferPoolSize", typeof (long), "524288", null, new LongValidator (0, 9223372036854775807, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferSize", typeof (int), "65536", null, new IntegerValidator (1, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxReceivedMessageSize", typeof (long), "65536", null, new LongValidator (1, 9223372036854775807, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("messageEncoding", typeof (WSMessageEncoding), "Text", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("proxyAddress", typeof (Uri), null, new UriTypeConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("readerQuotas", typeof (XmlDictionaryReaderQuotasElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("security", typeof (BasicHttpSecurityElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("textEncoding", typeof (Encoding), "utf-8", EncodingConverter.Instance, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("transferMode", typeof (TransferMode), "Buffered", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("useDefaultWebProxy", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("proxyAddress",
+                        DefaultValue = null,
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri ProxyAddress {
+                       get { return (Uri) this ["proxyAddress"]; }
+                       set { this ["proxyAddress"] = value; }
+               }
+
+               [ConfigurationProperty ("readerQuotas",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlDictionaryReaderQuotasElement ReaderQuotas {
+                       get { return (XmlDictionaryReaderQuotasElement) this ["readerQuotas"]; }
+               }
+
+               [ConfigurationProperty ("security",
+                        Options = ConfigurationPropertyOptions.None)]
+               public BasicHttpSecurityElement Security {
+                       get { return (BasicHttpSecurityElement) this ["security"]; }
+               }
+
+               [TypeConverter (typeof (EncodingConverter))]
+               [ConfigurationProperty ("textEncoding",
+                        DefaultValue = "utf-8",
+                        Options = ConfigurationPropertyOptions.None)]
+               public Encoding TextEncoding {
+                       get { return (Encoding) this ["textEncoding"]; }
+                       set { this ["textEncoding"] = value; }
+               }
+
+               [ConfigurationProperty ("transferMode",
+                        DefaultValue = "Buffered",
+                        Options = ConfigurationPropertyOptions.None)]
+               public TransferMode TransferMode {
+                       get { return (TransferMode) this ["transferMode"]; }
+                       set { this ["transferMode"] = value; }
+               }
+
+               [ConfigurationProperty ("useDefaultWebProxy",
+                       DefaultValue = true,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool UseDefaultWebProxy {
+                       get { return (bool) this ["useDefaultWebProxy"]; }
+                       set { this ["useDefaultWebProxy"] = value; }
+               }
+
+               protected override void OnApplyConfiguration (Binding binding) {
+                       BasicHttpBinding basicHttpBinding = (BasicHttpBinding) binding;
+                       
+                       basicHttpBinding.AllowCookies = AllowCookies;
+                       basicHttpBinding.BypassProxyOnLocal = BypassProxyOnLocal;
+                       basicHttpBinding.HostNameComparisonMode = HostNameComparisonMode;
+                       basicHttpBinding.MaxBufferPoolSize = MaxBufferPoolSize;
+                       basicHttpBinding.MaxBufferSize = MaxBufferSize;
+                       basicHttpBinding.MaxReceivedMessageSize = MaxReceivedMessageSize;
+                       basicHttpBinding.MessageEncoding = MessageEncoding;
+                       basicHttpBinding.ProxyAddress = ProxyAddress;
+
+                       basicHttpBinding.ReaderQuotas.MaxArrayLength = ReaderQuotas.MaxArrayLength;
+                       basicHttpBinding.ReaderQuotas.MaxBytesPerRead = ReaderQuotas.MaxBytesPerRead;
+                       basicHttpBinding.ReaderQuotas.MaxDepth = ReaderQuotas.MaxDepth;
+                       basicHttpBinding.ReaderQuotas.MaxNameTableCharCount = ReaderQuotas.MaxNameTableCharCount;
+                       basicHttpBinding.ReaderQuotas.MaxStringContentLength = ReaderQuotas.MaxStringContentLength;
+
+                       basicHttpBinding.Security.Mode = Security.Mode;
+                       basicHttpBinding.TextEncoding = TextEncoding;
+                       basicHttpBinding.TransferMode = TransferMode;
+                       basicHttpBinding.UseDefaultWebProxy = UseDefaultWebProxy;
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpMessageSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpMessageSecurityElement.cs
new file mode 100644 (file)
index 0000000..20fab31
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// BasicHttpMessageSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class BasicHttpMessageSecurityElement
+                : ConfigurationElement
+       {
+               // Properties
+
+               [ConfigurationProperty ("algorithmSuite",
+                        DefaultValue = "Default",
+                        Options = ConfigurationPropertyOptions.None)]
+               [TypeConverter (typeof (SecurityAlgorithmSuiteConverter))]
+               public SecurityAlgorithmSuite AlgorithmSuite {
+                       get { return (SecurityAlgorithmSuite) base ["algorithmSuite"]; }
+                       set { base ["algorithmSuite"] = value; }
+               }
+
+               [ConfigurationProperty ("clientCredentialType",
+                        DefaultValue = "UserName",
+                        Options = ConfigurationPropertyOptions.None)]
+               public BasicHttpMessageCredentialType ClientCredentialType {
+                       get { return (BasicHttpMessageCredentialType) base ["clientCredentialType"]; }
+                       set { base ["clientCredentialType"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BasicHttpSecurityElement.cs
new file mode 100644 (file)
index 0000000..780a670
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// BasicHttpSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class BasicHttpSecurityElement
+                : ConfigurationElement
+       {
+               // Properties
+
+               [ConfigurationProperty ("message",
+                        Options = ConfigurationPropertyOptions.None)]
+               public BasicHttpMessageSecurityElement Message {
+                       get { return (BasicHttpMessageSecurityElement) base ["message"]; }
+               }
+
+               [ConfigurationProperty ("mode",
+                        DefaultValue = "None",
+                        Options = ConfigurationPropertyOptions.None)]
+               public BasicHttpSecurityMode Mode {
+                       get { return (BasicHttpSecurityMode) base ["mode"]; }
+                       set { base ["mode"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("transport",
+                        Options = ConfigurationPropertyOptions.None)]
+               public HttpTransportSecurityElement Transport {
+                       get { return (HttpTransportSecurityElement) base ["transport"]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BehaviorExtensionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BehaviorExtensionElement.cs
new file mode 100644 (file)
index 0000000..3c05f29
--- /dev/null
@@ -0,0 +1,52 @@
+//\r
+// BehaviorExtensionElement.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Xml;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       // BehaviorExtensionElement\r
+       public abstract class BehaviorExtensionElement\r
+                : ServiceModelExtensionElement\r
+       {\r
+               protected BehaviorExtensionElement () {\r
+               }\r
+\r
+               // Properties\r
+               public abstract Type BehaviorType { get; }\r
+\r
+               protected internal abstract object CreateBehavior ();\r
+\r
+               internal override string GetConfigurationElementName () {\r
+                       return ConfigUtil.ExtensionsSection.BehaviorExtensions.GetConfigurationElementName (GetType ());\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BehaviorsSection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BehaviorsSection.cs
new file mode 100644 (file)
index 0000000..f925b79
--- /dev/null
@@ -0,0 +1,90 @@
+//
+// BehaviorsSection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class BehaviorsSection
+                : ConfigurationSection
+       {
+               ConfigurationPropertyCollection _properties;
+               
+               // Properties
+
+               [ConfigurationProperty ("endpointBehaviors",
+                        Options = ConfigurationPropertyOptions.None)]
+               public EndpointBehaviorElementCollection EndpointBehaviors {
+                       get { return (EndpointBehaviorElementCollection) base ["endpointBehaviors"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty ("endpointBehaviors", typeof (EndpointBehaviorElementCollection), null, null/* FIXME: get converter for EndpointBehaviorElementCollection*/, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("serviceBehaviors", typeof (ServiceBehaviorElementCollection), null, null/* FIXME: get converter for ServiceBehaviorElementCollection*/, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("serviceBehaviors",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ServiceBehaviorElementCollection ServiceBehaviors {
+                       get { return (ServiceBehaviorElementCollection) base ["serviceBehaviors"]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BinaryMessageEncodingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BinaryMessageEncodingElement.cs
new file mode 100644 (file)
index 0000000..ddfecf2
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// BinaryMessageEncodingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class BinaryMessageEncodingElement
+                : BindingElementExtensionElement
+       {
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (BinaryMessageEncodingBindingElement); }
+               }
+
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxReadPoolSize",
+                        DefaultValue = "64",
+                        Options = ConfigurationPropertyOptions.None)]
+               public int MaxReadPoolSize {
+                       get { return (int) base ["maxReadPoolSize"]; }
+                       set { base ["maxReadPoolSize"] = value; }
+               }
+
+               [IntegerValidator (MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxSessionSize",
+                        DefaultValue = "2048",
+                        Options = ConfigurationPropertyOptions.None)]
+               public int MaxSessionSize {
+                       get { return (int) base ["maxSessionSize"]; }
+                       set { base ["maxSessionSize"] = value; }
+               }
+
+               [ConfigurationProperty ("maxWritePoolSize",
+                        DefaultValue = "16",
+                        Options = ConfigurationPropertyOptions.None)]
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxWritePoolSize {
+                       get { return (int) base ["maxWritePoolSize"]; }
+                       set { base ["maxWritePoolSize"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("readerQuotas",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlDictionaryReaderQuotasElement ReaderQuotas {
+                       get { return (XmlDictionaryReaderQuotasElement) base ["readerQuotas"]; }
+               }
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..5496384
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// BindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public abstract class BindingCollectionElement
+                : ConfigurationElement
+       {
+
+               protected BindingCollectionElement () {
+               }
+
+
+               // Properties
+               [MonoTODO ("not implemented")]
+               public string BindingName {
+                       get { throw new NotImplementedException (); }
+               }
+               public abstract Type BindingType { get; }
+               public abstract ReadOnlyCollection<IBindingConfigurationElement> ConfiguredBindings { get; }
+
+               public abstract bool ContainsKey (string name);
+               protected internal abstract Binding GetDefault ();
+               protected internal abstract bool TryAdd (string name, Binding binding, System.Configuration.Configuration config);
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BindingElementExtensionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BindingElementExtensionElement.cs
new file mode 100644 (file)
index 0000000..6f2e4a7
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// BindingElementExtensionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public abstract partial class BindingElementExtensionElement
+                : ServiceModelExtensionElement
+       {
+               protected BindingElementExtensionElement () {
+               }
+
+               // Properties
+               public abstract Type BindingElementType { get; }
+
+               [MonoTODO]
+               public virtual void ApplyConfiguration (BindingElement bindingElement) {
+                       throw new NotImplementedException ();
+               }
+
+               protected internal abstract BindingElement CreateBindingElement ();
+
+               [MonoTODO]
+               protected internal virtual void InitializeFrom (BindingElement bindingElement) {
+                       throw new NotImplementedException ();
+               }
+
+               internal override string GetConfigurationElementName () {
+                       return ConfigUtil.ExtensionsSection.BindingElementExtensions.GetConfigurationElementName (GetType());
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BindingsSection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/BindingsSection.cs
new file mode 100644 (file)
index 0000000..bb6452a
--- /dev/null
@@ -0,0 +1,163 @@
+//
+// BindingsSection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class BindingsSection
+                : ConfigurationSection
+       {
+               ConfigurationPropertyCollection _properties;
+
+               // Properties
+
+               [ConfigurationProperty ("basicHttpBinding",
+                        Options = ConfigurationPropertyOptions.None)]
+               public BasicHttpBindingCollectionElement BasicHttpBinding {
+                       get { return (BasicHttpBindingCollectionElement) this ["basicHttpBinding"]; }
+               }
+
+               [MonoTODO ("Not Implemented")]
+               public List<BindingCollectionElement> BindingCollections {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [ConfigurationProperty ("customBinding",
+                        Options = ConfigurationPropertyOptions.None)]
+               public CustomBindingCollectionElement CustomBinding {
+                       get { return (CustomBindingCollectionElement) this ["customBinding"]; }
+               }
+
+               [ConfigurationProperty ("msmqIntegrationBinding",
+                        Options = ConfigurationPropertyOptions.None)]
+               public MsmqIntegrationBindingCollectionElement MsmqIntegrationBinding {
+                       get { return (MsmqIntegrationBindingCollectionElement) this ["msmqIntegrationBinding"]; }
+               }
+
+               [ConfigurationProperty ("netMsmqBinding",
+                        Options = ConfigurationPropertyOptions.None)]
+               public NetMsmqBindingCollectionElement NetMsmqBinding {
+                       get { return (NetMsmqBindingCollectionElement) this ["netMsmqBinding"]; }
+               }
+
+               [ConfigurationProperty ("netNamedPipeBinding",
+                        Options = ConfigurationPropertyOptions.None)]
+               public NetNamedPipeBindingCollectionElement NetNamedPipeBinding {
+                       get { return (NetNamedPipeBindingCollectionElement) this ["netNamedPipeBinding"]; }
+               }
+
+               [ConfigurationProperty ("netPeerTcpBinding",
+                        Options = ConfigurationPropertyOptions.None)]
+               public NetPeerTcpBindingCollectionElement NetPeerTcpBinding {
+                       get { return (NetPeerTcpBindingCollectionElement) this ["netPeerTcpBinding"]; }
+               }
+
+               [ConfigurationProperty ("netTcpBinding",
+                        Options = ConfigurationPropertyOptions.None)]
+               public NetTcpBindingCollectionElement NetTcpBinding {
+                       get { return (NetTcpBindingCollectionElement) this ["netTcpBinding"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       ExtensionElementCollection extensions = ((ExtensionsSection) EvaluationContext.GetSection ("system.serviceModel/extensions")).BindingExtensions;
+                                       for (int i = 0; i < extensions.Count; i++) {
+                                               ExtensionElement extension = extensions [i];
+                                               _properties.Add (new ConfigurationProperty (extension.Name, Type.GetType (extension.Type), null, null, null, ConfigurationPropertyOptions.None));
+                                       }
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("wsDualHttpBinding",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSDualHttpBindingCollectionElement WSDualHttpBinding {
+                       get { return (WSDualHttpBindingCollectionElement) this ["wsDualHttpBinding"]; }
+               }
+
+               [ConfigurationProperty ("wsFederationHttpBinding",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSFederationHttpBindingCollectionElement WSFederationHttpBinding {
+                       get { return (WSFederationHttpBindingCollectionElement) this ["wsFederationHttpBinding"]; }
+               }
+
+               [ConfigurationProperty ("wsHttpBinding",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSHttpBindingCollectionElement WSHttpBinding {
+                       get { return (WSHttpBindingCollectionElement) this ["wsHttpBinding"]; }
+               }
+
+               public static BindingsSection GetSection (System.Configuration.Configuration config) {
+                       ServiceModelSectionGroup sm = ServiceModelSectionGroup.GetSectionGroup (config);
+                       if (sm == null)
+                               throw new SystemException ("Could not retrieve configuration section group 'system.serviceModel'");
+                       if (sm.Bindings == null)
+                               throw new SystemException ("Could not retrieve configuration sub section group 'bindings' in 'system.serviceModel'");
+                       return sm.Bindings;
+               }
+
+               public new BindingCollectionElement this [string name] {
+                       get {
+                               object element = base [name];
+                               if (element is BindingCollectionElement)
+                                       return (BindingCollectionElement) element;
+                               throw new NotImplementedException (String.Format ("Could not find {0}", name));
+                       }
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CallbackDebugElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CallbackDebugElement.cs
new file mode 100644 (file)
index 0000000..5cd6896
--- /dev/null
@@ -0,0 +1,90 @@
+//
+// CallbackDebugElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class CallbackDebugElement
+                : BehaviorExtensionElement
+       {
+
+               public CallbackDebugElement ()
+               {
+               }
+
+
+               // Properties
+
+               public override Type BehaviorType {
+                       get { return typeof (CallbackDebugBehavior); }
+               }
+
+               [ConfigurationProperty ("includeExceptionDetailInFaults",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool IncludeExceptionDetailInFaults {
+                       get { return (bool) base ["includeExceptionDetailInFaults"]; }
+                       set { base ["includeExceptionDetailInFaults"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               protected internal override object CreateBehavior () {
+                       return new CallbackDebugBehavior (IncludeExceptionDetailInFaults);
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CallbackTimeoutsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CallbackTimeoutsElement.cs
new file mode 100644 (file)
index 0000000..599ebf2
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// CallbackTimeoutsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class CallbackTimeoutsElement
+                : BehaviorExtensionElement
+       {
+               public CallbackTimeoutsElement () {
+               }
+
+               // Properties
+
+               public override Type BehaviorType {
+                       get { return typeof (CallbackTimeoutsBehavior); }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("transactionTimeout",
+                        DefaultValue = "00:00:00",
+                        Options = ConfigurationPropertyOptions.None)]
+               public TimeSpan TransactionTimeout {
+                       get { return (TimeSpan) base ["transactionTimeout"]; }
+                       set { base ["transactionTimeout"] = value; }
+               }
+
+               protected internal override object CreateBehavior () {
+                       return new CallbackTimeoutsBehavior (TransactionTimeout);
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CertificateElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CertificateElement.cs
new file mode 100644 (file)
index 0000000..9cb6cb3
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// CertificateElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class CertificateElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty encoded_value;
+
+               static CertificateElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       encoded_value = new ConfigurationProperty ("encodedValue",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (encoded_value);
+               }
+
+               public CertificateElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("encodedValue",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string EncodedValue {
+                       get { return (string) base [encoded_value]; }
+                       set { base [encoded_value] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CertificateReferenceElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CertificateReferenceElement.cs
new file mode 100644 (file)
index 0000000..45a6d66
--- /dev/null
@@ -0,0 +1,156 @@
+//
+// CertificateReferenceElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class CertificateReferenceElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty find_value;
+               static ConfigurationProperty is_chain_included;
+               static ConfigurationProperty store_location;
+               static ConfigurationProperty store_name;
+               static ConfigurationProperty x509_find_type;
+
+               static CertificateReferenceElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       find_value = new ConfigurationProperty ("findValue",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       is_chain_included = new ConfigurationProperty ("isChainIncluded",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_location = new ConfigurationProperty ("storeLocation",
+                               typeof (StoreLocation), "LocalMachine", null/* FIXME: get converter for StoreLocation*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_name = new ConfigurationProperty ("storeName",
+                               typeof (StoreName), "My", null/* FIXME: get converter for StoreName*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       x509_find_type = new ConfigurationProperty ("x509FindType",
+                               typeof (X509FindType), "FindBySubjectDistinguishedName", null/* FIXME: get converter for X509FindType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (find_value);
+                       properties.Add (is_chain_included);
+                       properties.Add (store_location);
+                       properties.Add (store_name);
+                       properties.Add (x509_find_type);
+               }
+
+               public CertificateReferenceElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("findValue",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string FindValue {
+                       get { return (string) base [find_value]; }
+                       set { base [find_value] = value; }
+               }
+
+               [ConfigurationProperty ("isChainIncluded",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool IsChainIncluded {
+                       get { return (bool) base [is_chain_included]; }
+                       set { base [is_chain_included] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("storeLocation",
+                        DefaultValue = "LocalMachine",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreLocation StoreLocation {
+                       get { return (StoreLocation) base [store_location]; }
+                       set { base [store_location] = value; }
+               }
+
+               [ConfigurationProperty ("storeName",
+                        DefaultValue = "My",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreName StoreName {
+                       get { return (StoreName) base [store_name]; }
+                       set { base [store_name] = value; }
+               }
+
+               [ConfigurationProperty ("x509FindType",
+                        DefaultValue = "FindBySubjectDistinguishedName",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509FindType X509FindType {
+                       get { return (X509FindType) base [x509_find_type]; }
+                       set { base [x509_find_type] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChangeLog
new file mode 100755 (executable)
index 0000000..c38c95d
--- /dev/null
@@ -0,0 +1,590 @@
+2008-04-22  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceDebugElement.cs:
+       implement CreateBehavior method.
+       
+2008-04-03  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceModelExtensionCollectionElement.cs:
+       implement this[int index] api.
+       
+2008-04-01  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceEndpointElementCollection.cs: fix GetElementKey().
+       
+2008-03-31  Vladmir Krasnov  <vladmimir@mainsoft.com>
+
+       * ConfigUtil.cs: fixed CreateBinding
+       * BasicHttpBindingElement.cs: OnApplyConfiguration
+       * StandardBindingElement.cs: implemented ApplyConfiguration
+
+2008-03-27  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * XmlElementElementCollection.cs:
+       * XmlElementElement.cs:
+       * WSFederationHttpBindingElement.cs:
+       * WSDualHttpBindingElement.cs:
+       * WindowsStreamSecurityElement.cs:
+       * UseManagedPresentationElement.cs:
+       * TransportElement.cs:
+       * TransactionFlowElement.cs:
+       * TextMessageEncodingElement.cs:
+       * TcpTransportElement.cs:
+       * TcpConnectionPoolSettingsElement.cs:
+       * StandardBindingReliableSessionElement.cs:
+       * SslStreamSecurityElement.cs:
+       * SecurityElementBase.cs:
+       * SecurityElement.cs:
+       * ReliableSessionElement.cs:
+       * PrivacyNoticeElement.cs:
+       * PnrpPeerResolverElement.cs:
+       * PeerTransportElement.cs:
+       * OneWayElement.cs:
+       * NetPeerTcpBindingElement.cs:
+       * NetMsmqBindingElement.cs:
+       * NamedPipeTransportElement.cs:
+       * NamedPipeConnectionPoolSettingsElement.cs:
+       * MtomMessageEncodingElement.cs:
+       * MsmqTransportElement.cs:
+       * MsmqIntegrationElement.cs:
+       * MsmqIntegrationBindingElement.cs:
+       * MsmqElementBase.cs:
+       * MsmqBindingElementBase.cs:
+       * MethodStubs.cs:
+       * MessageSecurityOverMsmqElement.cs:
+       * LocalServiceSecuritySettingsElement.cs:
+       * LocalClientSecuritySettingsElement.cs:
+       * IssuedTokenParametersEndpointAddressElement.cs:
+       * IssuedTokenParametersElement.cs:
+       * IssuedTokenClientElement.cs:
+       * HttpTransportElement.cs:
+       * HttpsTransportElement.cs:
+       * FederatedMessageSecurityOverHttpElement.cs:
+       * EndpointAddressElementBase.cs:
+       * ConnectionOrientedTransportElement.cs:
+       * CompositeDuplexElement.cs:
+       * ChannelPoolSettingsElement.cs:
+       fix apis and implementation, make corresponding tests pass                                                                                                                                                                                      
+
+2008-03-27  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * IPAddressConverter.cs:
+       * MessageVersionConverter.cs:
+       * MessageSecurityVersionConverter.cs:
+       * ReliableMessagingVersionConverter.cs: 
+       new internal converters used for reading configuration.                 
+
+2008-03-26  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceModelExtensionCollectionElement.cs:
+       fix GetEnumerator method.       
+
+2008-03-26  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ClientSection.cs: implement InitializeDefaults, refactoring.
+       * MetadataElement.cs: implement LoadPolicyImporExtensions, 
+       LoasWsdlImportExtensions, refactoring.          
+       * MethodStubs.cs: refactoring.
+       * PolicyImporterElement.cs: add missing constructors, refactoring.
+       * PolicyImporterElementCollection.cs: refactoring.
+       * WsdlImporterElement.cs: add missing constructors, refactoring.
+       * WsdlImporterElementCollection.cs: refactoring.                        
+
+2008-03-24  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ExtensionsSection.cs: typo fix.
+       * MethodStubs.cs: refactoring.  
+       * PolicyVersionConverter.cs: implement ConvertTo method.
+       * ServiceAuthorizationElement.cs: refactoring.
+       * ServiceCredentialsElement.cs: fix BehaviorType property, refactoring.
+       * ServiceDebugElement.cs: fix BehaviorType property, refactoring.
+       * ServiceSecurityAuditElement.cs: fix BehaviorType property, refactoring.
+       * ServiceThrottlingElement.cs: fix BehaviorType property, refactoring.
+       * ServiceTimeoutsElement.cs: fix BehaviorType property, refactoring.
+       * X509CertificateTrustedIssuerElement.cs: refactoring.
+       * X509CertificateTrustedIssuerElementCollection.cs: implement GetElementKey.
+       all changes make corresponding tests pass.                                                                                                                                                                                      
+                                                                                       
+2008-03-04  Eyal Alaluf <eyala@mainsoft.com>
+
+       * EndpointBehaviorElement.cs: Add "callbackDebug" behavior element.
+       * MethodStubs.cs: Fix key calculcation of ChannelEndpointElementCollection.
+       * NamedServiceModelExtensionCollectionElement.cs: Allow derived classes
+         to extend the properties of this configuration element.
+    * ServiceModelExtensionCollectionElement.cs: Implement GetEnumerator.
+       * ServiceModelConfigurationElementCollection.cs: Implement collection.
+
+2008-03-02  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * StandardBindingOptionalReliableSessionElement.cs:
+       * StandardBindingReliableSessionElement.cs:     
+       fix properties collection initialization.       
+
+2008-03-02  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * MessageSecurityOverTcpElement.cs:
+       fix properties collection initialization.       
+
+2008-02-19  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * BasicHttpBindingElement.cs:
+       * BindingCollectionElement.cs:
+       * BindingsSection.cs:
+       * ChannelEndpointElementCollection.cs:
+       * MethodStubs.cs:
+       * MexBindingElement.cs:
+       * MexHttpBindingElement.cs:
+       * MexHttpsBindingElement.cs:
+       * MexNamedPipeBindingElement.cs:
+       * MexTcpBindingElement.cs:
+       * MsmqIntegrationBindingElement.cs:
+       * NetMsmqBindingElement.cs:
+       * NetNamedPipeBindingElement.cs:
+       * NetPeerTcpBindingElement.cs:
+       * NetTcpBindingElement.cs:
+       * PolicyImporterElementCollection.cs:
+       * TransactionProtocolConverter.cs       
+       * StandardBindingCollectionElement.cs:
+       * StandardBindingElement.cs:
+       * WsdlImporterElementCollection.cs:
+       * WSDualHttpBindingElement.cs:
+       * WSFederationHttpBindingElement.cs:
+       * WSHttpBindingElement.cs:
+       fix apis and implementation, make corresponding tests pass                                                                                                                                                                                      
+
+2008-02-17  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * BasicHttpBindingElement.cs:
+       * ServiceModelConfigurationElementCollection.cs:
+       * StandardBindingElement.cs: 
+       * StandardBindingElementCollection.cs:
+       fixed several bugs, make relevant tests pass.           
+       
+2008-02-17  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * EncodingConverter.cs: added internal class.
+       * SecurityAlgorithmSuiteConverter.cs: added internal class.
+       * BasicHttpMessageSecurityElement.cs: 
+       use SecurityAlgorithmSuiteConverter for "algorithmSuite" property.
+       
+2008-02-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MethodStubs.cs : Added CreateBehavior() method in couple of elements.
+
+2007-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelSectionGroup.cs :
+         Diagnostic section name is "diagnostics".
+
+2006-10-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceMetadataPublishingElement.cs : enable gets by default.
+       * ServiceModelConfigurationElementCollection.cs,
+         NamedServiceModelExtensionCollectionElement.cs :
+         cosmetic API fixes.
+       * MethodStubs.cs : (ServiceBehaviorElementCollection and 
+         ServiceBehaviorElement) override DeserializeElement() to read
+         individual extension elements (and make some DeserializeElement()
+         callable).
+
+2006-10-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MethodStubs.cs : implemented some GetElementKey() implementations.
+
+2006-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       Replaced Dummy.cs with individual class files:
+       * MethodStubs.cs : there were some API changes in Sep.CTP.
+       * Dummy.cs,
+         AddressHeaderCollectionElement.cs,
+         AuthorizationPolicyTypeElement.cs,
+         AuthorizationPolicyTypeElementCollection.cs,
+         BaseAddressElement.cs,
+         BaseAddressElementCollection.cs,
+         BasicHttpBindingCollectionElement.cs,
+         BasicHttpBindingElement.cs,
+         BasicHttpMessageSecurityElement.cs,
+         BasicHttpSecurityElement.cs,
+         BehaviorsSection.cs,
+         BinaryMessageEncodingElement.cs,
+         BindingCollectionElement.cs,
+         BindingElementExtensionElement.cs,
+         BindingsSection.cs,
+         CallbackDebugElement.cs,
+         CallbackTimeoutsElement.cs,
+         CertificateElement.cs,
+         CertificateReferenceElement.cs,
+         ChannelEndpointElement.cs,
+         ChannelEndpointElementCollection.cs,
+         ChannelPoolSettingsElement.cs,
+         ClaimTypeElement.cs,
+         ClaimTypeElementCollection.cs,
+         ClientCredentialsElement.cs,
+         ClientSection.cs,
+         ClientViaElement.cs,
+         ComContractElement.cs,
+         ComContractElementCollection.cs,
+         ComContractsSection.cs,
+         ComMethodElement.cs,
+         ComMethodElementCollection.cs,
+         ComPersistableTypeElement.cs,
+         ComPersistableTypeElementCollection.cs,
+         ComUdtElement.cs,
+         ComUdtElementCollection.cs,
+         CommonBehaviorsSection.cs,
+         CommonEndpointBehaviorElement.cs,
+         CommonServiceBehaviorElement.cs,
+         CompositeDuplexElement.cs,
+         ConnectionOrientedTransportElement.cs,
+         CustomBindingCollectionElement.cs,
+         CustomBindingElement.cs,
+         CustomBindingElementCollection.cs,
+         DataContractSerializerElement.cs,
+         DiagnosticSection.cs,
+         DnsElement.cs,
+         EndpointAddressElementBase.cs,
+         EndpointBehaviorElement.cs,
+         EndpointBehaviorElementCollection.cs,
+         ExtensionElement.cs,
+         ExtensionElementCollection.cs,
+         ExtensionsSection.cs,
+         FederatedMessageSecurityOverHttpElement.cs,
+         HostElement.cs,
+         HostTimeoutsElement.cs,
+         HttpDigestClientElement.cs,
+         HttpTransportElement.cs,
+         HttpTransportSecurityElement.cs,
+         HttpsTransportElement.cs,
+         IdentityElement.cs,
+         IssuedTokenClientBehaviorsElement.cs,
+         IssuedTokenClientBehaviorsElementCollection.cs,
+         IssuedTokenClientElement.cs,
+         IssuedTokenParametersElement.cs,
+         IssuedTokenParametersEndpointAddressElement.cs,
+         IssuedTokenServiceElement.cs,
+         LocalClientSecuritySettingsElement.cs,
+         LocalServiceSecuritySettingsElement.cs,
+         MessageLoggingElement.cs,
+         MessageSecurityOverHttpElement.cs,
+         MessageSecurityOverMsmqElement.cs,
+         MessageSecurityOverTcpElement.cs,
+         MetadataElement.cs,
+         MexBindingBindingCollectionElement.cs,
+         MexBindingElement.cs,
+         MexHttpBindingCollectionElement.cs,
+         MexHttpBindingElement.cs,
+         MexHttpsBindingCollectionElement.cs,
+         MexHttpsBindingElement.cs,
+         MexNamedPipeBindingCollectionElement.cs,
+         MexNamedPipeBindingElement.cs,
+         MexTcpBindingCollectionElement.cs,
+         MexTcpBindingElement.cs,
+         MsmqBindingElementBase.cs,
+         MsmqElementBase.cs,
+         MsmqIntegrationBindingCollectionElement.cs,
+         MsmqIntegrationBindingElement.cs,
+         MsmqIntegrationElement.cs,
+         MsmqIntegrationSecurityElement.cs,
+         MsmqTransportElement.cs,
+         MsmqTransportSecurityElement.cs,
+         MtomMessageEncodingElement.cs,
+         NamedPipeConnectionPoolSettingsElement.cs,
+         NamedPipeTransportElement.cs,
+         NamedPipeTransportSecurityElement.cs,
+         NamedServiceModelExtensionCollectionElement.cs,
+         NetMsmqBindingCollectionElement.cs,
+         NetMsmqBindingElement.cs,
+         NetMsmqSecurityElement.cs,
+         NetNamedPipeBindingCollectionElement.cs,
+         NetNamedPipeBindingElement.cs,
+         NetNamedPipeSecurityElement.cs,
+         NetPeerTcpBindingCollectionElement.cs,
+         NetPeerTcpBindingElement.cs,
+         NetTcpBindingCollectionElement.cs,
+         NetTcpBindingElement.cs,
+         NetTcpSecurityElement.cs,
+         NonDualMessageSecurityOverHttpElement.cs,
+         OneWayElement.cs,
+         PeerCredentialElement.cs,
+         PeerCustomResolverElement.cs,
+         PeerResolverElement.cs,
+         PeerSecurityElement.cs,
+         PeerTransportElement.cs,
+         PeerTransportSecurityElement.cs,
+         PnrpPeerResolverElement.cs,
+         PolicyImporterElement.cs,
+         PolicyImporterElementCollection.cs,
+         PrivacyNoticeElement.cs,
+         ReliableSessionElement.cs,
+         RsaElement.cs,
+         SecureConversationServiceElement.cs,
+         SecurityElement.cs,
+         SecurityElementBase.cs,
+         ServiceAuthorizationElement.cs,
+         ServiceBehaviorElement.cs,
+         ServiceBehaviorElementCollection.cs,
+         ServiceCredentialsElement.cs,
+         ServiceDebugElement.cs,
+         ServiceElement.cs,
+         ServiceElementCollection.cs,
+         ServiceEndpointElement.cs,
+         ServiceEndpointElementCollection.cs,
+         ServiceHostingEnvironmentSection.cs,
+         ServiceMetadataPublishingElement.cs,
+         ServiceModelEnhancedConfigurationElementCollection.cs,
+         ServiceModelExtensionElement.cs,
+         ServicePrincipalNameElement.cs,
+         ServiceSecurityAuditElement.cs,
+         ServiceThrottlingElement.cs,
+         ServiceTimeoutsElement.cs,
+         ServicesSection.cs,
+         SslStreamSecurityElement.cs,
+         StandardBindingCollectionElement.cs,
+         StandardBindingElement.cs,
+         StandardBindingElementCollection.cs,
+         StandardBindingOptionalReliableSessionElement.cs,
+         StandardBindingReliableSessionElement.cs,
+         SynchronousReceiveElement.cs,
+         TcpConnectionPoolSettingsElement.cs,
+         TcpTransportElement.cs,
+         TcpTransportSecurityElement.cs,
+         TextMessageEncodingElement.cs,
+         TransactedBatchingElement.cs,
+         TransactionFlowElement.cs,
+         TransportConfigurationTypeElement.cs,
+         TransportConfigurationTypeElementCollection.cs,
+         TransportElement.cs,
+         UseManagedPresentationElement.cs,
+         UserNameServiceElement.cs,
+         UserPrincipalNameElement.cs,
+         WSDualHttpBindingCollectionElement.cs,
+         WSDualHttpBindingElement.cs,
+         WSDualHttpSecurityElement.cs,
+         WSFederationHttpBindingCollectionElement.cs,
+         WSFederationHttpBindingElement.cs,
+         WSFederationHttpSecurityElement.cs,
+         WSHttpBindingBaseElement.cs,
+         WSHttpBindingCollectionElement.cs,
+         WSHttpBindingElement.cs,
+         WSHttpSecurityElement.cs,
+         WSHttpTransportSecurityElement.cs,
+         WindowsClientElement.cs,
+         WindowsServiceElement.cs,
+         WindowsStreamSecurityElement.cs,
+         WsdlImporterElement.cs,
+         WsdlImporterElementCollection.cs,
+         X509CertificateTrustedIssuerElement.cs,
+         X509CertificateTrustedIssuerElementCollection.cs,
+         X509ClientCertificateAuthenticationElement.cs,
+         X509ClientCertificateCredentialsElement.cs,
+         X509DefaultServiceCertificateElement.cs,
+         X509InitiatorCertificateClientElement.cs,
+         X509InitiatorCertificateServiceElement.cs,
+         X509PeerCertificateAuthenticationElement.cs,
+         X509PeerCertificateElement.cs,
+         X509RecipientCertificateClientElement.cs,
+         X509RecipientCertificateServiceElement.cs,
+         X509ScopedServiceCertificateElement.cs,
+         X509ScopedServiceCertificateElementCollection.cs,
+         X509ServiceCertificateAuthenticationElement.cs,
+         XPathMessageFilterElement.cs,
+         XPathMessageFilterElementCollection.cs,
+         XPathMessageFilterElementComparer.cs,
+         XmlDictionaryReaderQuotasElement.cs,
+         XmlElementElement.cs,
+         XmlElementElementCollection.cs : replaced.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : (config) regenerated.
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : regenerated.
+
+2006-06-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelEnhancedConfigurationElementCollection.cs :
+         oops, it is extraneous.
+
+2006-06-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MethodStubs.cs : several fixes due to the requirements from base
+         types.
+       * ServiceModelSectionGroup.cs,
+         ConfigUtil.cs : Reflect type name changes on properties.
+       * Dummy.cs : regenerated.
+
+       * ServiceModelEnhancedConfigurationElementCollection.cs,
+         ServiceModelExtensionCollectionElement.cs :
+         Added new types.
+       * BindingSectionGroup.cs,
+         ServiceModelExtensionSectionCollection.cs
+         StandardBindingSection.cs
+         NamedServiceModelExtensionSectionCollection.cs
+         SecuritySectionBase.cs
+         EndpointAddressElementBase.cs
+         MsmqSectionBase.cs
+         ServiceModelBasicMapConfigurationElementCollection.cs
+         MsmqBindingConfigurationElementBase.cs
+         StandardBindingConfigurationElementCollection.cs :
+         Removed old types.
+
+2006-06-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MethodStubs.cs : some API fixes.
+       * MsmqTransportSectionBase.cs : removed obsolete type.
+
+2006-06-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * StandardBindingSection.cs : removed ConfiguredBindings from
+         config properties (it conflicts with Bindings).
+       * Dummy.cs : regenerated (BindingName is not config property).
+       * ConfigUtil.cs : add bindingConfiguration parameter to
+         CreateBinding(). For now comment out ApplyConfiguration().
+
+2006-06-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingsSectionGroup.cs : refresh addition.
+       * StandardBindingSection.cs : added missing members.
+       * MethodStubs.cs : removed default constructor which now conflicts
+         with generated one.
+         Added missing interface members (since interfaces are written now).
+       * Dummy.cs : regenerated.
+       * StandardBindingConfigurationElementCollection.cs :
+         implemented GetElementKey().
+
+2006-06-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ConfigUtil.cs : reverted previous hack.
+       * MethodStubs.cs : added some BindingType property implementation.
+       * ServiceModelExtensionSectionCollection.cs : not abstract.
+       * StandardBindingConfigurationElementCollection.cs :
+         new missing type.
+
+2006-06-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingsSectionGroup.cs : removed and it is now autogenerated.
+       * ServiceModelConfigurationElementCollection.cs : some API fixes.
+       * ServiceModelBasicMapConfigurationElementCollection.cs : ditto.
+       * MethodStubs.cs : added some missing stuff. Especially, now
+         GetElementKey() is manually added to all collection types.
+       * ConfigUtil.cs : hacky Bindings properties.
+       * Dummy.cs : regenerated.
+
+2006-06-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelConfigurationElementCollection.cs :
+         implemented ElementName.
+
+2006-06-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : regerenerated.
+
+2006-06-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ConfigUtil.cs : new utility class.
+
+2006-06-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelSectionGroup.cs : 
+       * IBindingConfigurationElement.cs : added ApplyConfiguration().
+       * BindingsSectionGroup.cs : some API fixes. A bit of indexer
+         implementation.
+       * ServiceModelConfigurationElementCollection.cs : implemented a bit.
+       * ServiceModelSectionGroup.cs : implemented.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : regenerated.
+
+2006-05-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * configgen/configgen.cs : changed implementation strategy. Now it
+         generates code similar to existing Sys.Configuration classes.
+       * Dummy.cs : regenerated
+       * ServiceModelExtensionSectionCollection.cs,
+         StandardBindingSection.cs
+         AuthenticationMode.cs
+         IBindingConfigurationElement.cs
+         SecuritySectionBase.cs
+         EndpointAddressElementBase.cs
+         ServiceModelConfigurationElementCollection.cs
+         ServiceModelBasicMapConfigurationElementCollection.cs
+         MethodStubs.cs : several API updates.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs MethodStubs.cs StandardBindingSection.cs :
+         Feb. CTP API changes - chapter 1.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : regenerated.
+
+2006-02-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelConfigurationElementCollection.cs : signature fix
+         (in sync with sys.configuration.dll)
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MsmqSectionBase.cs, MsmqTransportSectionBase.cs,
+         NamedServiceModelExtensionSectionCollection.cs : new in Nov. CTP.
+       * Dummy.cs, AuthenticationMode.cs :
+         updated to Nov. CTP.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs, BindingsSectionGroup.cs :
+         removed items related to IntermediaryBinding (removed in beta2).
+
+2005-10-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * configgen/configgen.cs : now that bug #76365 is gone, we can use
+         partial types without problem.
+       * MethodStubs.cs : thus, new file for partial types to define
+         methods manually.
+       * Dummy.cs : regenerated.
+
+2005-10-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServicesSection.cs : remove.
+         Actually autogenerated ServicesSection is better.
+       * Dummy.cs : regenerated.
+
+2005-10-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelConfigurationElementCollection.cs,
+         StandardBindingSection.cs : added some missing members.
+       * Dummy.cs : regenereated.
+
+2005-10-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelBasicMapConfigurationElementCollection.cs,
+         ServiceModelExtensionSectionCollection.cs,
+         StandardBindingSection.cs, MsmqBindingConfigurationElementBase.cs :
+         new non-autogenerated files.
+       * Dummy.cs :regenerated.
+
+2005-10-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressElementBase.cs : new non-autogenerated file.
+       * Dummy.cs : regenerated.
+
+2005-10-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelConfigurationElementCollection.cs,
+         IBindingConfigurationElement.cs : new files.
+       * Dummy.cs : reflecting configgen.exe changes.
+
+2005-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AuthenticationMode.cs : new enum.
+       * Dummy.cs : autogenerated by configgen.exe.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingsSectionGroup.cs, ServiceModelSectionGroup.cs
+         ServicesSection.cs : new files.
+
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChannelEndpointElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChannelEndpointElement.cs
new file mode 100644 (file)
index 0000000..145a981
--- /dev/null
@@ -0,0 +1,207 @@
+//
+// ChannelEndpointElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class ChannelEndpointElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty address;
+               static ConfigurationProperty behavior_configuration;
+               static ConfigurationProperty binding;
+               static ConfigurationProperty binding_configuration;
+               static ConfigurationProperty contract;
+               static ConfigurationProperty headers;
+               static ConfigurationProperty identity;
+               static ConfigurationProperty name;
+
+               static ChannelEndpointElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       address = new ConfigurationProperty ("address",
+                               typeof (Uri), null, new UriTypeConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       behavior_configuration = new ConfigurationProperty ("behaviorConfiguration",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       binding = new ConfigurationProperty ("binding",
+                               typeof (string), null, new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired);
+
+                       binding_configuration = new ConfigurationProperty ("bindingConfiguration",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       contract = new ConfigurationProperty ("contract",
+                               typeof (string), null, new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       headers = new ConfigurationProperty ("headers",
+                               typeof (AddressHeaderCollectionElement), null, null/* FIXME: get converter for AddressHeaderCollectionElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       identity = new ConfigurationProperty ("identity",
+                               typeof (IdentityElement), null, null/* FIXME: get converter for IdentityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       name = new ConfigurationProperty ("name",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsKey);
+
+                       properties.Add (address);
+                       properties.Add (behavior_configuration);
+                       properties.Add (binding);
+                       properties.Add (binding_configuration);
+                       properties.Add (contract);
+                       properties.Add (headers);
+                       properties.Add (identity);
+                       properties.Add (name);
+               }
+
+               public ChannelEndpointElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("address",
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri Address {
+                       get { return (Uri) base [address]; }
+                       set { base [address] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("behaviorConfiguration",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               public string BehaviorConfiguration {
+                       get { return (string) base [behavior_configuration]; }
+                       set { base [behavior_configuration] = value; }
+               }
+
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("binding",
+                        Options = ConfigurationPropertyOptions.IsRequired,
+                       IsRequired = true)]
+               public string Binding {
+                       get { return (string) base [binding]; }
+                       set { base [binding] = value; }
+               }
+
+               [ConfigurationProperty ("bindingConfiguration",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string BindingConfiguration {
+                       get { return (string) base [binding_configuration]; }
+                       set { base [binding_configuration] = value; }
+               }
+
+               [ConfigurationProperty ("contract",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Contract {
+                       get { return (string) base [contract]; }
+                       set { base [contract] = value; }
+               }
+
+               [ConfigurationProperty ("headers",
+                        Options = ConfigurationPropertyOptions.None)]
+               public AddressHeaderCollectionElement Headers {
+                       get { return (AddressHeaderCollectionElement) base [headers]; }
+               }
+
+               [ConfigurationProperty ("identity",
+                        Options = ConfigurationPropertyOptions.None)]
+               public IdentityElement Identity {
+                       get { return (IdentityElement) base [identity]; }
+               }
+
+               [ConfigurationProperty ("name",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.IsKey,
+                       IsKey = true)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Name {
+                       get { return (string) base [name]; }
+                       set { base [name] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChannelEndpointElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChannelEndpointElementCollection.cs
new file mode 100644 (file)
index 0000000..e031bf4
--- /dev/null
@@ -0,0 +1,78 @@
+//
+// ChannelEndpointElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (ChannelEndpointElement),
+                AddItemName = "endpoint",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       [MonoTODO]
+       public sealed partial class ChannelEndpointElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ChannelEndpointElement>,  ICollection,  IEnumerable
+       {
+
+               public ChannelEndpointElementCollection ()
+               {
+                       AddElementName = "endpoint";
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChannelPoolSettingsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ChannelPoolSettingsElement.cs
new file mode 100644 (file)
index 0000000..60666ee
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// ChannelPoolSettingsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ChannelPoolSettingsElement
+                : ConfigurationElement
+       {
+               public ChannelPoolSettingsElement () {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("idleTimeout",
+                        DefaultValue = "00:02:00",
+                        Options = ConfigurationPropertyOptions.None)]
+               public TimeSpan IdleTimeout {
+                       get { return (TimeSpan) base ["idleTimeout"]; }
+                       set { base ["idleTimeout"] = value; }
+               }
+
+               [ConfigurationProperty ("leaseTimeout",
+                        DefaultValue = "00:10:00",
+                        Options = ConfigurationPropertyOptions.None)]
+               public TimeSpan LeaseTimeout {
+                       get { return (TimeSpan) base ["leaseTimeout"]; }
+                       set { base ["leaseTimeout"] = value; }
+               }
+
+               [ConfigurationProperty ("maxOutboundChannelsPerEndpoint",
+                        DefaultValue = "10",
+                        Options = ConfigurationPropertyOptions.None)]
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxOutboundChannelsPerEndpoint {
+                       get { return (int) base ["maxOutboundChannelsPerEndpoint"]; }
+                       set { base ["maxOutboundChannelsPerEndpoint"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClaimTypeElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClaimTypeElement.cs
new file mode 100644 (file)
index 0000000..3222dfb
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// ClaimTypeElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class ClaimTypeElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty claim_type;
+               static ConfigurationProperty is_optional;
+
+               static ClaimTypeElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       claim_type = new ConfigurationProperty ("claimType",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       is_optional = new ConfigurationProperty ("isOptional",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (claim_type);
+                       properties.Add (is_optional);
+               }
+
+               public ClaimTypeElement ()
+               {
+               }
+
+
+               // Properties
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("claimType",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               public string ClaimType {
+                       get { return (string) base [claim_type]; }
+                       set { base [claim_type] = value; }
+               }
+
+               [ConfigurationProperty ("isOptional",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool IsOptional {
+                       get { return (bool) base [is_optional]; }
+                       set { base [is_optional] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClaimTypeElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClaimTypeElementCollection.cs
new file mode 100644 (file)
index 0000000..b50d672
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// ClaimTypeElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (ClaimTypeElement),
+                AddItemName = "add",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       [MonoTODO]
+       public sealed partial class ClaimTypeElementCollection
+                : ServiceModelConfigurationElementCollection<ClaimTypeElement>,  ICollection,  IEnumerable
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static ClaimTypeElementCollection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public ClaimTypeElementCollection ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClientCredentialsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClientCredentialsElement.cs
new file mode 100644 (file)
index 0000000..5ea3822
--- /dev/null
@@ -0,0 +1,148 @@
+//
+// ClientCredentialsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class ClientCredentialsElement
+                : BehaviorExtensionElement
+       {
+               // Static Fields
+               ConfigurationPropertyCollection _properties;
+
+               // Properties
+
+               public override Type BehaviorType {
+                       get { return typeof (ClientCredentials); }
+               }
+
+               [ConfigurationProperty ("clientCertificate",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509InitiatorCertificateClientElement ClientCertificate {
+                       get { return (X509InitiatorCertificateClientElement) base ["clientCertificate"]; }
+               }
+
+               [ConfigurationProperty ("httpDigest",
+                        Options = ConfigurationPropertyOptions.None)]
+               public HttpDigestClientElement HttpDigest {
+                       get { return (HttpDigestClientElement) base ["httpDigest"]; }
+               }
+
+               [ConfigurationProperty ("issuedToken",
+                        Options = ConfigurationPropertyOptions.None)]
+               public IssuedTokenClientElement IssuedToken {
+                       get { return (IssuedTokenClientElement) base ["issuedToken"]; }
+               }
+
+               [ConfigurationProperty ("peer",
+                        Options = ConfigurationPropertyOptions.None)]
+               public PeerCredentialElement Peer {
+                       get { return (PeerCredentialElement) base ["peer"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty ("clientCertificate", typeof (X509InitiatorCertificateClientElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("httpDigest", typeof (HttpDigestClientElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("issuedToken", typeof (IssuedTokenClientElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("peer", typeof (PeerCredentialElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("serviceCertificate", typeof (X509RecipientCertificateClientElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("supportInteractive", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("type", typeof (string), String.Empty, new StringConverter (), new StringValidator (0, int.MaxValue, null), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("windows", typeof (WindowsClientElement), null, null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("serviceCertificate",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509RecipientCertificateClientElement ServiceCertificate {
+                       get { return (X509RecipientCertificateClientElement) base ["serviceCertificate"]; }
+               }
+
+               [ConfigurationProperty ("supportInteractive",
+                       DefaultValue = true,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool SupportInteractive {
+                       get { return (bool) base ["supportInteractive"]; }
+                       set { base ["supportInteractive"] = value; }
+               }
+
+               [ConfigurationProperty ("type",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator (MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Type {
+                       get { return (string) base ["type"]; }
+                       set { base ["type"] = value; }
+               }
+
+               [ConfigurationProperty ("windows",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WindowsClientElement Windows {
+                       get { return (WindowsClientElement) base ["windows"]; }
+               }
+
+               [MonoTODO]
+               protected internal override object CreateBehavior () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClientSection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClientSection.cs
new file mode 100644 (file)
index 0000000..b2a42f9
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// ClientSection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ClientSection
+                : ConfigurationSection
+       {
+               static Type [] _defaultPolicyImporters = new Type [] {
+                               typeof(CompositeDuplexBindingElementImporter),
+                               typeof(MessageEncodingBindingElementImporter),
+                               typeof(OneWayBindingElementImporter),
+                               typeof(PrivacyNoticeBindingElementImporter),
+                               typeof(ReliableSessionBindingElementImporter),
+                               typeof(SecurityBindingElementImporter),
+                               typeof(TransactionFlowBindingElementImporter),
+                               typeof(TransportBindingElementImporter),
+                               typeof(UseManagedPresentationBindingElementImporter)
+                       };
+
+               static Type [] _defaultWsdlImporters = new Type [] { 
+                               typeof(MessageEncodingBindingElementImporter),
+                               typeof(StandardBindingImporter),
+                               typeof(TransportBindingElementImporter),
+                               typeof(DataContractSerializerMessageContractImporter),
+                               typeof(XmlSerializerMessageContractImporter)
+                       };
+
+               public ClientSection () {
+               }
+
+               // Properties
+
+               [ConfigurationProperty ("",
+                        Options = ConfigurationPropertyOptions.IsDefaultCollection,
+                       IsDefaultCollection = true)]
+               public ChannelEndpointElementCollection Endpoints {
+                       get { return (ChannelEndpointElementCollection) this [String.Empty]; }
+               }
+
+               [ConfigurationProperty ("metadata",
+                        Options = ConfigurationPropertyOptions.None)]
+               public MetadataElement Metadata {
+                       get { return (MetadataElement) this ["metadata"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               protected override void InitializeDefault () {
+                       base.InitializeDefault ();
+
+                       PolicyImporterElementCollection policyImporters = Metadata.PolicyImporters;
+                       for (int i = 0; i < _defaultPolicyImporters.Length; i++)
+                               policyImporters.Add (new PolicyImporterElement (_defaultPolicyImporters [i]));
+
+                       WsdlImporterElementCollection wsdlImporters = Metadata.WsdlImporters;
+                       for (int i = 0; i < _defaultWsdlImporters.Length; i++)
+                               wsdlImporters.Add (new WsdlImporterElement (_defaultWsdlImporters [i]));
+               }
+
+               protected override void PostDeserialize () {
+                       base.PostDeserialize ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClientViaElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ClientViaElement.cs
new file mode 100644 (file)
index 0000000..b9f9b93
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// ClientViaElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ClientViaElement
+                : BehaviorExtensionElement
+       {
+               // Properties
+
+               public override Type BehaviorType {
+                       get { return typeof (ClientViaBehavior); }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("viaUri",
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri ViaUri {
+                       get { return (Uri) base ["viaUri"]; }
+                       set { base ["viaUri"] = value; }
+               }
+
+               protected internal override object CreateBehavior () {
+                       return new ClientViaBehavior (ViaUri);
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComContractElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComContractElement.cs
new file mode 100644 (file)
index 0000000..516f5ce
--- /dev/null
@@ -0,0 +1,185 @@
+//
+// ComContractElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class ComContractElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty contract;
+               static ConfigurationProperty exposed_methods;
+               static ConfigurationProperty name;
+               static ConfigurationProperty ns;
+               static ConfigurationProperty persistable_types;
+               static ConfigurationProperty requires_session;
+               static ConfigurationProperty user_defined_types;
+
+               static ComContractElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       contract = new ConfigurationProperty ("contract",
+                               typeof (string), null, new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       exposed_methods = new ConfigurationProperty ("exposedMethods",
+                               typeof (ComMethodElementCollection), null, null/* FIXME: get converter for ComMethodElementCollection*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       name = new ConfigurationProperty ("name",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       ns = new ConfigurationProperty ("namespace",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       persistable_types = new ConfigurationProperty ("persistableTypes",
+                               typeof (ComPersistableTypeElementCollection), null, null/* FIXME: get converter for ComPersistableTypeElementCollection*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       requires_session = new ConfigurationProperty ("requiresSession",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       user_defined_types = new ConfigurationProperty ("userDefinedTypes",
+                               typeof (ComUdtElementCollection), null, null/* FIXME: get converter for ComUdtElementCollection*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (contract);
+                       properties.Add (exposed_methods);
+                       properties.Add (name);
+                       properties.Add (ns);
+                       properties.Add (persistable_types);
+                       properties.Add (requires_session);
+                       properties.Add (user_defined_types);
+               }
+
+               public ComContractElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("contract",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Contract {
+                       get { return (string) base [contract]; }
+                       set { base [contract] = value; }
+               }
+
+               [ConfigurationProperty ("exposedMethods",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ComMethodElementCollection ExposedMethods {
+                       get { return (ComMethodElementCollection) base [exposed_methods]; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("name",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               public string Name {
+                       get { return (string) base [name]; }
+                       set { base [name] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("namespace",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               public string Namespace {
+                       get { return (string) base [ns]; }
+                       set { base [ns] = value; }
+               }
+
+               [ConfigurationProperty ("persistableTypes",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ComPersistableTypeElementCollection PersistableTypes {
+                       get { return (ComPersistableTypeElementCollection) base [persistable_types]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("requiresSession",
+                       DefaultValue = true,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool RequiresSession {
+                       get { return (bool) base [requires_session]; }
+                       set { base [requires_session] = value; }
+               }
+
+               [ConfigurationProperty ("userDefinedTypes",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ComUdtElementCollection UserDefinedTypes {
+                       get { return (ComUdtElementCollection) base [user_defined_types]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComContractElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComContractElementCollection.cs
new file mode 100644 (file)
index 0000000..18e4304
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// ComContractElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (ComContractElement),
+                AddItemName = "comContract",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       [MonoTODO]
+       public sealed partial class ComContractElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ComContractElement>,  ICollection,  IEnumerable
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static ComContractElementCollection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public ComContractElementCollection ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComContractsSection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComContractsSection.cs
new file mode 100644 (file)
index 0000000..2fc4a92
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// ComContractsSection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class ComContractsSection
+                : ConfigurationSection
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty com_contracts;
+
+               static ComContractsSection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       com_contracts = new ConfigurationProperty ("",
+                               typeof (ComContractElementCollection), null, null/* FIXME: get converter for ComContractElementCollection*/, null,
+                               ConfigurationPropertyOptions.IsDefaultCollection);
+
+                       properties.Add (com_contracts);
+               }
+
+               public ComContractsSection ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("",
+                        Options = ConfigurationPropertyOptions.IsDefaultCollection,
+                       IsDefaultCollection = true)]
+               public ComContractElementCollection ComContracts {
+                       get { return (ComContractElementCollection) base [com_contracts]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComMethodElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComMethodElement.cs
new file mode 100644 (file)
index 0000000..f28ca04
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// ComMethodElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class ComMethodElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty exposed_method;
+
+               static ComMethodElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       exposed_method = new ConfigurationProperty ("exposedMethod",
+                               typeof (string), null, new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       properties.Add (exposed_method);
+               }
+
+               public ComMethodElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("exposedMethod",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string ExposedMethod {
+                       get { return (string) base [exposed_method]; }
+                       set { base [exposed_method] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComMethodElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComMethodElementCollection.cs
new file mode 100644 (file)
index 0000000..fb3a1e9
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// ComMethodElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (ComMethodElement),
+                AddItemName = "add",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       [MonoTODO]
+       public sealed partial class ComMethodElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ComMethodElement>,  ICollection,  IEnumerable
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static ComMethodElementCollection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public ComMethodElementCollection ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComPersistableTypeElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComPersistableTypeElement.cs
new file mode 100644 (file)
index 0000000..975dfbb
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// ComPersistableTypeElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class ComPersistableTypeElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty i_d;
+               static ConfigurationProperty name;
+
+               static ComPersistableTypeElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       i_d = new ConfigurationProperty ("ID",
+                               typeof (string), null, new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       name = new ConfigurationProperty ("name",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (i_d);
+                       properties.Add (name);
+               }
+
+               public ComPersistableTypeElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("ID",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string ID {
+                       get { return (string) base [i_d]; }
+                       set { base [i_d] = value; }
+               }
+
+               [ConfigurationProperty ("name",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Name {
+                       get { return (string) base [name]; }
+                       set { base [name] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComPersistableTypeElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComPersistableTypeElementCollection.cs
new file mode 100644 (file)
index 0000000..852ebac
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// ComPersistableTypeElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (ComPersistableTypeElement),
+                AddItemName = "type",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       [MonoTODO]
+       public sealed partial class ComPersistableTypeElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ComPersistableTypeElement>,  ICollection,  IEnumerable
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static ComPersistableTypeElementCollection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public ComPersistableTypeElementCollection ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComUdtElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComUdtElement.cs
new file mode 100644 (file)
index 0000000..c608f1f
--- /dev/null
@@ -0,0 +1,152 @@
+//
+// ComUdtElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class ComUdtElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty name;
+               static ConfigurationProperty type_def_i_d;
+               static ConfigurationProperty type_lib_i_d;
+               static ConfigurationProperty type_lib_version;
+
+               static ComUdtElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       name = new ConfigurationProperty ("name",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       type_def_i_d = new ConfigurationProperty ("typeDefID",
+                               typeof (string), null, new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       type_lib_i_d = new ConfigurationProperty ("typeLibID",
+                               typeof (string), null, new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired);
+
+                       type_lib_version = new ConfigurationProperty ("typeLibVersion",
+                               typeof (string), null, new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired);
+
+                       properties.Add (name);
+                       properties.Add (type_def_i_d);
+                       properties.Add (type_lib_i_d);
+                       properties.Add (type_lib_version);
+               }
+
+               public ComUdtElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("name",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Name {
+                       get { return (string) base [name]; }
+                       set { base [name] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("typeDefID",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               public string TypeDefID {
+                       get { return (string) base [type_def_i_d]; }
+                       set { base [type_def_i_d] = value; }
+               }
+
+               [ConfigurationProperty ("typeLibID",
+                        Options = ConfigurationPropertyOptions.IsRequired,
+                       IsRequired = true)]
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string TypeLibID {
+                       get { return (string) base [type_lib_i_d]; }
+                       set { base [type_lib_i_d] = value; }
+               }
+
+               [ConfigurationProperty ("typeLibVersion",
+                        Options = ConfigurationPropertyOptions.IsRequired,
+                       IsRequired = true)]
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string TypeLibVersion {
+                       get { return (string) base [type_lib_version]; }
+                       set { base [type_lib_version] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComUdtElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ComUdtElementCollection.cs
new file mode 100644 (file)
index 0000000..606f654
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// ComUdtElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (ComUdtElement),
+                AddItemName = "userDefinedType",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       [MonoTODO]
+       public sealed partial class ComUdtElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ComUdtElement>,  ICollection,  IEnumerable
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static ComUdtElementCollection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public ComUdtElementCollection ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CommonBehaviorsSection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CommonBehaviorsSection.cs
new file mode 100644 (file)
index 0000000..134e319
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// CommonBehaviorsSection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class CommonBehaviorsSection
+                : ConfigurationSection
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty endpoint_behaviors;
+               static ConfigurationProperty service_behaviors;
+
+               static CommonBehaviorsSection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       endpoint_behaviors = new ConfigurationProperty ("endpointBehaviors",
+                               typeof (CommonEndpointBehaviorElement), null, null/* FIXME: get converter for CommonEndpointBehaviorElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       service_behaviors = new ConfigurationProperty ("serviceBehaviors",
+                               typeof (CommonServiceBehaviorElement), null, null/* FIXME: get converter for CommonServiceBehaviorElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (endpoint_behaviors);
+                       properties.Add (service_behaviors);
+               }
+
+               public CommonBehaviorsSection ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("endpointBehaviors",
+                        Options = ConfigurationPropertyOptions.None)]
+               public CommonEndpointBehaviorElement EndpointBehaviors {
+                       get { return (CommonEndpointBehaviorElement) base [endpoint_behaviors]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("serviceBehaviors",
+                        Options = ConfigurationPropertyOptions.None)]
+               public CommonServiceBehaviorElement ServiceBehaviors {
+                       get { return (CommonServiceBehaviorElement) base [service_behaviors]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CommonEndpointBehaviorElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CommonEndpointBehaviorElement.cs
new file mode 100644 (file)
index 0000000..68648db
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// CommonEndpointBehaviorElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class CommonEndpointBehaviorElement
+                : ServiceModelExtensionCollectionElement<BehaviorExtensionElement>,  ICollection<BehaviorExtensionElement>,  IEnumerable<BehaviorExtensionElement>,  IEnumerable
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static CommonEndpointBehaviorElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public CommonEndpointBehaviorElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CommonServiceBehaviorElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CommonServiceBehaviorElement.cs
new file mode 100644 (file)
index 0000000..f3876c4
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// CommonServiceBehaviorElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class CommonServiceBehaviorElement
+                : ServiceModelExtensionCollectionElement<BehaviorExtensionElement>,  ICollection<BehaviorExtensionElement>,  IEnumerable<BehaviorExtensionElement>,  IEnumerable
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static CommonServiceBehaviorElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public CommonServiceBehaviorElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CompositeDuplexElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CompositeDuplexElement.cs
new file mode 100644 (file)
index 0000000..29c405c
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// CompositeDuplexElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class CompositeDuplexElement
+                : BindingElementExtensionElement
+       {
+               public CompositeDuplexElement () {
+               }
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (CompositeDuplexBindingElement); }
+               }
+
+               [ConfigurationProperty ("clientBaseAddress",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = null)]
+               public Uri ClientBaseAddress {
+                       get { return (Uri) base ["clientBaseAddress"]; }
+                       set { base ["clientBaseAddress"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ConfigUtil.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ConfigUtil.cs
new file mode 100644 (file)
index 0000000..58b9895
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// ConfigUtil.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Configuration;
+using System.Collections.Generic;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Configuration
+{
+       internal static class ConfigUtil
+       {
+               public static BindingsSection BindingsSection {
+                       get { return (BindingsSection) ConfigurationManager.GetSection ("system.serviceModel/bindings"); }
+               }
+
+               public static ServicesSection ServicesSection {
+                       get { return (ServicesSection) ConfigurationManager.GetSection ("system.serviceModel/services"); }
+               }
+
+               public static BehaviorsSection BehaviorsSection {
+                       get { return (BehaviorsSection) ConfigurationManager.GetSection ("system.serviceModel/behaviors"); }
+               }
+
+               public static ExtensionsSection ExtensionsSection {
+                       get { return (ExtensionsSection) ConfigurationManager.GetSection ("system.serviceModel/extensions"); }
+               }
+
+               public static Binding CreateBinding (string binding, string bindingConfiguration)
+               {
+                       BindingCollectionElement section = ConfigUtil.BindingsSection [binding];
+                       if (section == null)
+                               throw new ArgumentException (String.Format ("binding section for {0} was not found.", binding));
+
+                       Binding b = (Binding) Activator.CreateInstance (section.BindingType, new object [0]);
+
+                       foreach (IBindingConfigurationElement el in section.ConfiguredBindings)
+                               if (el.Name == bindingConfiguration)
+                                       el.ApplyConfiguration (b);
+
+                       return b;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ConnectionOrientedTransportElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ConnectionOrientedTransportElement.cs
new file mode 100644 (file)
index 0000000..59c9bb2
--- /dev/null
@@ -0,0 +1,163 @@
+//
+// ConnectionOrientedTransportElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public abstract class ConnectionOrientedTransportElement
+                : TransportElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               protected ConnectionOrientedTransportElement () {
+               }
+
+               // Properties
+
+               [ConfigurationProperty ("channelInitializationTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:00:05")]
+               public TimeSpan ChannelInitializationTimeout {
+                       get { return (TimeSpan) base ["channelInitializationTimeout"]; }
+                       set { base ["channelInitializationTimeout"] = value; }
+               }
+
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("connectionBufferSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "8192")]
+               public int ConnectionBufferSize {
+                       get { return (int) base ["connectionBufferSize"]; }
+                       set { base ["connectionBufferSize"] = value; }
+               }
+
+               [ConfigurationProperty ("hostNameComparisonMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "StrongWildcard")]
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return (HostNameComparisonMode) base ["hostNameComparisonMode"]; }
+                       set { base ["hostNameComparisonMode"] = value; }
+               }
+
+               [ConfigurationProperty ("maxBufferSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxBufferSize {
+                       get { return (int) base ["maxBufferSize"]; }
+                       set { base ["maxBufferSize"] = value; }
+               }
+
+               [ConfigurationProperty ("maxOutputDelay",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:00:00.2")]
+               public TimeSpan MaxOutputDelay {
+                       get { return (TimeSpan) base ["maxOutputDelay"]; }
+                       set { base ["maxOutputDelay"] = value; }
+               }
+
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxPendingAccepts",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "1")]
+               public int MaxPendingAccepts {
+                       get { return (int) base ["maxPendingAccepts"]; }
+                       set { base ["maxPendingAccepts"] = value; }
+               }
+
+               [ConfigurationProperty ("maxPendingConnections",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10")]
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxPendingConnections {
+                       get { return (int) base ["maxPendingConnections"]; }
+                       set { base ["maxPendingConnections"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("channelInitializationTimeout", typeof (TimeSpan), "00:00:05", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("connectionBufferSize", typeof (int), "8192", null, new IntegerValidator (1, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("hostNameComparisonMode", typeof (HostNameComparisonMode), "StrongWildcard", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferSize", typeof (int), "65536", null, new IntegerValidator (1, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxOutputDelay", typeof (TimeSpan), "00:00:00.2", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxPendingAccepts", typeof (int), "1", null, new IntegerValidator (1, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxPendingConnections", typeof (int), "10", null, new IntegerValidator (1, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("transferMode", typeof (TransferMode), "Buffered", null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("transferMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Buffered")]
+               public TransferMode TransferMode {
+                       get { return (TransferMode) base ["transferMode"]; }
+                       set { base ["transferMode"] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CustomBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CustomBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..6316d2f
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// CustomBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class CustomBindingCollectionElement
+                : BindingCollectionElement
+       {
+
+               // Properties
+
+               [ConfigurationProperty ("",
+                        Options = ConfigurationPropertyOptions.IsDefaultCollection,
+                       IsDefaultCollection = true)]
+               public CustomBindingElementCollection Bindings {
+                       get { return (CustomBindingElementCollection) this [String.Empty]; }
+               }
+
+               public override ReadOnlyCollection<IBindingConfigurationElement> ConfiguredBindings {
+                       get {
+                               List<IBindingConfigurationElement> list = new List<IBindingConfigurationElement> ();
+                               CustomBindingElementCollection bindings = Bindings;
+                               for (int i = 0; i < bindings.Count; i++)
+                                       list.Add (bindings [i]);
+                               return new ReadOnlyCollection<IBindingConfigurationElement> (list);
+                       }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               public override Type BindingType {
+                       get { return typeof (CustomBinding); }
+               }
+
+
+               public override bool ContainsKey (string name) {
+                       throw new NotImplementedException ();
+               }
+
+               protected internal override Binding GetDefault () {
+                       throw new NotImplementedException ();
+               }
+
+               protected internal override bool TryAdd (string name, Binding binding, System.Configuration.Configuration config) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CustomBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CustomBindingElement.cs
new file mode 100644 (file)
index 0000000..afa1dd0
--- /dev/null
@@ -0,0 +1,138 @@
+//
+// CustomBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+using System.Diagnostics;
+
+namespace System.ServiceModel.Configuration
+{
+       public class CustomBindingElement
+                : NamedServiceModelExtensionCollectionElement<BindingElementExtensionElement>, ICollection<BindingElementExtensionElement>, IEnumerable<BindingElementExtensionElement>, IEnumerable, IBindingConfigurationElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public CustomBindingElement () {
+               }
+
+               public CustomBindingElement (string name) {
+                       Name = name;
+               }
+
+               // Properties
+
+               [ConfigurationProperty ("closeTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:01:00")]
+               public TimeSpan CloseTimeout {
+                       get { return (TimeSpan) base ["closeTimeout"]; }
+                       set { base ["closeTimeout"] = value; }
+               }
+
+               [ConfigurationProperty ("openTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:01:00")]
+               public TimeSpan OpenTimeout {
+                       get { return (TimeSpan) base ["openTimeout"]; }
+                       set { base ["openTimeout"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("closeTimeout", typeof (TimeSpan), "00:01:00", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("openTimeout", typeof (TimeSpan), "00:01:00", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("receiveTimeout", typeof (TimeSpan), "00:10:00", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("sendTimeout", typeof (TimeSpan), "00:01:00", null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("receiveTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:10:00")]
+               public TimeSpan ReceiveTimeout {
+                       get { return (TimeSpan) base ["receiveTimeout"]; }
+                       set { base ["receiveTimeout"] = value; }
+               }
+
+               [ConfigurationProperty ("sendTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:01:00")]
+               public TimeSpan SendTimeout {
+                       get { return (TimeSpan) base ["sendTimeout"]; }
+                       set { base ["sendTimeout"] = value; }
+               }
+
+               [MonoTODO]
+               public void ApplyConfiguration (Binding binding) {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO ("implement using EvaluationContext")]
+               internal override BindingElementExtensionElement DeserializeExtensionElement (string elementName, XmlReader reader) {
+                       //ExtensionElementCollection extensions = ((ExtensionsSection) EvaluationContext.GetSection ("system.serviceModel/extensions")).BindingElementExtensions;
+                       ExtensionElementCollection extensions = ConfigUtil.ExtensionsSection.BindingElementExtensions;
+
+                       ExtensionElement extension = extensions [elementName];
+                       if (extension == null)
+                               throw new ConfigurationErrorsException ("Invalid element in configuration. The extension name '" + reader.LocalName + "' is not registered in the collection at system.serviceModel/extensions/bindingElementExtensions");
+
+                       BindingElementExtensionElement element = (BindingElementExtensionElement) Activator.CreateInstance (Type.GetType (extension.Type));
+                       element.DeserializeElementInternal (reader, false);
+                       return element;
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CustomBindingElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/CustomBindingElementCollection.cs
new file mode 100644 (file)
index 0000000..7760d8b
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// CustomBindingElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (CustomBindingElement),
+                AddItemName = "binding",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       [MonoTODO]
+       public sealed partial class CustomBindingElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<CustomBindingElement>,  ICollection,  IEnumerable
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static CustomBindingElementCollection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public CustomBindingElementCollection ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/DataContractSerializerElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/DataContractSerializerElement.cs
new file mode 100644 (file)
index 0000000..623a087
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// DataContractSerializerElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class DataContractSerializerElement
+                : BehaviorExtensionElement
+       {
+               // Properties
+
+               public override Type BehaviorType {
+                       get { return typeof (DataContractSerializerServiceBehavior); }
+               }
+
+               [ConfigurationProperty ("ignoreExtensionDataObject",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool IgnoreExtensionDataObject {
+                       get { return (bool) base ["ignoreExtensionDataObject"]; }
+                       set { base ["ignoreExtensionDataObject"] = value; }
+               }
+
+               [ConfigurationProperty ("maxItemsInObjectGraph",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               [IntegerValidator (MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxItemsInObjectGraph {
+                       get { return (int) base ["maxItemsInObjectGraph"]; }
+                       set { base ["maxItemsInObjectGraph"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               protected internal override object CreateBehavior () {
+                       return new DataContractSerializerServiceBehavior (IgnoreExtensionDataObject, MaxItemsInObjectGraph);
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/DiagnosticSection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/DiagnosticSection.cs
new file mode 100644 (file)
index 0000000..3117eaf
--- /dev/null
@@ -0,0 +1,123 @@
+//
+// DiagnosticSection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class DiagnosticSection
+                : ConfigurationSection
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty message_logging;
+               static ConfigurationProperty performance_counters;
+               static ConfigurationProperty wmi_provider_enabled;
+
+               static DiagnosticSection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       message_logging = new ConfigurationProperty ("messageLogging",
+                               typeof (MessageLoggingElement), null, null/* FIXME: get converter for MessageLoggingElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       performance_counters = new ConfigurationProperty ("performanceCounters",
+                               typeof (PerformanceCounterScope), "Off", null/* FIXME: get converter for PerformanceCounterScope*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       wmi_provider_enabled = new ConfigurationProperty ("wmiProviderEnabled",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (message_logging);
+                       properties.Add (performance_counters);
+                       properties.Add (wmi_provider_enabled);
+               }
+
+               public DiagnosticSection ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("messageLogging",
+                        Options = ConfigurationPropertyOptions.None)]
+               public MessageLoggingElement MessageLogging {
+                       get { return (MessageLoggingElement) base [message_logging]; }
+               }
+
+               [ConfigurationProperty ("performanceCounters",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Off")]
+               public PerformanceCounterScope PerformanceCounters {
+                       get { return (PerformanceCounterScope) base [performance_counters]; }
+                       set { base [performance_counters] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("wmiProviderEnabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool WmiProviderEnabled {
+                       get { return (bool) base [wmi_provider_enabled]; }
+                       set { base [wmi_provider_enabled] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/DnsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/DnsElement.cs
new file mode 100644 (file)
index 0000000..43e7b3d
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// DnsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class DnsElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty value;
+
+               static DnsElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       value = new ConfigurationProperty ("value",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (value);
+               }
+
+               public DnsElement ()
+               {
+               }
+
+
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("value",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Value {
+                       get { return (string) base [value]; }
+                       set { base [value] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EncodingConverter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EncodingConverter.cs
new file mode 100644 (file)
index 0000000..aceb93d
--- /dev/null
@@ -0,0 +1,85 @@
+//\r
+// EncodingConverter.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ComponentModel;\r
+using System.Globalization;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       sealed class EncodingConverter : TypeConverter\r
+       {\r
+               static EncodingConverter _instance = new EncodingConverter ();\r
+\r
+               public static EncodingConverter Instance {\r
+                       get { return _instance; }\r
+               }\r
+\r
+               public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType) {\r
+                       return sourceType == typeof (string);\r
+               }\r
+\r
+               public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value) {\r
+                       string encString = (string) value;\r
+                       Encoding encoding;\r
+\r
+                       switch (encString.ToLower (CultureInfo.InvariantCulture)) {\r
+                       case "utf-16le":\r
+                       case "utf-16":\r
+                       case "ucs-2":\r
+                       case "unicode":\r
+                       case "iso-10646-ucs-2":\r
+                               encoding = new UnicodeEncoding (false, true);\r
+                               break;\r
+                       case "utf-16be":\r
+                       case "unicodefffe":\r
+                               encoding = new UnicodeEncoding (true, true);\r
+                               break;\r
+                       case "utf-8":\r
+                       case "unicode-1-1-utf-8":\r
+                       case "unicode-2-0-utf-8":\r
+                       case "x-unicode-1-1-utf-8":\r
+                       case "x-unicode-2-0-utf-8":\r
+                               encoding = Encoding.UTF8;\r
+                               break;\r
+                       default:\r
+                               encoding = Encoding.GetEncoding (encString);\r
+                               break;\r
+                       }\r
+\r
+                       return encoding;\r
+               }\r
+\r
+               public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {\r
+                       Encoding encoding = (Encoding) value;\r
+                       return encoding.WebName;\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EndpointAddressElementBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EndpointAddressElementBase.cs
new file mode 100644 (file)
index 0000000..7076dff
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// EndpointAddressElementBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class EndpointAddressElementBase
+                : ConfigurationElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public EndpointAddressElementBase () {
+               }
+
+               // Properties
+
+               [ConfigurationProperty ("address",
+                        Options = ConfigurationPropertyOptions.IsRequired,
+                        DefaultValue = null,
+                       IsRequired = true)]
+               public Uri Address {
+                       get { return (Uri) base ["address"]; }
+                       set { base ["address"] = value; }
+               }
+
+               [ConfigurationProperty ("headers",
+                        Options = ConfigurationPropertyOptions.None)]
+               public AddressHeaderCollectionElement Headers {
+                       get { return (AddressHeaderCollectionElement) base ["headers"]; }
+               }
+
+               [ConfigurationProperty ("identity",
+                        Options = ConfigurationPropertyOptions.None)]
+               public IdentityElement Identity {
+                       get { return (IdentityElement) base ["identity"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty ("address", typeof (Uri), null, new UriTypeConverter (), null, ConfigurationPropertyOptions.IsRequired));
+                                       _properties.Add (new ConfigurationProperty ("headers", typeof (AddressHeaderCollectionElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("identity", typeof (IdentityElement), null, null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EndpointBehaviorElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EndpointBehaviorElement.cs
new file mode 100644 (file)
index 0000000..495f0a8
--- /dev/null
@@ -0,0 +1,90 @@
+//
+// EndpointBehaviorElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class EndpointBehaviorElement
+                : NamedServiceModelExtensionCollectionElement<BehaviorExtensionElement>, ICollection<BehaviorExtensionElement>, IEnumerable<BehaviorExtensionElement>, IEnumerable
+       {
+               public EndpointBehaviorElement (string name) {
+                       Name = name;
+               }
+
+               public EndpointBehaviorElement () {
+               }
+
+               [MonoTODO ("implement using EvaluationContext")]
+               internal override BehaviorExtensionElement DeserializeExtensionElement (string elementName, XmlReader reader) {
+                       //ExtensionElementCollection extensions = ((ExtensionsSection) EvaluationContext.GetSection ("system.serviceModel/extensions")).BehaviorExtensions;
+                       ExtensionElementCollection extensions = ConfigUtil.ExtensionsSection.BehaviorExtensions;
+
+                       ExtensionElement extension = extensions [elementName];
+                       if (extension == null)
+                               throw new ConfigurationErrorsException ("Invalid element in configuration. The extension name '" + reader.LocalName + "' is not registered in the collection at system.serviceModel/extensions/behaviorExtensions");
+
+                       BehaviorExtensionElement element = (BehaviorExtensionElement) Activator.CreateInstance (Type.GetType (extension.Type));
+                       element.DeserializeElementInternal (reader, false);
+                       return element;
+               }
+
+               public override void Add (BehaviorExtensionElement element) {
+                       base.Add (element);
+               }
+
+               public override bool CanAdd (BehaviorExtensionElement element) {
+                       return base.CanAdd (element);
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EndpointBehaviorElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/EndpointBehaviorElementCollection.cs
new file mode 100644 (file)
index 0000000..1c3380e
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// EndpointBehaviorElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (EndpointBehaviorElement),
+                AddItemName = "behavior",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       public sealed class EndpointBehaviorElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<EndpointBehaviorElement>,  ICollection,  IEnumerable
+       {
+               public EndpointBehaviorElementCollection ()
+               {
+                       AddElementName = "behavior";
+               }
+
+               protected override object GetElementKey (ConfigurationElement element) {
+                       return ((EndpointBehaviorElement) element).Name;
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ExtensionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ExtensionElement.cs
new file mode 100644 (file)
index 0000000..18e4141
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// ExtensionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class ExtensionElement
+                : ConfigurationElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public ExtensionElement () {
+               }
+
+               public ExtensionElement (string name)
+                       : this () {
+                       if (String.IsNullOrEmpty (name))
+                               throw new ArgumentNullException ("name");
+                       Name = name;
+               }
+
+               public ExtensionElement (string name, string type)
+                       : this (name) {
+                       if (String.IsNullOrEmpty (type))
+                               throw new ArgumentNullException ("type");
+                       Type = type;
+               }
+
+               // Properties
+
+               [StringValidator (MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("name",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               public string Name {
+                       get { return (string) base ["name"]; }
+                       set { base ["name"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty ("name", typeof (string), null, new StringConverter (), new StringValidator (1, int.MaxValue, null), ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey));
+                                       _properties.Add (new ConfigurationProperty ("type", typeof (string), null, new StringConverter (), new StringValidator (1, int.MaxValue, null), ConfigurationPropertyOptions.IsRequired));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [StringValidator (MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("type",
+                        Options = ConfigurationPropertyOptions.IsRequired,
+                       IsRequired = true)]
+               public string Type {
+                       get { return (string) base ["type"]; }
+                       set { base ["type"] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ExtensionElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ExtensionElementCollection.cs
new file mode 100644 (file)
index 0000000..62d782c
--- /dev/null
@@ -0,0 +1,112 @@
+//
+// ExtensionElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (ExtensionElement),
+                AddItemName = "add",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.BasicMap)]
+       public class ExtensionElementCollection
+                : ServiceModelConfigurationElementCollection<ExtensionElement>, ICollection, IEnumerable
+       {
+               Dictionary<Type, ExtensionElement> _lookup;
+
+               Dictionary<Type, ExtensionElement> Lookup {
+                       get {
+                               if (_lookup == null) {
+                                       _lookup = new Dictionary<Type, ExtensionElement> ();
+                                       for (int i = 0; i < Count; i++) {
+                                               ExtensionElement extension = this [i];
+                                               Type type = Type.GetType (extension.Type);
+                                               _lookup.Add (type, extension);
+                                       }
+                               }
+                               return _lookup;
+                       }
+               }
+
+               protected override bool ThrowOnDuplicate {
+                       get {
+                               return base.ThrowOnDuplicate;
+                       }
+               }
+
+               protected override object GetElementKey (ConfigurationElement element) {
+                       return ((ExtensionElement) element).Name;
+               }
+
+               protected override void BaseAdd (ConfigurationElement element) {
+                       base.BaseAdd (element);
+               }
+
+               protected override void BaseAdd (int index, ConfigurationElement element) {
+                       base.BaseAdd (index, element);
+               }
+
+               private void AddLookup (ConfigurationElement element) {
+                       ExtensionElement extension = (ExtensionElement) element;
+                       Type type = Type.GetType (extension.Type);
+                       _lookup.Add (type, extension);
+               }
+
+               internal string GetConfigurationElementName (Type type) {
+                       if (Lookup.ContainsKey (type))
+                               return Lookup [type].Name;
+                       return null;
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ExtensionsSection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ExtensionsSection.cs
new file mode 100644 (file)
index 0000000..4e888ef
--- /dev/null
@@ -0,0 +1,162 @@
+//
+// ExtensionsSection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class ExtensionsSection
+                : ConfigurationSection
+       {
+               ConfigurationPropertyCollection _properties;
+
+               // Properties
+
+               [ConfigurationProperty ("behaviorExtensions",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ExtensionElementCollection BehaviorExtensions {
+                       get { return (ExtensionElementCollection) base ["behaviorExtensions"]; }
+               }
+
+               [ConfigurationProperty ("bindingElementExtensions",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ExtensionElementCollection BindingElementExtensions {
+                       get { return (ExtensionElementCollection) base ["bindingElementExtensions"]; }
+               }
+
+               [ConfigurationProperty ("bindingExtensions",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ExtensionElementCollection BindingExtensions {
+                       get { return (ExtensionElementCollection) base ["bindingExtensions"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty ("behaviorExtensions", typeof (ExtensionElementCollection), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("bindingElementExtensions", typeof (ExtensionElementCollection), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("bindingExtensions", typeof (ExtensionElementCollection), null, null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               protected override void InitializeDefault () {
+                       InitializeBehaviorExtensionsDefault ();
+                       InitializeBindingElementExtensionsDefault ();
+                       InitializeBindingExtensionsDefault ();
+               }
+
+               void InitializeBindingExtensionsDefault () {
+                       BindingExtensions.Add (new ExtensionElement ("basicHttpBinding", typeof (BasicHttpBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("customBinding", typeof (CustomBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("mexHttpBinding", typeof (MexHttpBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("mexHttpsBinding", typeof (MexHttpsBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("mexNamedPipeBinding", typeof (MexNamedPipeBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("mexTcpBinding", typeof (MexTcpBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("msmqIntegrationBinding", typeof (MsmqIntegrationBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("netMsmqBinding", typeof (NetMsmqBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("netNamedPipeBinding", typeof (NetNamedPipeBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("netPeerTcpBinding", typeof (NetPeerTcpBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("netTcpBinding", typeof (NetTcpBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("ws2007FederationHttpBinding", typeof (WS2007FederationHttpBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("ws2007HttpBinding", typeof (WS2007HttpBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("wsDualHttpBinding", typeof (WSDualHttpBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("wsFederationHttpBinding", typeof (WSFederationHttpBindingCollectionElement).AssemblyQualifiedName));
+                       BindingExtensions.Add (new ExtensionElement ("wsHttpBinding", typeof (WSHttpBindingCollectionElement).AssemblyQualifiedName));
+               }
+
+               void InitializeBindingElementExtensionsDefault () {
+                       BindingElementExtensions.Add (new ExtensionElement ("binaryMessageEncoding", typeof (BinaryMessageEncodingElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("compositeDuplex", typeof (CompositeDuplexElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("httpTransport", typeof (HttpTransportElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("httpsTransport", typeof (HttpsTransportElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("msmqIntegration", typeof (MsmqIntegrationElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("msmqTransport", typeof (MsmqTransportElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("mtomMessageEncoding", typeof (MtomMessageEncodingElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("namedPipeTransport", typeof (NamedPipeTransportElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("oneWay", typeof (OneWayElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("peerTransport", typeof (PeerTransportElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("pnrpPeerResolver", typeof (PnrpPeerResolverElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("privacyNoticeAt", typeof (PrivacyNoticeElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("reliableSession", typeof (ReliableSessionElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("security", typeof (SecurityElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("sslStreamSecurity", typeof (SslStreamSecurityElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("tcpTransport", typeof (TcpTransportElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("textMessageEncoding", typeof (TextMessageEncodingElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("transactionFlow", typeof (TransactionFlowElement).AssemblyQualifiedName));
+                       //BindingElementExtensions.Add (new ExtensionElement ("unrecognizedPolicyAssertion", typeof (UnrecognizedPolicyAssertionElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("useManagedPresentation", typeof (UseManagedPresentationElement).AssemblyQualifiedName));
+                       BindingElementExtensions.Add (new ExtensionElement ("windowsStreamSecurity", typeof (WindowsStreamSecurityElement).AssemblyQualifiedName));
+               }
+
+               void InitializeBehaviorExtensionsDefault () {
+                       BehaviorExtensions.Add (new ExtensionElement ("callbackDebug", typeof (CallbackDebugElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("callbackTimeouts", typeof (CallbackTimeoutsElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("clientCredentials", typeof (ClientCredentialsElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("clientVia", typeof (ClientViaElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("dataContractSerializer", typeof (DataContractSerializerElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("serviceAuthorization", typeof (ServiceAuthorizationElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("serviceCredentials", typeof (ServiceCredentialsElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("serviceDebug", typeof (ServiceDebugElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("serviceMetadata", typeof (ServiceMetadataPublishingElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("serviceSecurityAudit", typeof (ServiceSecurityAuditElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("serviceThrottling", typeof (ServiceThrottlingElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("serviceTimeouts", typeof (ServiceTimeoutsElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("synchronousReceive", typeof (SynchronousReceiveElement).AssemblyQualifiedName));
+                       BehaviorExtensions.Add (new ExtensionElement ("transactedBatching", typeof (TransactedBatchingElement).AssemblyQualifiedName));
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/FederatedMessageSecurityOverHttpElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/FederatedMessageSecurityOverHttpElement.cs
new file mode 100644 (file)
index 0000000..0a6adcc
--- /dev/null
@@ -0,0 +1,191 @@
+//
+// FederatedMessageSecurityOverHttpElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class FederatedMessageSecurityOverHttpElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty algorithm_suite;
+               static ConfigurationProperty claim_type_requirements;
+               static ConfigurationProperty issued_key_type;
+               static ConfigurationProperty issued_token_type;
+               static ConfigurationProperty issuer;
+               static ConfigurationProperty issuer_metadata;
+               static ConfigurationProperty negotiate_service_credential;
+               static ConfigurationProperty token_request_parameters;
+
+               static FederatedMessageSecurityOverHttpElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       algorithm_suite = new ConfigurationProperty ("algorithmSuite",
+                               typeof (SecurityAlgorithmSuite), "Default", null/* FIXME: get converter for SecurityAlgorithmSuite*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       claim_type_requirements = new ConfigurationProperty ("claimTypeRequirements",
+                               typeof (ClaimTypeElementCollection), null, null/* FIXME: get converter for ClaimTypeElementCollection*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       issued_key_type = new ConfigurationProperty ("issuedKeyType",
+                               typeof (SecurityKeyType), "SymmetricKey", null/* FIXME: get converter for SecurityKeyType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       issued_token_type = new ConfigurationProperty ("issuedTokenType",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       issuer = new ConfigurationProperty ("issuer",
+                               typeof (IssuedTokenParametersEndpointAddressElement), null, null/* FIXME: get converter for IssuedTokenParametersEndpointAddressElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       issuer_metadata = new ConfigurationProperty ("issuerMetadata",
+                               typeof (EndpointAddressElementBase), null, null/* FIXME: get converter for EndpointAddressElementBase*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       negotiate_service_credential = new ConfigurationProperty ("negotiateServiceCredential",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       token_request_parameters = new ConfigurationProperty ("tokenRequestParameters",
+                               typeof (XmlElementElementCollection), null, null/* FIXME: get converter for XmlElementElementCollection*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (algorithm_suite);
+                       properties.Add (claim_type_requirements);
+                       properties.Add (issued_key_type);
+                       properties.Add (issued_token_type);
+                       properties.Add (issuer);
+                       properties.Add (issuer_metadata);
+                       properties.Add (negotiate_service_credential);
+                       properties.Add (token_request_parameters);
+               }
+
+               public FederatedMessageSecurityOverHttpElement ()
+               {
+               }
+
+
+               // Properties
+
+               [TypeConverter (typeof (SecurityAlgorithmSuiteConverter))]
+               [ConfigurationProperty ("algorithmSuite",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Default")]
+               public SecurityAlgorithmSuite AlgorithmSuite {
+                       get { return (SecurityAlgorithmSuite) base [algorithm_suite]; }
+                       set { base [algorithm_suite] = value; }
+               }
+
+               [ConfigurationProperty ("claimTypeRequirements",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ClaimTypeElementCollection ClaimTypeRequirements {
+                       get { return (ClaimTypeElementCollection) base [claim_type_requirements]; }
+               }
+
+               [ConfigurationProperty ("issuedKeyType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "SymmetricKey")]
+               public SecurityKeyType IssuedKeyType {
+                       get { return (SecurityKeyType) base [issued_key_type]; }
+                       set { base [issued_key_type] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("issuedTokenType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string IssuedTokenType {
+                       get { return (string) base [issued_token_type]; }
+                       set { base [issued_token_type] = value; }
+               }
+
+               [ConfigurationProperty ("issuer",
+                        Options = ConfigurationPropertyOptions.None)]
+               public IssuedTokenParametersEndpointAddressElement Issuer {
+                       get { return (IssuedTokenParametersEndpointAddressElement) base [issuer]; }
+               }
+
+               [ConfigurationProperty ("issuerMetadata",
+                        Options = ConfigurationPropertyOptions.None)]
+               public EndpointAddressElementBase IssuerMetadata {
+                       get { return (EndpointAddressElementBase) base [issuer_metadata]; }
+               }
+
+               [ConfigurationProperty ("negotiateServiceCredential",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool NegotiateServiceCredential {
+                       get { return (bool) base [negotiate_service_credential]; }
+                       set { base [negotiate_service_credential] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("tokenRequestParameters",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlElementElementCollection TokenRequestParameters {
+                       get { return (XmlElementElementCollection) base [token_request_parameters]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HostElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HostElement.cs
new file mode 100644 (file)
index 0000000..757b47b
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// HostElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class HostElement
+                : ConfigurationElement
+       {
+               // Properties
+
+               [ConfigurationProperty ("baseAddresses",
+                        Options = ConfigurationPropertyOptions.None)]
+               public BaseAddressElementCollection BaseAddresses {
+                       get { return (BaseAddressElementCollection) base ["baseAddresses"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("timeouts",
+                        Options = ConfigurationPropertyOptions.None)]
+               public HostTimeoutsElement Timeouts {
+                       get { return (HostTimeoutsElement) base ["timeouts"]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HostTimeoutsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HostTimeoutsElement.cs
new file mode 100644 (file)
index 0000000..9b1e34f
--- /dev/null
@@ -0,0 +1,85 @@
+//
+// HostTimeoutsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class HostTimeoutsElement
+                : ConfigurationElement
+       {
+               // Properties
+
+               [ConfigurationProperty ("closeTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:00:10")]
+               public TimeSpan CloseTimeout {
+                       get { return (TimeSpan) base ["closeTimeout"]; }
+                       set { base ["closeTimeout"] = value; }
+               }
+
+               [ConfigurationProperty ("openTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:01:00")]
+               public TimeSpan OpenTimeout {
+                       get { return (TimeSpan) base ["openTimeout"]; }
+                       set { base ["openTimeout"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpDigestClientElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpDigestClientElement.cs
new file mode 100644 (file)
index 0000000..5d6dce6
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// HttpDigestClientElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class HttpDigestClientElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty impersonation_level;
+
+               static HttpDigestClientElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       impersonation_level = new ConfigurationProperty ("impersonationLevel",
+                               typeof (TokenImpersonationLevel), "Identification", null/* FIXME: get converter for TokenImpersonationLevel*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (impersonation_level);
+               }
+
+               public HttpDigestClientElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("impersonationLevel",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Identification")]
+               public TokenImpersonationLevel ImpersonationLevel {
+                       get { return (TokenImpersonationLevel) base [impersonation_level]; }
+                       set { base [impersonation_level] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpTransportElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpTransportElement.cs
new file mode 100644 (file)
index 0000000..2412b52
--- /dev/null
@@ -0,0 +1,203 @@
+//
+// HttpTransportElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class HttpTransportElement
+                : TransportElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public HttpTransportElement () {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("allowCookies",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool AllowCookies {
+                       get { return (bool) base ["allowCookies"]; }
+                       set { base ["allowCookies"] = value; }
+               }
+
+               [ConfigurationProperty ("authenticationScheme",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Anonymous")]
+               public AuthenticationSchemes AuthenticationScheme {
+                       get { return (AuthenticationSchemes) base ["authenticationScheme"]; }
+                       set { base ["authenticationScheme"] = value; }
+               }
+
+               public override Type BindingElementType {
+                       get { return typeof (HttpTransportBindingElement); }
+               }
+
+               [ConfigurationProperty ("bypassProxyOnLocal",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool BypassProxyOnLocal {
+                       get { return (bool) base ["bypassProxyOnLocal"]; }
+                       set { base ["bypassProxyOnLocal"] = value; }
+               }
+
+               [ConfigurationProperty ("hostNameComparisonMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "StrongWildcard")]
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return (HostNameComparisonMode) base ["hostNameComparisonMode"]; }
+                       set { base ["hostNameComparisonMode"] = value; }
+               }
+
+               [ConfigurationProperty ("keepAliveEnabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool KeepAliveEnabled {
+                       get { return (bool) base ["keepAliveEnabled"]; }
+                       set { base ["keepAliveEnabled"] = value; }
+               }
+
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxBufferSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               public int MaxBufferSize {
+                       get { return (int) base ["maxBufferSize"]; }
+                       set { base ["maxBufferSize"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("allowCookies", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("authenticationScheme", typeof (AuthenticationSchemes), "Anonymous", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("bypassProxyOnLocal", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("hostNameComparisonMode", typeof (HostNameComparisonMode), "StrongWildcard", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("keepAliveEnabled", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferSize", typeof (int), "65536", null, new IntegerValidator (1, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("proxyAddress", typeof (Uri), null, new UriTypeConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("proxyAuthenticationScheme", typeof (AuthenticationSchemes), "Anonymous", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("realm", typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("transferMode", typeof (TransferMode), "Buffered", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("unsafeConnectionNtlmAuthentication", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("useDefaultWebProxy", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("proxyAddress",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = null)]
+               public Uri ProxyAddress {
+                       get { return (Uri) base ["proxyAddress"]; }
+                       set { base ["proxyAddress"] = value; }
+               }
+
+               [ConfigurationProperty ("proxyAuthenticationScheme",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Anonymous")]
+               public AuthenticationSchemes ProxyAuthenticationScheme {
+                       get { return (AuthenticationSchemes) base ["proxyAuthenticationScheme"]; }
+                       set { base ["proxyAuthenticationScheme"] = value; }
+               }
+
+               [ConfigurationProperty ("realm",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               [StringValidator (MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Realm {
+                       get { return (string) base ["realm"]; }
+                       set { base ["realm"] = value; }
+               }
+
+               [ConfigurationProperty ("transferMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Buffered")]
+               public TransferMode TransferMode {
+                       get { return (TransferMode) base ["transferMode"]; }
+                       set { base ["transferMode"] = value; }
+               }
+
+               [ConfigurationProperty ("unsafeConnectionNtlmAuthentication",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool UnsafeConnectionNtlmAuthentication {
+                       get { return (bool) base ["unsafeConnectionNtlmAuthentication"]; }
+                       set { base ["unsafeConnectionNtlmAuthentication"] = value; }
+               }
+
+               [ConfigurationProperty ("useDefaultWebProxy",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool UseDefaultWebProxy {
+                       get { return (bool) base ["useDefaultWebProxy"]; }
+                       set { base ["useDefaultWebProxy"] = value; }
+               }
+
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpTransportSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpTransportSecurityElement.cs
new file mode 100644 (file)
index 0000000..323bf17
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// HttpTransportSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class HttpTransportSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty client_credential_type;
+               static ConfigurationProperty proxy_credential_type;
+               static ConfigurationProperty realm;
+
+               static HttpTransportSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       client_credential_type = new ConfigurationProperty ("clientCredentialType",
+                               typeof (HttpClientCredentialType), "None", null/* FIXME: get converter for HttpClientCredentialType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       proxy_credential_type = new ConfigurationProperty ("proxyCredentialType",
+                               typeof (HttpProxyCredentialType), "None", null/* FIXME: get converter for HttpProxyCredentialType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       realm = new ConfigurationProperty ("realm",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (client_credential_type);
+                       properties.Add (proxy_credential_type);
+                       properties.Add (realm);
+               }
+
+               public HttpTransportSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("clientCredentialType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "None")]
+               public HttpClientCredentialType ClientCredentialType {
+                       get { return (HttpClientCredentialType) base [client_credential_type]; }
+                       set { base [client_credential_type] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("proxyCredentialType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "None")]
+               public HttpProxyCredentialType ProxyCredentialType {
+                       get { return (HttpProxyCredentialType) base [proxy_credential_type]; }
+                       set { base [proxy_credential_type] = value; }
+               }
+
+               [ConfigurationProperty ("realm",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Realm {
+                       get { return (string) base [realm]; }
+                       set { base [realm] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpsTransportElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpsTransportElement.cs
new file mode 100644 (file)
index 0000000..c844e56
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// HttpsTransportElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class HttpsTransportElement
+                : HttpTransportElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public HttpsTransportElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (HttpsTransportBindingElement); }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("requireClientCertificate", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("requireClientCertificate",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool RequireClientCertificate {
+                       get { return (bool) base ["requireClientCertificate"]; }
+                       set { base ["requireClientCertificate"] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IBindingConfigurationElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IBindingConfigurationElement.cs
new file mode 100644 (file)
index 0000000..eadbf8b
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// IBindingConfigurationElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Configuration
+{
+       public interface IBindingConfigurationElement
+       {
+               TimeSpan CloseTimeout { get; }
+
+               string Name { get; }
+
+               TimeSpan OpenTimeout { get; }
+
+               TimeSpan ReceiveTimeout { get; }
+
+               TimeSpan SendTimeout { get; }
+
+               void ApplyConfiguration (Binding binding);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IPAddressConverter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IPAddressConverter.cs
new file mode 100644 (file)
index 0000000..a2b174e
--- /dev/null
@@ -0,0 +1,20 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ComponentModel;\r
+using System.Net;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       class IPAddressConverter\r
+        : TypeConverter\r
+       {\r
+               public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType) {\r
+                       return sourceType == typeof (string);\r
+               }\r
+\r
+               public override object ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {\r
+                       return IPAddress.Parse ((string) value);\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IdentityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IdentityElement.cs
new file mode 100644 (file)
index 0000000..a36f895
--- /dev/null
@@ -0,0 +1,105 @@
+//
+// IdentityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class IdentityElement
+                : ConfigurationElement
+       {
+               // Properties
+
+               [ConfigurationProperty ("certificate",
+                        Options = ConfigurationPropertyOptions.None)]
+               public CertificateElement Certificate {
+                       get { return (CertificateElement) base ["certificate"]; }
+               }
+
+               [ConfigurationProperty ("certificateReference",
+                        Options = ConfigurationPropertyOptions.None)]
+               public CertificateReferenceElement CertificateReference {
+                       get { return (CertificateReferenceElement) base ["certificateReference"]; }
+               }
+
+               [ConfigurationProperty ("dns",
+                        Options = ConfigurationPropertyOptions.None)]
+               public DnsElement Dns {
+                       get { return (DnsElement) base ["dns"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("rsa",
+                        Options = ConfigurationPropertyOptions.None)]
+               public RsaElement Rsa {
+                       get { return (RsaElement) base ["rsa"]; }
+               }
+
+               [ConfigurationProperty ("servicePrincipalName",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ServicePrincipalNameElement ServicePrincipalName {
+                       get { return (ServicePrincipalNameElement) base ["servicePrincipalName"]; }
+               }
+
+               [ConfigurationProperty ("userPrincipalName",
+                        Options = ConfigurationPropertyOptions.None)]
+               public UserPrincipalNameElement UserPrincipalName {
+                       get { return (UserPrincipalNameElement) base ["userPrincipalName"]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenClientBehaviorsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenClientBehaviorsElement.cs
new file mode 100644 (file)
index 0000000..9b02fb0
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// IssuedTokenClientBehaviorsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class IssuedTokenClientBehaviorsElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty behavior_configuration;
+               static ConfigurationProperty issuer_address;
+
+               static IssuedTokenClientBehaviorsElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       behavior_configuration = new ConfigurationProperty ("behaviorConfiguration",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       issuer_address = new ConfigurationProperty ("issuerAddress",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       properties.Add (behavior_configuration);
+                       properties.Add (issuer_address);
+               }
+
+               public IssuedTokenClientBehaviorsElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("behaviorConfiguration",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string BehaviorConfiguration {
+                       get { return (string) base [behavior_configuration]; }
+                       set { base [behavior_configuration] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("issuerAddress",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                        DefaultValue = "",
+                       IsRequired = true,
+                       IsKey = true)]
+               public string IssuerAddress {
+                       get { return (string) base [issuer_address]; }
+                       set { base [issuer_address] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenClientBehaviorsElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenClientBehaviorsElementCollection.cs
new file mode 100644 (file)
index 0000000..d7f26bf
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// IssuedTokenClientBehaviorsElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (IssuedTokenClientBehaviorsElement),
+                AddItemName = "add",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       [MonoTODO]
+       public sealed partial class IssuedTokenClientBehaviorsElementCollection
+                : ServiceModelConfigurationElementCollection<IssuedTokenClientBehaviorsElement>,  ICollection,  IEnumerable
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static IssuedTokenClientBehaviorsElementCollection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public IssuedTokenClientBehaviorsElementCollection ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenClientElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenClientElement.cs
new file mode 100644 (file)
index 0000000..064d26c
--- /dev/null
@@ -0,0 +1,183 @@
+//
+// IssuedTokenClientElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class IssuedTokenClientElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty cache_issued_tokens;
+               static ConfigurationProperty default_key_entropy_mode;
+               static ConfigurationProperty issued_token_renewal_threshold_percentage;
+               static ConfigurationProperty issuer_channel_behaviors;
+               static ConfigurationProperty local_issuer;
+               static ConfigurationProperty local_issuer_channel_behaviors;
+               static ConfigurationProperty max_issued_token_caching_time;
+
+               static IssuedTokenClientElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       cache_issued_tokens = new ConfigurationProperty ("cacheIssuedTokens",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       default_key_entropy_mode = new ConfigurationProperty ("defaultKeyEntropyMode",
+                               typeof (SecurityKeyEntropyMode), "CombinedEntropy", null/* FIXME: get converter for SecurityKeyEntropyMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       issued_token_renewal_threshold_percentage = new ConfigurationProperty ("issuedTokenRenewalThresholdPercentage",
+                               typeof (int), "60", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       issuer_channel_behaviors = new ConfigurationProperty ("issuerChannelBehaviors",
+                               typeof (IssuedTokenClientBehaviorsElementCollection), null, null/* FIXME: get converter for IssuedTokenClientBehaviorsElementCollection*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       local_issuer = new ConfigurationProperty ("localIssuer",
+                               typeof (IssuedTokenParametersEndpointAddressElement), null, null/* FIXME: get converter for IssuedTokenParametersEndpointAddressElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       local_issuer_channel_behaviors = new ConfigurationProperty ("localIssuerChannelBehaviors",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_issued_token_caching_time = new ConfigurationProperty ("maxIssuedTokenCachingTime",
+                               typeof (TimeSpan), "10675199.02:48:05.4775807", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (cache_issued_tokens);
+                       properties.Add (default_key_entropy_mode);
+                       properties.Add (issued_token_renewal_threshold_percentage);
+                       properties.Add (issuer_channel_behaviors);
+                       properties.Add (local_issuer);
+                       properties.Add (local_issuer_channel_behaviors);
+                       properties.Add (max_issued_token_caching_time);
+               }
+
+               public IssuedTokenClientElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("cacheIssuedTokens",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool CacheIssuedTokens {
+                       get { return (bool) base [cache_issued_tokens]; }
+                       set { base [cache_issued_tokens] = value; }
+               }
+
+               [ConfigurationProperty ("defaultKeyEntropyMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "CombinedEntropy")]
+               public SecurityKeyEntropyMode DefaultKeyEntropyMode {
+                       get { return (SecurityKeyEntropyMode) base [default_key_entropy_mode]; }
+                       set { base [default_key_entropy_mode] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 0,
+                        MaxValue = 100,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("issuedTokenRenewalThresholdPercentage",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "60")]
+               public int IssuedTokenRenewalThresholdPercentage {
+                       get { return (int) base [issued_token_renewal_threshold_percentage]; }
+                       set { base [issued_token_renewal_threshold_percentage] = value; }
+               }
+
+               [ConfigurationProperty ("issuerChannelBehaviors",
+                        Options = ConfigurationPropertyOptions.None)]
+               public IssuedTokenClientBehaviorsElementCollection IssuerChannelBehaviors {
+                       get { return (IssuedTokenClientBehaviorsElementCollection) base [issuer_channel_behaviors]; }
+               }
+
+               [ConfigurationProperty ("localIssuer",
+                        Options = ConfigurationPropertyOptions.None)]
+               public IssuedTokenParametersEndpointAddressElement LocalIssuer {
+                       get { return (IssuedTokenParametersEndpointAddressElement) base [local_issuer]; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("localIssuerChannelBehaviors",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string LocalIssuerChannelBehaviors {
+                       get { return (string) base [local_issuer_channel_behaviors]; }
+                       set { base [local_issuer_channel_behaviors] = value; }
+               }
+
+               [ConfigurationProperty ("maxIssuedTokenCachingTime",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10675199.02:48:05.4775807")]
+               public TimeSpan MaxIssuedTokenCachingTime {
+                       get { return (TimeSpan) base [max_issued_token_caching_time]; }
+                       set { base [max_issued_token_caching_time] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenParametersElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenParametersElement.cs
new file mode 100644 (file)
index 0000000..bb10384
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// IssuedTokenParametersElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class IssuedTokenParametersElement
+                : ConfigurationElement
+       {
+               public IssuedTokenParametersElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("additionalRequestParameters",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlElementElementCollection AdditionalRequestParameters {
+                       get { return (XmlElementElementCollection) base ["additionalRequestParameters"]; }
+               }
+
+               [ConfigurationProperty ("claimTypeRequirements",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ClaimTypeElementCollection ClaimTypeRequirements {
+                       get { return (ClaimTypeElementCollection) base ["claimTypeRequirements"]; }
+               }
+
+               [ConfigurationProperty ("issuer",
+                        Options = ConfigurationPropertyOptions.None)]
+               public IssuedTokenParametersEndpointAddressElement Issuer {
+                       get { return (IssuedTokenParametersEndpointAddressElement) base ["issuer"]; }
+               }
+
+               [ConfigurationProperty ("issuerMetadata",
+                        Options = ConfigurationPropertyOptions.None)]
+               public EndpointAddressElementBase IssuerMetadata {
+                       get { return (EndpointAddressElementBase) base ["issuerMetadata"]; }
+               }
+
+               [ConfigurationProperty ("keySize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "0")]
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int KeySize {
+                       get { return (int) base ["keySize"]; }
+                       set { base ["keySize"] = value; }
+               }
+
+               [ConfigurationProperty ("keyType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "SymmetricKey")]
+               public SecurityKeyType KeyType {
+                       get { return (SecurityKeyType) base ["keyType"]; }
+                       set { base ["keyType"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("tokenType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string TokenType {
+                       get { return (string) base ["tokenType"]; }
+                       set { base ["tokenType"] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenParametersEndpointAddressElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenParametersEndpointAddressElement.cs
new file mode 100644 (file)
index 0000000..30ebb28
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// IssuedTokenParametersEndpointAddressElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class IssuedTokenParametersEndpointAddressElement
+                : EndpointAddressElementBase
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public IssuedTokenParametersEndpointAddressElement () {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("binding",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               [StringValidator (MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Binding {
+                       get { return (string) base ["binding"]; }
+                       set { base ["binding"] = value; }
+               }
+
+               [ConfigurationProperty ("bindingConfiguration",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               [StringValidator (MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string BindingConfiguration {
+                       get { return (string) base ["bindingConfiguration"]; }
+                       set { base ["bindingConfiguration"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("binding", typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("bindingConfiguration", typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null), ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenServiceElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/IssuedTokenServiceElement.cs
new file mode 100644 (file)
index 0000000..9703681
--- /dev/null
@@ -0,0 +1,138 @@
+//
+// IssuedTokenServiceElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+using System.IdentityModel.Selectors;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class IssuedTokenServiceElement
+                : ConfigurationElement
+       {
+               public IssuedTokenServiceElement () {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("allowUntrustedRsaIssuers",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool AllowUntrustedRsaIssuers {
+                       get { return (bool) base ["allowUntrustedRsaIssuers"]; }
+                       set { base ["allowUntrustedRsaIssuers"] = value; }
+               }
+
+               [ConfigurationProperty ("knownCertificates",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509CertificateTrustedIssuerElementCollection KnownCertificates {
+                       get { return (X509CertificateTrustedIssuerElementCollection) base ["knownCertificates"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("samlSerializerType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               [StringValidator (MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string SamlSerializerType {
+                       get { return (string) base ["samlSerializerType"]; }
+                       set { base ["samlSerializerType"] = value; }
+               }
+
+               [ConfigurationProperty ("allowedAudienceUris")]
+               public AllowedAudienceUriElementCollection AllowedAudienceUris {
+                       get { return (AllowedAudienceUriElementCollection) base ["allowedAudienceUris"]; }
+               }
+
+               [ConfigurationPropertyAttribute ("audienceUriMode",
+                       DefaultValue = AudienceUriMode.BearerKeyOnly)]
+               public AudienceUriMode AudienceUriMode {
+                       get { return (AudienceUriMode) this ["audienceUriMode"]; }
+                       set { this ["audienceUriMode"] = value; }
+               }
+
+               [ConfigurationPropertyAttribute ("certificateValidationMode",
+                       DefaultValue = X509CertificateValidationMode.ChainTrust)]
+               public X509CertificateValidationMode CertificateValidationMode {
+                       get { return (X509CertificateValidationMode) this ["certificateValidationMode"]; }
+                       set { this ["certificateValidationMode"] = value; }
+               }
+
+               [StringValidatorAttribute (MinLength = 0)]
+               [ConfigurationPropertyAttribute ("customCertificateValidatorType",
+                       DefaultValue = "")]
+               public string CustomCertificateValidatorType {
+                       get { return (string) this ["customCertificateValidatorType"]; }
+                       set { this ["customCertificateValidatorType"] = value; }
+               }
+
+               [ConfigurationPropertyAttribute ("revocationMode", 
+                       DefaultValue = X509RevocationMode.Online)]
+               public X509RevocationMode RevocationMode {
+                       get { return (X509RevocationMode) this ["revocationMode"]; }
+                       set { this ["revocationMode"] = value; }
+               }
+
+               [ConfigurationPropertyAttribute ("trustedStoreLocation", 
+                       DefaultValue = StoreLocation.LocalMachine)]
+               public StoreLocation TrustedStoreLocation {
+                       get { return (StoreLocation) this ["trustedStoreLocation"]; }
+                       set { this ["trustedStoreLocation"] = value; }
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/LocalClientSecuritySettingsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/LocalClientSecuritySettingsElement.cs
new file mode 100644 (file)
index 0000000..c0dce43
--- /dev/null
@@ -0,0 +1,168 @@
+//
+// LocalClientSecuritySettingsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class LocalClientSecuritySettingsElement
+                : ConfigurationElement
+       {
+               public LocalClientSecuritySettingsElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("cacheCookies",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool CacheCookies {
+                       get { return (bool) base ["cacheCookies"]; }
+                       set { base ["cacheCookies"] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 0,
+                        MaxValue = 100,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("cookieRenewalThresholdPercentage",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "60")]
+               public int CookieRenewalThresholdPercentage {
+                       get { return (int) base ["cookieRenewalThresholdPercentage"]; }
+                       set { base ["cookieRenewalThresholdPercentage"] = value; }
+               }
+
+               [ConfigurationProperty ("detectReplays",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool DetectReplays {
+                       get { return (bool) base ["detectReplays"]; }
+                       set { base ["detectReplays"] = value; }
+               }
+
+               [ConfigurationProperty ("maxClockSkew",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:05:00")]
+               public TimeSpan MaxClockSkew {
+                       get { return (TimeSpan) base ["maxClockSkew"]; }
+                       set { base ["maxClockSkew"] = value; }
+               }
+
+               [ConfigurationProperty ("maxCookieCachingTime",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10675199.02:48:05.4775807")]
+               public TimeSpan MaxCookieCachingTime {
+                       get { return (TimeSpan) base ["maxCookieCachingTime"]; }
+                       set { base ["maxCookieCachingTime"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("reconnectTransportOnFailure",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool ReconnectTransportOnFailure {
+                       get { return (bool) base ["reconnectTransportOnFailure"]; }
+                       set { base ["reconnectTransportOnFailure"] = value; }
+               }
+
+               [ConfigurationProperty ("replayCacheSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "900000")]
+               [IntegerValidator ( MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int ReplayCacheSize {
+                       get { return (int) base ["replayCacheSize"]; }
+                       set { base ["replayCacheSize"] = value; }
+               }
+
+               [ConfigurationProperty ("replayWindow",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:05:00")]
+               public TimeSpan ReplayWindow {
+                       get { return (TimeSpan) base ["replayWindow"]; }
+                       set { base ["replayWindow"] = value; }
+               }
+
+               [ConfigurationProperty ("sessionKeyRenewalInterval",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10:00:00")]
+               public TimeSpan SessionKeyRenewalInterval {
+                       get { return (TimeSpan) base ["sessionKeyRenewalInterval"]; }
+                       set { base ["sessionKeyRenewalInterval"] = value; }
+               }
+
+               [ConfigurationProperty ("sessionKeyRolloverInterval",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:05:00")]
+               public TimeSpan SessionKeyRolloverInterval {
+                       get { return (TimeSpan) base ["sessionKeyRolloverInterval"]; }
+                       set { base ["sessionKeyRolloverInterval"] = value; }
+               }
+
+               [ConfigurationProperty ("timestampValidityDuration",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:05:00")]
+               public TimeSpan TimestampValidityDuration {
+                       get { return (TimeSpan) base ["timestampValidityDuration"]; }
+                       set { base ["timestampValidityDuration"] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/LocalServiceSecuritySettingsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/LocalServiceSecuritySettingsElement.cs
new file mode 100644 (file)
index 0000000..99d7649
--- /dev/null
@@ -0,0 +1,291 @@
+//
+// LocalServiceSecuritySettingsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class LocalServiceSecuritySettingsElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty detect_replays;
+               static ConfigurationProperty inactivity_timeout;
+               static ConfigurationProperty issued_cookie_lifetime;
+               static ConfigurationProperty max_cached_cookies;
+               static ConfigurationProperty max_clock_skew;
+               static ConfigurationProperty max_pending_sessions;
+               static ConfigurationProperty max_stateful_negotiations;
+               static ConfigurationProperty negotiation_timeout;
+               static ConfigurationProperty reconnect_transport_on_failure;
+               static ConfigurationProperty replay_cache_size;
+               static ConfigurationProperty replay_window;
+               static ConfigurationProperty session_key_renewal_interval;
+               static ConfigurationProperty session_key_rollover_interval;
+               static ConfigurationProperty timestamp_validity_duration;
+
+               static LocalServiceSecuritySettingsElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       detect_replays = new ConfigurationProperty ("detectReplays",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       inactivity_timeout = new ConfigurationProperty ("inactivityTimeout",
+                               typeof (TimeSpan), "00:02:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       issued_cookie_lifetime = new ConfigurationProperty ("issuedCookieLifetime",
+                               typeof (TimeSpan), "10:00:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_cached_cookies = new ConfigurationProperty ("maxCachedCookies",
+                               typeof (int), "1000", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_clock_skew = new ConfigurationProperty ("maxClockSkew",
+                               typeof (TimeSpan), "00:05:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_pending_sessions = new ConfigurationProperty ("maxPendingSessions",
+                               typeof (int), "128", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_stateful_negotiations = new ConfigurationProperty ("maxStatefulNegotiations",
+                               typeof (int), "128", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       negotiation_timeout = new ConfigurationProperty ("negotiationTimeout",
+                               typeof (TimeSpan), "00:01:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       reconnect_transport_on_failure = new ConfigurationProperty ("reconnectTransportOnFailure",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       replay_cache_size = new ConfigurationProperty ("replayCacheSize",
+                               typeof (int), "900000", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       replay_window = new ConfigurationProperty ("replayWindow",
+                               typeof (TimeSpan), "00:05:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       session_key_renewal_interval = new ConfigurationProperty ("sessionKeyRenewalInterval",
+                               typeof (TimeSpan), "15:00:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       session_key_rollover_interval = new ConfigurationProperty ("sessionKeyRolloverInterval",
+                               typeof (TimeSpan), "00:05:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       timestamp_validity_duration = new ConfigurationProperty ("timestampValidityDuration",
+                               typeof (TimeSpan), "00:05:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (detect_replays);
+                       properties.Add (inactivity_timeout);
+                       properties.Add (issued_cookie_lifetime);
+                       properties.Add (max_cached_cookies);
+                       properties.Add (max_clock_skew);
+                       properties.Add (max_pending_sessions);
+                       properties.Add (max_stateful_negotiations);
+                       properties.Add (negotiation_timeout);
+                       properties.Add (reconnect_transport_on_failure);
+                       properties.Add (replay_cache_size);
+                       properties.Add (replay_window);
+                       properties.Add (session_key_renewal_interval);
+                       properties.Add (session_key_rollover_interval);
+                       properties.Add (timestamp_validity_duration);
+               }
+
+               public LocalServiceSecuritySettingsElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("detectReplays",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool DetectReplays {
+                       get { return (bool) base [detect_replays]; }
+                       set { base [detect_replays] = value; }
+               }
+
+               [ConfigurationProperty ("inactivityTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:02:00")]
+               public TimeSpan InactivityTimeout {
+                       get { return (TimeSpan) base [inactivity_timeout]; }
+                       set { base [inactivity_timeout] = value; }
+               }
+
+               [ConfigurationProperty ("issuedCookieLifetime",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10:00:00")]
+               public TimeSpan IssuedCookieLifetime {
+                       get { return (TimeSpan) base [issued_cookie_lifetime]; }
+                       set { base [issued_cookie_lifetime] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxCachedCookies",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "1000")]
+               public int MaxCachedCookies {
+                       get { return (int) base [max_cached_cookies]; }
+                       set { base [max_cached_cookies] = value; }
+               }
+
+               [ConfigurationProperty ("maxClockSkew",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:05:00")]
+               public TimeSpan MaxClockSkew {
+                       get { return (TimeSpan) base [max_clock_skew]; }
+                       set { base [max_clock_skew] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxPendingSessions",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "128")]
+               public int MaxPendingSessions {
+                       get { return (int) base [max_pending_sessions]; }
+                       set { base [max_pending_sessions] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxStatefulNegotiations",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "128")]
+               public int MaxStatefulNegotiations {
+                       get { return (int) base [max_stateful_negotiations]; }
+                       set { base [max_stateful_negotiations] = value; }
+               }
+
+               [ConfigurationProperty ("negotiationTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:01:00")]
+               public TimeSpan NegotiationTimeout {
+                       get { return (TimeSpan) base [negotiation_timeout]; }
+                       set { base [negotiation_timeout] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("reconnectTransportOnFailure",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool ReconnectTransportOnFailure {
+                       get { return (bool) base [reconnect_transport_on_failure]; }
+                       set { base [reconnect_transport_on_failure] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("replayCacheSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "900000")]
+               public int ReplayCacheSize {
+                       get { return (int) base [replay_cache_size]; }
+                       set { base [replay_cache_size] = value; }
+               }
+
+               [ConfigurationProperty ("replayWindow",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:05:00")]
+               public TimeSpan ReplayWindow {
+                       get { return (TimeSpan) base [replay_window]; }
+                       set { base [replay_window] = value; }
+               }
+
+               [ConfigurationProperty ("sessionKeyRenewalInterval",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "15:00:00")]
+               public TimeSpan SessionKeyRenewalInterval {
+                       get { return (TimeSpan) base [session_key_renewal_interval]; }
+                       set { base [session_key_renewal_interval] = value; }
+               }
+
+               [ConfigurationProperty ("sessionKeyRolloverInterval",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:05:00")]
+               public TimeSpan SessionKeyRolloverInterval {
+                       get { return (TimeSpan) base [session_key_rollover_interval]; }
+                       set { base [session_key_rollover_interval] = value; }
+               }
+
+               [ConfigurationProperty ("timestampValidityDuration",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:05:00")]
+               public TimeSpan TimestampValidityDuration {
+                       get { return (TimeSpan) base [timestamp_validity_duration]; }
+                       set { base [timestamp_validity_duration] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageLoggingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageLoggingElement.cs
new file mode 100644 (file)
index 0000000..8bd6d6b
--- /dev/null
@@ -0,0 +1,186 @@
+//
+// MessageLoggingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class MessageLoggingElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty filters;
+               static ConfigurationProperty log_entire_message;
+               static ConfigurationProperty log_malformed_messages;
+               static ConfigurationProperty log_messages_at_service_level;
+               static ConfigurationProperty log_messages_at_transport_level;
+               static ConfigurationProperty max_messages_to_log;
+               static ConfigurationProperty max_size_of_message_to_log;
+
+               static MessageLoggingElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       filters = new ConfigurationProperty ("filters",
+                               typeof (XPathMessageFilterElementCollection), null, null/* FIXME: get converter for XPathMessageFilterElementCollection*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       log_entire_message = new ConfigurationProperty ("logEntireMessage",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       log_malformed_messages = new ConfigurationProperty ("logMalformedMessages",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       log_messages_at_service_level = new ConfigurationProperty ("logMessagesAtServiceLevel",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       log_messages_at_transport_level = new ConfigurationProperty ("logMessagesAtTransportLevel",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_messages_to_log = new ConfigurationProperty ("maxMessagesToLog",
+                               typeof (int), "10000", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_size_of_message_to_log = new ConfigurationProperty ("maxSizeOfMessageToLog",
+                               typeof (int), "262144", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (filters);
+                       properties.Add (log_entire_message);
+                       properties.Add (log_malformed_messages);
+                       properties.Add (log_messages_at_service_level);
+                       properties.Add (log_messages_at_transport_level);
+                       properties.Add (max_messages_to_log);
+                       properties.Add (max_size_of_message_to_log);
+               }
+
+               public MessageLoggingElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("filters",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = null)]
+               public XPathMessageFilterElementCollection Filters {
+                       get { return (XPathMessageFilterElementCollection) base [filters]; }
+               }
+
+               [ConfigurationProperty ("logEntireMessage",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool LogEntireMessage {
+                       get { return (bool) base [log_entire_message]; }
+                       set { base [log_entire_message] = value; }
+               }
+
+               [ConfigurationProperty ("logMalformedMessages",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool LogMalformedMessages {
+                       get { return (bool) base [log_malformed_messages]; }
+                       set { base [log_malformed_messages] = value; }
+               }
+
+               [ConfigurationProperty ("logMessagesAtServiceLevel",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool LogMessagesAtServiceLevel {
+                       get { return (bool) base [log_messages_at_service_level]; }
+                       set { base [log_messages_at_service_level] = value; }
+               }
+
+               [ConfigurationProperty ("logMessagesAtTransportLevel",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool LogMessagesAtTransportLevel {
+                       get { return (bool) base [log_messages_at_transport_level]; }
+                       set { base [log_messages_at_transport_level] = value; }
+               }
+
+               [IntegerValidator ( MinValue = -1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxMessagesToLog",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10000")]
+               public int MaxMessagesToLog {
+                       get { return (int) base [max_messages_to_log]; }
+                       set { base [max_messages_to_log] = value; }
+               }
+
+               [IntegerValidator ( MinValue = -1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxSizeOfMessageToLog",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "262144")]
+               public int MaxSizeOfMessageToLog {
+                       get { return (int) base [max_size_of_message_to_log]; }
+                       set { base [max_size_of_message_to_log] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityOverHttpElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityOverHttpElement.cs
new file mode 100644 (file)
index 0000000..c704b8d
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// MessageSecurityOverHttpElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public partial class MessageSecurityOverHttpElement
+                : ConfigurationElement
+       {
+               // Properties
+
+               [TypeConverter (typeof (SecurityAlgorithmSuiteConverter))]
+               [ConfigurationProperty ("algorithmSuite",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Default")]
+               public SecurityAlgorithmSuite AlgorithmSuite {
+                       get { return (SecurityAlgorithmSuite) base ["algorithmSuite"]; }
+                       set { base ["algorithmSuite"] = value; }
+               }
+
+               [ConfigurationProperty ("clientCredentialType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Windows")]
+               public MessageCredentialType ClientCredentialType {
+                       get { return (MessageCredentialType) base ["clientCredentialType"]; }
+                       set { base ["clientCredentialType"] = value; }
+               }
+
+               [ConfigurationProperty ("negotiateServiceCredential",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool NegotiateServiceCredential {
+                       get { return (bool) base ["negotiateServiceCredential"]; }
+                       set { base ["negotiateServiceCredential"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityOverMsmqElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityOverMsmqElement.cs
new file mode 100644 (file)
index 0000000..811c3cb
--- /dev/null
@@ -0,0 +1,112 @@
+//
+// MessageSecurityOverMsmqElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class MessageSecurityOverMsmqElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty algorithm_suite;
+               static ConfigurationProperty client_credential_type;
+
+               static MessageSecurityOverMsmqElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       algorithm_suite = new ConfigurationProperty ("algorithmSuite",
+                               typeof (SecurityAlgorithmSuite), "Default", null/* FIXME: get converter for SecurityAlgorithmSuite*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       client_credential_type = new ConfigurationProperty ("clientCredentialType",
+                               typeof (MessageCredentialType), "Windows", null/* FIXME: get converter for MessageCredentialType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (algorithm_suite);
+                       properties.Add (client_credential_type);
+               }
+
+               public MessageSecurityOverMsmqElement ()
+               {
+               }
+
+
+               // Properties
+
+               [TypeConverter (typeof(SecurityAlgorithmSuiteConverter))]
+               [ConfigurationProperty ("algorithmSuite",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Default")]
+               public SecurityAlgorithmSuite AlgorithmSuite {
+                       get { return (SecurityAlgorithmSuite) base [algorithm_suite]; }
+                       set { base [algorithm_suite] = value; }
+               }
+
+               [ConfigurationProperty ("clientCredentialType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Windows")]
+               public MessageCredentialType ClientCredentialType {
+                       get { return (MessageCredentialType) base [client_credential_type]; }
+                       set { base [client_credential_type] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityOverTcpElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityOverTcpElement.cs
new file mode 100644 (file)
index 0000000..24e4d6c
--- /dev/null
@@ -0,0 +1,112 @@
+//
+// MessageSecurityOverTcpElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class MessageSecurityOverTcpElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty algorithm_suite;
+               static ConfigurationProperty client_credential_type;
+
+               static MessageSecurityOverTcpElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       algorithm_suite = new ConfigurationProperty ("algorithmSuite",
+                               typeof (SecurityAlgorithmSuite), "Default", new SecurityAlgorithmSuiteConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       client_credential_type = new ConfigurationProperty ("clientCredentialType",
+                               typeof (MessageCredentialType), "Windows", null, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (algorithm_suite);
+                       properties.Add (client_credential_type);
+               }
+
+               public MessageSecurityOverTcpElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("algorithmSuite",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Default")]
+               [TypeConverter (typeof (SecurityAlgorithmSuiteConverter))]
+               public SecurityAlgorithmSuite AlgorithmSuite {
+                       get { return (SecurityAlgorithmSuite) base [algorithm_suite]; }
+                       set { base [algorithm_suite] = value; }
+               }
+
+               [ConfigurationProperty ("clientCredentialType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Windows")]
+               public MessageCredentialType ClientCredentialType {
+                       get { return (MessageCredentialType) base [client_credential_type]; }
+                       set { base [client_credential_type] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityVersionConverter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageSecurityVersionConverter.cs
new file mode 100644 (file)
index 0000000..ce0b8fd
--- /dev/null
@@ -0,0 +1,59 @@
+//\r
+// MessageSecurityVersionConverter.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ComponentModel;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       class MessageSecurityVersionConverter : TypeConverter\r
+       {\r
+               static readonly Dictionary<string, MessageSecurityVersion> _lookup;\r
+\r
+               static MessageSecurityVersionConverter () {\r
+                       _lookup = new Dictionary<string, MessageSecurityVersion> (StringComparer.OrdinalIgnoreCase);\r
+                       _lookup.Add ("Default", MessageSecurityVersion.Default);\r
+                       _lookup.Add ("WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10", MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10);\r
+                       _lookup.Add ("WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11", MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11);\r
+                       _lookup.Add ("WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10", MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10);\r
+               }\r
+\r
+               public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType) {\r
+                       return sourceType == typeof (string);\r
+               }\r
+\r
+               public override object ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {\r
+                       string stringValue = (string) value;\r
+                       if (_lookup.ContainsKey (stringValue))\r
+                               return _lookup [stringValue];\r
+                       throw new ArgumentOutOfRangeException ();\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageVersionConverter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MessageVersionConverter.cs
new file mode 100644 (file)
index 0000000..57d3d0b
--- /dev/null
@@ -0,0 +1,65 @@
+//\r
+// MessageVersionConverter.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ComponentModel;\r
+using System.ServiceModel.Channels;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       class MessageVersionConverter\r
+        : TypeConverter\r
+       {\r
+               static readonly Dictionary<string, MessageVersion> _lookup;\r
+\r
+               static MessageVersionConverter () {\r
+                       _lookup = new Dictionary<string, MessageVersion> (StringComparer.OrdinalIgnoreCase);\r
+                       _lookup.Add ("Default", MessageVersion.Default);\r
+                       _lookup.Add ("None", MessageVersion.None);\r
+                       _lookup.Add ("Soap11", MessageVersion.Soap11);\r
+                       _lookup.Add ("Soap11WSAddressing10", MessageVersion.Soap11WSAddressing10);\r
+                       _lookup.Add ("Soap11WSAddressingAugust2004", MessageVersion.Soap11WSAddressingAugust2004);\r
+                       _lookup.Add ("Soap12", MessageVersion.Soap12);\r
+                       _lookup.Add ("Soap12WSAddressing10", MessageVersion.Soap12WSAddressing10);\r
+                       _lookup.Add ("Soap12WSAddressingAugust2004", MessageVersion.Soap12WSAddressingAugust2004);\r
+               }\r
+\r
+               public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType) {\r
+                       return sourceType == typeof (string);\r
+               }\r
+\r
+               public override object ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {\r
+                       string stringValue = (string) value;\r
+                       if (_lookup.ContainsKey (stringValue))\r
+                               return _lookup [stringValue];\r
+                       throw new ArgumentOutOfRangeException ();\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MetadataElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MetadataElement.cs
new file mode 100644 (file)
index 0000000..510cbec
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// MetadataElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class MetadataElement
+                : ConfigurationElement
+       {
+               public MetadataElement () {
+               }
+
+               // Properties
+
+               [ConfigurationProperty ("policyImporters",
+                        Options = ConfigurationPropertyOptions.None)]
+               public PolicyImporterElementCollection PolicyImporters {
+                       get { return (PolicyImporterElementCollection) base ["policyImporters"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("wsdlImporters",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WsdlImporterElementCollection WsdlImporters {
+                       get { return (WsdlImporterElementCollection) base ["wsdlImporters"]; }
+               }
+
+               public Collection<IPolicyImportExtension> LoadPolicyImportExtensions () {
+                       Collection<IPolicyImportExtension> col = new Collection<IPolicyImportExtension> ();
+                       for (int i = 0; i < PolicyImporters.Count; i++) {
+                               Type t = Type.GetType (PolicyImporters [i].Type);
+                               IPolicyImportExtension ext = (IPolicyImportExtension) Activator.CreateInstance (t);
+                               col.Add (ext);
+                       }
+                       return col;
+               }
+
+               public Collection<IWsdlImportExtension> LoadWsdlImportExtensions () {
+                       Collection<IWsdlImportExtension> col = new Collection<IWsdlImportExtension> ();
+                       for (int i = 0; i < WsdlImporters.Count; i++) {
+                               Type t = Type.GetType (WsdlImporters [i].Type);
+                               IWsdlImportExtension ext = (IWsdlImportExtension) Activator.CreateInstance (t);
+                               col.Add (ext);
+                       }
+                       return col;
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MethodStubs.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MethodStubs.cs
new file mode 100644 (file)
index 0000000..6569fda
--- /dev/null
@@ -0,0 +1,131 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Configuration;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Xml;
+
+using ConfigurationType = System.Configuration.Configuration;
+
+namespace System.ServiceModel.Configuration
+{
+
+// ChannelEndpointElementCollection
+       public sealed partial class ChannelEndpointElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ChannelEndpointElement>
+       {
+               protected override object GetElementKey (ConfigurationElement element)
+               {
+                       ChannelEndpointElement el = (ChannelEndpointElement) element;
+                       return el.Name + ";" + el.Contract;
+               }
+       }
+
+// ClaimTypeElementCollection
+       public sealed partial class ClaimTypeElementCollection
+                : ServiceModelConfigurationElementCollection<ClaimTypeElement>,  ICollection,  IEnumerable
+       {
+               protected override object GetElementKey (ConfigurationElement element)
+               {
+                       return ((ClaimTypeElement) element).ClaimType;
+               }
+       }
+
+// ComContractElementCollection
+       public sealed partial class ComContractElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ComContractElement>
+       {
+               protected override object GetElementKey (ConfigurationElement element)
+               {
+                       return ((ComContractElement) element).Name;
+               }
+       }
+
+// ComMethodElementCollection
+       public sealed partial class ComMethodElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ComMethodElement>
+       {
+               protected override object GetElementKey (ConfigurationElement element)
+               {
+                       return ((ComMethodElement) element).ExposedMethod;
+               }
+       }
+
+// ComPersistableTypeElementCollection
+       public sealed partial class ComPersistableTypeElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ComPersistableTypeElement>
+       {
+               protected override object GetElementKey (ConfigurationElement element)
+               {
+                       // FIXME: ID? anyways, cosmetic COM stuff...
+                       return ((ComPersistableTypeElement) element).Name;
+               }
+       }
+
+// ComUdtElementCollection
+       public sealed partial class ComUdtElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ComUdtElement>
+       {
+               protected override object GetElementKey (ConfigurationElement element)
+               {
+                       // FIXME: another property? anyways COM stuff...
+                       return ((ComUdtElement) element).Name;
+               }
+       }
+
+// CustomBindingElementCollection
+       public sealed partial class CustomBindingElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<CustomBindingElement>,  ICollection,  IEnumerable
+       {
+               protected override object GetElementKey (ConfigurationElement element)
+               {
+                       return ((CustomBindingElement) element).Name;
+               }
+       }
+
+// IssuedTokenClientBehaviorsElementCollection
+       public sealed partial class IssuedTokenClientBehaviorsElementCollection
+                : ServiceModelConfigurationElementCollection<IssuedTokenClientBehaviorsElement>
+       {
+               [MonoTODO]
+               protected override object GetElementKey (ConfigurationElement element)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
+// StandardBindingElementCollection
+       public sealed partial class StandardBindingElementCollection<TBindingConfiguration>
+                : ServiceModelEnhancedConfigurationElementCollection<TBindingConfiguration>,  ICollection,  IEnumerable
+                where TBindingConfiguration : StandardBindingElement, new()
+       {
+               protected override object GetElementKey (ConfigurationElement element)
+               {
+                       return ((StandardBindingElement) element).Name;
+               }
+       }
+
+// TransportConfigurationTypeElementCollection
+       public sealed partial class TransportConfigurationTypeElementCollection
+                : ServiceModelConfigurationElementCollection<TransportConfigurationTypeElement>
+       {
+               protected override object GetElementKey (ConfigurationElement element)
+               {
+                       return ((TransportConfigurationTypeElement) element).Name;
+               }
+       }
+
+// XPathMessageFilterElementCollection
+       public sealed partial class XPathMessageFilterElementCollection
+                : ServiceModelConfigurationElementCollection<XPathMessageFilterElement>
+       {
+               [MonoTODO]
+               protected override object GetElementKey (ConfigurationElement element)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexBindingBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexBindingBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..d726b7a
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// MexBindingBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public abstract partial class MexBindingBindingCollectionElement<TStandardBinding,TBindingConfiguration>
+                : StandardBindingCollectionElement<TStandardBinding, TBindingConfiguration>
+               where TStandardBinding : Binding
+               where TBindingConfiguration : StandardBindingElement, new()
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static MexBindingBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               protected MexBindingBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexBindingElement.cs
new file mode 100644 (file)
index 0000000..13bfbf1
--- /dev/null
@@ -0,0 +1,78 @@
+//
+// MexBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public abstract partial class MexBindingElement<TStandardBinding>
+                : StandardBindingElement,  IBindingConfigurationElement
+               where TStandardBinding : Binding
+       {
+
+               protected MexBindingElement (string name)
+                       : base (name) {
+               }
+
+
+               // Properties
+
+               protected override Type BindingElementType {
+                       get { return typeof (TStandardBinding); }
+               }
+
+               protected override void OnApplyConfiguration (Binding binding) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..d9d252e
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// MexHttpBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class MexHttpBindingCollectionElement
+                : MexBindingBindingCollectionElement<WSHttpBinding, MexHttpBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static MexHttpBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public MexHttpBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpBindingElement.cs
new file mode 100644 (file)
index 0000000..456e2bc
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// MexHttpBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public partial class MexHttpBindingElement
+                : MexBindingElement<WSHttpBinding>,  IBindingConfigurationElement
+       {
+
+               public MexHttpBindingElement ()
+                       : this (String.Empty) {
+               }
+
+               public MexHttpBindingElement (string name)
+                       : base (name) {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpsBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpsBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..09eaf39
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// MexHttpsBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class MexHttpsBindingCollectionElement
+                : MexBindingBindingCollectionElement<WSHttpBinding, MexHttpsBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static MexHttpsBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public MexHttpsBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpsBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexHttpsBindingElement.cs
new file mode 100644 (file)
index 0000000..1891909
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// MexHttpsBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public partial class MexHttpsBindingElement
+                : MexBindingElement<WSHttpBinding>,  IBindingConfigurationElement
+       {
+
+               public MexHttpsBindingElement ()
+                       : this (String.Empty) {
+               }
+
+               public MexHttpsBindingElement (string name)
+                       : base (name) {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexNamedPipeBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexNamedPipeBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..7a0fb14
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// MexNamedPipeBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class MexNamedPipeBindingCollectionElement
+                : MexBindingBindingCollectionElement<CustomBinding, MexNamedPipeBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static MexNamedPipeBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public MexNamedPipeBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexNamedPipeBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexNamedPipeBindingElement.cs
new file mode 100644 (file)
index 0000000..c6462f9
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// MexNamedPipeBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public partial class MexNamedPipeBindingElement
+                : MexBindingElement<CustomBinding>,  IBindingConfigurationElement
+       {
+
+               public MexNamedPipeBindingElement ()
+                       : this (String.Empty) {
+               }
+
+               public MexNamedPipeBindingElement (string name)
+                       : base (name) {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexTcpBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexTcpBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..3a41234
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// MexTcpBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class MexTcpBindingCollectionElement
+                : MexBindingBindingCollectionElement<CustomBinding, MexTcpBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static MexTcpBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public MexTcpBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexTcpBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MexTcpBindingElement.cs
new file mode 100644 (file)
index 0000000..365ea66
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// MexTcpBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public partial class MexTcpBindingElement
+                : MexBindingElement<CustomBinding>,  IBindingConfigurationElement
+       {
+               public MexTcpBindingElement ()
+                       : this (String.Empty) {
+               }
+
+               public MexTcpBindingElement (string name)
+                       : base (name) {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqBindingElementBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqBindingElementBase.cs
new file mode 100644 (file)
index 0000000..d4f5d86
--- /dev/null
@@ -0,0 +1,260 @@
+//
+// MsmqBindingElementBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public abstract partial class MsmqBindingElementBase
+                : StandardBindingElement,  IBindingConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty custom_dead_letter_queue;
+               static ConfigurationProperty dead_letter_queue;
+               static ConfigurationProperty durable;
+               static ConfigurationProperty exactly_once;
+               static ConfigurationProperty max_received_message_size;
+               static ConfigurationProperty max_retry_cycles;
+               static ConfigurationProperty receive_error_handling;
+               static ConfigurationProperty receive_retry_count;
+               static ConfigurationProperty retry_cycle_delay;
+               static ConfigurationProperty time_to_live;
+               static ConfigurationProperty use_msmq_tracing;
+               static ConfigurationProperty use_source_journal;
+
+               static MsmqBindingElementBase ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       custom_dead_letter_queue = new ConfigurationProperty ("customDeadLetterQueue",
+                               typeof (Uri), null, new UriTypeConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       dead_letter_queue = new ConfigurationProperty ("deadLetterQueue",
+                               typeof (DeadLetterQueue), "System", null/* FIXME: get converter for DeadLetterQueue*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       durable = new ConfigurationProperty ("durable",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       exactly_once = new ConfigurationProperty ("exactlyOnce",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_received_message_size = new ConfigurationProperty ("maxReceivedMessageSize",
+                               typeof (long), "65536", null/* FIXME: get converter for long*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_retry_cycles = new ConfigurationProperty ("maxRetryCycles",
+                               typeof (int), "2", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       receive_error_handling = new ConfigurationProperty ("receiveErrorHandling",
+                               typeof (ReceiveErrorHandling), "Fault", null/* FIXME: get converter for ReceiveErrorHandling*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       receive_retry_count = new ConfigurationProperty ("receiveRetryCount",
+                               typeof (int), "5", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       retry_cycle_delay = new ConfigurationProperty ("retryCycleDelay",
+                               typeof (TimeSpan), "00:30:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       time_to_live = new ConfigurationProperty ("timeToLive",
+                               typeof (TimeSpan), "1.00:00:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       use_msmq_tracing = new ConfigurationProperty ("useMsmqTracing",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       use_source_journal = new ConfigurationProperty ("useSourceJournal",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (custom_dead_letter_queue);
+                       properties.Add (dead_letter_queue);
+                       properties.Add (durable);
+                       properties.Add (exactly_once);
+                       properties.Add (max_received_message_size);
+                       properties.Add (max_retry_cycles);
+                       properties.Add (receive_error_handling);
+                       properties.Add (receive_retry_count);
+                       properties.Add (retry_cycle_delay);
+                       properties.Add (time_to_live);
+                       properties.Add (use_msmq_tracing);
+                       properties.Add (use_source_journal);
+               }
+
+               protected MsmqBindingElementBase ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("customDeadLetterQueue",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = null)]
+               public Uri CustomDeadLetterQueue {
+                       get { return (Uri) base [custom_dead_letter_queue]; }
+                       set { base [custom_dead_letter_queue] = value; }
+               }
+
+               [ConfigurationProperty ("deadLetterQueue",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "System")]
+               public DeadLetterQueue DeadLetterQueue {
+                       get { return (DeadLetterQueue) base [dead_letter_queue]; }
+                       set { base [dead_letter_queue] = value; }
+               }
+
+               [ConfigurationProperty ("durable",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool Durable {
+                       get { return (bool) base [durable]; }
+                       set { base [durable] = value; }
+               }
+
+               [ConfigurationProperty ("exactlyOnce",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool ExactlyOnce {
+                       get { return (bool) base [exactly_once]; }
+                       set { base [exactly_once] = value; }
+               }
+
+               [LongValidator ( MinValue = 0,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxReceivedMessageSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               public long MaxReceivedMessageSize {
+                       get { return (long) base [max_received_message_size]; }
+                       set { base [max_received_message_size] = value; }
+               }
+
+               [ConfigurationProperty ("maxRetryCycles",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "2")]
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxRetryCycles {
+                       get { return (int) base [max_retry_cycles]; }
+                       set { base [max_retry_cycles] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("receiveErrorHandling",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Fault")]
+               public ReceiveErrorHandling ReceiveErrorHandling {
+                       get { return (ReceiveErrorHandling) base [receive_error_handling]; }
+                       set { base [receive_error_handling] = value; }
+               }
+
+               [ConfigurationProperty ("receiveRetryCount",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "5")]
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int ReceiveRetryCount {
+                       get { return (int) base [receive_retry_count]; }
+                       set { base [receive_retry_count] = value; }
+               }
+
+               [ConfigurationProperty ("retryCycleDelay",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:30:00")]
+               public TimeSpan RetryCycleDelay {
+                       get { return (TimeSpan) base [retry_cycle_delay]; }
+                       set { base [retry_cycle_delay] = value; }
+               }
+
+               [ConfigurationProperty ("timeToLive",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "1.00:00:00")]
+               public TimeSpan TimeToLive {
+                       get { return (TimeSpan) base [time_to_live]; }
+                       set { base [time_to_live] = value; }
+               }
+
+               [ConfigurationProperty ("useMsmqTracing",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool UseMsmqTracing {
+                       get { return (bool) base [use_msmq_tracing]; }
+                       set { base [use_msmq_tracing] = value; }
+               }
+
+               [ConfigurationProperty ("useSourceJournal",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool UseSourceJournal {
+                       get { return (bool) base [use_source_journal]; }
+                       set { base [use_source_journal] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqElementBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqElementBase.cs
new file mode 100644 (file)
index 0000000..81d0595
--- /dev/null
@@ -0,0 +1,192 @@
+//
+// MsmqElementBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public abstract class MsmqElementBase
+                : TransportElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               protected MsmqElementBase () {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("customDeadLetterQueue",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = null)]
+               public Uri CustomDeadLetterQueue {
+                       get { return (Uri) base ["customDeadLetterQueue"]; }
+                       set { base ["customDeadLetterQueue"] = value; }
+               }
+
+               [ConfigurationProperty ("deadLetterQueue",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "System")]
+               public DeadLetterQueue DeadLetterQueue {
+                       get { return (DeadLetterQueue) base ["deadLetterQueue"]; }
+                       set { base ["deadLetterQueue"] = value; }
+               }
+
+               [ConfigurationProperty ("durable",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool Durable {
+                       get { return (bool) base ["durable"]; }
+                       set { base ["durable"] = value; }
+               }
+
+               [ConfigurationProperty ("exactlyOnce",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool ExactlyOnce {
+                       get { return (bool) base ["exactlyOnce"]; }
+                       set { base ["exactlyOnce"] = value; }
+               }
+
+               [ConfigurationProperty ("maxRetryCycles",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "2")]
+               [IntegerValidator (MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxRetryCycles {
+                       get { return (int) base ["maxRetryCycles"]; }
+                       set { base ["maxRetryCycles"] = value; }
+               }
+
+               [ConfigurationProperty ("msmqTransportSecurity",
+                        Options = ConfigurationPropertyOptions.None)]
+               public MsmqTransportSecurityElement MsmqTransportSecurity {
+                       get { return (MsmqTransportSecurityElement) base ["msmqTransportSecurity"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("customDeadLetterQueue", typeof (Uri), null, new UriTypeConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("deadLetterQueue", typeof (DeadLetterQueue), "System", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("durable", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("exactlyOnce", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxRetryCycles", typeof (int), "2", null, new IntegerValidator (0, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("msmqTransportSecurity", typeof (MsmqTransportSecurityElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("receiveErrorHandling", typeof (ReceiveErrorHandling), "Fault", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("receiveRetryCount", typeof (int), "5", null, new IntegerValidator (0, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("retryCycleDelay", typeof (TimeSpan), "00:30:00", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("timeToLive", typeof (TimeSpan), "1.00:00:00", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("useMsmqTracing", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("useSourceJournal", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("receiveErrorHandling",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Fault")]
+               public ReceiveErrorHandling ReceiveErrorHandling {
+                       get { return (ReceiveErrorHandling) base ["receiveErrorHandling"]; }
+                       set { base ["receiveErrorHandling"] = value; }
+               }
+
+               [ConfigurationProperty ("receiveRetryCount",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "5")]
+               [IntegerValidator (MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int ReceiveRetryCount {
+                       get { return (int) base ["receiveRetryCount"]; }
+                       set { base ["receiveRetryCount"] = value; }
+               }
+
+               [ConfigurationProperty ("retryCycleDelay",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:30:00")]
+               public TimeSpan RetryCycleDelay {
+                       get { return (TimeSpan) base ["retryCycleDelay"]; }
+                       set { base ["retryCycleDelay"] = value; }
+               }
+
+               [ConfigurationProperty ("timeToLive",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "1.00:00:00")]
+               public TimeSpan TimeToLive {
+                       get { return (TimeSpan) base ["timeToLive"]; }
+                       set { base ["timeToLive"] = value; }
+               }
+
+               [ConfigurationProperty ("useMsmqTracing",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool UseMsmqTracing {
+                       get { return (bool) base ["useMsmqTracing"]; }
+                       set { base ["useMsmqTracing"] = value; }
+               }
+
+               [ConfigurationProperty ("useSourceJournal",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool UseSourceJournal {
+                       get { return (bool) base ["useSourceJournal"]; }
+                       set { base ["useSourceJournal"] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..8e69b04
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// MsmqIntegrationBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class MsmqIntegrationBindingCollectionElement
+                : StandardBindingCollectionElement<MsmqIntegrationBinding, MsmqIntegrationBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static MsmqIntegrationBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public MsmqIntegrationBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationBindingElement.cs
new file mode 100644 (file)
index 0000000..4bcf6e9
--- /dev/null
@@ -0,0 +1,120 @@
+//
+// MsmqIntegrationBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class MsmqIntegrationBindingElement
+                : MsmqBindingElementBase,  IBindingConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty binding_element_type;
+               static ConfigurationProperty security;
+               static ConfigurationProperty serialization_format;
+
+               static MsmqIntegrationBindingElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+
+                       security = new ConfigurationProperty ("security",
+                               typeof (MsmqIntegrationSecurityElement), null, null/* FIXME: get converter for MsmqIntegrationSecurityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       serialization_format = new ConfigurationProperty ("serializationFormat",
+                               typeof (MsmqMessageSerializationFormat), "Xml", null/* FIXME: get converter for MsmqMessageSerializationFormat*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (binding_element_type);
+                       properties.Add (security);
+                       properties.Add (serialization_format);
+               }
+
+               public MsmqIntegrationBindingElement ()
+               {
+               }
+
+
+               // Properties
+
+               protected override Type BindingElementType {
+                       get { return (Type) base [binding_element_type]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("security",
+                        Options = ConfigurationPropertyOptions.None)]
+               public MsmqIntegrationSecurityElement Security {
+                       get { return (MsmqIntegrationSecurityElement) base [security]; }
+               }
+
+               [ConfigurationProperty ("serializationFormat",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Xml")]
+               public MsmqMessageSerializationFormat SerializationFormat {
+                       get { return (MsmqMessageSerializationFormat) base [serialization_format]; }
+                       set { base [serialization_format] = value; }
+               }
+
+
+
+               protected override void OnApplyConfiguration (Binding binding) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationElement.cs
new file mode 100644 (file)
index 0000000..06876fd
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// MsmqIntegrationElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class MsmqIntegrationElement
+                : MsmqElementBase
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public MsmqIntegrationElement () {
+               }
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (System.ServiceModel.MsmqIntegration.MsmqIntegrationBindingElement); }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("serializationFormat", typeof (MsmqMessageSerializationFormat), "Xml", null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("serializationFormat",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Xml")]
+               public MsmqMessageSerializationFormat SerializationFormat {
+                       get { return (MsmqMessageSerializationFormat) base ["serializationFormat"]; }
+                       set { base ["serializationFormat"] = value; }
+               }
+
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqIntegrationSecurityElement.cs
new file mode 100644 (file)
index 0000000..c929221
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// MsmqIntegrationSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class MsmqIntegrationSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty mode;
+               static ConfigurationProperty transport;
+
+               static MsmqIntegrationSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       mode = new ConfigurationProperty ("mode",
+                               typeof (MsmqIntegrationSecurityMode), "Transport", null/* FIXME: get converter for MsmqIntegrationSecurityMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       transport = new ConfigurationProperty ("transport",
+                               typeof (MsmqTransportSecurityElement), null, null/* FIXME: get converter for MsmqTransportSecurityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (mode);
+                       properties.Add (transport);
+               }
+
+               public MsmqIntegrationSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("mode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Transport")]
+               public MsmqIntegrationSecurityMode Mode {
+                       get { return (MsmqIntegrationSecurityMode) base [mode]; }
+                       set { base [mode] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("transport",
+                        Options = ConfigurationPropertyOptions.None)]
+               public MsmqTransportSecurityElement Transport {
+                       get { return (MsmqTransportSecurityElement) base [transport]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqTransportElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqTransportElement.cs
new file mode 100644 (file)
index 0000000..59bb88b
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// MsmqTransportElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class MsmqTransportElement
+                : MsmqElementBase
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public MsmqTransportElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (MsmqTransportBindingElement); }
+               }
+
+               [IntegerValidator (MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxPoolSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "8")]
+               public int MaxPoolSize {
+                       get { return (int) base ["maxPoolSize"]; }
+                       set { base ["maxPoolSize"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("maxPoolSize", typeof (int), "8", null, new IntegerValidator (0, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("queueTransferProtocol", typeof (QueueTransferProtocol), "Native", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("useActiveDirectory", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("queueTransferProtocol",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Native")]
+               public QueueTransferProtocol QueueTransferProtocol {
+                       get { return (QueueTransferProtocol) base ["queueTransferProtocol"]; }
+                       set { base ["queueTransferProtocol"] = value; }
+               }
+
+               [ConfigurationProperty ("useActiveDirectory",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool UseActiveDirectory {
+                       get { return (bool) base ["useActiveDirectory"]; }
+                       set { base ["useActiveDirectory"] = value; }
+               }
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqTransportSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MsmqTransportSecurityElement.cs
new file mode 100644 (file)
index 0000000..8784120
--- /dev/null
@@ -0,0 +1,139 @@
+//
+// MsmqTransportSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class MsmqTransportSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty msmq_authentication_mode;
+               static ConfigurationProperty msmq_encryption_algorithm;
+               static ConfigurationProperty msmq_protection_level;
+               static ConfigurationProperty msmq_secure_hash_algorithm;
+
+               static MsmqTransportSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       msmq_authentication_mode = new ConfigurationProperty ("msmqAuthenticationMode",
+                               typeof (MsmqAuthenticationMode), "WindowsDomain", null/* FIXME: get converter for MsmqAuthenticationMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       msmq_encryption_algorithm = new ConfigurationProperty ("msmqEncryptionAlgorithm",
+                               typeof (MsmqEncryptionAlgorithm), "RC4Stream", null/* FIXME: get converter for MsmqEncryptionAlgorithm*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       msmq_protection_level = new ConfigurationProperty ("msmqProtectionLevel",
+                               typeof (ProtectionLevel), "Sign", null/* FIXME: get converter for ProtectionLevel*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       msmq_secure_hash_algorithm = new ConfigurationProperty ("msmqSecureHashAlgorithm",
+                               typeof (MsmqSecureHashAlgorithm), "Sha1", null/* FIXME: get converter for MsmqSecureHashAlgorithm*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (msmq_authentication_mode);
+                       properties.Add (msmq_encryption_algorithm);
+                       properties.Add (msmq_protection_level);
+                       properties.Add (msmq_secure_hash_algorithm);
+               }
+
+               public MsmqTransportSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("msmqAuthenticationMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "WindowsDomain")]
+               public MsmqAuthenticationMode MsmqAuthenticationMode {
+                       get { return (MsmqAuthenticationMode) base [msmq_authentication_mode]; }
+                       set { base [msmq_authentication_mode] = value; }
+               }
+
+               [ConfigurationProperty ("msmqEncryptionAlgorithm",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "RC4Stream")]
+               public MsmqEncryptionAlgorithm MsmqEncryptionAlgorithm {
+                       get { return (MsmqEncryptionAlgorithm) base [msmq_encryption_algorithm]; }
+                       set { base [msmq_encryption_algorithm] = value; }
+               }
+
+               [ConfigurationProperty ("msmqProtectionLevel",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Sign")]
+               public ProtectionLevel MsmqProtectionLevel {
+                       get { return (ProtectionLevel) base [msmq_protection_level]; }
+                       set { base [msmq_protection_level] = value; }
+               }
+
+               [ConfigurationProperty ("msmqSecureHashAlgorithm",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Sha1")]
+               public MsmqSecureHashAlgorithm MsmqSecureHashAlgorithm {
+                       get { return (MsmqSecureHashAlgorithm) base [msmq_secure_hash_algorithm]; }
+                       set { base [msmq_secure_hash_algorithm] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MtomMessageEncodingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/MtomMessageEncodingElement.cs
new file mode 100644 (file)
index 0000000..39c1481
--- /dev/null
@@ -0,0 +1,139 @@
+//
+// MtomMessageEncodingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed partial class MtomMessageEncodingElement
+                : BindingElementExtensionElement
+       {
+               public MtomMessageEncodingElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (MtomMessageEncodingBindingElement); }
+               }
+
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxBufferSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               public int MaxBufferSize {
+                       get { return (int) base ["maxBufferSize"]; }
+                       set { base ["maxBufferSize"] = value; }
+               }
+
+               [ConfigurationProperty ("maxReadPoolSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "64")]
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxReadPoolSize {
+                       get { return (int) base ["maxReadPoolSize"]; }
+                       set { base ["maxReadPoolSize"] = value; }
+               }
+
+               [ConfigurationProperty ("maxWritePoolSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "16")]
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxWritePoolSize {
+                       get { return (int) base ["maxWritePoolSize"]; }
+                       set { base ["maxWritePoolSize"] = value; }
+               }
+
+               [ConfigurationProperty ("messageVersion",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Soap12WSAddressing10")]
+               [TypeConverter (typeof (MessageVersionConverter))]
+               public MessageVersion MessageVersion {
+                       get { return (MessageVersion) base ["messageVersion"]; }
+                       set { base ["messageVersion"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("readerQuotas",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlDictionaryReaderQuotasElement ReaderQuotas {
+                       get { return (XmlDictionaryReaderQuotasElement) base ["readerQuotas"]; }
+               }
+
+               [ConfigurationProperty ("writeEncoding",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "utf-8")]
+               [TypeConverter (typeof (EncodingConverter))]
+               public Encoding WriteEncoding {
+                       get { return (Encoding) base ["writeEncoding"]; }
+                       set { base ["writeEncoding"] = value; }
+               }
+
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedPipeConnectionPoolSettingsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedPipeConnectionPoolSettingsElement.cs
new file mode 100644 (file)
index 0000000..e66eee7
--- /dev/null
@@ -0,0 +1,131 @@
+//
+// NamedPipeConnectionPoolSettingsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class NamedPipeConnectionPoolSettingsElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty group_name;
+               static ConfigurationProperty idle_timeout;
+               static ConfigurationProperty max_outbound_connections_per_endpoint;
+
+               static NamedPipeConnectionPoolSettingsElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       group_name = new ConfigurationProperty ("groupName",
+                               typeof (string), "default", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       idle_timeout = new ConfigurationProperty ("idleTimeout",
+                               typeof (TimeSpan), "00:02:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_outbound_connections_per_endpoint = new ConfigurationProperty ("maxOutboundConnectionsPerEndpoint",
+                               typeof (int), "10", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (group_name);
+                       properties.Add (idle_timeout);
+                       properties.Add (max_outbound_connections_per_endpoint);
+               }
+
+               public NamedPipeConnectionPoolSettingsElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("groupName",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "default")]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string GroupName {
+                       get { return (string) base [group_name]; }
+                       set { base [group_name] = value; }
+               }
+
+               [ConfigurationProperty ("idleTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:02:00")]
+               public TimeSpan IdleTimeout {
+                       get { return (TimeSpan) base [idle_timeout]; }
+                       set { base [idle_timeout] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxOutboundConnectionsPerEndpoint",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10")]
+               public int MaxOutboundConnectionsPerEndpoint {
+                       get { return (int) base [max_outbound_connections_per_endpoint]; }
+                       set { base [max_outbound_connections_per_endpoint] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedPipeTransportElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedPipeTransportElement.cs
new file mode 100644 (file)
index 0000000..d8ba18e
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// NamedPipeTransportElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class NamedPipeTransportElement
+                : ConnectionOrientedTransportElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public NamedPipeTransportElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (NamedPipeTransportBindingElement); }
+               }
+
+               [ConfigurationProperty ("connectionPoolSettings",
+                        Options = ConfigurationPropertyOptions.None)]
+               public NamedPipeConnectionPoolSettingsElement ConnectionPoolSettings {
+                       get { return (NamedPipeConnectionPoolSettingsElement) base ["connectionPoolSettings"]; }
+                       set { base ["connectionPoolSettings"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("connectionPoolSettings", typeof (NamedPipeConnectionPoolSettingsElement), null, null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedPipeTransportSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedPipeTransportSecurityElement.cs
new file mode 100644 (file)
index 0000000..7f4f132
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// NamedPipeTransportSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class NamedPipeTransportSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty protection_level;
+
+               static NamedPipeTransportSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       protection_level = new ConfigurationProperty ("protectionLevel",
+                               typeof (ProtectionLevel), "EncryptAndSign", null/* FIXME: get converter for ProtectionLevel*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (protection_level);
+               }
+
+               public NamedPipeTransportSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("protectionLevel",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "EncryptAndSign")]
+               public ProtectionLevel ProtectionLevel {
+                       get { return (ProtectionLevel) base [protection_level]; }
+                       set { base [protection_level] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedServiceModelExtensionCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NamedServiceModelExtensionCollectionElement.cs
new file mode 100644 (file)
index 0000000..80eb141
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// NamedServiceModelExtensionCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public abstract class NamedServiceModelExtensionCollectionElement<TServiceModelExtensionElement>
+                : ServiceModelExtensionCollectionElement<TServiceModelExtensionElement>,  ICollection<TServiceModelExtensionElement>,  IEnumerable<TServiceModelExtensionElement>,  IEnumerable
+               where TServiceModelExtensionElement : ServiceModelExtensionElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               internal NamedServiceModelExtensionCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("name",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               public virtual string Name {
+                       get { return (string) base ["name"]; }
+                       set { base ["name"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty ("name", typeof (string), null, new StringConverter (), new StringValidator (1, int.MaxValue, null), ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey));
+                               }
+                               return _properties;
+                       }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetMsmqBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetMsmqBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..d141246
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// NetMsmqBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class NetMsmqBindingCollectionElement
+                : StandardBindingCollectionElement<NetMsmqBinding, NetMsmqBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static NetMsmqBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public NetMsmqBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetMsmqBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetMsmqBindingElement.cs
new file mode 100644 (file)
index 0000000..e3dac33
--- /dev/null
@@ -0,0 +1,163 @@
+//
+// NetMsmqBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class NetMsmqBindingElement
+                : MsmqBindingElementBase,  IBindingConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty binding_element_type;
+               static ConfigurationProperty max_buffer_pool_size;
+               static ConfigurationProperty queue_transfer_protocol;
+               static ConfigurationProperty reader_quotas;
+               static ConfigurationProperty security;
+               static ConfigurationProperty use_active_directory;
+
+               static NetMsmqBindingElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+
+                       max_buffer_pool_size = new ConfigurationProperty ("maxBufferPoolSize",
+                               typeof (long), "524288", null/* FIXME: get converter for long*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       queue_transfer_protocol = new ConfigurationProperty ("queueTransferProtocol",
+                               typeof (QueueTransferProtocol), "Native", null/* FIXME: get converter for QueueTransferProtocol*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       reader_quotas = new ConfigurationProperty ("readerQuotas",
+                               typeof (XmlDictionaryReaderQuotasElement), null, null/* FIXME: get converter for XmlDictionaryReaderQuotasElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       security = new ConfigurationProperty ("security",
+                               typeof (NetMsmqSecurityElement), null, null/* FIXME: get converter for NetMsmqSecurityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       use_active_directory = new ConfigurationProperty ("useActiveDirectory",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (binding_element_type);
+                       properties.Add (max_buffer_pool_size);
+                       properties.Add (queue_transfer_protocol);
+                       properties.Add (reader_quotas);
+                       properties.Add (security);
+                       properties.Add (use_active_directory);
+               }
+
+               public NetMsmqBindingElement ()
+               {
+               }
+
+
+               // Properties
+
+               protected override Type BindingElementType {
+                       get { return (Type) base [binding_element_type]; }
+               }
+
+               [ConfigurationProperty ("maxBufferPoolSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "524288")]
+               [LongValidator ( MinValue = 0,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               public long MaxBufferPoolSize {
+                       get { return (long) base [max_buffer_pool_size]; }
+                       set { base [max_buffer_pool_size] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("queueTransferProtocol",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Native")]
+               public QueueTransferProtocol QueueTransferProtocol {
+                       get { return (QueueTransferProtocol) base [queue_transfer_protocol]; }
+                       set { base [queue_transfer_protocol] = value; }
+               }
+
+               [ConfigurationProperty ("readerQuotas",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlDictionaryReaderQuotasElement ReaderQuotas {
+                       get { return (XmlDictionaryReaderQuotasElement) base [reader_quotas]; }
+               }
+
+               [ConfigurationProperty ("security",
+                        Options = ConfigurationPropertyOptions.None)]
+               public NetMsmqSecurityElement Security {
+                       get { return (NetMsmqSecurityElement) base [security]; }
+               }
+
+               [ConfigurationProperty ("useActiveDirectory",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool UseActiveDirectory {
+                       get { return (bool) base [use_active_directory]; }
+                       set { base [use_active_directory] = value; }
+               }
+
+
+
+               protected override void OnApplyConfiguration (Binding binding) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetMsmqSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetMsmqSecurityElement.cs
new file mode 100644 (file)
index 0000000..bf04ee8
--- /dev/null
@@ -0,0 +1,121 @@
+//
+// NetMsmqSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class NetMsmqSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty message;
+               static ConfigurationProperty mode;
+               static ConfigurationProperty transport;
+
+               static NetMsmqSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       message = new ConfigurationProperty ("message",
+                               typeof (MessageSecurityOverMsmqElement), null, null/* FIXME: get converter for MessageSecurityOverMsmqElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       mode = new ConfigurationProperty ("mode",
+                               typeof (NetMsmqSecurityMode), "Transport", null/* FIXME: get converter for NetMsmqSecurityMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       transport = new ConfigurationProperty ("transport",
+                               typeof (MsmqTransportSecurityElement), null, null/* FIXME: get converter for MsmqTransportSecurityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (message);
+                       properties.Add (mode);
+                       properties.Add (transport);
+               }
+
+               public NetMsmqSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("message",
+                        Options = ConfigurationPropertyOptions.None)]
+               public MessageSecurityOverMsmqElement Message {
+                       get { return (MessageSecurityOverMsmqElement) base [message]; }
+               }
+
+               [ConfigurationProperty ("mode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Transport")]
+               public NetMsmqSecurityMode Mode {
+                       get { return (NetMsmqSecurityMode) base [mode]; }
+                       set { base [mode] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("transport",
+                        Options = ConfigurationPropertyOptions.None)]
+               public MsmqTransportSecurityElement Transport {
+                       get { return (MsmqTransportSecurityElement) base [transport]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetNamedPipeBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetNamedPipeBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..c7af623
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// NetNamedPipeBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class NetNamedPipeBindingCollectionElement
+                : StandardBindingCollectionElement<NetNamedPipeBinding, NetNamedPipeBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static NetNamedPipeBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public NetNamedPipeBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetNamedPipeBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetNamedPipeBindingElement.cs
new file mode 100644 (file)
index 0000000..df5e789
--- /dev/null
@@ -0,0 +1,189 @@
+//
+// NetNamedPipeBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public partial class NetNamedPipeBindingElement
+                : StandardBindingElement,  IBindingConfigurationElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public NetNamedPipeBindingElement ()
+               {
+               }
+
+               public NetNamedPipeBindingElement (string name) : base (name) { }
+
+               // Properties
+
+               protected override Type BindingElementType {
+                       get { return typeof (NetNamedPipeBinding); }
+               }
+
+               [ConfigurationProperty ("hostNameComparisonMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "StrongWildcard")]
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return (HostNameComparisonMode) this ["hostNameComparisonMode"]; }
+                       set { this ["hostNameComparisonMode"] = value; }
+               }
+
+               [ConfigurationProperty ("maxBufferPoolSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "524288")]
+               [LongValidator ( MinValue = 0,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               public long MaxBufferPoolSize {
+                       get { return (long) this ["maxBufferPoolSize"]; }
+                       set { this ["maxBufferPoolSize"] = value; }
+               }
+
+               [ConfigurationProperty ("maxBufferSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               [IntegerValidator ( MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxBufferSize {
+                       get { return (int) this ["maxBufferSize"]; }
+                       set { this ["maxBufferSize"] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxConnections",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10")]
+               public int MaxConnections {
+                       get { return (int) this ["maxConnections"]; }
+                       set { this ["maxConnections"] = value; }
+               }
+
+               [ConfigurationProperty ("maxReceivedMessageSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               [LongValidator ( MinValue = 1,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               public long MaxReceivedMessageSize {
+                       get { return (long) this ["maxReceivedMessageSize"]; }
+                       set { this ["maxReceivedMessageSize"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("hostNameComparisonMode", typeof (HostNameComparisonMode), "StrongWildcard", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferPoolSize", typeof (long), "524288", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferSize", typeof (int), "65536", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxConnections", typeof (int), "10", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxReceivedMessageSize", typeof (long), "65536", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("readerQuotas", typeof (XmlDictionaryReaderQuotasElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("security", typeof (NetNamedPipeSecurityElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("transactionFlow", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("transactionProtocol", typeof (TransactionProtocol), "OleTransactions", TransactionProtocolConverter.Instance, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("transferMode", typeof (TransferMode), "Buffered", null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("readerQuotas",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlDictionaryReaderQuotasElement ReaderQuotas {
+                       get { return (XmlDictionaryReaderQuotasElement) this ["readerQuotas"]; }
+               }
+
+               [ConfigurationProperty ("security",
+                        Options = ConfigurationPropertyOptions.None)]
+               public NetNamedPipeSecurityElement Security {
+                       get { return (NetNamedPipeSecurityElement) this ["security"]; }
+               }
+
+               [ConfigurationProperty ("transactionFlow",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool TransactionFlow {
+                       get { return (bool) this ["transactionFlow"]; }
+                       set { this ["transactionFlow"] = value; }
+               }
+
+               [ConfigurationProperty ("transactionProtocol",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "OleTransactions")]
+               [TypeConverter (typeof (TransactionProtocolConverter))]
+               public TransactionProtocol TransactionProtocol {
+                       get { return (TransactionProtocol) this ["transactionProtocol"]; }
+                       set { this ["transactionProtocol"] = value; }
+               }
+
+               [ConfigurationProperty ("transferMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Buffered")]
+               public TransferMode TransferMode {
+                       get { return (TransferMode) this ["transferMode"]; }
+                       set { this ["transferMode"] = value; }
+               }
+
+
+
+               protected override void OnApplyConfiguration (Binding binding) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetNamedPipeSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetNamedPipeSecurityElement.cs
new file mode 100644 (file)
index 0000000..7282406
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// NetNamedPipeSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class NetNamedPipeSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty mode;
+               static ConfigurationProperty transport;
+
+               static NetNamedPipeSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       mode = new ConfigurationProperty ("mode",
+                               typeof (NetNamedPipeSecurityMode), "Transport", null/* FIXME: get converter for NetNamedPipeSecurityMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       transport = new ConfigurationProperty ("transport",
+                               typeof (NamedPipeTransportSecurityElement), null, null/* FIXME: get converter for NamedPipeTransportSecurityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (mode);
+                       properties.Add (transport);
+               }
+
+               public NetNamedPipeSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("mode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Transport")]
+               public NetNamedPipeSecurityMode Mode {
+                       get { return (NetNamedPipeSecurityMode) base [mode]; }
+                       set { base [mode] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("transport",
+                        Options = ConfigurationPropertyOptions.None)]
+               public NamedPipeTransportSecurityElement Transport {
+                       get { return (NamedPipeTransportSecurityElement) base [transport]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetPeerTcpBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetPeerTcpBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..538308c
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// NetPeerTcpBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class NetPeerTcpBindingCollectionElement
+                : StandardBindingCollectionElement<NetPeerTcpBinding, NetPeerTcpBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static NetPeerTcpBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public NetPeerTcpBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetPeerTcpBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetPeerTcpBindingElement.cs
new file mode 100644 (file)
index 0000000..50509c4
--- /dev/null
@@ -0,0 +1,159 @@
+//
+// NetPeerTcpBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public partial class NetPeerTcpBindingElement
+                : StandardBindingElement,  IBindingConfigurationElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public NetPeerTcpBindingElement ()
+               {
+               }
+
+               public NetPeerTcpBindingElement (string name) : base (name) { }
+
+               // Properties
+
+               protected override Type BindingElementType {
+                       get { return typeof (NetPeerTcpBinding); }
+               }
+
+               [MonoTODO ("get converter for IPAddress")]
+               //[TypeConverter (typeof(IPAddressConverter))]
+               [ConfigurationProperty ("listenIPAddress",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = null)]
+               public IPAddress ListenIPAddress {
+                       get { return (IPAddress) this ["listenIPAddress"]; }
+                       set { this ["listenIPAddress"] = value; }
+               }
+
+               [ConfigurationProperty ("maxBufferPoolSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "524288")]
+               [LongValidator ( MinValue = 0,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               public long MaxBufferPoolSize {
+                       get { return (long) this ["maxBufferPoolSize"]; }
+                       set { this ["maxBufferPoolSize"] = value; }
+               }
+
+               [ConfigurationProperty ("maxReceivedMessageSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               [LongValidator ( MinValue = 16384,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               public long MaxReceivedMessageSize {
+                       get { return (long) this ["maxReceivedMessageSize"]; }
+                       set { this ["maxReceivedMessageSize"] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 0,
+                        MaxValue = 65535,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("port",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "0")]
+               public int Port {
+                       get { return (int) this ["port"]; }
+                       set { this ["port"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("listenIPAddress", typeof (IPAddress), null, null/* FIXME: get converter for IPAddress*/, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferPoolSize", typeof (long), "524288", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxReceivedMessageSize", typeof (long), "65536", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("port", typeof (int), "0", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("readerQuotas", typeof (XmlDictionaryReaderQuotasElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("resolver", typeof (PeerResolverElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("security", typeof (PeerSecurityElement), null, null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("readerQuotas",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlDictionaryReaderQuotasElement ReaderQuotas {
+                       get { return (XmlDictionaryReaderQuotasElement) this ["readerQuotas"]; }
+               }
+
+               [ConfigurationProperty ("resolver",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = null)]
+               public PeerResolverElement Resolver {
+                       get { return (PeerResolverElement) this ["resolver"]; }
+               }
+
+               [ConfigurationProperty ("security",
+                        Options = ConfigurationPropertyOptions.None)]
+               public PeerSecurityElement Security {
+                       get { return (PeerSecurityElement) this ["security"]; }
+               }
+
+
+
+               protected override void OnApplyConfiguration (Binding binding) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetTcpBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetTcpBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..4b3a8c3
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// NetTcpBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class NetTcpBindingCollectionElement
+                : StandardBindingCollectionElement<NetTcpBinding, NetTcpBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static NetTcpBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public NetTcpBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetTcpBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetTcpBindingElement.cs
new file mode 100644 (file)
index 0000000..65eb175
--- /dev/null
@@ -0,0 +1,217 @@
+//
+// NetTcpBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public partial class NetTcpBindingElement
+                : StandardBindingElement,  IBindingConfigurationElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public NetTcpBindingElement ()
+               {
+               }
+               public NetTcpBindingElement (string name) : base (name) { }
+
+
+               // Properties
+
+               protected override Type BindingElementType {
+                       get { return typeof (NetTcpBinding); }
+               }
+
+               [ConfigurationProperty ("hostNameComparisonMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "StrongWildcard")]
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return (HostNameComparisonMode) this ["hostNameComparisonMode"]; }
+                       set { this ["hostNameComparisonMode"] = value; }
+               }
+
+               [ConfigurationProperty ("listenBacklog",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10")]
+               [IntegerValidator ( MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int ListenBacklog {
+                       get { return (int) this ["listenBacklog"]; }
+                       set { this ["listenBacklog"] = value; }
+               }
+
+               [LongValidator ( MinValue = 0,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxBufferPoolSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "524288")]
+               public long MaxBufferPoolSize {
+                       get { return (long) this ["maxBufferPoolSize"]; }
+                       set { this ["maxBufferPoolSize"] = value; }
+               }
+
+               [ConfigurationProperty ("maxBufferSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               [IntegerValidator ( MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxBufferSize {
+                       get { return (int) this ["maxBufferSize"]; }
+                       set { this ["maxBufferSize"] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxConnections",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10")]
+               public int MaxConnections {
+                       get { return (int) this ["maxConnections"]; }
+                       set { this ["maxConnections"] = value; }
+               }
+
+               [LongValidator ( MinValue = 1,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxReceivedMessageSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               public long MaxReceivedMessageSize {
+                       get { return (long) this ["maxReceivedMessageSize"]; }
+                       set { this ["maxReceivedMessageSize"] = value; }
+               }
+
+               [ConfigurationProperty ("portSharingEnabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool PortSharingEnabled {
+                       get { return (bool) this ["portSharingEnabled"]; }
+                       set { this ["portSharingEnabled"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("hostNameComparisonMode", typeof (HostNameComparisonMode), "StrongWildcard", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("listenBacklog", typeof (int), "10", null, new IntegerValidator (1, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferPoolSize", typeof (long), "524288", null, new LongValidator (0, 9223372036854775807, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferSize", typeof (int), "65536", null, new IntegerValidator (1, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxConnections", typeof (int), "10", null, new IntegerValidator (1, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxReceivedMessageSize", typeof (long), "65536", null, new LongValidator (1, 9223372036854775807, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("portSharingEnabled", typeof (bool), "false", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("readerQuotas", typeof (XmlDictionaryReaderQuotasElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("reliableSession", typeof (StandardBindingOptionalReliableSessionElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("security", typeof (NetTcpSecurityElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("transactionFlow", typeof (bool), "false", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("transactionProtocol", typeof (TransactionProtocol), "OleTransactions", TransactionProtocolConverter.Instance, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("transferMode", typeof (TransferMode), "Buffered", null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("readerQuotas",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlDictionaryReaderQuotasElement ReaderQuotas {
+                       get { return (XmlDictionaryReaderQuotasElement) this ["readerQuotas"]; }
+               }
+
+               [ConfigurationProperty ("reliableSession",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StandardBindingOptionalReliableSessionElement ReliableSession {
+                       get { return (StandardBindingOptionalReliableSessionElement) this ["reliableSession"]; }
+               }
+
+               [ConfigurationProperty ("security",
+                        Options = ConfigurationPropertyOptions.None)]
+               public NetTcpSecurityElement Security {
+                       get { return (NetTcpSecurityElement) this ["security"]; }
+               }
+
+               [ConfigurationProperty ("transactionFlow",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool TransactionFlow {
+                       get { return (bool) this ["transactionFlow"]; }
+                       set { this ["transactionFlow"] = value; }
+               }
+
+               [TypeConverter (typeof (TransactionProtocolConverter))]
+               [ConfigurationProperty ("transactionProtocol",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "OleTransactions")]
+               public TransactionProtocol TransactionProtocol {
+                       get { return (TransactionProtocol) this ["transactionProtocol"]; }
+                       set { this ["transactionProtocol"] = value; }
+               }
+
+               [ConfigurationProperty ("transferMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Buffered")]
+               public TransferMode TransferMode {
+                       get { return (TransferMode) this ["transferMode"]; }
+                       set { this ["transferMode"] = value; }
+               }
+
+
+
+               protected override void OnApplyConfiguration (Binding binding) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetTcpSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NetTcpSecurityElement.cs
new file mode 100644 (file)
index 0000000..3a71877
--- /dev/null
@@ -0,0 +1,121 @@
+//
+// NetTcpSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class NetTcpSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty message;
+               static ConfigurationProperty mode;
+               static ConfigurationProperty transport;
+
+               static NetTcpSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       message = new ConfigurationProperty ("message",
+                               typeof (MessageSecurityOverTcpElement), null, null/* FIXME: get converter for MessageSecurityOverTcpElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       mode = new ConfigurationProperty ("mode",
+                               typeof (SecurityMode), "Transport", null/* FIXME: get converter for SecurityMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       transport = new ConfigurationProperty ("transport",
+                               typeof (TcpTransportSecurityElement), null, null/* FIXME: get converter for TcpTransportSecurityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (message);
+                       properties.Add (mode);
+                       properties.Add (transport);
+               }
+
+               public NetTcpSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("message",
+                        Options = ConfigurationPropertyOptions.None)]
+               public MessageSecurityOverTcpElement Message {
+                       get { return (MessageSecurityOverTcpElement) base [message]; }
+               }
+
+               [ConfigurationProperty ("mode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Transport")]
+               public SecurityMode Mode {
+                       get { return (SecurityMode) base [mode]; }
+                       set { base [mode] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("transport",
+                        Options = ConfigurationPropertyOptions.None)]
+               public TcpTransportSecurityElement Transport {
+                       get { return (TcpTransportSecurityElement) base [transport]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NonDualMessageSecurityOverHttpElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/NonDualMessageSecurityOverHttpElement.cs
new file mode 100644 (file)
index 0000000..cdb2d07
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// NonDualMessageSecurityOverHttpElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed partial class NonDualMessageSecurityOverHttpElement
+                : MessageSecurityOverHttpElement
+       {
+               // Properties
+
+               [ConfigurationProperty ("establishSecurityContext",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool EstablishSecurityContext {
+                       get { return (bool) base ["establishSecurityContext"]; }
+                       set { base ["establishSecurityContext"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/OneWayElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/OneWayElement.cs
new file mode 100644 (file)
index 0000000..4db3741
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// OneWayElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class OneWayElement
+                : BindingElementExtensionElement
+       {
+               public OneWayElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (OneWayBindingElement); }
+               }
+
+               [ConfigurationProperty ("channelPoolSettings",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ChannelPoolSettingsElement ChannelPoolSettings {
+                       get { return (ChannelPoolSettingsElement) base ["channelPoolSettings"]; }
+               }
+
+               [ConfigurationProperty ("maxAcceptedChannels",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10")]
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxAcceptedChannels {
+                       get { return (int) base ["maxAcceptedChannels"]; }
+                       set { base ["maxAcceptedChannels"] = value; }
+               }
+
+               [ConfigurationProperty ("packetRoutable",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool PacketRoutable {
+                       get { return (bool) base ["packetRoutable"]; }
+                       set { base ["packetRoutable"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerCredentialElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerCredentialElement.cs
new file mode 100644 (file)
index 0000000..c6d86dd
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// PeerCredentialElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class PeerCredentialElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty certificate;
+               static ConfigurationProperty message_sender_authentication;
+               static ConfigurationProperty peer_authentication;
+
+               static PeerCredentialElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       certificate = new ConfigurationProperty ("certificate",
+                               typeof (X509PeerCertificateElement), null, null/* FIXME: get converter for X509PeerCertificateElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       message_sender_authentication = new ConfigurationProperty ("messageSenderAuthentication",
+                               typeof (X509PeerCertificateAuthenticationElement), null, null/* FIXME: get converter for X509PeerCertificateAuthenticationElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       peer_authentication = new ConfigurationProperty ("peerAuthentication",
+                               typeof (X509PeerCertificateAuthenticationElement), null, null/* FIXME: get converter for X509PeerCertificateAuthenticationElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (certificate);
+                       properties.Add (message_sender_authentication);
+                       properties.Add (peer_authentication);
+               }
+
+               public PeerCredentialElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("certificate",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509PeerCertificateElement Certificate {
+                       get { return (X509PeerCertificateElement) base [certificate]; }
+               }
+
+               [ConfigurationProperty ("messageSenderAuthentication",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509PeerCertificateAuthenticationElement MessageSenderAuthentication {
+                       get { return (X509PeerCertificateAuthenticationElement) base [message_sender_authentication]; }
+               }
+
+               [ConfigurationProperty ("peerAuthentication",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509PeerCertificateAuthenticationElement PeerAuthentication {
+                       get { return (X509PeerCertificateAuthenticationElement) base [peer_authentication]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerCustomResolverElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerCustomResolverElement.cs
new file mode 100644 (file)
index 0000000..a0c585b
--- /dev/null
@@ -0,0 +1,172 @@
+//
+// PeerCustomResolverElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class PeerCustomResolverElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty address;
+               static ConfigurationProperty binding;
+               static ConfigurationProperty binding_configuration;
+               static ConfigurationProperty headers;
+               static ConfigurationProperty identity;
+               static ConfigurationProperty resolver_type;
+
+               static PeerCustomResolverElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       address = new ConfigurationProperty ("address",
+                               typeof (Uri), null, new UriTypeConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       binding = new ConfigurationProperty ("binding",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       binding_configuration = new ConfigurationProperty ("bindingConfiguration",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       headers = new ConfigurationProperty ("headers",
+                               typeof (AddressHeaderCollectionElement), null, null/* FIXME: get converter for AddressHeaderCollectionElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       identity = new ConfigurationProperty ("identity",
+                               typeof (IdentityElement), null, null/* FIXME: get converter for IdentityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       resolver_type = new ConfigurationProperty ("resolverType",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (address);
+                       properties.Add (binding);
+                       properties.Add (binding_configuration);
+                       properties.Add (headers);
+                       properties.Add (identity);
+                       properties.Add (resolver_type);
+               }
+
+               public PeerCustomResolverElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("address",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = null)]
+               public Uri Address {
+                       get { return (Uri) base [address]; }
+                       set { base [address] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("binding",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string Binding {
+                       get { return (string) base [binding]; }
+                       set { base [binding] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("bindingConfiguration",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string BindingConfiguration {
+                       get { return (string) base [binding_configuration]; }
+                       set { base [binding_configuration] = value; }
+               }
+
+               [ConfigurationProperty ("headers",
+                        Options = ConfigurationPropertyOptions.None)]
+               public AddressHeaderCollectionElement Headers {
+                       get { return (AddressHeaderCollectionElement) base [headers]; }
+               }
+
+               [ConfigurationProperty ("identity",
+                        Options = ConfigurationPropertyOptions.None)]
+               public IdentityElement Identity {
+                       get { return (IdentityElement) base [identity]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("resolverType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string ResolverType {
+                       get { return (string) base [resolver_type]; }
+                       set { base [resolver_type] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerResolverElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerResolverElement.cs
new file mode 100644 (file)
index 0000000..6da65f1
--- /dev/null
@@ -0,0 +1,123 @@
+//
+// PeerResolverElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class PeerResolverElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty custom;
+               static ConfigurationProperty mode;
+               static ConfigurationProperty referral_policy;
+
+               static PeerResolverElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       custom = new ConfigurationProperty ("custom",
+                               typeof (PeerCustomResolverElement), null, null/* FIXME: get converter for PeerCustomResolverElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       mode = new ConfigurationProperty ("mode",
+                               typeof (PeerResolverMode), "Auto", null/* FIXME: get converter for PeerResolverMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       referral_policy = new ConfigurationProperty ("referralPolicy",
+                               typeof (PeerReferralPolicy), "Service", null/* FIXME: get converter for PeerReferralPolicy*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (custom);
+                       properties.Add (mode);
+                       properties.Add (referral_policy);
+               }
+
+               public PeerResolverElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("custom",
+                        Options = ConfigurationPropertyOptions.None)]
+               public PeerCustomResolverElement Custom {
+                       get { return (PeerCustomResolverElement) base [custom]; }
+               }
+
+               [ConfigurationProperty ("mode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Auto")]
+               public PeerResolverMode Mode {
+                       get { return (PeerResolverMode) base [mode]; }
+                       set { base [mode] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("referralPolicy",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Service")]
+               public PeerReferralPolicy ReferralPolicy {
+                       get { return (PeerReferralPolicy) base [referral_policy]; }
+                       set { base [referral_policy] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerSecurityElement.cs
new file mode 100644 (file)
index 0000000..1fef36a
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// PeerSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class PeerSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty mode;
+               static ConfigurationProperty transport;
+
+               static PeerSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       mode = new ConfigurationProperty ("mode",
+                               typeof (SecurityMode), "Transport", null/* FIXME: get converter for SecurityMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       transport = new ConfigurationProperty ("transport",
+                               typeof (PeerTransportSecurityElement), null, null/* FIXME: get converter for PeerTransportSecurityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (mode);
+                       properties.Add (transport);
+               }
+
+               public PeerSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("mode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Transport")]
+               public SecurityMode Mode {
+                       get { return (SecurityMode) base [mode]; }
+                       set { base [mode] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("transport",
+                        Options = ConfigurationPropertyOptions.None)]
+               public PeerTransportSecurityElement Transport {
+                       get { return (PeerTransportSecurityElement) base [transport]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerTransportElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerTransportElement.cs
new file mode 100644 (file)
index 0000000..7eab194
--- /dev/null
@@ -0,0 +1,141 @@
+//
+// PeerTransportElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class PeerTransportElement
+                : BindingElementExtensionElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public PeerTransportElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (PeerTransportBindingElement); }
+               }
+
+               [TypeConverter (typeof (IPAddressConverter))]
+               [ConfigurationProperty ("listenIPAddress",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = null)]
+               public IPAddress ListenIPAddress {
+                       get { return (IPAddress) base ["listenIPAddress"]; }
+                       set { base ["listenIPAddress"] = value; }
+               }
+
+               [LongValidator (MinValue = 1,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxBufferPoolSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "524288")]
+               public long MaxBufferPoolSize {
+                       get { return (long) base ["maxBufferPoolSize"]; }
+                       set { base ["maxBufferPoolSize"] = value; }
+               }
+
+               [LongValidator (MinValue = 1,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxReceivedMessageSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               public long MaxReceivedMessageSize {
+                       get { return (long) base ["maxReceivedMessageSize"]; }
+                       set { base ["maxReceivedMessageSize"] = value; }
+               }
+
+               [ConfigurationProperty ("port",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "0")]
+               [IntegerValidator (MinValue = 0,
+                        MaxValue = 65535,
+                       ExcludeRange = false)]
+               public int Port {
+                       get { return (int) base ["port"]; }
+                       set { base ["port"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("listenIPAddress", typeof (IPAddress), null, new IPAddressConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferPoolSize", typeof (long), "524288", null, new LongValidator (1, 9223372036854775807, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxReceivedMessageSize", typeof (long), "65536", null, new LongValidator (1, 9223372036854775807, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("port", typeof (int), "0", null, new IntegerValidator (0, 65535, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("security", typeof (PeerSecurityElement), null, null/* FIXME: get converter for PeerSecurityElement*/, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("security",
+                        Options = ConfigurationPropertyOptions.None)]
+               public PeerSecurityElement Security {
+                       get { return (PeerSecurityElement) base ["security"]; }
+               }
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerTransportSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PeerTransportSecurityElement.cs
new file mode 100644 (file)
index 0000000..16d4b8b
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// PeerTransportSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class PeerTransportSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty credential_type;
+
+               static PeerTransportSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       credential_type = new ConfigurationProperty ("credentialType",
+                               typeof (PeerTransportCredentialType), "Password", null/* FIXME: get converter for PeerTransportCredentialType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (credential_type);
+               }
+
+               public PeerTransportSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("credentialType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Password")]
+               public PeerTransportCredentialType CredentialType {
+                       get { return (PeerTransportCredentialType) base [credential_type]; }
+                       set { base [credential_type] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PnrpPeerResolverElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PnrpPeerResolverElement.cs
new file mode 100644 (file)
index 0000000..5a09469
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// PnrpPeerResolverElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class PnrpPeerResolverElement
+                : BindingElementExtensionElement
+       {
+               public PnrpPeerResolverElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (PnrpPeerResolverBindingElement); }
+               }
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PolicyImporterElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PolicyImporterElement.cs
new file mode 100644 (file)
index 0000000..dccd3d5
--- /dev/null
@@ -0,0 +1,103 @@
+//
+// PolicyImporterElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class PolicyImporterElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty type;
+
+               static PolicyImporterElement () {
+                       properties = new ConfigurationPropertyCollection ();
+                       type = new ConfigurationProperty ("type",
+                               typeof (string), null, new StringConverter (), new StringValidator (1),
+                               ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
+
+                       properties.Add (type);
+               }
+
+               public PolicyImporterElement () {
+               }
+
+               public PolicyImporterElement (string type) {
+                       Type = type;
+               }
+
+               public PolicyImporterElement (Type type) {
+                       Type = type.AssemblyQualifiedName;
+               }
+
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("type",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               [StringValidator (MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Type {
+                       get { return (string) base [type]; }
+                       set { base [type] = value; }
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PolicyImporterElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PolicyImporterElementCollection.cs
new file mode 100644 (file)
index 0000000..36aca4c
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// PolicyImporterElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (PolicyImporterElement),
+                AddItemName = "extension",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       public sealed class PolicyImporterElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<PolicyImporterElement>, ICollection, IEnumerable
+       {
+               public PolicyImporterElementCollection () {
+                       AddElementName = "extension";
+               }
+
+               protected override object GetElementKey (ConfigurationElement element) {
+                       return ((PolicyImporterElement) element).Type;
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PolicyVersionConverter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PolicyVersionConverter.cs
new file mode 100644 (file)
index 0000000..8137ed6
--- /dev/null
@@ -0,0 +1,68 @@
+//\r
+// PolicyVersionConverter.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ComponentModel;\r
+using System.ServiceModel.Description;\r
+using System.Globalization;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       class PolicyVersionConverter : TypeConverter\r
+       {\r
+               public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType) {\r
+                       return sourceType == typeof (string);\r
+               }\r
+\r
+               public override object ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {\r
+                       string policyString = (string) value;\r
+                       switch (policyString.ToLower (CultureInfo.InvariantCulture)) {\r
+                       case "default":\r
+                               return PolicyVersion.Default;\r
+                       case "policy12":\r
+                               return PolicyVersion.Policy12;\r
+                       case "policy15":\r
+                               return PolicyVersion.Policy15;\r
+                       default:\r
+                               throw new ArgumentException ();\r
+                       }\r
+               }\r
+\r
+               public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {\r
+                       PolicyVersion policy = (PolicyVersion) value;\r
+                       if (policy == PolicyVersion.Policy12)\r
+                               return "Policy12";\r
+                       else if (policy == PolicyVersion.Policy15)\r
+                               return "Policy15";\r
+                       else\r
+                               return "Default";\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PrivacyNoticeElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/PrivacyNoticeElement.cs
new file mode 100644 (file)
index 0000000..f2a3025
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// PrivacyNoticeElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class PrivacyNoticeElement
+                : BindingElementExtensionElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public PrivacyNoticeElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof(PrivacyNoticeBindingElement); }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty ("url", typeof (Uri), null, new UriTypeConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("version", typeof (int), "0", null, new IntegerValidator (0, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("url",
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri Url {
+                       get { return (Uri) base ["url"]; }
+                       set { base ["url"] = value; }
+               }
+
+               [IntegerValidator (MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("version",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "0")]
+               public int Version {
+                       get { return (int) base ["version"]; }
+                       set { base ["version"] = value; }
+               }
+
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ReliableMessagingVersionConverter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ReliableMessagingVersionConverter.cs
new file mode 100644 (file)
index 0000000..bb9dfb0
--- /dev/null
@@ -0,0 +1,58 @@
+//\r
+// ReliableMessagingVersionConverter.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ComponentModel;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       class ReliableMessagingVersionConverter : TypeConverter\r
+       {\r
+               static readonly Dictionary<string, ReliableMessagingVersion> _lookup;\r
+\r
+               static ReliableMessagingVersionConverter () {\r
+                       _lookup = new Dictionary<string, ReliableMessagingVersion> (StringComparer.OrdinalIgnoreCase);\r
+                       _lookup.Add ("Default", ReliableMessagingVersion.Default);\r
+                       _lookup.Add ("WSReliableMessaging11", ReliableMessagingVersion.WSReliableMessaging11);\r
+                       _lookup.Add ("WSReliableMessagingFebruary2005", ReliableMessagingVersion.WSReliableMessagingFebruary2005);\r
+               }\r
+\r
+               public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType) {\r
+                       return sourceType == typeof (string);\r
+               }\r
+\r
+               public override object ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {\r
+                       string stringValue = (string) value;\r
+                       if (_lookup.ContainsKey (stringValue))\r
+                               return _lookup [stringValue];\r
+                       throw new ArgumentOutOfRangeException ();\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ReliableSessionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ReliableSessionElement.cs
new file mode 100644 (file)
index 0000000..dc241fe
--- /dev/null
@@ -0,0 +1,153 @@
+//
+// ReliableSessionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ReliableSessionElement
+                : BindingElementExtensionElement
+       {
+               public ReliableSessionElement () {
+               }
+
+               // Properties
+
+               [ConfigurationProperty ("acknowledgementInterval",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:00:00.2")]
+               public TimeSpan AcknowledgementInterval {
+                       get { return (TimeSpan) base ["acknowledgementInterval"]; }
+                       set { base ["acknowledgementInterval"] = value; }
+               }
+
+               public override Type BindingElementType {
+                       get { return typeof (ReliableSessionBindingElement); }
+               }
+
+               [ConfigurationProperty ("flowControlEnabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool FlowControlEnabled {
+                       get { return (bool) base ["flowControlEnabled"]; }
+                       set { base ["flowControlEnabled"] = value; }
+               }
+
+               [ConfigurationProperty ("inactivityTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:10:00")]
+               public TimeSpan InactivityTimeout {
+                       get { return (TimeSpan) base ["inactivityTimeout"]; }
+                       set { base ["inactivityTimeout"] = value; }
+               }
+
+               [ConfigurationProperty ("maxPendingChannels",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "4")]
+               [IntegerValidator (MinValue = 1,
+                        MaxValue = 16384,
+                       ExcludeRange = false)]
+               public int MaxPendingChannels {
+                       get { return (int) base ["maxPendingChannels"]; }
+                       set { base ["maxPendingChannels"] = value; }
+               }
+
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxRetryCount",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "8")]
+               public int MaxRetryCount {
+                       get { return (int) base ["maxRetryCount"]; }
+                       set { base ["maxRetryCount"] = value; }
+               }
+
+               [ConfigurationProperty ("maxTransferWindowSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "8")]
+               [IntegerValidator (MinValue = 1,
+                        MaxValue = 4096,
+                       ExcludeRange = false)]
+               public int MaxTransferWindowSize {
+                       get { return (int) this ["maxTransferWindowSize"]; }
+                       set { this ["maxTransferWindowSize"] = value; }
+               }
+
+               [ConfigurationProperty ("ordered",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool Ordered {
+                       get { return (bool) this ["ordered"]; }
+                       set { this ["ordered"] = value; }
+               }
+
+               [ConfigurationPropertyAttribute ("reliableMessagingVersion",
+                       DefaultValue = "WSReliableMessagingFebruary2005")]
+               [TypeConverter (typeof (ReliableMessagingVersionConverter))]
+               public ReliableMessagingVersion ReliableMessagingVersion {
+                       get { return (ReliableMessagingVersion) this ["reliableMessagingVersion"]; }
+                       set { this ["reliableMessagingVersion"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/RsaElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/RsaElement.cs
new file mode 100644 (file)
index 0000000..f257fdf
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// RsaElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class RsaElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty value;
+
+               static RsaElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       value = new ConfigurationProperty ("value",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (value);
+               }
+
+               public RsaElement ()
+               {
+               }
+
+
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("value",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string Value {
+                       get { return (string) base [value]; }
+                       set { base [value] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecureConversationServiceElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecureConversationServiceElement.cs
new file mode 100644 (file)
index 0000000..74ed5bd
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// SecureConversationServiceElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class SecureConversationServiceElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty security_state_encoder_type;
+
+               static SecureConversationServiceElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       security_state_encoder_type = new ConfigurationProperty ("securityStateEncoderType",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (security_state_encoder_type);
+               }
+
+               public SecureConversationServiceElement ()
+               {
+               }
+
+
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("securityStateEncoderType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string SecurityStateEncoderType {
+                       get { return (string) base [security_state_encoder_type]; }
+                       set { base [security_state_encoder_type] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecurityAlgorithmSuiteConverter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecurityAlgorithmSuiteConverter.cs
new file mode 100644 (file)
index 0000000..99f488a
--- /dev/null
@@ -0,0 +1,81 @@
+//\r
+// SecurityAlgorithmSuiteConverter.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ComponentModel;\r
+using System.ServiceModel.Security;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       sealed class SecurityAlgorithmSuiteConverter : TypeConverter\r
+       {\r
+               public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType) {\r
+                       return sourceType == typeof (string);\r
+               }\r
+\r
+               public override object ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {\r
+                       string strValue = (string) value;\r
+                       switch (strValue.ToLowerInvariant ()) {\r
+                       case "default":\r
+                               return SecurityAlgorithmSuite.Default;\r
+                       case "basic128":\r
+                               return SecurityAlgorithmSuite.Basic128;\r
+                       case "basic128rsa15":\r
+                               return SecurityAlgorithmSuite.Basic128Rsa15;\r
+                       case "basic128sha256":\r
+                               return SecurityAlgorithmSuite.Basic128Sha256;\r
+                       case "basic128sha256rsa15":\r
+                               return SecurityAlgorithmSuite.Basic128Sha256Rsa15;\r
+                       case "basic192":\r
+                               return SecurityAlgorithmSuite.Basic192;\r
+                       case "basic192rsa15":\r
+                               return SecurityAlgorithmSuite.Basic192Rsa15;\r
+                       case "basic192sha256":\r
+                               return SecurityAlgorithmSuite.Basic192Sha256;\r
+                       case "basic192sha256rsa15":\r
+                               return SecurityAlgorithmSuite.Basic192Sha256Rsa15;\r
+                       case "basic256":\r
+                               return SecurityAlgorithmSuite.Basic256;\r
+                       case "basic256rsa15":\r
+                               return SecurityAlgorithmSuite.Basic256Rsa15;\r
+                       case "basic256sha256":\r
+                               return SecurityAlgorithmSuite.Basic256Sha256;\r
+                       case "basic256sha256rsa15":\r
+                               return SecurityAlgorithmSuite.Basic256Sha256Rsa15;\r
+                       }\r
+                       throw new ArgumentException ();\r
+               }\r
+\r
+               public override object ConvertTo (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {\r
+                       return base.ConvertTo (context, culture, value, destinationType);\r
+               }\r
+\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecurityElement.cs
new file mode 100644 (file)
index 0000000..a362262
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// SecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class SecurityElement
+                : SecurityElementBase
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public SecurityElement () {
+               }
+
+
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("secureConversationBootstrap", typeof (SecurityElementBase), null, null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("secureConversationBootstrap",
+                        Options = ConfigurationPropertyOptions.None)]
+               public SecurityElementBase SecureConversationBootstrap {
+                       get { return (SecurityElementBase) base ["secureConversationBootstrap"]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecurityElementBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SecurityElementBase.cs
new file mode 100644 (file)
index 0000000..3358642
--- /dev/null
@@ -0,0 +1,212 @@
+//
+// SecurityElementBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class SecurityElementBase
+                : BindingElementExtensionElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public SecurityElementBase () {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("allowSerializedSigningTokenOnReply",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool AllowSerializedSigningTokenOnReply {
+                       get { return (bool) base ["allowSerializedSigningTokenOnReply"]; }
+                       set { base ["allowSerializedSigningTokenOnReply"] = value; }
+               }
+
+               [ConfigurationProperty ("authenticationMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "SspiNegotiated")]
+               public AuthenticationMode AuthenticationMode {
+                       get { return (AuthenticationMode) base ["authenticationMode"]; }
+                       set { base ["authenticationMode"] = value; }
+               }
+
+               public override Type BindingElementType {
+                       get { return typeof (SecurityBindingElement); }
+               }
+
+               [ConfigurationProperty ("defaultAlgorithmSuite",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Default")]
+               [TypeConverter (typeof (SecurityAlgorithmSuiteConverter))]
+               public SecurityAlgorithmSuite DefaultAlgorithmSuite {
+                       get { return (SecurityAlgorithmSuite) base ["defaultAlgorithmSuite"]; }
+                       set { base ["defaultAlgorithmSuite"] = value; }
+               }
+
+               [ConfigurationProperty ("includeTimestamp",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool IncludeTimestamp {
+                       get { return (bool) base ["includeTimestamp"]; }
+                       set { base ["includeTimestamp"] = value; }
+               }
+
+               [ConfigurationProperty ("issuedTokenParameters",
+                        Options = ConfigurationPropertyOptions.None)]
+               public IssuedTokenParametersElement IssuedTokenParameters {
+                       get { return (IssuedTokenParametersElement) base ["issuedTokenParameters"]; }
+               }
+
+               [ConfigurationProperty ("keyEntropyMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "CombinedEntropy")]
+               public SecurityKeyEntropyMode KeyEntropyMode {
+                       get { return (SecurityKeyEntropyMode) base ["keyEntropyMode"]; }
+                       set { base ["keyEntropyMode"] = value; }
+               }
+
+               [ConfigurationProperty ("localClientSettings",
+                        Options = ConfigurationPropertyOptions.None)]
+               public LocalClientSecuritySettingsElement LocalClientSettings {
+                       get { return (LocalClientSecuritySettingsElement) base ["localClientSettings"]; }
+               }
+
+               [ConfigurationProperty ("localServiceSettings",
+                        Options = ConfigurationPropertyOptions.None)]
+               public LocalServiceSecuritySettingsElement LocalServiceSettings {
+                       get { return (LocalServiceSecuritySettingsElement) base ["localServiceSettings"]; }
+               }
+
+               [ConfigurationProperty ("messageProtectionOrder",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "SignBeforeEncryptAndEncryptSignature")]
+               public MessageProtectionOrder MessageProtectionOrder {
+                       get { return (MessageProtectionOrder) base ["messageProtectionOrder"]; }
+                       set { base ["messageProtectionOrder"] = value; }
+               }
+
+               [ConfigurationProperty ("messageSecurityVersion",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Default")]
+               [TypeConverter (typeof (MessageSecurityVersionConverter))]
+               public MessageSecurityVersion MessageSecurityVersion {
+                       get { return (MessageSecurityVersion) base ["messageSecurityVersion"]; }
+                       set { base ["messageSecurityVersion"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty ("allowSerializedSigningTokenOnReply", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("authenticationMode", typeof (AuthenticationMode), "SspiNegotiated", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("defaultAlgorithmSuite", typeof (SecurityAlgorithmSuite), "Default", new SecurityAlgorithmSuiteConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("includeTimestamp", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("issuedTokenParameters", typeof (IssuedTokenParametersElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("keyEntropyMode", typeof (SecurityKeyEntropyMode), "CombinedEntropy", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("localClientSettings", typeof (LocalClientSecuritySettingsElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("localServiceSettings", typeof (LocalServiceSecuritySettingsElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("messageProtectionOrder", typeof (MessageProtectionOrder), "SignBeforeEncryptAndEncryptSignature", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("messageSecurityVersion", typeof (MessageSecurityVersion), "Default", new MessageSecurityVersionConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("requireDerivedKeys", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("requireSecurityContextCancellation", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("requireSignatureConfirmation", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("securityHeaderLayout", typeof (SecurityHeaderLayout), "Strict", null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("requireDerivedKeys",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool RequireDerivedKeys {
+                       get { return (bool) base ["requireDerivedKeys"]; }
+                       set { base ["requireDerivedKeys"] = value; }
+               }
+
+               [ConfigurationProperty ("requireSecurityContextCancellation",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool RequireSecurityContextCancellation {
+                       get { return (bool) base ["requireSecurityContextCancellation"]; }
+                       set { base ["requireSecurityContextCancellation"] = value; }
+               }
+
+               [ConfigurationProperty ("requireSignatureConfirmation",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool RequireSignatureConfirmation {
+                       get { return (bool) base ["requireSignatureConfirmation"]; }
+                       set { base ["requireSignatureConfirmation"] = value; }
+               }
+
+               [ConfigurationProperty ("securityHeaderLayout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Strict")]
+               public SecurityHeaderLayout SecurityHeaderLayout {
+                       get { return (SecurityHeaderLayout) base ["securityHeaderLayout"]; }
+                       set { base ["securityHeaderLayout"] = value; }
+               }
+
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceAuthorizationElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceAuthorizationElement.cs
new file mode 100644 (file)
index 0000000..8564ceb
--- /dev/null
@@ -0,0 +1,126 @@
+//
+// ServiceAuthorizationElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ServiceAuthorizationElement
+                : BehaviorExtensionElement
+       {
+               public ServiceAuthorizationElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("authorizationPolicies",
+                        Options = ConfigurationPropertyOptions.None)]
+               public AuthorizationPolicyTypeElementCollection AuthorizationPolicies {
+                       get { return (AuthorizationPolicyTypeElementCollection) base ["authorizationPolicies"]; }
+               }
+
+               public override Type BehaviorType {
+                       get { return typeof(ServiceAuthorizationBehavior); }
+               }
+
+               [ConfigurationProperty ("impersonateCallerForAllOperations",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool ImpersonateCallerForAllOperations {
+                       get { return (bool) base ["impersonateCallerForAllOperations"]; }
+                       set { base ["impersonateCallerForAllOperations"] = value; }
+               }
+
+               [ConfigurationProperty ("principalPermissionMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "UseWindowsGroups")]
+               public PrincipalPermissionMode PrincipalPermissionMode {
+                       get { return (PrincipalPermissionMode) base ["principalPermissionMode"]; }
+                       set { base ["principalPermissionMode"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("roleProviderName",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string RoleProviderName {
+                       get { return (string) base ["roleProviderName"]; }
+                       set { base ["roleProviderName"] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("serviceAuthorizationManagerType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string ServiceAuthorizationManagerType {
+                       get { return (string) base ["serviceAuthorizationManagerType"]; }
+                       set { base ["serviceAuthorizationManagerType"] = value; }
+               }
+
+               [MonoTODO]
+               protected internal override object CreateBehavior () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceBehaviorElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceBehaviorElement.cs
new file mode 100644 (file)
index 0000000..a6e1101
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// ServiceBehaviorElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+using System.Diagnostics;
+
+namespace System.ServiceModel.Configuration
+{
+       public class ServiceBehaviorElement
+                : NamedServiceModelExtensionCollectionElement<BehaviorExtensionElement>, ICollection<BehaviorExtensionElement>, IEnumerable<BehaviorExtensionElement>, IEnumerable
+       {
+               public ServiceBehaviorElement (string name) {
+                       Name = name;
+               }
+
+               public ServiceBehaviorElement () {
+               }
+
+               protected override void DeserializeElement (XmlReader reader, bool serializeCollectionKey) {
+                       base.DeserializeElement (reader, serializeCollectionKey);
+               }
+
+               [MonoTODO ("implement using EvaluationContext")]
+               internal override BehaviorExtensionElement DeserializeExtensionElement (string elementName, XmlReader reader) {
+                       //ExtensionElementCollection extensions = ((ExtensionsSection) EvaluationContext.GetSection ("system.serviceModel/extensions")).BehaviorExtensions;
+                       ExtensionElementCollection extensions = ConfigUtil.ExtensionsSection.BehaviorExtensions;
+
+                       ExtensionElement extension = extensions [elementName];
+                       if (extension == null)
+                               throw new ConfigurationErrorsException ("Invalid element in configuration. The extension name '" + reader.LocalName + "' is not registered in the collection at system.serviceModel/extensions/behaviorExtensions");
+
+                       BehaviorExtensionElement element = (BehaviorExtensionElement) Activator.CreateInstance (Type.GetType (extension.Type));
+                       element.DeserializeElementInternal (reader, false);
+                       return element;
+               }
+
+               public override void Add (BehaviorExtensionElement element) {
+                       base.Add (element);
+               }
+
+               public override bool CanAdd (BehaviorExtensionElement element) {
+                       return base.CanAdd (element);
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceBehaviorElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceBehaviorElementCollection.cs
new file mode 100644 (file)
index 0000000..c078c3f
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// ServiceBehaviorElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (ServiceBehaviorElement),
+                AddItemName = "behavior",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       public sealed class ServiceBehaviorElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ServiceBehaviorElement>,  ICollection,  IEnumerable
+       {
+               public ServiceBehaviorElementCollection ()
+               {
+                       AddElementName = "behavior";
+               }
+
+
+               // Properties
+               protected override object GetElementKey (ConfigurationElement element) {
+                       return ((ServiceBehaviorElement) element).Name;
+               }
+
+               protected override bool ThrowOnDuplicate {
+                       get { return true; }
+               }
+
+               internal ServiceBehaviorElement Find (string name) {
+                       foreach (ServiceBehaviorElement el in this)
+                               if (el.Name == name)
+                                       return el;
+                       return null;
+               }
+
+               [MonoTODO]
+               protected override void BaseAdd (ConfigurationElement element) {
+                       base.BaseAdd (element);
+               }
+
+               [MonoTODO]
+               protected override void DeserializeElement (
+                       XmlReader reader, bool serializeCollectionKey) {
+                       base.DeserializeElement (reader, serializeCollectionKey);
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceCredentialsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceCredentialsElement.cs
new file mode 100644 (file)
index 0000000..04c0885
--- /dev/null
@@ -0,0 +1,134 @@
+//
+// ServiceCredentialsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ServiceCredentialsElement
+                : BehaviorExtensionElement
+       {
+               public ServiceCredentialsElement () {
+               }
+
+
+               // Properties
+
+               public override Type BehaviorType {
+                       get { return typeof (ServiceCredentials); }
+               }
+
+               [ConfigurationProperty ("clientCertificate",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509InitiatorCertificateServiceElement ClientCertificate {
+                       get { return (X509InitiatorCertificateServiceElement) base ["clientCertificate"]; }
+               }
+
+               [ConfigurationProperty ("issuedTokenAuthentication",
+                        Options = ConfigurationPropertyOptions.None)]
+               public IssuedTokenServiceElement IssuedTokenAuthentication {
+                       get { return (IssuedTokenServiceElement) base ["issuedTokenAuthentication"]; }
+               }
+
+               [ConfigurationProperty ("peer",
+                        Options = ConfigurationPropertyOptions.None)]
+               public PeerCredentialElement Peer {
+                       get { return (PeerCredentialElement) base ["peer"]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("secureConversationAuthentication",
+                        Options = ConfigurationPropertyOptions.None)]
+               public SecureConversationServiceElement SecureConversationAuthentication {
+                       get { return (SecureConversationServiceElement) base ["secureConversationAuthentication"]; }
+               }
+
+               [ConfigurationProperty ("serviceCertificate",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509RecipientCertificateServiceElement ServiceCertificate {
+                       get { return (X509RecipientCertificateServiceElement) base ["serviceCertificate"]; }
+               }
+
+               [StringValidator (MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("type",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string Type {
+                       get { return (string) base ["type"]; }
+                       set { base ["type"] = value; }
+               }
+
+               [ConfigurationProperty ("userNameAuthentication",
+                        Options = ConfigurationPropertyOptions.None)]
+               public UserNameServiceElement UserNameAuthentication {
+                       get { return (UserNameServiceElement) base ["userNameAuthentication"]; }
+               }
+
+               [ConfigurationProperty ("windowsAuthentication",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WindowsServiceElement WindowsAuthentication {
+                       get { return (WindowsServiceElement) base ["windowsAuthentication"]; }
+               }
+
+               [MonoTODO]
+               protected internal override object CreateBehavior () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceDebugElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceDebugElement.cs
new file mode 100644 (file)
index 0000000..e42254b
--- /dev/null
@@ -0,0 +1,125 @@
+//
+// ServiceDebugElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ServiceDebugElement
+                : BehaviorExtensionElement
+       {
+               public ServiceDebugElement () {
+               }
+
+
+               // Properties
+
+               public override Type BehaviorType {
+                       get { return typeof (ServiceDebugBehavior); }
+               }
+
+               [ConfigurationProperty ("httpHelpPageEnabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool HttpHelpPageEnabled {
+                       get { return (bool) base ["httpHelpPageEnabled"]; }
+                       set { base ["httpHelpPageEnabled"] = value; }
+               }
+
+               [ConfigurationProperty ("httpHelpPageUrl",
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri HttpHelpPageUrl {
+                       get { return (Uri) base ["httpHelpPageUrl"]; }
+                       set { base ["httpHelpPageUrl"] = value; }
+               }
+
+               [ConfigurationProperty ("httpsHelpPageEnabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool HttpsHelpPageEnabled {
+                       get { return (bool) base ["httpsHelpPageEnabled"]; }
+                       set { base ["httpsHelpPageEnabled"] = value; }
+               }
+
+               [ConfigurationProperty ("httpsHelpPageUrl",
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri HttpsHelpPageUrl {
+                       get { return (Uri) base ["httpsHelpPageUrl"]; }
+                       set { base ["httpsHelpPageUrl"] = value; }
+               }
+
+               [ConfigurationProperty ("includeExceptionDetailInFaults",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool IncludeExceptionDetailInFaults {
+                       get { return (bool) base ["includeExceptionDetailInFaults"]; }
+                       set { base ["includeExceptionDetailInFaults"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               protected internal override object CreateBehavior () {
+                       return new ServiceDebugBehavior ()
+                       {
+                               HttpHelpPageEnabled = HttpHelpPageEnabled,
+                               HttpsHelpPageEnabled = HttpsHelpPageEnabled,
+                               HttpHelpPageUrl = HttpHelpPageUrl,
+                               HttpsHelpPageUrl = HttpsHelpPageUrl,
+                               IncludeExceptionDetailInFaults = IncludeExceptionDetailInFaults,
+                       };
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceElement.cs
new file mode 100644 (file)
index 0000000..ef84e0b
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// ServiceElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ServiceElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty behavior_configuration;
+               static ConfigurationProperty endpoints;
+               static ConfigurationProperty host;
+               static ConfigurationProperty name;
+
+               static ServiceElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       behavior_configuration = new ConfigurationProperty ("behaviorConfiguration",
+                               typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
+                               ConfigurationPropertyOptions.None);
+
+                       endpoints = new ConfigurationProperty ("",
+                               typeof (ServiceEndpointElementCollection), null, null, null,
+                               ConfigurationPropertyOptions.IsDefaultCollection);
+
+                       host = new ConfigurationProperty ("host",
+                               typeof (HostElement), null, null, null,
+                               ConfigurationPropertyOptions.None);
+
+                       name = new ConfigurationProperty ("name",
+                               typeof (string), null, new StringConverter (), new StringValidator (1, int.MaxValue, null),
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       properties.Add (behavior_configuration);
+                       properties.Add (endpoints);
+                       properties.Add (host);
+                       properties.Add (name);
+               }
+
+               public ServiceElement ()
+               {
+               }
+
+
+               // Properties
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("behaviorConfiguration",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string BehaviorConfiguration {
+                       get { return (string) base [behavior_configuration]; }
+                       set { base [behavior_configuration] = value; }
+               }
+
+               [ConfigurationProperty ("",
+                        Options = ConfigurationPropertyOptions.IsDefaultCollection,
+                       IsDefaultCollection = true)]
+               public ServiceEndpointElementCollection Endpoints {
+                       get { return (ServiceEndpointElementCollection) base [endpoints]; }
+               }
+
+               [ConfigurationProperty ("host",
+                        Options = ConfigurationPropertyOptions.None)]
+               public HostElement Host {
+                       get { return (HostElement) base [host]; }
+               }
+
+               [ConfigurationProperty ("name",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Name {
+                       get { return (string) base [name]; }
+                       set { base [name] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceElementCollection.cs
new file mode 100644 (file)
index 0000000..c63eb7f
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// ServiceElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (ServiceElement),
+                AddItemName = "service",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       public sealed class ServiceElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ServiceElement>,  ICollection,  IEnumerable
+       {
+
+               public ServiceElementCollection ()
+               {
+                       AddElementName = "service";
+               }
+
+               protected override object GetElementKey (ConfigurationElement element) {
+                       return ((ServiceElement) element).Name;
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceEndpointElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceEndpointElement.cs
new file mode 100644 (file)
index 0000000..8ae3569
--- /dev/null
@@ -0,0 +1,273 @@
+//
+// ServiceEndpointElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ServiceEndpointElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty address;
+               static ConfigurationProperty behavior_configuration;
+               static ConfigurationProperty binding;
+               static ConfigurationProperty binding_configuration;
+               static ConfigurationProperty binding_name;
+               static ConfigurationProperty binding_namespace;
+               static ConfigurationProperty contract;
+               static ConfigurationProperty headers;
+               static ConfigurationProperty identity;
+               static ConfigurationProperty listen_uri;
+               static ConfigurationProperty listen_uri_mode;
+               static ConfigurationProperty name;
+
+               static ServiceEndpointElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       address = new ConfigurationProperty ("address",
+                               typeof (Uri), "", new UriTypeConverter (), null,
+                               ConfigurationPropertyOptions.IsKey);
+
+                       behavior_configuration = new ConfigurationProperty ("behaviorConfiguration",
+                               typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
+                               ConfigurationPropertyOptions.None);
+
+                       binding = new ConfigurationProperty ("binding",
+                               typeof (string), null, new StringConverter (), new StringValidator (1, int.MaxValue, null),
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       binding_configuration = new ConfigurationProperty ("bindingConfiguration",
+                               typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
+                               ConfigurationPropertyOptions.IsKey);
+
+                       binding_name = new ConfigurationProperty ("bindingName",
+                               typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
+                               ConfigurationPropertyOptions.IsKey);
+
+                       binding_namespace = new ConfigurationProperty ("bindingNamespace",
+                               typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
+                               ConfigurationPropertyOptions.IsKey);
+
+                       contract = new ConfigurationProperty ("contract",
+                               typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
+                               ConfigurationPropertyOptions.IsKey);
+
+                       headers = new ConfigurationProperty ("headers",
+                               typeof (AddressHeaderCollectionElement), null, null, null,
+                               ConfigurationPropertyOptions.None);
+
+                       identity = new ConfigurationProperty ("identity",
+                               typeof (IdentityElement), null, null, null,
+                               ConfigurationPropertyOptions.None);
+
+                       listen_uri = new ConfigurationProperty ("listenUri",
+                               typeof (Uri), null, new UriTypeConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       listen_uri_mode = new ConfigurationProperty ("listenUriMode",
+                               typeof (ListenUriMode), "Explicit", null, null,
+                               ConfigurationPropertyOptions.None);
+
+                       name = new ConfigurationProperty ("name",
+                               typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (address);
+                       properties.Add (behavior_configuration);
+                       properties.Add (binding);
+                       properties.Add (binding_configuration);
+                       properties.Add (binding_name);
+                       properties.Add (binding_namespace);
+                       properties.Add (contract);
+                       properties.Add (headers);
+                       properties.Add (identity);
+                       properties.Add (listen_uri);
+                       properties.Add (listen_uri_mode);
+                       properties.Add (name);
+               }
+
+               public ServiceEndpointElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("address",
+                        Options = ConfigurationPropertyOptions.IsKey,
+                        DefaultValue = "",
+                       IsKey = true)]
+               public Uri Address {
+                       get { return (Uri) base [address]; }
+                       set { base [address] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("behaviorConfiguration",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string BehaviorConfiguration {
+                       get { return (string) base [behavior_configuration]; }
+                       set { base [behavior_configuration] = value; }
+               }
+
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("binding",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               public string Binding {
+                       get { return (string) base [binding]; }
+                       set { base [binding] = value; }
+               }
+
+               [ConfigurationProperty ("bindingConfiguration",
+                        Options = ConfigurationPropertyOptions.IsKey,
+                        DefaultValue = "",
+                       IsKey = true)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string BindingConfiguration {
+                       get { return (string) base [binding_configuration]; }
+                       set { base [binding_configuration] = value; }
+               }
+
+               [ConfigurationProperty ("bindingName",
+                        Options = ConfigurationPropertyOptions.IsKey,
+                        DefaultValue = "",
+                       IsKey = true)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string BindingName {
+                       get { return (string) base [binding_name]; }
+                       set { base [binding_name] = value; }
+               }
+
+               [ConfigurationProperty ("bindingNamespace",
+                        Options = ConfigurationPropertyOptions.IsKey,
+                        DefaultValue = "",
+                       IsKey = true)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string BindingNamespace {
+                       get { return (string) base [binding_namespace]; }
+                       set { base [binding_namespace] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("contract",
+                        Options = ConfigurationPropertyOptions.IsKey,
+                        DefaultValue = "",
+                       IsKey = true)]
+               public string Contract {
+                       get { return (string) base [contract]; }
+                       set { base [contract] = value; }
+               }
+
+               [ConfigurationProperty ("headers",
+                        Options = ConfigurationPropertyOptions.None)]
+               public AddressHeaderCollectionElement Headers {
+                       get { return (AddressHeaderCollectionElement) base [headers]; }
+               }
+
+               [ConfigurationProperty ("identity",
+                        Options = ConfigurationPropertyOptions.None)]
+               public IdentityElement Identity {
+                       get { return (IdentityElement) base [identity]; }
+               }
+
+               [ConfigurationProperty ("listenUri",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = null)]
+               public Uri ListenUri {
+                       get { return (Uri) base [listen_uri]; }
+                       set { base [listen_uri] = value; }
+               }
+
+               [ConfigurationProperty ("listenUriMode",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Explicit")]
+               public ListenUriMode ListenUriMode {
+                       get { return (ListenUriMode) base [listen_uri_mode]; }
+                       set { base [listen_uri_mode] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("name",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string Name {
+                       get { return (string) base [name]; }
+                       set { base [name] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceEndpointElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceEndpointElementCollection.cs
new file mode 100644 (file)
index 0000000..b5f5327
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// ServiceEndpointElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (ServiceEndpointElement),
+                AddItemName = "endpoint",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       public sealed class ServiceEndpointElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<ServiceEndpointElement>,  ICollection,  IEnumerable
+       {
+
+               public ServiceEndpointElementCollection ()
+               {
+                       AddElementName = "endpoint";
+               }
+
+               protected override object GetElementKey (ConfigurationElement element) {
+                       ServiceEndpointElement el = (ServiceEndpointElement) element;
+
+                       return el.Address + ";" +
+                               el.Binding.GetHashCode () + ";" +
+                               el.BindingConfiguration.GetHashCode () + ";" +
+                               el.BindingName.GetHashCode () + ";" +
+                               el.BindingNamespace.GetHashCode () + ";" +
+                               el.Contract.GetHashCode ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceHostingEnvironmentSection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceHostingEnvironmentSection.cs
new file mode 100644 (file)
index 0000000..14ce953
--- /dev/null
@@ -0,0 +1,127 @@
+//
+// ServiceHostingEnvironmentSection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class ServiceHostingEnvironmentSection
+                : ConfigurationSection
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty asp_net_compatibility_enabled;
+               static ConfigurationProperty min_free_memory_percentage_to_activate_service;
+               static ConfigurationProperty transport_configuration_types;
+
+               static ServiceHostingEnvironmentSection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       asp_net_compatibility_enabled = new ConfigurationProperty ("aspNetCompatibilityEnabled",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       min_free_memory_percentage_to_activate_service = new ConfigurationProperty ("minFreeMemoryPercentageToActivateService",
+                               typeof (int), "5", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       transport_configuration_types = new ConfigurationProperty ("",
+                               typeof (TransportConfigurationTypeElementCollection), null, null/* FIXME: get converter for TransportConfigurationTypeElementCollection*/, null,
+                               ConfigurationPropertyOptions.IsDefaultCollection);
+
+                       properties.Add (asp_net_compatibility_enabled);
+                       properties.Add (min_free_memory_percentage_to_activate_service);
+                       properties.Add (transport_configuration_types);
+               }
+
+               public ServiceHostingEnvironmentSection ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("aspNetCompatibilityEnabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool AspNetCompatibilityEnabled {
+                       get { return (bool) base [asp_net_compatibility_enabled]; }
+                       set { base [asp_net_compatibility_enabled] = value; }
+               }
+
+               [ConfigurationProperty ("minFreeMemoryPercentageToActivateService",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "5")]
+               [IntegerValidator ( MinValue = 0,
+                        MaxValue = 99,
+                       ExcludeRange = false)]
+               public int MinFreeMemoryPercentageToActivateService {
+                       get { return (int) base [min_free_memory_percentage_to_activate_service]; }
+                       set { base [min_free_memory_percentage_to_activate_service] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("",
+                        Options = ConfigurationPropertyOptions.IsDefaultCollection,
+                       IsDefaultCollection = true)]
+               public TransportConfigurationTypeElementCollection TransportConfigurationTypes {
+                       get { return (TransportConfigurationTypeElementCollection) base [transport_configuration_types]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceMetadataPublishingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceMetadataPublishingElement.cs
new file mode 100644 (file)
index 0000000..40d59d6
--- /dev/null
@@ -0,0 +1,125 @@
+//
+// ServiceMetadataPublishingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ServiceMetadataPublishingElement
+                : BehaviorExtensionElement
+       {
+
+               public override Type BehaviorType {
+                       get { return typeof (ServiceMetadataBehavior); }
+               }
+
+               [ConfigurationProperty ("externalMetadataLocation",
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri ExternalMetadataLocation {
+                       get { return (Uri) base ["externalMetadataLocation"]; }
+                       set { base ["externalMetadataLocation"] = value; }
+               }
+
+               [ConfigurationProperty ("httpGetEnabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool HttpGetEnabled {
+                       get { return (bool) base ["httpGetEnabled"]; }
+                       set { base ["httpGetEnabled"] = value; }
+               }
+
+               [ConfigurationProperty ("httpGetUrl",
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri HttpGetUrl {
+                       get { return (Uri) base ["httpGetUrl"]; }
+                       set { base ["httpGetUrl"] = value; }
+               }
+
+               [ConfigurationProperty ("httpsGetEnabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool HttpsGetEnabled {
+                       get { return (bool) base ["httpsGetEnabled"]; }
+                       set { base ["httpsGetEnabled"] = value; }
+               }
+
+               [ConfigurationProperty ("httpsGetUrl",
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri HttpsGetUrl {
+                       get { return (Uri) base ["httpsGetUrl"]; }
+                       set { base ["httpsGetUrl"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               protected internal override object CreateBehavior () {
+                       ServiceMetadataBehavior b = new ServiceMetadataBehavior ();
+                       b.HttpGetEnabled = HttpGetEnabled;
+                       b.HttpsGetEnabled = HttpsGetEnabled;
+                       b.HttpGetUrl = HttpGetUrl;
+                       b.HttpsGetUrl = HttpsGetUrl;
+                       return b;
+               }
+
+               [ConfigurationPropertyAttribute ("policyVersion",
+                       DefaultValue = "Default")]
+               [TypeConverter (typeof (PolicyVersionConverter))]
+               public PolicyVersion PolicyVersion {
+                       get { return (PolicyVersion) base ["policyVersion"]; }
+                       set { base ["policyVersion"] = value; }
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelConfigurationElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelConfigurationElementCollection.cs
new file mode 100644 (file)
index 0000000..5f3cac3
--- /dev/null
@@ -0,0 +1,117 @@
+//
+// ServiceModelConfigurationElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Configuration;
+
+namespace System.ServiceModel.Configuration
+{
+       public abstract class ServiceModelConfigurationElementCollection<ConfigurationElementType> : ConfigurationElementCollection
+               where ConfigurationElementType : ConfigurationElement, new()
+       {
+               internal ServiceModelConfigurationElementCollection ()
+                       : base (StringComparer.Ordinal)
+               {
+               }
+
+               public ConfigurationElementType this [int index] {
+                       get { return (ConfigurationElementType) base.BaseGet (index); }
+                       set { throw new NotImplementedException (); }
+               }
+
+               public virtual ConfigurationElementType this [object key] {
+                       get {
+                               return (ConfigurationElementType) BaseGet (key);
+                       }
+                       set {
+                               if (!GetElementKey(value).Equals (key))
+                                       throw new ArgumentException (String.Format ("The key '{0}' does not match the element key '{1}'", key, GetElementKey(value)));
+                               Add (value);
+                       }
+               }
+
+               public override ConfigurationElementCollectionType CollectionType {
+                       get { return ConfigurationElementCollectionType.AddRemoveClearMap; }
+               }
+
+               protected override string ElementName {
+                       get {
+                               return AddElementName;
+                       }
+               }
+
+               public void Add (ConfigurationElementType element)
+               {
+                       BaseAdd (element);
+               }
+
+               protected override void BaseAdd (ConfigurationElement element)
+               {
+                       BaseAdd (element, false);
+               }
+
+               public void Clear ()
+               {
+                       BaseClear ();
+               }
+
+               public virtual bool ContainsKey (object key)
+               {
+                       return BaseGet (key) != null;
+               }
+
+               protected override ConfigurationElement CreateNewElement ()
+               {
+                       return (ConfigurationElement) Activator.CreateInstance (typeof (ConfigurationElementType), new object [0]);
+               }
+
+               public void CopyTo (ConfigurationElementType [] array, int index)
+               {
+                       base.CopyTo (array, index);
+               }
+
+               public int IndexOf (ConfigurationElementType item)
+               {
+                       return BaseIndexOf (item);
+               }
+
+               public void Remove (ConfigurationElementType item)
+               {
+                       BaseRemove (GetElementKey (item));
+               }
+
+               public void RemoveAt (int index)
+               {
+                       BaseRemoveAt (index);
+               }
+
+               public void RemoveAt (object index)
+               {
+                       BaseRemove (index);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelEnhancedConfigurationElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelEnhancedConfigurationElementCollection.cs
new file mode 100644 (file)
index 0000000..1663108
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// ServiceModelEnhancedConfigurationElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public abstract class ServiceModelEnhancedConfigurationElementCollection<TConfigurationElement>
+                : ServiceModelConfigurationElementCollection<TConfigurationElement>,  ICollection,  IEnumerable
+               where TConfigurationElement : ConfigurationElement, new()
+       {
+               // Properties
+               [MonoTODO]
+               protected override bool ThrowOnDuplicate {
+                       get { return base.ThrowOnDuplicate; }
+               }
+
+               [MonoTODO]
+               protected override void BaseAdd (ConfigurationElement element) {
+                       base.BaseAdd (element);
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelExtensionCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelExtensionCollectionElement.cs
new file mode 100644 (file)
index 0000000..f9cd1bd
--- /dev/null
@@ -0,0 +1,132 @@
+//
+// ServiceModelExtensionCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Configuration;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public class ServiceModelExtensionCollectionElement<TServiceModelExtensionElement> 
+               : ConfigurationElement,
+               ICollection<TServiceModelExtensionElement>,
+               IEnumerable<TServiceModelExtensionElement>, 
+               IEnumerable
+               where TServiceModelExtensionElement : ServiceModelExtensionElement
+       {
+               KeyedByTypeCollection<TServiceModelExtensionElement> _list = new KeyedByTypeCollection<TServiceModelExtensionElement> ();
+
+               public virtual void Add (TServiceModelExtensionElement element)
+               {
+                       _list.Add (element);
+               }
+               
+               public virtual bool CanAdd (TServiceModelExtensionElement element) {
+                       throw new NotImplementedException ();
+               }
+
+               public void Clear ()
+               {
+                       _list.Clear ();
+               }
+
+               public bool Contains (TServiceModelExtensionElement element)
+               {
+                       return _list.Contains (element);
+               }
+
+               public bool ContainsKey (string elementName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool ContainsKey (Type elementType)
+               {
+                       return _list.Contains (elementType);
+               }
+
+               public void CopyTo (TServiceModelExtensionElement[] elements,
+                       int start)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public IEnumerator<TServiceModelExtensionElement> GetEnumerator () {
+                       for (int i = 0; i < Count; i++)
+                               yield return this [i];
+               }
+
+               public bool Remove (TServiceModelExtensionElement element) {
+                       return _list.Remove (element.GetType ());
+               }
+
+               IEnumerator IEnumerable.GetEnumerator ()
+               {
+                       return GetEnumerator ();
+               }
+
+               bool ICollection<TServiceModelExtensionElement>.IsReadOnly {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public TServiceModelExtensionElement this [int index] {
+                       get {
+                               return _list [index];
+                       }
+               }
+
+               public TServiceModelExtensionElement this [Type extensionType] {
+                       get {
+                               if (_list.Contains (extensionType))
+                                       return _list [extensionType];
+                               return null;
+                       }
+               }
+
+               protected override void DeserializeElement (System.Xml.XmlReader reader, bool serializeCollectionKey) {
+                       base.DeserializeElement (reader, serializeCollectionKey);
+               }
+
+               protected override bool OnDeserializeUnrecognizedElement (string elementName, System.Xml.XmlReader reader) {
+                       TServiceModelExtensionElement ext= DeserializeExtensionElement (elementName, reader);
+                       if (ext == null)
+                               return false;
+                       Add (ext);
+                       return true;
+               }
+
+               internal virtual TServiceModelExtensionElement DeserializeExtensionElement (string elementName, System.Xml.XmlReader reader) {
+                       return null;
+               }
+
+               public int Count {
+                       get { return _list.Count; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelExtensionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelExtensionElement.cs
new file mode 100644 (file)
index 0000000..18d531e
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// ServiceModelExtensionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public abstract class ServiceModelExtensionElement
+                : ConfigurationElement
+       {
+               string _configurationElementName;
+
+               protected ServiceModelExtensionElement () {
+               }
+
+               public string ConfigurationElementName {
+                       get {
+                               return _configurationElementName ?? (_configurationElementName = GetConfigurationElementName ());
+                       }
+               }
+
+               internal virtual string GetConfigurationElementName () {
+                       throw new NotImplementedException ();
+               }
+
+               public virtual void CopyFrom (ServiceModelExtensionElement from) {
+                       throw new NotImplementedException ();
+               }
+
+               protected override bool IsModified () {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void Reset (ConfigurationElement parentElement) {
+                       throw new NotImplementedException ();
+               }
+
+               protected override bool SerializeElement (XmlWriter writer, bool serializeCollectionKey) {
+                       throw new NotImplementedException ();
+               }
+
+               internal void DeserializeElementInternal (XmlReader reader, bool serializeCollectionKey) {
+                       DeserializeElement (reader, serializeCollectionKey);
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelSectionGroup.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceModelSectionGroup.cs
new file mode 100644 (file)
index 0000000..b9c5433
--- /dev/null
@@ -0,0 +1,82 @@
+//
+// ServiceModelSectionGroup.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Configuration;
+
+using ConfigurationType = System.Configuration.Configuration;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ServiceModelSectionGroup : ConfigurationSectionGroup
+       {
+               public static ServiceModelSectionGroup GetSectionGroup (
+                       ConfigurationType config)
+               {
+                       ServiceModelSectionGroup ret = (ServiceModelSectionGroup) config.GetSectionGroup ("system.serviceModel");
+                       if (ret == null)
+                               throw new SystemException ("Internal configuration error: section 'system.serviceModel' was not found.");
+                       return ret;
+               }
+
+               public ServiceModelSectionGroup ()
+               {
+               }
+
+               public BehaviorsSection Behaviors {
+                       get { return (BehaviorsSection) Sections ["behaviors"]; }
+               }
+
+               public BindingsSection Bindings {
+                       get { return (BindingsSection) Sections ["bindings"]; }
+               }
+
+               public ClientSection Client {
+                       get { return (ClientSection) Sections ["client"]; }
+               }
+
+               public CommonBehaviorsSection CommonBehaviors {
+                       get { return (CommonBehaviorsSection) Sections ["commonBehaviors"]; }
+               }
+
+               public DiagnosticSection Diagnostic {
+                       get { return (DiagnosticSection) Sections ["diagnostics"]; }
+               }
+
+               public ExtensionsSection Extensions {
+                       get { return (ExtensionsSection) Sections ["extensions"]; }
+               }
+
+               public ServiceHostingEnvironmentSection ServiceHostingEnvironment {
+                       get { return (ServiceHostingEnvironmentSection) Sections ["serviceHostingEnvironment"]; }
+               }
+
+               public ServicesSection Services {
+                       get { return (ServicesSection) Sections ["services"]; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServicePrincipalNameElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServicePrincipalNameElement.cs
new file mode 100644 (file)
index 0000000..888fded
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// ServicePrincipalNameElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class ServicePrincipalNameElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty value;
+
+               static ServicePrincipalNameElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       value = new ConfigurationProperty ("value",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (value);
+               }
+
+               public ServicePrincipalNameElement ()
+               {
+               }
+
+
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("value",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "")]
+               public string Value {
+                       get { return (string) base [value]; }
+                       set { base [value] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceSecurityAuditElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceSecurityAuditElement.cs
new file mode 100644 (file)
index 0000000..1599ba7
--- /dev/null
@@ -0,0 +1,113 @@
+//
+// ServiceSecurityAuditElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ServiceSecurityAuditElement
+                : BehaviorExtensionElement
+       {
+               public ServiceSecurityAuditElement () {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("auditLogLocation",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Default")]
+               public AuditLogLocation AuditLogLocation {
+                       get { return (AuditLogLocation) base ["auditLogLocation"]; }
+                       set { base ["auditLogLocation"] = value; }
+               }
+
+               public override Type BehaviorType {
+                       get { return typeof (ServiceSecurityAuditBehavior); }
+               }
+
+               [ConfigurationProperty ("messageAuthenticationAuditLevel",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "None")]
+               public AuditLevel MessageAuthenticationAuditLevel {
+                       get { return (AuditLevel) base ["messageAuthenticationAuditLevel"]; }
+                       set { base ["messageAuthenticationAuditLevel"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("serviceAuthorizationAuditLevel",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "None")]
+               public AuditLevel ServiceAuthorizationAuditLevel {
+                       get { return (AuditLevel) base ["serviceAuthorizationAuditLevel"]; }
+                       set { base ["serviceAuthorizationAuditLevel"] = value; }
+               }
+
+               [ConfigurationProperty ("suppressAuditFailure",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool SuppressAuditFailure {
+                       get { return (bool) base ["suppressAuditFailure"]; }
+                       set { base ["suppressAuditFailure"] = value; }
+               }
+
+               [MonoTODO]
+               protected internal override object CreateBehavior () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceThrottlingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceThrottlingElement.cs
new file mode 100644 (file)
index 0000000..00fcdc8
--- /dev/null
@@ -0,0 +1,114 @@
+//
+// ServiceThrottlingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ServiceThrottlingElement
+                : BehaviorExtensionElement
+       {
+               public ServiceThrottlingElement () {
+               }
+
+
+               // Properties
+
+               public override Type BehaviorType {
+                       get { return typeof (ServiceThrottlingBehavior); }
+               }
+
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxConcurrentCalls",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "16")]
+               public int MaxConcurrentCalls {
+                       get { return (int) base ["maxConcurrentCalls"]; }
+                       set { base ["maxConcurrentCalls"] = value; }
+               }
+
+               [ConfigurationProperty ("maxConcurrentInstances",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = 26)]
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxConcurrentInstances {
+                       get { return (int) base ["maxConcurrentInstances"]; }
+                       set { base ["maxConcurrentInstances"] = value; }
+               }
+
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxConcurrentSessions",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10")]
+               public int MaxConcurrentSessions {
+                       get { return (int) base ["maxConcurrentSessions"]; }
+                       set { base ["maxConcurrentSessions"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [MonoTODO]
+               protected internal override object CreateBehavior () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceTimeoutsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServiceTimeoutsElement.cs
new file mode 100644 (file)
index 0000000..4ab1968
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// ServiceTimeoutsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ServiceTimeoutsElement
+                : BehaviorExtensionElement
+       {
+               public ServiceTimeoutsElement () {
+               }
+
+
+               // Properties
+
+               public override Type BehaviorType {
+                       get { return typeof (ServiceTimeoutsBehavior); }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("transactionTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:00:00")]
+               public TimeSpan TransactionTimeout {
+                       get { return (TimeSpan) base ["transactionTimeout"]; }
+                       set { base ["transactionTimeout"] = value; }
+               }
+
+               protected internal override object CreateBehavior () {
+                       return new ServiceTimeoutsBehavior (TransactionTimeout);
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServicesSection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/ServicesSection.cs
new file mode 100644 (file)
index 0000000..dbc6502
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// ServicesSection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class ServicesSection
+                : ConfigurationSection
+       {
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("",
+                        Options = ConfigurationPropertyOptions.IsDefaultCollection,
+                       IsDefaultCollection = true)]
+               public ServiceElementCollection Services {
+                       get { return (ServiceElementCollection) base [String.Empty]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SslStreamSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SslStreamSecurityElement.cs
new file mode 100644 (file)
index 0000000..d96e88a
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// SslStreamSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class SslStreamSecurityElement
+                : BindingElementExtensionElement
+       {
+
+               public SslStreamSecurityElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (SslStreamSecurityBindingElement); }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("requireClientCertificate",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool RequireClientCertificate {
+                       get { return (bool) base ["requireClientCertificate"]; }
+                       set { base ["requireClientCertificate"] = value; }
+               }
+
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..fd75d55
--- /dev/null
@@ -0,0 +1,111 @@
+//
+// StandardBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class StandardBindingCollectionElement<TStandardBinding,TBindingConfiguration>
+                : BindingCollectionElement
+               where TStandardBinding : Binding
+               where TBindingConfiguration : StandardBindingElement, new()
+       {
+               ConfigurationPropertyCollection _properties;
+
+               // Properties
+
+               [ConfigurationProperty ("",
+                        Options = ConfigurationPropertyOptions.IsDefaultCollection,
+                       IsDefaultCollection = true)]
+               public StandardBindingElementCollection<TBindingConfiguration> Bindings {
+                       get { return (StandardBindingElementCollection<TBindingConfiguration>) this [String.Empty]; }
+               }
+
+               public override ReadOnlyCollection<IBindingConfigurationElement> ConfiguredBindings {
+                       get {
+                               List<IBindingConfigurationElement> list = new List<IBindingConfigurationElement> ();
+                               StandardBindingElementCollection<TBindingConfiguration> bindings = Bindings;
+                               for (int i = 0; i < bindings.Count; i++)
+                                       list.Add (bindings [i]);
+                               return new ReadOnlyCollection<IBindingConfigurationElement> (list);
+                       }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty (String.Empty, typeof (StandardBindingElementCollection<TBindingConfiguration>), null, null, null, ConfigurationPropertyOptions.IsDefaultCollection));
+                               }
+                               return _properties;
+                       }
+               }
+
+               public override Type BindingType {
+                       get { return typeof (TStandardBinding); }
+               }
+
+
+               public override bool ContainsKey (string name) {
+                       throw new NotImplementedException ();
+               }
+
+               protected internal override Binding GetDefault () {
+                       throw new NotImplementedException ();
+               }
+
+               protected internal override bool TryAdd (string name, Binding binding, System.Configuration.Configuration config) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingElement.cs
new file mode 100644 (file)
index 0000000..d3bf240
--- /dev/null
@@ -0,0 +1,143 @@
+//
+// StandardBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public abstract class StandardBindingElement
+                : ConfigurationElement,  IBindingConfigurationElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               protected StandardBindingElement ()
+               {
+               }
+               
+               protected StandardBindingElement (string name) {
+                       Name = name;
+               }
+
+
+               // Properties
+               protected abstract Type BindingElementType { get;  }
+
+               [ConfigurationProperty ("closeTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:01:00")]
+               public TimeSpan CloseTimeout {
+                       get { return (TimeSpan) this ["closeTimeout"]; }
+                       set { this ["closeTimeout"] = value; }
+               }
+
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("name",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               public string Name {
+                       get { return (string) this ["name"]; }
+                       set { this ["name"] = value; }
+               }
+
+               [ConfigurationProperty ("openTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:01:00")]
+               public TimeSpan OpenTimeout {
+                       get { return (TimeSpan) this ["openTimeout"]; }
+                       set { this ["openTimeout"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty ("closeTimeout", typeof (TimeSpan), "00:01:00", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("name", typeof (string), null, null, new StringValidator (1), ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey));
+                                       _properties.Add (new ConfigurationProperty ("openTimeout", typeof (TimeSpan), "00:01:00", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("receiveTimeout", typeof (TimeSpan), "00:10:00", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("sendTimeout", typeof (TimeSpan), "00:01:00", null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("receiveTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:10:00")]
+               public TimeSpan ReceiveTimeout {
+                       get { return (TimeSpan) this ["receiveTimeout"]; }
+                       set { this ["receiveTimeout"] = value; }
+               }
+
+               [ConfigurationProperty ("sendTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:01:00")]
+               public TimeSpan SendTimeout {
+                       get { return (TimeSpan) this ["sendTimeout"]; }
+                       set { this ["sendTimeout"] = value; }
+               }
+
+               protected abstract void OnApplyConfiguration (Binding binding);
+               
+               public void ApplyConfiguration (Binding binding) {
+                       binding.CloseTimeout = CloseTimeout;
+                       binding.OpenTimeout = OpenTimeout;
+                       binding.ReceiveTimeout = ReceiveTimeout;
+                       binding.SendTimeout = SendTimeout;
+                       OnApplyConfiguration (binding);
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingElementCollection.cs
new file mode 100644 (file)
index 0000000..387b3ee
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// StandardBindingElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class StandardBindingElementCollection<TBindingConfiguration>
+                : ServiceModelEnhancedConfigurationElementCollection<TBindingConfiguration>,  ICollection,  IEnumerable
+               where TBindingConfiguration : StandardBindingElement, new()
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static StandardBindingElementCollection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public StandardBindingElementCollection ()
+               {
+                       AddElementName = "binding";
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingOptionalReliableSessionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingOptionalReliableSessionElement.cs
new file mode 100644 (file)
index 0000000..e87e659
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// StandardBindingOptionalReliableSessionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class StandardBindingOptionalReliableSessionElement
+                : StandardBindingReliableSessionElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty enabled;
+
+               static StandardBindingOptionalReliableSessionElement ()
+               {
+                       properties = StandardBindingReliableSessionElement.CreateBaseProperties ();
+                       enabled = new ConfigurationProperty ("enabled",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (enabled);
+               }
+
+               public StandardBindingOptionalReliableSessionElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("enabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool Enabled {
+                       get { return (bool) base [enabled]; }
+                       set { base [enabled] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingReliableSessionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/StandardBindingReliableSessionElement.cs
new file mode 100644 (file)
index 0000000..ce9d811
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// StandardBindingReliableSessionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class StandardBindingReliableSessionElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty inactivity_timeout;
+               static ConfigurationProperty ordered;
+
+               internal static ConfigurationPropertyCollection CreateBaseProperties () {
+                       ConfigurationPropertyCollection baseProperties = new ConfigurationPropertyCollection ();
+                       foreach (ConfigurationProperty prop in properties)
+                               baseProperties.Add (prop);
+                       return baseProperties;
+               }
+
+               static StandardBindingReliableSessionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       inactivity_timeout = new ConfigurationProperty ("inactivityTimeout",
+                               typeof (TimeSpan), "00:10:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       ordered = new ConfigurationProperty ("ordered",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (inactivity_timeout);
+                       properties.Add (ordered);
+               }
+
+               public StandardBindingReliableSessionElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("inactivityTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:10:00")]
+               public TimeSpan InactivityTimeout {
+                       get { return (TimeSpan) base [inactivity_timeout]; }
+                       set { base [inactivity_timeout] = value; }
+               }
+
+               [ConfigurationProperty ("ordered",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = true)]
+               public bool Ordered {
+                       get { return (bool) base [ordered]; }
+                       set { base [ordered] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SynchronousReceiveElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/SynchronousReceiveElement.cs
new file mode 100644 (file)
index 0000000..faa4f68
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// SynchronousReceiveElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class SynchronousReceiveElement
+                : BehaviorExtensionElement
+       {
+               // Properties
+
+               public override Type BehaviorType {
+                       get { return typeof (SynchronousReceiveBehavior); }
+               }
+
+               protected internal override object CreateBehavior () {
+                       return new SynchronousReceiveBehavior ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TcpConnectionPoolSettingsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TcpConnectionPoolSettingsElement.cs
new file mode 100644 (file)
index 0000000..c5509bb
--- /dev/null
@@ -0,0 +1,145 @@
+//
+// TcpConnectionPoolSettingsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class TcpConnectionPoolSettingsElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty group_name;
+               static ConfigurationProperty idle_timeout;
+               static ConfigurationProperty lease_timeout;
+               static ConfigurationProperty max_outbound_connections_per_endpoint;
+
+               static TcpConnectionPoolSettingsElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       group_name = new ConfigurationProperty ("groupName",
+                               typeof (string), "default", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       idle_timeout = new ConfigurationProperty ("idleTimeout",
+                               typeof (TimeSpan), "00:02:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       lease_timeout = new ConfigurationProperty ("leaseTimeout",
+                               typeof (TimeSpan), "00:05:00", null/* FIXME: get converter for TimeSpan*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_outbound_connections_per_endpoint = new ConfigurationProperty ("maxOutboundConnectionsPerEndpoint",
+                               typeof (int), "10", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (group_name);
+                       properties.Add (idle_timeout);
+                       properties.Add (lease_timeout);
+                       properties.Add (max_outbound_connections_per_endpoint);
+               }
+
+               public TcpConnectionPoolSettingsElement ()
+               {
+               }
+
+
+               // Properties
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("groupName",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "default")]
+               public string GroupName {
+                       get { return (string) base [group_name]; }
+                       set { base [group_name] = value; }
+               }
+
+               [ConfigurationProperty ("idleTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:02:00")]
+               public TimeSpan IdleTimeout {
+                       get { return (TimeSpan) base [idle_timeout]; }
+                       set { base [idle_timeout] = value; }
+               }
+
+               [ConfigurationProperty ("leaseTimeout",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "00:05:00")]
+               public TimeSpan LeaseTimeout {
+                       get { return (TimeSpan) base [lease_timeout]; }
+                       set { base [lease_timeout] = value; }
+               }
+
+               [ConfigurationProperty ("maxOutboundConnectionsPerEndpoint",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10")]
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxOutboundConnectionsPerEndpoint {
+                       get { return (int) base [max_outbound_connections_per_endpoint]; }
+                       set { base [max_outbound_connections_per_endpoint] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TcpTransportElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TcpTransportElement.cs
new file mode 100644 (file)
index 0000000..c75adfb
--- /dev/null
@@ -0,0 +1,127 @@
+//
+// TcpTransportElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class TcpTransportElement
+                : ConnectionOrientedTransportElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public TcpTransportElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (TcpTransportBindingElement); }
+               }
+
+               [ConfigurationProperty ("connectionPoolSettings",
+                        Options = ConfigurationPropertyOptions.None)]
+               public TcpConnectionPoolSettingsElement ConnectionPoolSettings {
+                       get { return (TcpConnectionPoolSettingsElement) base ["connectionPoolSettings"]; }
+                       set { base ["connectionPoolSettings"] = value; }
+               }
+
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("listenBacklog",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "10")]
+               public int ListenBacklog {
+                       get { return (int) base ["listenBacklog"]; }
+                       set { base ["listenBacklog"] = value; }
+               }
+
+               [ConfigurationProperty ("portSharingEnabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool PortSharingEnabled {
+                       get { return (bool) base ["portSharingEnabled"]; }
+                       set { base ["portSharingEnabled"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("connectionPoolSettings", typeof (TcpConnectionPoolSettingsElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("listenBacklog", typeof (int), "10", null, new IntegerValidator (1, int.MaxValue, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("portSharingEnabled", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("teredoEnabled", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("teredoEnabled",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool TeredoEnabled {
+                       get { return (bool) base ["teredoEnabled"]; }
+                       set { base ["teredoEnabled"] = value; }
+               }
+
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TcpTransportSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TcpTransportSecurityElement.cs
new file mode 100644 (file)
index 0000000..21fd7ce
--- /dev/null
@@ -0,0 +1,111 @@
+//
+// TcpTransportSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class TcpTransportSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty client_credential_type;
+               static ConfigurationProperty protection_level;
+
+               static TcpTransportSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       client_credential_type = new ConfigurationProperty ("clientCredentialType",
+                               typeof (TcpClientCredentialType), "Windows", null/* FIXME: get converter for TcpClientCredentialType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       protection_level = new ConfigurationProperty ("protectionLevel",
+                               typeof (ProtectionLevel), "EncryptAndSign", null/* FIXME: get converter for ProtectionLevel*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (client_credential_type);
+                       properties.Add (protection_level);
+               }
+
+               public TcpTransportSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("clientCredentialType",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Windows")]
+               public TcpClientCredentialType ClientCredentialType {
+                       get { return (TcpClientCredentialType) base [client_credential_type]; }
+                       set { base [client_credential_type] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("protectionLevel",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "EncryptAndSign")]
+               public ProtectionLevel ProtectionLevel {
+                       get { return (ProtectionLevel) base [protection_level]; }
+                       set { base [protection_level] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TextMessageEncodingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TextMessageEncodingElement.cs
new file mode 100644 (file)
index 0000000..06a3473
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// TextMessageEncodingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class TextMessageEncodingElement
+                : BindingElementExtensionElement
+       {
+               public TextMessageEncodingElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (TextMessageEncodingBindingElement); }
+               }
+
+               [ConfigurationProperty ("maxReadPoolSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "64")]
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxReadPoolSize {
+                       get { return (int) base ["maxReadPoolSize"]; }
+                       set { base ["maxReadPoolSize"] = value; }
+               }
+
+               [ConfigurationProperty ("maxWritePoolSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "16")]
+               [IntegerValidator (MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxWritePoolSize {
+                       get { return (int) base ["maxWritePoolSize"]; }
+                       set { base ["maxWritePoolSize"] = value; }
+               }
+
+               [ConfigurationProperty ("messageVersion",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "Soap12WSAddressing10")]
+               [TypeConverter (typeof (MessageVersionConverter))]
+               public MessageVersion MessageVersion {
+                       get { return (MessageVersion) base ["messageVersion"]; }
+                       set { base ["messageVersion"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("readerQuotas",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlDictionaryReaderQuotasElement ReaderQuotas {
+                       get { return (XmlDictionaryReaderQuotasElement) base ["readerQuotas"]; }
+               }
+
+               [ConfigurationProperty ("writeEncoding",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "utf-8")]
+               [TypeConverter (typeof (EncodingConverter))]
+               public Encoding WriteEncoding {
+                       get { return (Encoding) base ["writeEncoding"]; }
+                       set { base ["writeEncoding"] = value; }
+               }
+
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransactedBatchingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransactedBatchingElement.cs
new file mode 100644 (file)
index 0000000..bb779e8
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// TransactedBatchingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class TransactedBatchingElement
+                : BehaviorExtensionElement
+       {
+               // Properties
+
+               public override Type BehaviorType {
+                       get { return typeof (TransactedBatchingBehavior); }
+               }
+
+               [IntegerValidator (MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxBatchSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "0")]
+               public int MaxBatchSize {
+                       get { return (int) base ["maxBatchSize"]; }
+                       set { base ["maxBatchSize"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               protected internal override object CreateBehavior () {
+                       return new TransactedBatchingBehavior (MaxBatchSize);
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransactionFlowElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransactionFlowElement.cs
new file mode 100644 (file)
index 0000000..36922ed
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// TransactionFlowElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public partial class TransactionFlowElement
+                : BindingElementExtensionElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public TransactionFlowElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (TransactionFlowBindingElement); }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty ("transactionProtocol", typeof (TransactionProtocol), "OleTransactions", new TransactionProtocolConverter (), null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("transactionProtocol",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "OleTransactions")]
+               [TypeConverter (typeof (TransactionProtocolConverter))]
+               public TransactionProtocol TransactionProtocol {
+                       get { return (TransactionProtocol) base ["transactionProtocol"]; }
+                       set { base ["transactionProtocol"] = value; }
+               }
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransactionProtocolConverter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransactionProtocolConverter.cs
new file mode 100644 (file)
index 0000000..14bf69e
--- /dev/null
@@ -0,0 +1,63 @@
+//\r
+// EncodingConverter.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ComponentModel;\r
+using System.Globalization;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       sealed class TransactionProtocolConverter : TypeConverter\r
+       {\r
+               static TransactionProtocolConverter _instance = new TransactionProtocolConverter ();\r
+\r
+               public static TransactionProtocolConverter Instance {\r
+                       get { return _instance; }\r
+               }\r
+\r
+               public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType) {\r
+                       return sourceType == typeof (string);\r
+               }\r
+\r
+               public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value) {\r
+                       string valueString = (string) value;\r
+\r
+                       switch (valueString.ToLower (CultureInfo.InvariantCulture)) {\r
+                       case "default":\r
+                               return TransactionProtocol.Default;\r
+                       case "oletransactions":\r
+                               return TransactionProtocol.OleTransactions;\r
+                       case "wsatomictransactionoctober2004":\r
+                               return TransactionProtocol.WSAtomicTransactionOctober2004;\r
+                       }\r
+                       throw new NotSupportedException ();\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransportConfigurationTypeElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransportConfigurationTypeElement.cs
new file mode 100644 (file)
index 0000000..0505daf
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// TransportConfigurationTypeElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class TransportConfigurationTypeElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty name;
+               static ConfigurationProperty transport_configuration_type;
+
+               static TransportConfigurationTypeElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       name = new ConfigurationProperty ("name",
+                               typeof (string), null, new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       transport_configuration_type = new ConfigurationProperty ("transportConfigurationType",
+                               typeof (string), null, new StringConverter (), null,
+                               ConfigurationPropertyOptions.IsRequired);
+
+                       properties.Add (name);
+                       properties.Add (transport_configuration_type);
+               }
+
+               public TransportConfigurationTypeElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("name",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Name {
+                       get { return (string) base [name]; }
+                       set { base [name] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [StringValidator ( MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("transportConfigurationType",
+                        Options = ConfigurationPropertyOptions.IsRequired,
+                       IsRequired = true)]
+               public string TransportConfigurationType {
+                       get { return (string) base [transport_configuration_type]; }
+                       set { base [transport_configuration_type] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransportConfigurationTypeElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransportConfigurationTypeElementCollection.cs
new file mode 100644 (file)
index 0000000..7864d20
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// TransportConfigurationTypeElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (TransportConfigurationTypeElement),
+                AddItemName = "add",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       [MonoTODO]
+       public sealed partial class TransportConfigurationTypeElementCollection
+                : ServiceModelConfigurationElementCollection<TransportConfigurationTypeElement>,  ICollection,  IEnumerable
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static TransportConfigurationTypeElementCollection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public TransportConfigurationTypeElementCollection ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransportElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/TransportElement.cs
new file mode 100644 (file)
index 0000000..081e2b1
--- /dev/null
@@ -0,0 +1,114 @@
+//
+// TransportElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public abstract partial class TransportElement
+                : BindingElementExtensionElement
+       {
+               // Static Fields
+               ConfigurationPropertyCollection _properties;
+
+               protected TransportElement () {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("manualAddressing",
+                        Options = ConfigurationPropertyOptions.None,
+                       DefaultValue = false)]
+               public bool ManualAddressing {
+                       get { return (bool) base ["manualAddressing"]; }
+                       set { base ["manualAddressing"] = value; }
+               }
+
+               [ConfigurationProperty ("maxBufferPoolSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "524288")]
+               [LongValidator (MinValue = 1,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               public long MaxBufferPoolSize {
+                       get { return (long) base ["maxBufferPoolSize"]; }
+                       set { base ["maxBufferPoolSize"] = value; }
+               }
+
+               [LongValidator (MinValue = 1,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxReceivedMessageSize",
+                        Options = ConfigurationPropertyOptions.None,
+                        DefaultValue = "65536")]
+               public long MaxReceivedMessageSize {
+                       get { return (long) base ["maxReceivedMessageSize"]; }
+                       set { base ["maxReceivedMessageSize"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       _properties.Add (new ConfigurationProperty ("manualAddressing", typeof (bool), "false", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferPoolSize", typeof (long), "524288", null, new LongValidator (1, 9223372036854775807, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxReceivedMessageSize", typeof (long), "65536", null, new LongValidator (1, 9223372036854775807, false), ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/UseManagedPresentationElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/UseManagedPresentationElement.cs
new file mode 100644 (file)
index 0000000..3e6d90d
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// UseManagedPresentationElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public class UseManagedPresentationElement
+                : BindingElementExtensionElement
+       {
+               public UseManagedPresentationElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (UseManagedPresentationBindingElement); }
+               }
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/UserNameServiceElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/UserNameServiceElement.cs
new file mode 100644 (file)
index 0000000..420d5f9
--- /dev/null
@@ -0,0 +1,139 @@
+//
+// UserNameServiceElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class UserNameServiceElement
+                : ConfigurationElement
+       {
+               public UserNameServiceElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("cachedLogonTokenLifetime",
+                        DefaultValue = "00:15:00",
+                        Options = ConfigurationPropertyOptions.None)]
+               public TimeSpan CachedLogonTokenLifetime {
+                       get { return (TimeSpan) base ["cachedLogonTokenLifetime"]; }
+                       set { base ["cachedLogonTokenLifetime"] = value; }
+               }
+
+               [ConfigurationProperty ("cacheLogonTokens",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool CacheLogonTokens {
+                       get { return (bool) base ["cacheLogonTokens"]; }
+                       set { base ["cacheLogonTokens"] = value; }
+               }
+
+               [ConfigurationProperty ("customUserNamePasswordValidatorType",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string CustomUserNamePasswordValidatorType {
+                       get { return (string) base ["customUserNamePasswordValidatorType"]; }
+                       set { base ["customUserNamePasswordValidatorType"] = value; }
+               }
+
+               [ConfigurationProperty ("includeWindowsGroups",
+                       DefaultValue = true,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool IncludeWindowsGroups {
+                       get { return (bool) base ["includeWindowsGroups"]; }
+                       set { base ["includeWindowsGroups"] = value; }
+               }
+
+               [ConfigurationProperty ("maxCachedLogonTokens",
+                        DefaultValue = "128",
+                        Options = ConfigurationPropertyOptions.None)]
+               [IntegerValidator ( MinValue = 1,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxCachedLogonTokens {
+                       get { return (int) base ["maxCachedLogonTokens"]; }
+                       set { base ["maxCachedLogonTokens"] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("membershipProviderName",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               public string MembershipProviderName {
+                       get { return (string) base ["membershipProviderName"]; }
+                       set { base ["membershipProviderName"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("userNamePasswordValidationMode",
+                        DefaultValue = "Windows",
+                        Options = ConfigurationPropertyOptions.None)]
+               public UserNamePasswordValidationMode UserNamePasswordValidationMode {
+                       get { return (UserNamePasswordValidationMode) base ["userNamePasswordValidationMode"]; }
+                       set { base ["userNamePasswordValidationMode"] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/UserPrincipalNameElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/UserPrincipalNameElement.cs
new file mode 100644 (file)
index 0000000..bf56515
--- /dev/null
@@ -0,0 +1,100 @@
+//
+// UserPrincipalNameElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class UserPrincipalNameElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty value;
+
+               static UserPrincipalNameElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       value = new ConfigurationProperty ("value",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (value);
+               }
+
+               public UserPrincipalNameElement ()
+               {
+               }
+
+
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("value",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Value {
+                       get { return (string) base [value]; }
+                       set { base [value] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007FederationHttpBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007FederationHttpBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..1785356
--- /dev/null
@@ -0,0 +1,39 @@
+//\r
+// WS2007FederationHttpBindingCollectionElement.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       [MonoTODO]\r
+       public class WS2007FederationHttpBindingCollectionElement : StandardBindingCollectionElement<WS2007FederationHttpBinding, WS2007FederationHttpBindingElement>\r
+       {\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007FederationHttpBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007FederationHttpBindingElement.cs
new file mode 100644 (file)
index 0000000..998ae3b
--- /dev/null
@@ -0,0 +1,39 @@
+//\r
+// WS2007FederationHttpBindingElement.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       [MonoTODO]\r
+       public class WS2007FederationHttpBindingElement : WSFederationHttpBindingElement\r
+       {\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007HttpBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007HttpBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..0c5a712
--- /dev/null
@@ -0,0 +1,39 @@
+//\r
+// WS2007HttpBindingCollectionElement.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       [MonoTODO]\r
+       public class WS2007HttpBindingCollectionElement : StandardBindingCollectionElement<WS2007HttpBinding, WS2007HttpBindingElement>\r
+       {\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007HttpBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WS2007HttpBindingElement.cs
new file mode 100644 (file)
index 0000000..27e59ce
--- /dev/null
@@ -0,0 +1,39 @@
+//\r
+// WS2007HttpBindingElement.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Configuration\r
+{\r
+       [MonoTODO]\r
+       public class WS2007HttpBindingElement : WSHttpBindingElement\r
+       {\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSDualHttpBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSDualHttpBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..f33e009
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// WSDualHttpBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class WSDualHttpBindingCollectionElement
+                : StandardBindingCollectionElement<WSDualHttpBinding, WSDualHttpBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static WSDualHttpBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public WSDualHttpBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSDualHttpBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSDualHttpBindingElement.cs
new file mode 100644 (file)
index 0000000..d64c7a9
--- /dev/null
@@ -0,0 +1,280 @@
+//
+// WSDualHttpBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class WSDualHttpBindingElement
+                : StandardBindingElement,  IBindingConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty binding_element_type;
+               static ConfigurationProperty bypass_proxy_on_local;
+               static ConfigurationProperty client_base_address;
+               static ConfigurationProperty host_name_comparison_mode;
+               static ConfigurationProperty max_buffer_pool_size;
+               static ConfigurationProperty max_received_message_size;
+               static ConfigurationProperty message_encoding;
+               static ConfigurationProperty proxy_address;
+               static ConfigurationProperty reader_quotas;
+               static ConfigurationProperty reliable_session;
+               static ConfigurationProperty security;
+               static ConfigurationProperty text_encoding;
+               static ConfigurationProperty transaction_flow;
+               static ConfigurationProperty use_default_web_proxy;
+
+               static WSDualHttpBindingElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       binding_element_type = new ConfigurationProperty ("",
+                               typeof (Type), null, new TypeConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       bypass_proxy_on_local = new ConfigurationProperty ("bypassProxyOnLocal",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       client_base_address = new ConfigurationProperty ("clientBaseAddress",
+                               typeof (Uri), null, new UriTypeConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       host_name_comparison_mode = new ConfigurationProperty ("hostNameComparisonMode",
+                               typeof (HostNameComparisonMode), "StrongWildcard", null/* FIXME: get converter for HostNameComparisonMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_buffer_pool_size = new ConfigurationProperty ("maxBufferPoolSize",
+                               typeof (long), "524288", null/* FIXME: get converter for long*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_received_message_size = new ConfigurationProperty ("maxReceivedMessageSize",
+                               typeof (long), "65536", null/* FIXME: get converter for long*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       message_encoding = new ConfigurationProperty ("messageEncoding",
+                               typeof (WSMessageEncoding), "Text", null/* FIXME: get converter for WSMessageEncoding*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       proxy_address = new ConfigurationProperty ("proxyAddress",
+                               typeof (Uri), null, new UriTypeConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       reader_quotas = new ConfigurationProperty ("readerQuotas",
+                               typeof (XmlDictionaryReaderQuotasElement), null, null/* FIXME: get converter for XmlDictionaryReaderQuotasElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       reliable_session = new ConfigurationProperty ("reliableSession",
+                               typeof (StandardBindingReliableSessionElement), null, null/* FIXME: get converter for StandardBindingReliableSessionElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       security = new ConfigurationProperty ("security",
+                               typeof (WSDualHttpSecurityElement), null, null/* FIXME: get converter for WSDualHttpSecurityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       text_encoding = new ConfigurationProperty ("textEncoding",
+                               typeof (Encoding), "utf-8", null/* FIXME: get converter for Encoding*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       transaction_flow = new ConfigurationProperty ("transactionFlow",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       use_default_web_proxy = new ConfigurationProperty ("useDefaultWebProxy",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (binding_element_type);
+                       properties.Add (bypass_proxy_on_local);
+                       properties.Add (client_base_address);
+                       properties.Add (host_name_comparison_mode);
+                       properties.Add (max_buffer_pool_size);
+                       properties.Add (max_received_message_size);
+                       properties.Add (message_encoding);
+                       properties.Add (proxy_address);
+                       properties.Add (reader_quotas);
+                       properties.Add (reliable_session);
+                       properties.Add (security);
+                       properties.Add (text_encoding);
+                       properties.Add (transaction_flow);
+                       properties.Add (use_default_web_proxy);
+               }
+
+               public WSDualHttpBindingElement ()
+               {
+               }
+
+
+               // Properties
+
+               protected override Type BindingElementType {
+                       get { return (Type) base [binding_element_type]; }
+               }
+
+               [ConfigurationProperty ("bypassProxyOnLocal",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool BypassProxyOnLocal {
+                       get { return (bool) base [bypass_proxy_on_local]; }
+                       set { base [bypass_proxy_on_local] = value; }
+               }
+
+               [ConfigurationProperty ("clientBaseAddress",
+                        DefaultValue = null,
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri ClientBaseAddress {
+                       get { return (Uri) base [client_base_address]; }
+                       set { base [client_base_address] = value; }
+               }
+
+               [ConfigurationProperty ("hostNameComparisonMode",
+                        DefaultValue = "StrongWildcard",
+                        Options = ConfigurationPropertyOptions.None)]
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return (HostNameComparisonMode) base [host_name_comparison_mode]; }
+                       set { base [host_name_comparison_mode] = value; }
+               }
+
+               [LongValidator ( MinValue = 0,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxBufferPoolSize",
+                        DefaultValue = "524288",
+                        Options = ConfigurationPropertyOptions.None)]
+               public long MaxBufferPoolSize {
+                       get { return (long) base [max_buffer_pool_size]; }
+                       set { base [max_buffer_pool_size] = value; }
+               }
+
+               [LongValidator ( MinValue = 1,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxReceivedMessageSize",
+                        DefaultValue = "65536",
+                        Options = ConfigurationPropertyOptions.None)]
+               public long MaxReceivedMessageSize {
+                       get { return (long) base [max_received_message_size]; }
+                       set { base [max_received_message_size] = value; }
+               }
+
+               [ConfigurationProperty ("messageEncoding",
+                        DefaultValue = "Text",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSMessageEncoding MessageEncoding {
+                       get { return (WSMessageEncoding) base [message_encoding]; }
+                       set { base [message_encoding] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("proxyAddress",
+                        DefaultValue = null,
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri ProxyAddress {
+                       get { return (Uri) base [proxy_address]; }
+                       set { base [proxy_address] = value; }
+               }
+
+               [ConfigurationProperty ("readerQuotas",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlDictionaryReaderQuotasElement ReaderQuotas {
+                       get { return (XmlDictionaryReaderQuotasElement) base [reader_quotas]; }
+               }
+
+               [ConfigurationProperty ("reliableSession",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StandardBindingReliableSessionElement ReliableSession {
+                       get { return (StandardBindingReliableSessionElement) base [reliable_session]; }
+               }
+
+               [ConfigurationProperty ("security",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSDualHttpSecurityElement Security {
+                       get { return (WSDualHttpSecurityElement) base [security]; }
+               }
+
+               [ConfigurationProperty ("textEncoding",
+                        DefaultValue = "utf-8",
+                        Options = ConfigurationPropertyOptions.None)]
+               [TypeConverter (typeof(EncodingConverter))]
+               public Encoding TextEncoding {
+                       get { return (Encoding) base [text_encoding]; }
+                       set { base [text_encoding] = value; }
+               }
+
+               [ConfigurationProperty ("transactionFlow",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool TransactionFlow {
+                       get { return (bool) base [transaction_flow]; }
+                       set { base [transaction_flow] = value; }
+               }
+
+               [ConfigurationProperty ("useDefaultWebProxy",
+                       DefaultValue = true,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool UseDefaultWebProxy {
+                       get { return (bool) base [use_default_web_proxy]; }
+                       set { base [use_default_web_proxy] = value; }
+               }
+
+
+
+               protected override void OnApplyConfiguration (Binding binding) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSDualHttpSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSDualHttpSecurityElement.cs
new file mode 100644 (file)
index 0000000..35aeae8
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// WSDualHttpSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class WSDualHttpSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty message;
+               static ConfigurationProperty mode;
+
+               static WSDualHttpSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       message = new ConfigurationProperty ("message",
+                               typeof (MessageSecurityOverHttpElement), null, null/* FIXME: get converter for MessageSecurityOverHttpElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       mode = new ConfigurationProperty ("mode",
+                               typeof (WSDualHttpSecurityMode), "Message", null/* FIXME: get converter for WSDualHttpSecurityMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (message);
+                       properties.Add (mode);
+               }
+
+               public WSDualHttpSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("message",
+                        Options = ConfigurationPropertyOptions.None)]
+               public MessageSecurityOverHttpElement Message {
+                       get { return (MessageSecurityOverHttpElement) base [message]; }
+               }
+
+               [ConfigurationProperty ("mode",
+                        DefaultValue = "Message",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSDualHttpSecurityMode Mode {
+                       get { return (WSDualHttpSecurityMode) base [mode]; }
+                       set { base [mode] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSFederationHttpBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSFederationHttpBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..c44fadc
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// WSFederationHttpBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class WSFederationHttpBindingCollectionElement
+                : StandardBindingCollectionElement<WSFederationHttpBinding, WSFederationHttpBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static WSFederationHttpBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public WSFederationHttpBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSFederationHttpBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSFederationHttpBindingElement.cs
new file mode 100644 (file)
index 0000000..ea00e56
--- /dev/null
@@ -0,0 +1,137 @@
+//
+// WSFederationHttpBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class WSFederationHttpBindingElement
+                : WSHttpBindingBaseElement,  IBindingConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty binding_element_type;
+               static ConfigurationProperty privacy_notice_at;
+               static ConfigurationProperty privacy_notice_version;
+               static ConfigurationProperty security;
+
+               static WSFederationHttpBindingElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+
+                       privacy_notice_at = new ConfigurationProperty ("privacyNoticeAt",
+                               typeof (Uri), null, new UriTypeConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       privacy_notice_version = new ConfigurationProperty ("privacyNoticeVersion",
+                               typeof (int), "0", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       security = new ConfigurationProperty ("security",
+                               typeof (WSFederationHttpSecurityElement), null, null/* FIXME: get converter for WSFederationHttpSecurityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (binding_element_type);
+                       properties.Add (privacy_notice_at);
+                       properties.Add (privacy_notice_version);
+                       properties.Add (security);
+               }
+
+               public WSFederationHttpBindingElement ()
+               {
+               }
+
+
+               // Properties
+
+               protected override Type BindingElementType {
+                       get { return (Type) base [binding_element_type]; }
+               }
+
+               [ConfigurationProperty ("privacyNoticeAt",
+                        DefaultValue = null,
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri PrivacyNoticeAt {
+                       get { return (Uri) base [privacy_notice_at]; }
+                       set { base [privacy_notice_at] = value; }
+               }
+
+               [ConfigurationProperty ("privacyNoticeVersion",
+                        DefaultValue = "0",
+                        Options = ConfigurationPropertyOptions.None)]
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int PrivacyNoticeVersion {
+                       get { return (int) base [privacy_notice_version]; }
+                       set { base [privacy_notice_version] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("security",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSFederationHttpSecurityElement Security {
+                       get { return (WSFederationHttpSecurityElement) base [security]; }
+               }
+
+
+
+               protected override void OnApplyConfiguration (Binding binding) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSFederationHttpSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSFederationHttpSecurityElement.cs
new file mode 100644 (file)
index 0000000..d199117
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// WSFederationHttpSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class WSFederationHttpSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty message;
+               static ConfigurationProperty mode;
+
+               static WSFederationHttpSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       message = new ConfigurationProperty ("message",
+                               typeof (FederatedMessageSecurityOverHttpElement), null, null/* FIXME: get converter for FederatedMessageSecurityOverHttpElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       mode = new ConfigurationProperty ("mode",
+                               typeof (WSFederationHttpSecurityMode), "Message", null/* FIXME: get converter for WSFederationHttpSecurityMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (message);
+                       properties.Add (mode);
+               }
+
+               public WSFederationHttpSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("message",
+                        Options = ConfigurationPropertyOptions.None)]
+               public FederatedMessageSecurityOverHttpElement Message {
+                       get { return (FederatedMessageSecurityOverHttpElement) base [message]; }
+               }
+
+               [ConfigurationProperty ("mode",
+                        DefaultValue = "Message",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSFederationHttpSecurityMode Mode {
+                       get { return (WSFederationHttpSecurityMode) base [mode]; }
+                       set { base [mode] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpBindingBaseElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpBindingBaseElement.cs
new file mode 100644 (file)
index 0000000..27f51e7
--- /dev/null
@@ -0,0 +1,185 @@
+//
+// WSHttpBindingBaseElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public abstract partial class WSHttpBindingBaseElement
+                : StandardBindingElement,  IBindingConfigurationElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               protected WSHttpBindingBaseElement () {
+               }
+
+               protected WSHttpBindingBaseElement (string name)
+                       : base (name) {
+               }
+
+               // Properties
+
+               [ConfigurationProperty ("bypassProxyOnLocal",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool BypassProxyOnLocal {
+                       get { return (bool) this ["bypassProxyOnLocal"]; }
+                       set { this ["bypassProxyOnLocal"] = value; }
+               }
+
+               [ConfigurationProperty ("hostNameComparisonMode",
+                        DefaultValue = "StrongWildcard",
+                        Options = ConfigurationPropertyOptions.None)]
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return (HostNameComparisonMode) this ["hostNameComparisonMode"]; }
+                       set { this ["hostNameComparisonMode"] = value; }
+               }
+
+               [LongValidator ( MinValue = 0,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxBufferPoolSize",
+                        DefaultValue = "524288",
+                        Options = ConfigurationPropertyOptions.None)]
+               public long MaxBufferPoolSize {
+                       get { return (long) this ["maxBufferPoolSize"]; }
+                       set { this ["maxBufferPoolSize"] = value; }
+               }
+
+               [LongValidator ( MinValue = 1,
+                        MaxValue = 9223372036854775807,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxReceivedMessageSize",
+                        DefaultValue = "65536",
+                        Options = ConfigurationPropertyOptions.None)]
+               public long MaxReceivedMessageSize {
+                       get { return (long) this ["maxReceivedMessageSize"]; }
+                       set { this ["maxReceivedMessageSize"] = value; }
+               }
+
+               [ConfigurationProperty ("messageEncoding",
+                        DefaultValue = "Text",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSMessageEncoding MessageEncoding {
+                       get { return (WSMessageEncoding) this ["messageEncoding"]; }
+                       set { this ["messageEncoding"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("bypassProxyOnLocal", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("hostNameComparisonMode", typeof (HostNameComparisonMode), "StrongWildcard", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxBufferPoolSize", typeof (long), "524288", null, new LongValidator (0, 9223372036854775807, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("maxReceivedMessageSize", typeof (long), "65536", null, new LongValidator (1, 9223372036854775807, false), ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("messageEncoding", typeof (WSMessageEncoding), "Text", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("proxyAddress", typeof (Uri), null, new UriTypeConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("readerQuotas", typeof (XmlDictionaryReaderQuotasElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("reliableSession", typeof (StandardBindingOptionalReliableSessionElement), null, null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("textEncoding", typeof (Encoding), "utf-8", EncodingConverter.Instance, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("transactionFlow", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("useDefaultWebProxy", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("proxyAddress",
+                        DefaultValue = null,
+                        Options = ConfigurationPropertyOptions.None)]
+               public Uri ProxyAddress {
+                       get { return (Uri) this ["proxyAddress"]; }
+                       set { this ["proxyAddress"] = value; }
+               }
+
+               [ConfigurationProperty ("readerQuotas",
+                        Options = ConfigurationPropertyOptions.None)]
+               public XmlDictionaryReaderQuotasElement ReaderQuotas {
+                       get { return (XmlDictionaryReaderQuotasElement) this ["readerQuotas"]; }
+               }
+
+               [ConfigurationProperty ("reliableSession",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StandardBindingOptionalReliableSessionElement ReliableSession {
+                       get { return (StandardBindingOptionalReliableSessionElement) this ["reliableSession"]; }
+               }
+
+               [TypeConverter (typeof (EncodingConverter))]
+               [ConfigurationProperty ("textEncoding",
+                        DefaultValue = "utf-8",
+                        Options = ConfigurationPropertyOptions.None)]
+               public Encoding TextEncoding {
+                       get { return (Encoding) this ["textEncoding"]; }
+                       set { this ["textEncoding"] = value; }
+               }
+
+               [ConfigurationProperty ("transactionFlow",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool TransactionFlow {
+                       get { return (bool) this ["transactionFlow"]; }
+                       set { this ["transactionFlow"] = value; }
+               }
+
+               [ConfigurationProperty ("useDefaultWebProxy",
+                       DefaultValue = true,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool UseDefaultWebProxy {
+                       get { return (bool) this ["useDefaultWebProxy"]; }
+                       set { this ["useDefaultWebProxy"] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpBindingCollectionElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpBindingCollectionElement.cs
new file mode 100644 (file)
index 0000000..37aeac0
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// WSHttpBindingCollectionElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public partial class WSHttpBindingCollectionElement
+                : StandardBindingCollectionElement<WSHttpBinding, WSHttpBindingElement>
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static WSHttpBindingCollectionElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public WSHttpBindingCollectionElement ()
+               {
+               }
+
+
+               // Properties
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpBindingElement.cs
new file mode 100644 (file)
index 0000000..ed32745
--- /dev/null
@@ -0,0 +1,105 @@
+//
+// WSHttpBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public partial class WSHttpBindingElement
+                : WSHttpBindingBaseElement,  IBindingConfigurationElement
+       {
+               ConfigurationPropertyCollection _properties;
+
+               public WSHttpBindingElement () {
+               }
+
+               public WSHttpBindingElement (string name) :
+                       base (name) {
+               }
+
+               // Properties
+
+               [ConfigurationProperty ("allowCookies",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool AllowCookies {
+                       get { return (bool)this ["allowCookies"]; }
+                       set {this ["allowCookies"] = value; }
+               }
+
+               protected override Type BindingElementType {
+                       get { return typeof (WSHttpBinding); }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get {
+                               if (_properties == null) {
+                                       _properties = base.Properties;
+                                       _properties.Add (new ConfigurationProperty ("allowCookies", typeof (bool), "false", null, null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("security", typeof (WSHttpSecurityElement), null, null, null, ConfigurationPropertyOptions.None));
+                               }
+                               return _properties;
+                       }
+               }
+
+               [ConfigurationProperty ("security",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSHttpSecurityElement Security {
+                       get { return (WSHttpSecurityElement)this ["security"]; }
+               }
+
+               protected override void OnApplyConfiguration (Binding binding) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpSecurityElement.cs
new file mode 100644 (file)
index 0000000..e86b69e
--- /dev/null
@@ -0,0 +1,121 @@
+//
+// WSHttpSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class WSHttpSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty message;
+               static ConfigurationProperty mode;
+               static ConfigurationProperty transport;
+
+               static WSHttpSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       message = new ConfigurationProperty ("message",
+                               typeof (NonDualMessageSecurityOverHttpElement), null, null/* FIXME: get converter for NonDualMessageSecurityOverHttpElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       mode = new ConfigurationProperty ("mode",
+                               typeof (SecurityMode), "Message", null/* FIXME: get converter for SecurityMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       transport = new ConfigurationProperty ("transport",
+                               typeof (WSHttpTransportSecurityElement), null, null/* FIXME: get converter for WSHttpTransportSecurityElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (message);
+                       properties.Add (mode);
+                       properties.Add (transport);
+               }
+
+               public WSHttpSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("message",
+                        Options = ConfigurationPropertyOptions.None)]
+               public NonDualMessageSecurityOverHttpElement Message {
+                       get { return (NonDualMessageSecurityOverHttpElement) base [message]; }
+               }
+
+               [ConfigurationProperty ("mode",
+                        DefaultValue = "Message",
+                        Options = ConfigurationPropertyOptions.None)]
+               public SecurityMode Mode {
+                       get { return (SecurityMode) base [mode]; }
+                       set { base [mode] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("transport",
+                        Options = ConfigurationPropertyOptions.None)]
+               public WSHttpTransportSecurityElement Transport {
+                       get { return (WSHttpTransportSecurityElement) base [transport]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpTransportSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WSHttpTransportSecurityElement.cs
new file mode 100644 (file)
index 0000000..ac4852a
--- /dev/null
@@ -0,0 +1,128 @@
+//
+// WSHttpTransportSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class WSHttpTransportSecurityElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty client_credential_type;
+               static ConfigurationProperty proxy_credential_type;
+               static ConfigurationProperty realm;
+
+               static WSHttpTransportSecurityElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       client_credential_type = new ConfigurationProperty ("clientCredentialType",
+                               typeof (HttpClientCredentialType), "Windows", null/* FIXME: get converter for HttpClientCredentialType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       proxy_credential_type = new ConfigurationProperty ("proxyCredentialType",
+                               typeof (HttpProxyCredentialType), "None", null/* FIXME: get converter for HttpProxyCredentialType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       realm = new ConfigurationProperty ("realm",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (client_credential_type);
+                       properties.Add (proxy_credential_type);
+                       properties.Add (realm);
+               }
+
+               public WSHttpTransportSecurityElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("clientCredentialType",
+                        DefaultValue = "Windows",
+                        Options = ConfigurationPropertyOptions.None)]
+               public HttpClientCredentialType ClientCredentialType {
+                       get { return (HttpClientCredentialType) base [client_credential_type]; }
+                       set { base [client_credential_type] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("proxyCredentialType",
+                        DefaultValue = "None",
+                        Options = ConfigurationPropertyOptions.None)]
+               public HttpProxyCredentialType ProxyCredentialType {
+                       get { return (HttpProxyCredentialType) base [proxy_credential_type]; }
+                       set { base [proxy_credential_type] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("realm",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               public string Realm {
+                       get { return (string) base [realm]; }
+                       set { base [realm] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WindowsClientElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WindowsClientElement.cs
new file mode 100644 (file)
index 0000000..ddbe186
--- /dev/null
@@ -0,0 +1,111 @@
+//
+// WindowsClientElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class WindowsClientElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty allowed_impersonation_level;
+               static ConfigurationProperty allow_ntlm;
+
+               static WindowsClientElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       allowed_impersonation_level = new ConfigurationProperty ("allowedImpersonationLevel",
+                               typeof (TokenImpersonationLevel), "Identification", null/* FIXME: get converter for TokenImpersonationLevel*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       allow_ntlm = new ConfigurationProperty ("allowNtlm",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (allowed_impersonation_level);
+                       properties.Add (allow_ntlm);
+               }
+
+               public WindowsClientElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("allowedImpersonationLevel",
+                        DefaultValue = "Identification",
+                        Options = ConfigurationPropertyOptions.None)]
+               public TokenImpersonationLevel AllowedImpersonationLevel {
+                       get { return (TokenImpersonationLevel) base [allowed_impersonation_level]; }
+                       set { base [allowed_impersonation_level] = value; }
+               }
+
+               [ConfigurationProperty ("allowNtlm",
+                       DefaultValue = true,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool AllowNtlm {
+                       get { return (bool) base [allow_ntlm]; }
+                       set { base [allow_ntlm] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WindowsServiceElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WindowsServiceElement.cs
new file mode 100644 (file)
index 0000000..f5dead5
--- /dev/null
@@ -0,0 +1,111 @@
+//
+// WindowsServiceElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class WindowsServiceElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty allow_anonymous_logons;
+               static ConfigurationProperty include_windows_groups;
+
+               static WindowsServiceElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       allow_anonymous_logons = new ConfigurationProperty ("allowAnonymousLogons",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       include_windows_groups = new ConfigurationProperty ("includeWindowsGroups",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (allow_anonymous_logons);
+                       properties.Add (include_windows_groups);
+               }
+
+               public WindowsServiceElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("allowAnonymousLogons",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool AllowAnonymousLogons {
+                       get { return (bool) base [allow_anonymous_logons]; }
+                       set { base [allow_anonymous_logons] = value; }
+               }
+
+               [ConfigurationProperty ("includeWindowsGroups",
+                       DefaultValue = true,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool IncludeWindowsGroups {
+                       get { return (bool) base [include_windows_groups]; }
+                       set { base [include_windows_groups] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WindowsStreamSecurityElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WindowsStreamSecurityElement.cs
new file mode 100644 (file)
index 0000000..91bfa69
--- /dev/null
@@ -0,0 +1,90 @@
+//
+// WindowsStreamSecurityElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class WindowsStreamSecurityElement
+                : BindingElementExtensionElement
+       {
+               public WindowsStreamSecurityElement () {
+               }
+
+
+               // Properties
+
+               public override Type BindingElementType {
+                       get { return typeof (WindowsStreamSecurityBindingElement); }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("protectionLevel",
+                        DefaultValue = "EncryptAndSign",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ProtectionLevel ProtectionLevel {
+                       get { return (ProtectionLevel) base ["protectionLevel"]; }
+                       set { base ["protectionLevel"] = value; }
+               }
+
+
+               [MonoTODO]
+               protected internal override BindingElement CreateBindingElement () {
+                       throw new NotImplementedException ();
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WsdlImporterElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WsdlImporterElement.cs
new file mode 100644 (file)
index 0000000..90dde36
--- /dev/null
@@ -0,0 +1,103 @@
+//
+// WsdlImporterElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class WsdlImporterElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty type;
+
+               static WsdlImporterElement () {
+                       properties = new ConfigurationPropertyCollection ();
+                       type = new ConfigurationProperty ("type",
+                               typeof (string), null, new StringConverter (), new StringValidator (1),
+                               ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
+
+                       properties.Add (type);
+               }
+
+               public WsdlImporterElement () {
+               }
+
+               public WsdlImporterElement (string type) {
+                       Type = type;
+               }
+
+               public WsdlImporterElement (Type type) {
+                       Type = type.AssemblyQualifiedName;
+               }
+
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("type",
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               [StringValidator (MinLength = 1,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string Type {
+                       get { return (string) base [type]; }
+                       set { base [type] = value; }
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WsdlImporterElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/WsdlImporterElementCollection.cs
new file mode 100644 (file)
index 0000000..e21dd57
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// WsdlImporterElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (WsdlImporterElement),
+                AddItemName = "extension",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       public sealed class WsdlImporterElementCollection
+                : ServiceModelEnhancedConfigurationElementCollection<WsdlImporterElement>, ICollection, IEnumerable
+       {
+               public WsdlImporterElementCollection () {
+                       AddElementName = "extension";
+               }
+
+               protected override object GetElementKey (ConfigurationElement element) {
+                       return ((WsdlImporterElement) element).Type;
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509CertificateTrustedIssuerElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509CertificateTrustedIssuerElement.cs
new file mode 100644 (file)
index 0000000..db148c0
--- /dev/null
@@ -0,0 +1,113 @@
+//
+// X509CertificateTrustedIssuerElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class X509CertificateTrustedIssuerElement
+                : ConfigurationElement
+       {
+               public X509CertificateTrustedIssuerElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("findValue",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.IsKey,
+                       IsKey = true)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string FindValue {
+                       get { return (string) base ["findValue"]; }
+                       set { base ["findValue"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("storeLocation",
+                        DefaultValue = "LocalMachine",
+                        Options = ConfigurationPropertyOptions.IsKey,
+                       IsKey = true)]
+               public StoreLocation StoreLocation {
+                       get { return (StoreLocation) base ["storeLocation"]; }
+                       set { base ["storeLocation"] = value; }
+               }
+
+               [ConfigurationProperty ("storeName",
+                        DefaultValue = "My",
+                        Options = ConfigurationPropertyOptions.IsKey,
+                       IsKey = true)]
+               public StoreName StoreName {
+                       get { return (StoreName) base ["storeName"]; }
+                       set { base ["storeName"] = value; }
+               }
+
+               [ConfigurationProperty ("x509FindType",
+                        DefaultValue = "FindBySubjectDistinguishedName",
+                        Options = ConfigurationPropertyOptions.IsKey,
+                       IsKey = true)]
+               public X509FindType X509FindType {
+                       get { return (X509FindType) base ["x509FindType"]; }
+                       set { base ["x509FindType"] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509CertificateTrustedIssuerElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509CertificateTrustedIssuerElementCollection.cs
new file mode 100644 (file)
index 0000000..f3aedb2
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// X509CertificateTrustedIssuerElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (X509CertificateTrustedIssuerElement),
+                AddItemName = "add",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       public sealed class X509CertificateTrustedIssuerElementCollection
+                : ServiceModelConfigurationElementCollection<X509CertificateTrustedIssuerElement>,  ICollection,  IEnumerable
+       {
+
+               protected override object GetElementKey (ConfigurationElement element) {
+                       X509CertificateTrustedIssuerElement el = (X509CertificateTrustedIssuerElement) element;
+                       return el.FindValue + ";" + el.StoreLocation + ";" + el.StoreName + ";" + el.X509FindType;
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ClientCertificateAuthenticationElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ClientCertificateAuthenticationElement.cs
new file mode 100644 (file)
index 0000000..45dc2e5
--- /dev/null
@@ -0,0 +1,170 @@
+//
+// X509ClientCertificateAuthenticationElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class X509ClientCertificateAuthenticationElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty certificate_validation_mode;
+               static ConfigurationProperty custom_certificate_validator_type;
+               static ConfigurationProperty include_windows_groups;
+               static ConfigurationProperty map_client_certificate_to_windows_account;
+               static ConfigurationProperty revocation_mode;
+               static ConfigurationProperty trusted_store_location;
+
+               static X509ClientCertificateAuthenticationElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       certificate_validation_mode = new ConfigurationProperty ("certificateValidationMode",
+                               typeof (X509CertificateValidationMode), "ChainTrust", null/* FIXME: get converter for X509CertificateValidationMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       custom_certificate_validator_type = new ConfigurationProperty ("customCertificateValidatorType",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       include_windows_groups = new ConfigurationProperty ("includeWindowsGroups",
+                               typeof (bool), "true", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       map_client_certificate_to_windows_account = new ConfigurationProperty ("mapClientCertificateToWindowsAccount",
+                               typeof (bool), "false", new BooleanConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       revocation_mode = new ConfigurationProperty ("revocationMode",
+                               typeof (X509RevocationMode), "Online", null/* FIXME: get converter for X509RevocationMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       trusted_store_location = new ConfigurationProperty ("trustedStoreLocation",
+                               typeof (StoreLocation), "LocalMachine", null/* FIXME: get converter for StoreLocation*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (certificate_validation_mode);
+                       properties.Add (custom_certificate_validator_type);
+                       properties.Add (include_windows_groups);
+                       properties.Add (map_client_certificate_to_windows_account);
+                       properties.Add (revocation_mode);
+                       properties.Add (trusted_store_location);
+               }
+
+               public X509ClientCertificateAuthenticationElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("certificateValidationMode",
+                        DefaultValue = "ChainTrust",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509CertificateValidationMode CertificateValidationMode {
+                       get { return (X509CertificateValidationMode) base [certificate_validation_mode]; }
+                       set { base [certificate_validation_mode] = value; }
+               }
+
+               [ConfigurationProperty ("customCertificateValidatorType",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string CustomCertificateValidatorType {
+                       get { return (string) base [custom_certificate_validator_type]; }
+                       set { base [custom_certificate_validator_type] = value; }
+               }
+
+               [ConfigurationProperty ("includeWindowsGroups",
+                       DefaultValue = true,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool IncludeWindowsGroups {
+                       get { return (bool) base [include_windows_groups]; }
+                       set { base [include_windows_groups] = value; }
+               }
+
+               [ConfigurationProperty ("mapClientCertificateToWindowsAccount",
+                       DefaultValue = false,
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool MapClientCertificateToWindowsAccount {
+                       get { return (bool) base [map_client_certificate_to_windows_account]; }
+                       set { base [map_client_certificate_to_windows_account] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("revocationMode",
+                        DefaultValue = "Online",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509RevocationMode RevocationMode {
+                       get { return (X509RevocationMode) base [revocation_mode]; }
+                       set { base [revocation_mode] = value; }
+               }
+
+               [ConfigurationProperty ("trustedStoreLocation",
+                        DefaultValue = "LocalMachine",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreLocation TrustedStoreLocation {
+                       get { return (StoreLocation) base [trusted_store_location]; }
+                       set { base [trusted_store_location] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ClientCertificateCredentialsElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ClientCertificateCredentialsElement.cs
new file mode 100644 (file)
index 0000000..d6e1a2a
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// X509ClientCertificateCredentialsElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class X509ClientCertificateCredentialsElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty find_value;
+               static ConfigurationProperty store_location;
+               static ConfigurationProperty store_name;
+               static ConfigurationProperty x509_find_type;
+
+               static X509ClientCertificateCredentialsElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       find_value = new ConfigurationProperty ("findValue",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_location = new ConfigurationProperty ("storeLocation",
+                               typeof (StoreLocation), "LocalMachine", null/* FIXME: get converter for StoreLocation*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_name = new ConfigurationProperty ("storeName",
+                               typeof (StoreName), "My", null/* FIXME: get converter for StoreName*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       x509_find_type = new ConfigurationProperty ("x509FindType",
+                               typeof (X509FindType), "FindBySubjectDistinguishedName", null/* FIXME: get converter for X509FindType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (find_value);
+                       properties.Add (store_location);
+                       properties.Add (store_name);
+                       properties.Add (x509_find_type);
+               }
+
+               public X509ClientCertificateCredentialsElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("findValue",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string FindValue {
+                       get { return (string) base [find_value]; }
+                       set { base [find_value] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("storeLocation",
+                        DefaultValue = "LocalMachine",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreLocation StoreLocation {
+                       get { return (StoreLocation) base [store_location]; }
+                       set { base [store_location] = value; }
+               }
+
+               [ConfigurationProperty ("storeName",
+                        DefaultValue = "My",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreName StoreName {
+                       get { return (StoreName) base [store_name]; }
+                       set { base [store_name] = value; }
+               }
+
+               [ConfigurationProperty ("x509FindType",
+                        DefaultValue = "FindBySubjectDistinguishedName",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509FindType X509FindType {
+                       get { return (X509FindType) base [x509_find_type]; }
+                       set { base [x509_find_type] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509DefaultServiceCertificateElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509DefaultServiceCertificateElement.cs
new file mode 100644 (file)
index 0000000..f5fcfc9
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// X509DefaultServiceCertificateElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class X509DefaultServiceCertificateElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty find_value;
+               static ConfigurationProperty store_location;
+               static ConfigurationProperty store_name;
+               static ConfigurationProperty x509_find_type;
+
+               static X509DefaultServiceCertificateElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       find_value = new ConfigurationProperty ("findValue",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_location = new ConfigurationProperty ("storeLocation",
+                               typeof (StoreLocation), "CurrentUser", null/* FIXME: get converter for StoreLocation*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_name = new ConfigurationProperty ("storeName",
+                               typeof (StoreName), "My", null/* FIXME: get converter for StoreName*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       x509_find_type = new ConfigurationProperty ("x509FindType",
+                               typeof (X509FindType), "FindBySubjectDistinguishedName", null/* FIXME: get converter for X509FindType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (find_value);
+                       properties.Add (store_location);
+                       properties.Add (store_name);
+                       properties.Add (x509_find_type);
+               }
+
+               public X509DefaultServiceCertificateElement ()
+               {
+               }
+
+
+               // Properties
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("findValue",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               public string FindValue {
+                       get { return (string) base [find_value]; }
+                       set { base [find_value] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("storeLocation",
+                        DefaultValue = "CurrentUser",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreLocation StoreLocation {
+                       get { return (StoreLocation) base [store_location]; }
+                       set { base [store_location] = value; }
+               }
+
+               [ConfigurationProperty ("storeName",
+                        DefaultValue = "My",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreName StoreName {
+                       get { return (StoreName) base [store_name]; }
+                       set { base [store_name] = value; }
+               }
+
+               [ConfigurationProperty ("x509FindType",
+                        DefaultValue = "FindBySubjectDistinguishedName",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509FindType X509FindType {
+                       get { return (X509FindType) base [x509_find_type]; }
+                       set { base [x509_find_type] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509InitiatorCertificateClientElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509InitiatorCertificateClientElement.cs
new file mode 100644 (file)
index 0000000..eae9edc
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// X509InitiatorCertificateClientElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class X509InitiatorCertificateClientElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty find_value;
+               static ConfigurationProperty store_location;
+               static ConfigurationProperty store_name;
+               static ConfigurationProperty x509_find_type;
+
+               static X509InitiatorCertificateClientElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       find_value = new ConfigurationProperty ("findValue",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_location = new ConfigurationProperty ("storeLocation",
+                               typeof (StoreLocation), "CurrentUser", null/* FIXME: get converter for StoreLocation*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_name = new ConfigurationProperty ("storeName",
+                               typeof (StoreName), "My", null/* FIXME: get converter for StoreName*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       x509_find_type = new ConfigurationProperty ("x509FindType",
+                               typeof (X509FindType), "FindBySubjectDistinguishedName", null/* FIXME: get converter for X509FindType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (find_value);
+                       properties.Add (store_location);
+                       properties.Add (store_name);
+                       properties.Add (x509_find_type);
+               }
+
+               public X509InitiatorCertificateClientElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("findValue",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string FindValue {
+                       get { return (string) base [find_value]; }
+                       set { base [find_value] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("storeLocation",
+                        DefaultValue = "CurrentUser",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreLocation StoreLocation {
+                       get { return (StoreLocation) base [store_location]; }
+                       set { base [store_location] = value; }
+               }
+
+               [ConfigurationProperty ("storeName",
+                        DefaultValue = "My",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreName StoreName {
+                       get { return (StoreName) base [store_name]; }
+                       set { base [store_name] = value; }
+               }
+
+               [ConfigurationProperty ("x509FindType",
+                        DefaultValue = "FindBySubjectDistinguishedName",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509FindType X509FindType {
+                       get { return (X509FindType) base [x509_find_type]; }
+                       set { base [x509_find_type] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509InitiatorCertificateServiceElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509InitiatorCertificateServiceElement.cs
new file mode 100644 (file)
index 0000000..d8ced69
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// X509InitiatorCertificateServiceElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class X509InitiatorCertificateServiceElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty authentication;
+               static ConfigurationProperty certificate;
+
+               static X509InitiatorCertificateServiceElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       authentication = new ConfigurationProperty ("authentication",
+                               typeof (X509ClientCertificateAuthenticationElement), null, null/* FIXME: get converter for X509ClientCertificateAuthenticationElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       certificate = new ConfigurationProperty ("certificate",
+                               typeof (X509ClientCertificateCredentialsElement), null, null/* FIXME: get converter for X509ClientCertificateCredentialsElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (authentication);
+                       properties.Add (certificate);
+               }
+
+               public X509InitiatorCertificateServiceElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("authentication",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509ClientCertificateAuthenticationElement Authentication {
+                       get { return (X509ClientCertificateAuthenticationElement) base [authentication]; }
+               }
+
+               [ConfigurationProperty ("certificate",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509ClientCertificateCredentialsElement Certificate {
+                       get { return (X509ClientCertificateCredentialsElement) base [certificate]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509PeerCertificateAuthenticationElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509PeerCertificateAuthenticationElement.cs
new file mode 100644 (file)
index 0000000..1e2b597
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// X509PeerCertificateAuthenticationElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class X509PeerCertificateAuthenticationElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty certificate_validation_mode;
+               static ConfigurationProperty custom_certificate_validator_type;
+               static ConfigurationProperty revocation_mode;
+               static ConfigurationProperty trusted_store_location;
+
+               static X509PeerCertificateAuthenticationElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       certificate_validation_mode = new ConfigurationProperty ("certificateValidationMode",
+                               typeof (X509CertificateValidationMode), "PeerOrChainTrust", null/* FIXME: get converter for X509CertificateValidationMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       custom_certificate_validator_type = new ConfigurationProperty ("customCertificateValidatorType",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       revocation_mode = new ConfigurationProperty ("revocationMode",
+                               typeof (X509RevocationMode), "Online", null/* FIXME: get converter for X509RevocationMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       trusted_store_location = new ConfigurationProperty ("trustedStoreLocation",
+                               typeof (StoreLocation), "CurrentUser", null/* FIXME: get converter for StoreLocation*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (certificate_validation_mode);
+                       properties.Add (custom_certificate_validator_type);
+                       properties.Add (revocation_mode);
+                       properties.Add (trusted_store_location);
+               }
+
+               public X509PeerCertificateAuthenticationElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("certificateValidationMode",
+                        DefaultValue = "PeerOrChainTrust",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509CertificateValidationMode CertificateValidationMode {
+                       get { return (X509CertificateValidationMode) base [certificate_validation_mode]; }
+                       set { base [certificate_validation_mode] = value; }
+               }
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("customCertificateValidatorType",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               public string CustomCertificateValidatorType {
+                       get { return (string) base [custom_certificate_validator_type]; }
+                       set { base [custom_certificate_validator_type] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("revocationMode",
+                        DefaultValue = "Online",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509RevocationMode RevocationMode {
+                       get { return (X509RevocationMode) base [revocation_mode]; }
+                       set { base [revocation_mode] = value; }
+               }
+
+               [ConfigurationProperty ("trustedStoreLocation",
+                        DefaultValue = "CurrentUser",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreLocation TrustedStoreLocation {
+                       get { return (StoreLocation) base [trusted_store_location]; }
+                       set { base [trusted_store_location] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509PeerCertificateElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509PeerCertificateElement.cs
new file mode 100644 (file)
index 0000000..9ec1a52
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// X509PeerCertificateElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class X509PeerCertificateElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty find_value;
+               static ConfigurationProperty store_location;
+               static ConfigurationProperty store_name;
+               static ConfigurationProperty x509_find_type;
+
+               static X509PeerCertificateElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       find_value = new ConfigurationProperty ("findValue",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_location = new ConfigurationProperty ("storeLocation",
+                               typeof (StoreLocation), "CurrentUser", null/* FIXME: get converter for StoreLocation*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_name = new ConfigurationProperty ("storeName",
+                               typeof (StoreName), "My", null/* FIXME: get converter for StoreName*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       x509_find_type = new ConfigurationProperty ("x509FindType",
+                               typeof (X509FindType), "FindBySubjectDistinguishedName", null/* FIXME: get converter for X509FindType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (find_value);
+                       properties.Add (store_location);
+                       properties.Add (store_name);
+                       properties.Add (x509_find_type);
+               }
+
+               public X509PeerCertificateElement ()
+               {
+               }
+
+
+               // Properties
+
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               [ConfigurationProperty ("findValue",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               public string FindValue {
+                       get { return (string) base [find_value]; }
+                       set { base [find_value] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("storeLocation",
+                        DefaultValue = "CurrentUser",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreLocation StoreLocation {
+                       get { return (StoreLocation) base [store_location]; }
+                       set { base [store_location] = value; }
+               }
+
+               [ConfigurationProperty ("storeName",
+                        DefaultValue = "My",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreName StoreName {
+                       get { return (StoreName) base [store_name]; }
+                       set { base [store_name] = value; }
+               }
+
+               [ConfigurationProperty ("x509FindType",
+                        DefaultValue = "FindBySubjectDistinguishedName",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509FindType X509FindType {
+                       get { return (X509FindType) base [x509_find_type]; }
+                       set { base [x509_find_type] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509RecipientCertificateClientElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509RecipientCertificateClientElement.cs
new file mode 100644 (file)
index 0000000..7ab0978
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// X509RecipientCertificateClientElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class X509RecipientCertificateClientElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty authentication;
+               static ConfigurationProperty default_certificate;
+               static ConfigurationProperty scoped_certificates;
+
+               static X509RecipientCertificateClientElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       authentication = new ConfigurationProperty ("authentication",
+                               typeof (X509ServiceCertificateAuthenticationElement), null, null/* FIXME: get converter for X509ServiceCertificateAuthenticationElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       default_certificate = new ConfigurationProperty ("defaultCertificate",
+                               typeof (X509DefaultServiceCertificateElement), null, null/* FIXME: get converter for X509DefaultServiceCertificateElement*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       scoped_certificates = new ConfigurationProperty ("scopedCertificates",
+                               typeof (X509ScopedServiceCertificateElementCollection), null, null/* FIXME: get converter for X509ScopedServiceCertificateElementCollection*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (authentication);
+                       properties.Add (default_certificate);
+                       properties.Add (scoped_certificates);
+               }
+
+               public X509RecipientCertificateClientElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("authentication",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509ServiceCertificateAuthenticationElement Authentication {
+                       get { return (X509ServiceCertificateAuthenticationElement) base [authentication]; }
+               }
+
+               [ConfigurationProperty ("defaultCertificate",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509DefaultServiceCertificateElement DefaultCertificate {
+                       get { return (X509DefaultServiceCertificateElement) base [default_certificate]; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("scopedCertificates",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509ScopedServiceCertificateElementCollection ScopedCertificates {
+                       get { return (X509ScopedServiceCertificateElementCollection) base [scoped_certificates]; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509RecipientCertificateServiceElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509RecipientCertificateServiceElement.cs
new file mode 100644 (file)
index 0000000..e60953e
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// X509RecipientCertificateServiceElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class X509RecipientCertificateServiceElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty find_value;
+               static ConfigurationProperty store_location;
+               static ConfigurationProperty store_name;
+               static ConfigurationProperty x509_find_type;
+
+               static X509RecipientCertificateServiceElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       find_value = new ConfigurationProperty ("findValue",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_location = new ConfigurationProperty ("storeLocation",
+                               typeof (StoreLocation), "LocalMachine", null/* FIXME: get converter for StoreLocation*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       store_name = new ConfigurationProperty ("storeName",
+                               typeof (StoreName), "My", null/* FIXME: get converter for StoreName*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       x509_find_type = new ConfigurationProperty ("x509FindType",
+                               typeof (X509FindType), "FindBySubjectDistinguishedName", null/* FIXME: get converter for X509FindType*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (find_value);
+                       properties.Add (store_location);
+                       properties.Add (store_name);
+                       properties.Add (x509_find_type);
+               }
+
+               public X509RecipientCertificateServiceElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("findValue",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string FindValue {
+                       get { return (string) base [find_value]; }
+                       set { base [find_value] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("storeLocation",
+                        DefaultValue = "LocalMachine",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreLocation StoreLocation {
+                       get { return (StoreLocation) base [store_location]; }
+                       set { base [store_location] = value; }
+               }
+
+               [ConfigurationProperty ("storeName",
+                        DefaultValue = "My",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreName StoreName {
+                       get { return (StoreName) base [store_name]; }
+                       set { base [store_name] = value; }
+               }
+
+               [ConfigurationProperty ("x509FindType",
+                        DefaultValue = "FindBySubjectDistinguishedName",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509FindType X509FindType {
+                       get { return (X509FindType) base [x509_find_type]; }
+                       set { base [x509_find_type] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ScopedServiceCertificateElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ScopedServiceCertificateElement.cs
new file mode 100644 (file)
index 0000000..2aba888
--- /dev/null
@@ -0,0 +1,114 @@
+//
+// X509ScopedServiceCertificateElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class X509ScopedServiceCertificateElement
+                : ConfigurationElement
+       {
+               public X509ScopedServiceCertificateElement () {
+               }
+
+               // Properties
+
+               [ConfigurationProperty ("findValue",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator (MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string FindValue {
+                       get { return (string) base ["findValue"]; }
+                       set { base ["findValue"] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("storeLocation",
+                        DefaultValue = "CurrentUser",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreLocation StoreLocation {
+                       get { return (StoreLocation) base ["storeLocation"]; }
+                       set { base ["storeLocation"] = value; }
+               }
+
+               [ConfigurationProperty ("storeName",
+                        DefaultValue = "My",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreName StoreName {
+                       get { return (StoreName) base ["storeName"]; }
+                       set { base ["storeName"] = value; }
+               }
+
+               [ConfigurationProperty ("targetUri",
+                        DefaultValue = null,
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               public Uri TargetUri {
+                       get { return (Uri) base ["targetUri"]; }
+                       set { base ["targetUri"] = value; }
+               }
+
+               [ConfigurationProperty ("x509FindType",
+                        DefaultValue = "FindBySubjectDistinguishedName",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509FindType X509FindType {
+                       get { return (X509FindType) base ["x509FindType"]; }
+                       set { base ["x509FindType"] = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ScopedServiceCertificateElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ScopedServiceCertificateElementCollection.cs
new file mode 100644 (file)
index 0000000..6d341ea
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// X509ScopedServiceCertificateElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (X509ScopedServiceCertificateElement),
+                AddItemName = "add",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       public sealed class X509ScopedServiceCertificateElementCollection
+                : ServiceModelConfigurationElementCollection<X509ScopedServiceCertificateElement>,  ICollection,  IEnumerable
+       {
+               protected override object GetElementKey (ConfigurationElement element) {
+                       X509ScopedServiceCertificateElement el = (X509ScopedServiceCertificateElement) element;
+                       return el.TargetUri;
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ServiceCertificateAuthenticationElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/X509ServiceCertificateAuthenticationElement.cs
new file mode 100644 (file)
index 0000000..0c7110e
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// X509ServiceCertificateAuthenticationElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class X509ServiceCertificateAuthenticationElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty certificate_validation_mode;
+               static ConfigurationProperty custom_certificate_validator_type;
+               static ConfigurationProperty revocation_mode;
+               static ConfigurationProperty trusted_store_location;
+
+               static X509ServiceCertificateAuthenticationElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       certificate_validation_mode = new ConfigurationProperty ("certificateValidationMode",
+                               typeof (X509CertificateValidationMode), "ChainTrust", null/* FIXME: get converter for X509CertificateValidationMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       custom_certificate_validator_type = new ConfigurationProperty ("customCertificateValidatorType",
+                               typeof (string), "", new StringConverter (), null,
+                               ConfigurationPropertyOptions.None);
+
+                       revocation_mode = new ConfigurationProperty ("revocationMode",
+                               typeof (X509RevocationMode), "Online", null/* FIXME: get converter for X509RevocationMode*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       trusted_store_location = new ConfigurationProperty ("trustedStoreLocation",
+                               typeof (StoreLocation), "CurrentUser", null/* FIXME: get converter for StoreLocation*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (certificate_validation_mode);
+                       properties.Add (custom_certificate_validator_type);
+                       properties.Add (revocation_mode);
+                       properties.Add (trusted_store_location);
+               }
+
+               public X509ServiceCertificateAuthenticationElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("certificateValidationMode",
+                        DefaultValue = "ChainTrust",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509CertificateValidationMode CertificateValidationMode {
+                       get { return (X509CertificateValidationMode) base [certificate_validation_mode]; }
+                       set { base [certificate_validation_mode] = value; }
+               }
+
+               [ConfigurationProperty ("customCertificateValidatorType",
+                        DefaultValue = "",
+                        Options = ConfigurationPropertyOptions.None)]
+               [StringValidator ( MinLength = 0,
+                       MaxLength = int.MaxValue,
+                        InvalidCharacters = null)]
+               public string CustomCertificateValidatorType {
+                       get { return (string) base [custom_certificate_validator_type]; }
+                       set { base [custom_certificate_validator_type] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+               [ConfigurationProperty ("revocationMode",
+                        DefaultValue = "Online",
+                        Options = ConfigurationPropertyOptions.None)]
+               public X509RevocationMode RevocationMode {
+                       get { return (X509RevocationMode) base [revocation_mode]; }
+                       set { base [revocation_mode] = value; }
+               }
+
+               [ConfigurationProperty ("trustedStoreLocation",
+                        DefaultValue = "CurrentUser",
+                        Options = ConfigurationPropertyOptions.None)]
+               public StoreLocation TrustedStoreLocation {
+                       get { return (StoreLocation) base [trusted_store_location]; }
+                       set { base [trusted_store_location] = value; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XPathMessageFilterElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XPathMessageFilterElement.cs
new file mode 100644 (file)
index 0000000..81eb38a
--- /dev/null
@@ -0,0 +1,99 @@
+//
+// XPathMessageFilterElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class XPathMessageFilterElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty filter;
+
+               static XPathMessageFilterElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       filter = new ConfigurationProperty ("filter",
+                               typeof (XPathMessageFilter), null, null/* FIXME: get converter for XPathMessageFilter*/, null,
+                               ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
+
+                       properties.Add (filter);
+               }
+
+               public XPathMessageFilterElement ()
+               {
+               }
+
+
+               // Properties
+
+               [ConfigurationProperty ("filter",
+                        DefaultValue = null,
+                        Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
+                       IsRequired = true,
+                       IsKey = true)]
+               public XPathMessageFilter Filter {
+                       get { return (XPathMessageFilter) base [filter]; }
+                       set { base [filter] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XPathMessageFilterElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XPathMessageFilterElementCollection.cs
new file mode 100644 (file)
index 0000000..0d37bdb
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// XPathMessageFilterElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (XPathMessageFilterElement),
+                AddItemName = "add",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
+       [MonoTODO]
+       public sealed partial class XPathMessageFilterElementCollection
+                : ServiceModelConfigurationElementCollection<XPathMessageFilterElement>,  ICollection,  IEnumerable
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+
+               static XPathMessageFilterElementCollection ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+               }
+
+               public XPathMessageFilterElementCollection ()
+               {
+               }
+
+
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XPathMessageFilterElementComparer.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XPathMessageFilterElementComparer.cs
new file mode 100644 (file)
index 0000000..e6a2090
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// XPathMessageFilterElementComparer.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XmlDictionaryReaderQuotasElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XmlDictionaryReaderQuotasElement.cs
new file mode 100644 (file)
index 0000000..c61174a
--- /dev/null
@@ -0,0 +1,168 @@
+//
+// XmlDictionaryReaderQuotasElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [MonoTODO]
+       public sealed partial class XmlDictionaryReaderQuotasElement
+                : ConfigurationElement
+       {
+               // Static Fields
+               static ConfigurationPropertyCollection properties;
+               static ConfigurationProperty max_array_length;
+               static ConfigurationProperty max_bytes_per_read;
+               static ConfigurationProperty max_depth;
+               static ConfigurationProperty max_name_table_char_count;
+               static ConfigurationProperty max_string_content_length;
+
+               static XmlDictionaryReaderQuotasElement ()
+               {
+                       properties = new ConfigurationPropertyCollection ();
+                       max_array_length = new ConfigurationProperty ("maxArrayLength",
+                               typeof (int), "0", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_bytes_per_read = new ConfigurationProperty ("maxBytesPerRead",
+                               typeof (int), "0", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_depth = new ConfigurationProperty ("maxDepth",
+                               typeof (int), "0", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_name_table_char_count = new ConfigurationProperty ("maxNameTableCharCount",
+                               typeof (int), "0", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       max_string_content_length = new ConfigurationProperty ("maxStringContentLength",
+                               typeof (int), "0", null/* FIXME: get converter for int*/, null,
+                               ConfigurationPropertyOptions.None);
+
+                       properties.Add (max_array_length);
+                       properties.Add (max_bytes_per_read);
+                       properties.Add (max_depth);
+                       properties.Add (max_name_table_char_count);
+                       properties.Add (max_string_content_length);
+               }
+
+               public XmlDictionaryReaderQuotasElement ()
+               {
+               }
+
+
+               // Properties
+
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxArrayLength",
+                        DefaultValue = "0",
+                        Options = ConfigurationPropertyOptions.None)]
+               public int MaxArrayLength {
+                       get { return (int) base [max_array_length]; }
+                       set { base [max_array_length] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxBytesPerRead",
+                        DefaultValue = "0",
+                        Options = ConfigurationPropertyOptions.None)]
+               public int MaxBytesPerRead {
+                       get { return (int) base [max_bytes_per_read]; }
+                       set { base [max_bytes_per_read] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxDepth",
+                        DefaultValue = "0",
+                        Options = ConfigurationPropertyOptions.None)]
+               public int MaxDepth {
+                       get { return (int) base [max_depth]; }
+                       set { base [max_depth] = value; }
+               }
+
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               [ConfigurationProperty ("maxNameTableCharCount",
+                        DefaultValue = "0",
+                        Options = ConfigurationPropertyOptions.None)]
+               public int MaxNameTableCharCount {
+                       get { return (int) base [max_name_table_char_count]; }
+                       set { base [max_name_table_char_count] = value; }
+               }
+
+               [ConfigurationProperty ("maxStringContentLength",
+                        DefaultValue = "0",
+                        Options = ConfigurationPropertyOptions.None)]
+               [IntegerValidator ( MinValue = 0,
+                       MaxValue = int.MaxValue,
+                       ExcludeRange = false)]
+               public int MaxStringContentLength {
+                       get { return (int) base [max_string_content_length]; }
+                       set { base [max_string_content_length] = value; }
+               }
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return properties; }
+               }
+
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XmlElementElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XmlElementElement.cs
new file mode 100644 (file)
index 0000000..c564f51
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// XmlElementElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       public sealed class XmlElementElement
+                : ConfigurationElement
+       {
+               public XmlElementElement () {
+               }
+
+               public XmlElementElement (XmlElement element) {
+                       XmlElement = element;
+               }
+
+               // Properties
+
+               protected override ConfigurationPropertyCollection Properties {
+                       get { return base.Properties; }
+               }
+
+               [ConfigurationProperty ("xmlElement",
+                        DefaultValue = null,
+                        Options = ConfigurationPropertyOptions.IsKey,
+                       IsKey = true)]
+               public XmlElement XmlElement {
+                       get { return (XmlElement) base ["xmlElement"]; }
+                       set { base ["xmlElement"] = value; }
+               }
+
+               protected override void DeserializeElement (XmlReader reader, bool serializeCollectionKey) {
+                       base.DeserializeElement (reader, serializeCollectionKey);
+               }
+
+               protected override void PostDeserialize () {
+                       base.PostDeserialize ();
+               }
+
+               protected override bool SerializeToXmlElement (XmlWriter writer, string elementName) {
+                       return base.SerializeToXmlElement (writer, elementName);
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XmlElementElementCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Configuration/XmlElementElementCollection.cs
new file mode 100644 (file)
index 0000000..25677a6
--- /dev/null
@@ -0,0 +1,85 @@
+//
+// XmlElementElementCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Configuration;
+using System.Net;
+using System.Net.Security;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Diagnostics;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.MsmqIntegration;
+using System.ServiceModel.PeerResolvers;
+using System.ServiceModel.Security;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Configuration
+{
+       [ConfigurationCollection (typeof (XmlElementElement),
+                AddItemName = "xmlElement",
+                RemoveItemName = "remove",
+                ClearItemsName = "clear",
+                CollectionType = ConfigurationElementCollectionType.BasicMap)]
+       public sealed class XmlElementElementCollection
+                : ServiceModelConfigurationElementCollection<XmlElementElement>, ICollection, IEnumerable
+       {
+               public XmlElementElementCollection () {
+                       AddElementName = "xmlElement";
+               }
+
+               protected override object GetElementKey (ConfigurationElement element) {
+                       return ((XmlElementElement) element).XmlElement;
+               }
+
+               [MonoTODO]
+               protected override bool OnDeserializeUnrecognizedElement (string elementName, XmlReader reader) {
+                       //return base.OnDeserializeUnrecognizedElement (elementName, reader);
+                       reader.ReadOuterXml ();
+                       return true;
+               }
+
+               protected override void Unmerge (ConfigurationElement sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode saveMode) {
+                       base.Unmerge (sourceElement, parentElement, saveMode);
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/CallbackDebugBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/CallbackDebugBehavior.cs
new file mode 100644 (file)
index 0000000..74e9fde
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// CallbackDebugBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2008 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public class CallbackDebugBehavior : IEndpointBehavior
+       {
+               bool include_exception;
+
+               public CallbackDebugBehavior (bool includeExceptionDetailInFaults)
+               {
+                       this.include_exception = includeExceptionDetailInFaults;
+               }
+
+               public bool IncludeExceptionDetailInFaults {
+                       get { return include_exception; }
+                       set { include_exception = value; }
+               }
+
+               void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint,
+                       BindingParameterCollection parameters)
+               {
+               }
+
+               void IEndpointBehavior.ApplyDispatchBehavior (ServiceEndpoint endpoint,
+                       EndpointDispatcher dispatcher)
+               {
+               }
+
+               void IEndpointBehavior.ApplyClientBehavior (
+                       ServiceEndpoint endpoint, ClientRuntime behavior)
+               {
+                       behavior.CallbackDispatchRuntime.ChannelDispatcher.IncludeExceptionDetailInFaults = IncludeExceptionDetailInFaults;
+               }
+
+               void IEndpointBehavior.Validate (ServiceEndpoint endpoint)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/CallbackTimeoutsBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/CallbackTimeoutsBehavior.cs
new file mode 100644 (file)
index 0000000..e37af41
--- /dev/null
@@ -0,0 +1,66 @@
+//\r
+// CallbackTimeoutsBehavior.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Novell, Inc.  http://www.novell.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Description\r
+{\r
+       class CallbackTimeoutsBehavior : IEndpointBehavior\r
+       {\r
+               public TimeSpan TransactionTimeout {\r
+                       get;\r
+                       set;\r
+               }\r
+\r
+               public CallbackTimeoutsBehavior (TimeSpan timeout) {\r
+                       TransactionTimeout = timeout;\r
+               }\r
+\r
+               #region IEndpointBehavior Members\r
+\r
+               void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection parameters) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               void IEndpointBehavior.ApplyDispatchBehavior (ServiceEndpoint serviceEndpoint, System.ServiceModel.Dispatcher.EndpointDispatcher dispatcher) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               void IEndpointBehavior.ApplyClientBehavior (ServiceEndpoint serviceEndpoint, System.ServiceModel.Dispatcher.ClientRuntime behavior) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               void IEndpointBehavior.Validate (ServiceEndpoint serviceEndpoint) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               #endregion\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ChangeLog
new file mode 100644 (file)
index 0000000..30f241c
--- /dev/null
@@ -0,0 +1,967 @@
+2008-05-28  Noam Lampert <noaml@mainsoft.com>
+       * ContractDescriptionGenerator.cs: Allow services to implement more than one contract.
+         
+2008-05-22  Noam Lampert <noaml@mainsoft.com>
+       * ServiceDebugBehavior.cs: Correctly propagate IncludeExceptionDetailsInFaults. Previous code
+         overwrote values set in ServiceBehaviorAttribute.
+         
+2008-05-22  Roei Erez  <roeie@mainsoft.com>
+       * fix ContractDescription.GetContract implementation
+       * Refactor Request processing
+       * Add support for message inspectors
+       * Add support for InstanceContextProvider & InstanceProvider, including lifecycles events
+       like: ReleaseServiceInstance, Open, Close...
+       * Add relevant test cases.
+
+2008-05-01  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ContractDescriptionGenerator.cs: Support specifying custom names of
+         operations, actions, parameters and return value via attributes.
+
+2008-04-21  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceDebugBehavior.cs: implement ApplyDispatchBehavior.
+       * ServiceMetadataBehavior.cs: fix ApplyDispatchBehavior.
+       * ServiceMetadataExtension.cs: refactoring, serves both 
+       ServiceDebugBehavior and ServiceMetadataBehavior by providing suitable 
+       functionality.          
+
+2008-04-21  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * WsdlExporter.cs: fix ExportEndpoint: SoapBinding.Style is initialized 
+       with SoapBindingStyle.Document value. 
+
+2008-04-17  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * ServiceEndpoint.cs: fixed Name property
+
+2008-04-10  Eyal Alaluf <eyala@mainsoft.com>
+
+       * TypedMessageConverter.cs: Simplified to use XmlMessagesFormatter and
+         DataContractMessagesFormatter that handle the actual message
+         serialization/deserialization.
+         Added support for XmlSerializaerFormat serialization.
+       * ContractDescriptionGenerator.cs: Refactored to expose utilities for
+         creating MessageDescription from types for TypedMessageConverter use.
+       * ServiceModelInternalConverter.cs: Removed.
+
+2008-04-08  Roei Erez <roeie@mainsoft.com>
+
+       * ServiceAuthorizationBehavior.cs:
+         -- remove throwing NotImplementedException and add MonoTODO
+       * ServiceDebugBehavior.cs
+         -- remove throwing NotImplementedException and add MonoTODO
+       * ServiceEndpoint.cs
+         -- Add validate method.
+       * ServiceMetadataBehavior.cs
+         -- remove throwing NotImplementedException and add MonoTODO
+       
+2008-03-24  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * PolicyVersion.cs: imפlement ToString method, fix Namespace property.
+       * ServiceTimeoutsBehavior.cs: add internal class behavior corresponds
+       ServiceTimeoutsElement.
+
+2008-03-23  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * ContractDescriptionGenerator.cs: fixed GetMessage, fixed namespace
+       while creating message part
+
+2008-03-04  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ContractDescriptionGenerator.cs: Init ConfigurationName from attribute.
+
+2008-02-27  Eyal Alaluf <eyala@mainsoft.com>
+
+       * MetadataSectionSerializerBase.cs WSTrustMessageConverters.cs:
+         Fix compilation warnings.
+
+2008-02-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CallbackDebugBehavior.cs : new class.
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : When reflecting a method,
+         iterate attributes and added such attribute that implements
+         IOperationBehavior to operation's Behaviors.
+
+2007-08-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TypedMessageConverter.cs, ServiceModelInternalConverter.cs,
+         ContractDescriptionGenerator.cs : significant rewrite for
+         message serialization and deserialization. Proxy types are not
+         created anymore. Instead, serializers are created for every
+         message member. (Deserialization had been broken due to missing
+         default constructor of the proxy type.)
+
+2007-08-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelInternalConverter.cs : use MessagePartDescription.Name
+         instead of MemberInfo.Name.
+
+2007-08-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TypedMessageConverter.cs ServiceModelInternalConverter.cs
+         ContractDescriptionGenerator.cs :
+         support MessageContractAttribute wrapper name specification and
+         non-wrapping outputs.
+
+2007-07-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : reverted previous change. It is
+         conceptually wrong. RegisterInfo serialization is still possible
+         because it could contain private DataContract member which works
+         as a proxy to get or set properties on the RegisterInfo itself.
+
+2007-07-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : added hack to support
+         [MessageContract] type which has no [MessageBody] member.
+
+2007-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSTrustSTSContract.cs : write prefixes.
+
+2007-03-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSTrustMessageConverters.cs, WSTrustSTSContract.cs:
+         now they could be used for both TLS and SPNego.
+
+2007-03-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSTrustMessageConverters.cs : fixed incorrect empty element check.
+       * WSTrustSTSContract.cs :
+         Fixed Lifetime content namespace. Write KeySize.
+
+2007-03-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSTrustSTSContract.cs, WSTrustMessageConverters.cs :
+         process RequestedProofToken as raw TLS 1.0 application data, which
+         is likely a shared key.
+
+2007-03-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSTrustSTSContract.cs : support t:Authenticator output in RSTR.
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSTrustSTSContract.cs, WSTrustMessageConverters.cs :
+         (This inidividual commit breaks the build.)
+         Support all xml contents required for Sslnego RSTR collection.
+
+2007-03-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSTrustSTSContract.cs, WSTrustMessageConverters.cs :
+         Added IssueReply() operation to support RSTR from client.
+         Several fixes to read and write RSTR correctly.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceMetadataExtension.cs :
+         DispatchRuntime.InternalEndpointDispatcher was eliminated.
+
+2007-03-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSTrustSTSContract.cs, WSTrustMessageConverters.cs :
+         added missing support for token negotiation (WS-Trust section 10.3).
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentials.cs : oops.
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentials.cs, ServiceCredentials.cs : Clone() throws
+         NotImplementedException when it returns an instance of different
+         type.
+
+2006-12-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceMetadataExtension.cs : raising an NIE than returning null
+         is better (at least it avoids extra debugging).
+
+2006-12-04  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WsdlExporter.cs : Binding.MessageVersion could be null.
+
+2006-12-04  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * DataContractSerializerMessageContractImporter.cs :
+         The latest XmlSchemaImporter.ImportTypeMapping() correctly reports
+         an error for xs:* primitive type argument. So it should not do
+         that as well.
+
+2006-12-04  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * MetadataSectionSerializerBase.cs : Build fix.
+         It was based on old 2.0 beta API
+
+2006-10-18  Ankit Jain  <jankit@novell.com>
+
+       * ServiceMetadataBehavior.cs (AddBindingParameters): Add endpoint for
+       HTTP GET requests.
+       (ApplyDispatchBehavior): Move code to add *InstanceContextProviders to ..
+       * ServiceMetadataExtension.cs (ServiceMetadataExtension.Attach): .. here.
+       (HttpGetWsdl): Service HTTP GET requests like ?wsdl.
+
+2006-10-17  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs (ExportEndpoint): Don't emit Soap* if
+       MessageVersion.None
+       (ExportService): Likewise.
+
+2006-10-13  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs (ExportContract): Move code to .. 
+       (ExportContractInternal): .. this. Add support for IWsdlExportExtension.
+       (ExportEndpoint): Add support for IWsdlExportExtension.
+       (ExportService): Return Port.
+       * DataContractSerializerOperationBehavior.cs : Add IWsdlExportExtension
+       interface.
+
+2006-10-12  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ServiceDebugBehavior.cs : added Http[s]Help properties.
+
+2006-10-04  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ServiceCredentials.cs : do nothing in ApplyDispatchBehavior().
+
+2006-10-04  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : reject async begin method whose
+         name does not begin with "Begin". (It even applies to operations
+         which has OperationContractAttribute with an explicit name(!).)
+
+2006-10-04  Ankit Jain  <jankit@novell.com>
+
+       * ServiceAuthorizationBehavior.cs (ApplyDispatchBehavior): Remove NYI
+       exception.
+       * ServiceMetadataBehavior.cs (ApplyDispatchBehavior): Instantiate and add a
+       ServiceMetadataExtension to service host's extensions. Also, set the
+       InstanceContextProvider for endpoints with IMetadataExchange contract
+       to MexInstanceContextProvider.
+       * ServiceMetadataExtension.cs (Metadata): Add internal 'set'.
+
+2006-10-04  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * OperationDescriptionCollection.cs,
+         ContractDescriptionGenerator.cs : operation names must not conflict
+         each other.
+
+2006-10-04  Ankit Jain  <jankit@novell.com>
+
+       * ServiceContractGenerator.cs (GenerateProxyClass): Make .ctors public.
+
+2006-10-03  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : EndBlah() must not be assigned an
+         OperationContractAttribute.
+
+2006-09-22  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * LocalServiceSecuritySettings.cs : fix Clone().
+
+2006-09-22  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : copy ProtectionLevel from attributes
+         to descriptions if required.
+
+2006-09-22  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * FaultDescription.cs, MessageDescription.cs, ContractDescription.cs,
+         MessagePartDescription.cs, OperationDescription.cs :
+         Fixed HasProtectionLevel. It is always true when ProtectionLevel is set.
+
+2006-09-18  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs (ExportEndpoint): Throw if endpoint.Binding is null.
+       (ExportParameters):
+       (ExportTypeMessage): Reprocess the schema.      
+
+2006-09-08  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs (ExportParameters): Split into this and ..
+       (ExportMessageBodyDescription): .. this.
+       Check for duplicate message elements.
+       (IsTypeMessage): Checks is a MessageBodyDescription has a single part of
+       type System.ServiceModel.Channels.Message
+       (ExportTypeMessage): Exports a complex type for type 
+       System.ServiceModel.Channels.Message
+
+2006-09-07  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs (ExportedContracts): New hashtable to keep track of
+       the exported contracts.
+       (ExportContract): Throw exception if contract has already been exported.
+
+2006-09-07  Ankit Jain  <jankit@novell.com>
+
+       * MetadataBundle.cs (MetadataSet.WriteTo): Remove WriteStartDocument
+       as suggested by Atsushi.
+
+2006-09-07  Ankit Jain  <jankit@novell.com>
+
+       * MetadataBundle.cs (MetadataSet.WriteTo): Add WriteStartDocument.
+
+2006-09-07  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs (ExportService): Export <service> and <port>.
+       (GetService): New.
+       (XsdExporter): New. Update code to use this instead of the 
+       field, xsd_exporter.
+       (schema_set): Remove.
+       (GeneratedXmlSchemas): Use XsdExporter.Schemas directly.
+
+2006-09-07  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs (ExportContract): Add 'imports'.
+
+2006-09-07  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ServiceCredentials.cs : added missing members.
+
+2006-09-06  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs (ExportContract): Use String.Concat
+       * ContractDescriptionGenerator.cs
+       (ContractDescriptionGenerator.GetOperation): Set IsOneWay.
+       * OperationDescription.cs (OperationDescription.IsOneWay): Add an
+       internal setter.
+
+2006-09-06  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs (WsdlExporter.ExportEndpoint): Initial implementation.
+
+2006-09-06  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ServiceMetadataBehavior.cs : updated API to RC1.
+
+2006-09-05  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs (WsdlExporter.ExportContract): Add Namespaces.
+
+2006-09-05  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ServiceModelInternalConverter.cs : when a message part type is null
+         (such as void return value), supply dummy type (object).
+
+2006-09-05  Ankit Jain  <jankit@novell.com>
+
+       * MetadataBundle.cs (MetadataSet.WriteTo): Implement.
+       * MetadataSectionSerializerBase.cs (WriteObject_ServiceDescription): Use
+       ServiceDescription.Serializer to serialize.
+
+2006-09-05  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs (WsdlExporter.AddImport): New.
+       (WsdlExporter.GetSchemaElementForPart): Add 'schema' param.
+       (WsdlExporter.ExportContract): Update to changes.
+
+2006-09-05  Ankit Jain  <jankit@novell.com>
+
+       * MetadataSection.cs (MetadataSection.CreateFromSchema): Implement.
+       (MetadataSection.CreateFromServiceDescription): Implement.
+       * WsdlExporter.cs (WsdlExporter.GetGeneratedMetadata): Update to use
+       new methods above.
+
+2006-09-04  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporter.cs: Initial implementation for ExportContract.
+       * MetadataExporter.cs (GetGeneratedMetadata): Fix signature.
+       * ContractDescriptionGenerator.cs (GetMessage): Seperate Namespace and
+       Name with "/" if its not there in Namespace.
+
+2006-08-30  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ServiceMetadataBehavior.cs : for now avoid NotImplementedException.
+       * ServiceDebugBehavior.cs : implemented AddBindingParameters() and
+         ApplyDispatchBehavior().
+       * ServiceCredentials.cs : implemented AddBindingParameters().
+
+2006-08-28  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSTrustMessageConverters.cs : added response reader class.
+
+2006-08-23  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSTrustSTSContract.cs : rewritten to not use DataContract.
+       * WSTrustMessageConverters.cs : new file.
+
+2006-08-22  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ClientCredentials.cs :
+         CloneCore() is virtual. CreateSecurityTokenManager() is public.
+       * ServiceCredentials.cs :
+         Added secure conversation credential.
+         CreateSecurityTokenManager() is public.
+
+2006-08-16  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSTrustSTSContract.cs : added some more members in request type.
+         WST request and response types are renamed.
+
+2006-08-14  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSTrustSTSContract.cs : added internal interface for security token
+         service (STS).
+
+2006-08-11  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ClientCredentials.cs : implement CreateSecurityTokenManager() and
+         partly AddBindingParameters().
+       * ServiceCredentials.cs : CreateSecurityTokenManager() as well.
+
+2006-08-10  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ClientCredentials.cs : temporarily comment out NIE in 
+         ApplyClientBehavior().
+
+2006-08-02  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * MetadataSectionSerializerBase.cs : made internal, namespace fix.
+
+2006-07-31  Ankit Jain  <jankit@novell.com>
+
+       * MetadataExchangeClient.cs (GetMetadataInternal): Use
+       MessageHeaders.MessageId instead of manually adding the header.
+       (SoapEnvelopeNamespace): Remove.
+       (AddressingNamespace): Remove.
+
+2006-07-28  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ServiceCredentials.cs :
+         added missing IssuedTokenAuthentication property.
+
+2006-07-27  Ankit Jain  <jankit@novell.com>
+
+       * DataContractSerializerMessageContractImporter.cs (resolveElement): Use
+       XmlSchemaSet.Compile ()
+
+2006-07-28  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ClientCredentials.cs : initialize SupportInteractive as true.
+
+2006-07-28  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * LocalClientSecuritySettings.cs : moved to S.SM.Channels.
+
+2006-07-27  Ankit Jain  <jankit@novell.com>
+
+       * MessagePartDescription.cs (TypeName):
+       (XmlTypeMapping): New, internal properties, used by
+       ServiceContractGenerator.
+       * DataContractSerializerMessageContractImporter.cs (ImportContract):
+       Handle a void return type.
+       (resolveElement):
+       (resolveParticle): Use XmlSchemaImporter to fill in
+       MessagePartDescription.XmlTypeMapping .
+       (GetCLRTypeName): New.
+       * ServiceContractGenerator.cs (.ctor): Set default options.
+       (GenerateServiceContractType): Support ChannelInterface.        
+       (GenerateProxyClass): Emit more .ctors
+       (GenerateChannelInterface): New.
+       (ExportInterface): Emit ServiceContractAttribute.Namespace property.
+       (ExportParameters): New. Extract code for emitting methods params from
+       AddOperationMethods & AddImplementationMethods.
+       (ExportMessages): New. Emits method params using MessageDescriptionCollection.
+       (ExportDataContract): New. Emits code for a DataContract from a XmlTypeMapping.
+       (GetXmlNamespace): New. Gets the Namespace param of XmlTypeAttribute or
+       XmlRootAttribute.
+
+2006-07-27  Ankit Jain  <jankit@novell.com>
+
+       * MetadataResolver.cs (ResolveContracts): Move the exception handling
+       code for MetadataProxy.Get to .. 
+       * MetadataExchangeClient.cs (GetMetadataInternal): .. here.
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentials.cs : July CTP API updates.
+
+2006-07-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PolicyConversionContext.cs : GetFaultBindingAssertions() argument:
+         MessageFault -> FaultDescription.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TypedMessageConverter.cs : implemented FromMessage() for
+         DataContract converter. Though it won't work right now.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelInternalConverter.cs : It was bug #78855, and is fixed.
+       * TypedMessageConverter.cs :
+         June CTP changed to write wrapper element.
+         Default URI is http://tempuri.org/, trailing '/' was missing.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelInternalConverter.cs :
+         The runtime errors are still there...
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IContractBehavior.cs : The API became sane in June CTP.
+       * MatchAllEndpointBehavior.cs : vanished.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelInternalConverter.cs : assembly.Save() does not seem
+         to be required anymore. Maybe it was a runtime bug.
+
+2006-07-13  Ankit Jain  <jankit@novell.com>
+
+       * MetadataImporter.cs:
+       * WsdlImporter.cs: 
+       * DataContractSerializerMessageContractImporter.cs:
+       * MetadataResolver.cs: Update to June CTP changes.
+
+2006-07-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : fix async method handling. Since
+         begin methods return IAsyncResult, not the return value type, it
+         should not be used to generate MessagePartDescription.
+         OperationContractAttribute.ReplyAction should not be ignored.
+
+2006-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WebServiceHelper.cs : comment out the entire source (unused now).
+
+2006-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IMetadataExchange.cs : another unexpected change ;-)
+
+2006-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IMetadataExchange.cs : take back async methods.
+
+2006-07-12  Ankit Jain  <jankit@novell.com>
+
+       * MetadataTransferClient.cs: Renamed to .. 
+       * MetadataExchangeClient.cs: .. this. Update to June CTP changes.
+       (MetadataExchangeClient.MetadataProxy): Proxy for IMetadataExchange
+       service contract.
+       (MetadataExchangeClient.GetMetadataInternal): Move GetMetadata() code
+       here. Updated to use MetadataProxy instead of doing everything manually.
+       * MetadataSectionSerializerBase.cs: Regenerated for the updated API.
+       * MetadataReference.cs: June CTP updates. Now implements
+       IXmlSerializable.
+       * MetadataResolver.cs: Update for related changes in other classes. June
+       CTP updates pending.
+       * MetadataExchangeBindings.cs
+       (MetadataExchangeBindings.CreateMexHttpBinding): Implement.
+
+2006-07-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceDebugBehavior.cs : new file.
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : support AsyncPattern methods.
+
+2006-07-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageContractConverter.cs, ServiceModelInternalConverter.cs :
+         renamed file from former to latter.
+
+2006-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceContractGenerator.cs : in ClientBase, InnerProxy -> Channel.
+
+2006-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageContractConverter.cs : exception type changed.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs :
+         MessageBodyAttribute -> MessageBodyMemberAttribute.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ReflectedContractCollection.cs : removed unused file.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescription.cs, ContractDescriptionGenerator.cs :
+         some June CTP updates (SessionMode).
+
+2006-07-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TypedMessageConverter.cs : June CTP update.
+
+2006-07-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ViaUriBehavior.cs : renamed to ClientViaBehavior.
+         File name is also being changed.
+
+2006-07-03  Ankit Jain  <jankit@novell.com>
+
+       * WsdlImporter.cs:
+       * MetadataImporter.cs: Update for changes in other files. (June CTP)
+
+2006-07-03  Ankit Jain  <jankit@novell.com>
+
+       * XmlSerializerMessageContractConverter.cs: Renaming type to ..
+       * XmlSerializerMessageContractImporter.cs: .. this.
+       * DataContractSerializerMessageContractConverter.cs: Renaming type to ..
+       * DataContractSerializerMessageContractImporter.cs: .. this.
+       * IOperationContractGenerator.cs: Renaming to ..
+       * IOperationContractGenerationExtension.cs: .. this.
+       * IServiceContractGenerator.cs: Renaming to ..
+       * IServiceContractGenerationExtension.cs: .. this.
+
+       * DataContractSerializerOperationBehavior.cs:
+       * MetadataResolver.cs:
+       * MetadataSection.cs: Update to June CTP changes.
+
+       * WsdlImporter.cs:
+       * ServiceContractGenerator.cs: Update for changes in other files.
+
+       * IMetadataExchange.cs: New.
+       * MetadataExchangeBindings.cs: New.
+
+2006-06-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageContractConverter.cs : in MessageBodyToDataContractType(),
+         support ReturnValue part as well.
+
+2006-06-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : extracted public method
+         GetOperationContractAttribute() from existing code.
+
+2006-06-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageContractConverter.cs : renaming type to 
+         ServiceModelInternalConverter as well as methods. Now it holds
+         conversion from MessageBodyDescription to DataContract Type.
+       * TypedMessageConverter.cs : dependent changes from above.
+       * ContractDescriptionGenerator.cs :
+         Temporarily commented out lines that rejects service contract
+         that does not contain any operation contracts.
+         Some refactoring.
+
+2006-06-16  Ankit Jain  <jankit@novell.com>
+
+       * MetadataSectionSerializerBase.cs: Remove debug Console.WriteLine-s.
+       * WsdlImporter.cs: Streamline .ctors
+       * MetadataImporter.cs: Likewise.
+       * MetadataResolver.cs (MetadataResolver.Resolve): Update to use
+       WSTransferGet instead of WsTransferGet.
+
+2006-06-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageContractConverter.cs, TypedMessageConverter.cs :
+         Now it generates correct code, still emitting extra assemblies...
+
+2006-06-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageContractConverter.cs :
+         Now it generates code (which is incorrect), spitting dummy.dll
+         everywhere you run code that uses TypedMessageConverter...
+
+2006-06-12 Ankit Jain  <jankit@novell.com>
+
+       * MetadataSectionSerializerBase.cs: New.
+       * MetadataBundle.cs (MetadataSet.ReadFrom): Use XmlSerializer for
+       deserializing.
+       (MetadataSet.ReadXml): Use MetadataSectionSerializer to deserialize
+       MetadataSection-s.
+
+       * MetadataImporter.cs (MetadataImporter..ctor): Use a predefined list of
+       IPolicyImportExtensions if none is specified.
+       * WsdlImporter.cs (WsdlImporter.ImportAllContracts): Cache the imported contracts.
+       (WsdlImporter.ImportAllEndpoints): Implement.
+       (WsdlImporter.ImportEndpoint): Likewise.
+       (WsdlImporter..ctor): Use a predefined list of IWsdlImportExtentions if
+       none is specified.
+       * IWsdlImporter.cs (ImportContract):
+       (ImportEndpoint): Fix param names.
+       * WsdlEndpointConversionContext.cs: Update .ctor, and implement
+       properties.
+
+       * ServiceContractGenerator.cs: Update to not depend on
+       contractDescription.ContractType as it can be null.
+       * DataContractSerializerMessageContractConverter.cs (.resolveParticle):
+       Add 'depth' param.
+
+2006-06-12  Atsushi Enomoto  <atsushi@ximian.com>
+       * TypedMessageConverter.cs, MessageContractConverter.cs :
+         ongoing implementation using Mono.CodeGeneration.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentials.cs, ClientCredentials.cs,
+         ServiceMetadataBehavior.cs : moved from Sys.SvcModel.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TypedMessageConverter.cs : some ToMessage() code.
+       * MessageContractConverter.cs,
+       * ContractDescriptionGenerator.cs : some code to generate contract 
+         type from an arbitrary Type.
+
+2006-04-27  Ankit Jain  <jankit@novell.com>
+
+       * WsdlImporter.cs:
+       * DataContractSerializerMessageContractConverter.cs:
+       * MetadataImporter.cs:
+       * WsdlContractConversionContext.cs: Change member field names from
+       camelCase to underscore_names.
+
+2006-04-26  Ankit Jain  <jankit@novell.com>
+
+       * MetadataBundle.cs (MetadataSet.ReadFrom): Initial implementation.
+       (MetadataSet.Attributes): Add missing property.
+       * MetadataReference.cs: Fix to match Feb CTP.
+       * MetadataResolver.cs: Likewise.
+       * MetadataSection.cs: Likewise.
+
+       * MetadataImporter.cs (PolicyExtensions): Implement property.
+       * MetadataTransferClient.cs (GetMetadata): Initial implementation.
+       * WsdlImporter.cs: Initial implementation.
+
+       * OperationDescription.cs (.ctor): Set is_initiating = true.
+       * MessageDescription.cs (.ctor): 'action' parameter can be null or
+       zero-length.
+       * MessageBodyDescription.cs (Parts): Add internal set method.
+
+       * WsdlContractConversionContext.cs (Contract): Implement property.
+       (WsdlPortType): Likewise.
+       * DataContractSerializerMessageContractConverter.cs (ImportContract):
+       Initial implementation.
+
+       * WebServiceHelper.cs: Copied from
+       mcs/class/System.Web.Services/System.Web.Services.Protocols
+       
+2006-04-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : it is internal.
+       * ServiceContractGenerator.cs : minimum implementation for
+         GenerateServiceContractType() for "client-proxy-gen" tool.
+
+2006-04-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : reject operation-less contract.
+
+2006-04-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionGenerator.cs : The target contract type should be
+         the interface, not the implementation type.
+
+2006-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescription.cs : extracted GetContract() implementation
+         part into ContractDescriptionGenerator.cs.
+       * ContractDescriptionGenerator.cs : new file.
+
+2006-03-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceEndpointCollection.cs WsdlImporter.cs
+         PolicyConversionContext.cs OperationDescriptionCollection.cs
+         PolicyAssertionCollection.cs MessageDescriptionCollection.cs :
+         couple of API fixes.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PeerSecurityBehavior.cs ServiceCredentials.cs
+         ServiceAuthorizationBehavior.cs :
+         Dependent fixes for System.IdentityModel reorgainzation.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointBehaviorCollection.cs ChannelDescription.cs
+         MessageHeaderDescriptionCollection.cs ServiceCredentials.cs
+         FaultDescription.cs TypedMessageConverter.cs
+         AspNetIntegrationRequirementsAttribute.cs
+         MessageDescription.cs MessagePartDescriptionCollection.cs
+         OperationBehaviorCollection.cs ListenUriBehavior.cs
+         ServiceAuthorizationBehavior.cs ChannelBehaviorCollection.cs
+         MessageBodyDescription.cs IContractBehavior.cs
+         MessagePropertyDescriptionCollection.cs
+         ContractBehaviorCollection.cs BehaviorCollection.cs
+         ServiceEndpointCollection.cs ContractDescription.cs
+         XmlFormatterOperationBehavior.cs FaultDescriptionCollection.cs
+         ServiceSecurityAuditBehavior.cs IChannelBehavior.cs
+         ServiceDescription.cs OperationBehaviorAttribute.cs
+         MatchAllEndpointBehavior.cs IEndpointBehavior.cs
+         ServiceMetadataBehavior.cs XmlSerializerOperationBehavior.cs
+         ServiceBehaviorCollection.cs HostedBindingBehavior.cs
+         MessageHeaderDescription.cs ViaUriBehavior.cs
+         MessagePartDescription.cs OperationDescriptionCollection.cs
+         IServiceBehavior.cs IOperationBehavior.cs
+         MessagePropertyDescription.cs MustUnderstandBehavior.cs
+         ServiceEndpoint.cs PeerSecurityBehavior.cs
+         OperationDescription.cs MessageDescriptionCollection.cs
+         ReflectedContractCollection.cs :
+         moved from System.ServiceModel due to the API changes.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContext.cs ContractExportBehavior.cs
+         IMessageEncodingBindingElement.cs IOperationContractGenerator.cs
+         IPolicyImporter.cs IServiceContractGenerator.cs
+         IStreamUpgradeBindingElement.cs ITransportTokenAssertionProvider.cs
+         IWsdlExporter.cs IWsdlImporter.cs InvalidChannelBindingException.cs
+         IpolicyExporter.cs MessageEncodingBindingElementConverter.cs
+         MetadataConversionError.cs MetadataExporter.cs MetadataImporter.cs
+         MetadataResolver.cs OperationContractGenerationContext.cs
+         PolicyConversionContext.cs ReliableSessionBindingElementConverter.cs
+         SecurityBindingElementConverter.cs
+         ServiceContractGenerationContext.cs ServiceContractGenerator.cs
+         ServiceThrottlingBehavior.cs
+         TransactionFlowBindingElementConverter.cs
+         TransportBindingElementConverter.cs WsdlContractConversionContext.cs
+         WsdlEndpointConversionContext.cs WsdlExporter.cs WsdlImporter.cs
+         XmlFormatterMessageContractConverter.cs
+         XmlSerializerMessageContractConverter.cs :
+         Feb. CTP API changes - chapter 1.
+
+2006-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceThrottlingBehavior.cs : ServiceThrottle was moved.
+
+2006-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContext.cs :
+         All builder methods now "reset" UnhandledBindingElements after
+         the outermost processing.
+
+2006-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContext.cs :
+         Use BindingElement's BuildBlahFactory directly. Implemented Clone().
+       * ChannelLoader.cs : removed obsolete type.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlSerializerMessageContractConverter.cs,
+         MessageEncodingBindingElementConverter.cs,
+         XmlFormatterMessageContractConverter.cs : new files in Nov. CTP.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceLoader.cs, TypeLoader.cs : removed.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContext.cs : IListener/-Factory vanished in Nov. CTP.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IWsdlExporter.cs, InvalidChannelBindingException.cs,
+         MetadataImporter.cs, IWsdlImporter.cs, IPolicyImporter.cs,
+         MetadataConversionError.cs, IpolicyExporter.cs,
+         MetadataExporter.cs, PolicyConversionContext.cs :
+         New files in beta2
+       * ITypeResolver.cs, WsdlBindingConversionContext.cs, 
+         IWsdlBindingElementConverter.cs,
+         WsdlOperationBindingCoversionContext.cs, 
+         WsdlMessageBindingConversionContext.cs,
+         WsdlMessageConversionContext.cs, IWsdlBindingConverter.cs,
+         IWsdlContractConverter.cs, IWsdlEndpointConverter.cs,
+         WsdlConversionContext.cs, WsdlConverters.cs,
+         InvalidSettingsException.cs, WsdlBindingConverterBase.cs,
+         WsdlConversionError.cs, CustomBindingConverter.cs, 
+         WsdlOperationConversionContext.cs :
+         Removed in beta2
+       * ReliableSessionBindingElementConverter.cs, ServiceLoader.cs,
+         TransportBindingElementConverter.cs, ContractExportBehavior.cs,
+         ChannelLoader.cs, WsdlExporter.cs, MetadataResolver.cs,
+         SecurityBindingElementConverter.cs,
+         WsdlContractConversionContext.cs,
+         WsdlEndpointConversionContext.cs, WsdlImporter.cs,
+         ServiceThrottlingBehavior.cs, ServiceContractGenerator.cs,
+         TypeLoader.cs, TransactionFlowBindingElementConverter.cs :
+         Updated signatures to beta2.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContext.cs : was seeing
+         http://savas.parastatidis.name/2005/04/08/4b0b99b1-92c6-4442-ab2e-4c4951009ef4.aspx
+         and modified channel build logic a bit.
+
+2005-10-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceThrottlingBehavior.cs : implemented ApplyBehavior().
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContext.cs : added DequeueBindingElement() for
+         BindingElements' internal use. It becomes UnhandledBindingElements.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContext.cs : implemented BuildListenerFactory().
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContext.cs :
+         several API fixes detected by improved corcompare.
+
+2005-10-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContext.cs : added missing generic class constraint.
+
+2005-10-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ReliableSessionBindingElementConverter.cs,
+         TransportBindingElementConverter.cs, ContractExportBehavior.cs,
+         SecurityBindingElementConverter.cs,
+         OperationContractGenerationContext.cs,
+         ServiceContractGenerationContext.cs, InvalidSettingsException.cs
+         WsdlBindingConverterBase.cs, WsdlConversionError.cs,
+         CustomBindingConverter.cs, ServiceContractGenerator.cs,
+         TransactionFlowBindingElementConverter.cs :
+         added all missing bits.
+       * Dummy.cs : finally removed.
+       * ServiceThrottlingBehavior.cs, WsdlBindingConversionContext.cs :
+         tiny API fix.
+
+2005-10-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceLoader.cs : serviceType is moved to ServiceDescription.
+
+2005-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceLoader.cs, TypeLoader.cs : implemented some.
+
+2005-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IWsdlEndpointConverter.cs, IOperationContractGenerator.cs,
+         IServiceContractGenerator.cs, WsdlBindingConversionContext.cs,
+         IWsdlBindingElementConverter.cs, IStreamUpgradeBindingElement.cs,
+         WsdlContractConversionContext.cs,
+         WsdlOperationBindingCoversionContext.cs,
+         WsdlMessageBindingConversionContext.cs,
+         WsdlEndpointConversionContext.cs, WsdlMessageConversionContext.cs,
+         IWsdlBindingConverter.cs, WsdlOperationConversionContext.cs,
+         IWsdlContractConverter.cs, ITransportTokenAssertionProvider.cs:
+         new files for wsdl importer.
+       * Dummy.cs : removed above.
+       * WsdlConversionContext.cs, IMessageEncodingBindingElement.cs :
+         tiny API fixes.
+
+2005-10-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IMessageEncodingBindingElement.cs : new file.
+       * Dummy.cs : removed above.
+
+2005-10-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuilderContext.cs : new file.
+       * Dummy.cs : removed above.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceThrottlingBehavior.cs : moved from sys.ServiceModel dir.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ITypeResolver.cs, ChannelLoader.cs, ServiceLoader.cs,
+         TypeLoader.cs : new files.
+       * Dummy.cs : removed those classes added above.
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ClientCredentials.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ClientCredentials.cs
new file mode 100644 (file)
index 0000000..04db9f0
--- /dev/null
@@ -0,0 +1,154 @@
+//
+// ClientCredentials.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Description
+{
+       public class ClientCredentials
+               : SecurityCredentialsManager, IEndpointBehavior
+       {
+               public ClientCredentials ()
+               {
+               }
+
+               [MonoTODO]
+               protected ClientCredentials (ClientCredentials source)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               IssuedTokenClientCredential issued_token =
+                       new IssuedTokenClientCredential ();
+               HttpDigestClientCredential digest =
+                       new HttpDigestClientCredential ();
+               X509CertificateInitiatorClientCredential initiator =
+                       new X509CertificateInitiatorClientCredential ();
+               X509CertificateRecipientClientCredential recipient =
+                       new X509CertificateRecipientClientCredential ();
+               UserNamePasswordClientCredential userpass =
+                       new UserNamePasswordClientCredential ();
+               WindowsClientCredential windows =
+                       new WindowsClientCredential ();
+               PeerCredential peer = new PeerCredential ();
+               bool support_interactive = true;
+
+               public X509CertificateInitiatorClientCredential ClientCertificate {
+                       get { return initiator; }
+               }
+
+               public HttpDigestClientCredential HttpDigest {
+                       get { return digest; }
+               }
+
+               public IssuedTokenClientCredential IssuedToken {
+                       get { return issued_token; }
+               }
+
+               public PeerCredential Peer {
+                       get { return peer; }
+               }
+
+               public X509CertificateRecipientClientCredential ServiceCertificate {
+                       get { return recipient; }
+               }
+
+               public bool SupportInteractive {
+                       get { return support_interactive; }
+                       set { support_interactive = value; }
+               }
+
+               public UserNamePasswordClientCredential UserName {
+                       get { return userpass; }
+               }
+
+               public WindowsClientCredential Windows {
+                       get { return windows; }
+               }
+
+               public ClientCredentials Clone ()
+               {
+                       ClientCredentials ret = CloneCore ();
+                       if (ret.GetType () != GetType ())
+                               throw new NotImplementedException ("CloneCore() must be implemented to return an instance of the same type in this custom ClientCredentials type.");
+                       return ret;
+               }
+
+               protected virtual ClientCredentials CloneCore ()
+               {
+                       return new ClientCredentials (this);
+               }
+
+               public override SecurityTokenManager CreateSecurityTokenManager ()
+               {
+                       return new ClientCredentialsSecurityTokenManager (this);
+               }
+
+               [MonoTODO]
+               protected virtual SecurityToken GetInfoCardSecurityToken (
+                       bool requiresInfoCard, CardSpacePolicyElement [] chain,
+                       SecurityTokenSerializer tokenSerializer)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint,
+                       BindingParameterCollection parameters)
+               {
+                       parameters.Add (this);
+               }
+
+               [MonoTODO]
+               void IEndpointBehavior.ApplyDispatchBehavior (ServiceEndpoint endpoint,
+                       EndpointDispatcher dispatcher)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IEndpointBehavior.ApplyClientBehavior (
+                       ServiceEndpoint endpoint, ClientRuntime behavior)
+               {
+                       //throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IEndpointBehavior.Validate (ServiceEndpoint endpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ClientViaBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ClientViaBehavior.cs
new file mode 100644 (file)
index 0000000..80c3914
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// ClientViaBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public class ClientViaBehavior : IEndpointBehavior
+       {
+               Uri uri;
+
+               public ClientViaBehavior (Uri uri)
+               {
+                       this.uri = uri;
+               }
+
+               public Uri Uri {
+                       get { return uri; }
+                       set { uri = value; }
+               }
+
+               void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint,
+                       BindingParameterCollection parameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IEndpointBehavior.ApplyDispatchBehavior (ServiceEndpoint endpoint,
+                       EndpointDispatcher dispatcher)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IEndpointBehavior.ApplyClientBehavior (
+                       ServiceEndpoint endpoint, ClientRuntime behavior)
+               {
+                       behavior.Via = Uri;
+               }
+
+               void IEndpointBehavior.Validate (ServiceEndpoint endpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescription.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescription.cs
new file mode 100644 (file)
index 0000000..1958eba
--- /dev/null
@@ -0,0 +1,146 @@
+//
+// ContractDescription.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.Reflection;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Description
+{
+       public class ContractDescription
+       {               
+               [MonoTODO]
+               public static ContractDescription GetContract (
+                       Type contractType)
+               {
+                       return ContractDescriptionGenerator.GetContract (contractType);
+               }
+
+               [MonoTODO]
+               public static ContractDescription GetContract (
+                       Type contractType, object serviceImplementation)
+               {
+                       return ContractDescriptionGenerator.GetContract (contractType, serviceImplementation);
+               }
+
+               [MonoTODO]
+               public static ContractDescription GetContract (
+                       Type contractType, Type serviceType)
+               {
+                       return ContractDescriptionGenerator.GetContract (contractType, serviceType);
+               }
+
+               OperationDescriptionCollection operations;
+               KeyedByTypeCollection<IContractBehavior> behaviors;
+               Type callback_contract_type, contract_type;
+               string name, ns, config_name;
+               ProtectionLevel protection_level;
+               bool has_protection_level;
+               SessionMode session;
+
+               public ContractDescription (string name)
+                       : this (name, null)
+               {
+               }
+
+               public ContractDescription (string name, string ns)
+               {
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+                       if (name.Length == 0)
+                               throw new ArgumentOutOfRangeException ("ContractDescription's Name must be a non-empty string.");
+                       if (ns == null)
+                               ns = "http://tempuri.org/";
+
+                       this.name = name;
+                       this.ns = ns;
+                       behaviors = new KeyedByTypeCollection<IContractBehavior>  ();
+                       operations = new OperationDescriptionCollection ();
+               }
+
+               public KeyedByTypeCollection<IContractBehavior> Behaviors {
+                       get { return behaviors; }
+               }
+
+               public Type CallbackContractType {
+                       get { return callback_contract_type; }
+                       set { callback_contract_type = value; }
+               }
+
+               public string ConfigurationName {
+                       get { return config_name; }
+                       set { config_name = value; }
+               }
+
+               public Type ContractType {
+                       get { return contract_type; }
+                       set { contract_type = value; }
+               }
+
+               public bool HasProtectionLevel {
+                       get { return has_protection_level; }
+               }
+
+               public ProtectionLevel ProtectionLevel {
+                       get { return protection_level; }
+                       set {
+                               protection_level = value;
+                               has_protection_level = true;
+                       }
+               }
+
+               public string Name {
+                       get { return name; }
+               }
+
+               public string Namespace {
+                       get { return ns; }
+                       set { ns = value; }
+               }
+
+               public OperationDescriptionCollection Operations {
+                       get { return operations; }
+               }
+
+               public SessionMode SessionMode {
+                       get { return session; }
+                       set { session = value; }
+               }
+
+               [MonoTODO]
+               public Collection<ContractDescription> GetInheritedContracts ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs
new file mode 100644 (file)
index 0000000..714186e
--- /dev/null
@@ -0,0 +1,415 @@
+//
+// ContractDescriptionGenerator.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.Reflection;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Description
+{
+       internal static class ContractDescriptionGenerator
+       {
+               public static OperationContractAttribute
+                       GetOperationContractAttribute (MethodBase method)
+               {
+                       object [] matts = method.GetCustomAttributes (
+                               typeof (OperationContractAttribute), false);
+                       if (matts.Length == 0)
+                               return null;
+                       return (OperationContractAttribute) matts [0];
+               }
+
+               static void GetServiceContractAttribute (Type type, Dictionary<Type,ServiceContractAttribute> table)
+               {
+                       for (; type != null; type = type.BaseType) {
+                               foreach (ServiceContractAttribute i in
+                                       type.GetCustomAttributes (
+                                       typeof (ServiceContractAttribute), true))
+                                       table [type] = i;
+                               foreach (Type t in type.GetInterfaces ())
+                                       GetServiceContractAttribute (t, table);
+                       }
+               }
+               public static Dictionary<Type, ServiceContractAttribute> GetServiceContractAttributes (Type type) 
+               {
+                       Dictionary<Type, ServiceContractAttribute> table = new Dictionary<Type, ServiceContractAttribute> ();
+                       GetServiceContractAttribute (type, table);
+                       return table;
+               }
+
+               [MonoTODO]
+               public static ContractDescription GetContract (
+                       Type contractType) {
+                       return GetContract (contractType, (Type) null);
+               }
+
+               [MonoTODO]
+               public static ContractDescription GetContract (
+                       Type contractType, object serviceImplementation) {
+                       if (serviceImplementation == null)
+                               throw new ArgumentNullException ("serviceImplementation");
+                       return GetContract (contractType,
+                               serviceImplementation.GetType ());
+               }
+
+               public static MessageContractAttribute GetMessageContractAttribute (Type type)
+               {
+                       for (Type t = type; t != null; t = t.BaseType) {
+                               object [] matts = t.GetCustomAttributes (
+                                       typeof (MessageContractAttribute), true);
+                               if (matts.Length > 0)
+                                       return (MessageContractAttribute) matts [0];
+                       }
+                       return null;
+               }
+
+               [MonoTODO]
+               public static ContractDescription GetContract (
+                       Type givenContractType, Type givenServiceType)
+               {
+                       // FIXME: serviceType should be used for specifying attributes like OperationBehavior.
+
+                       Type exactContractType = null;
+                       ServiceContractAttribute sca = null;
+                       Dictionary<Type, ServiceContractAttribute> contracts = 
+                               GetServiceContractAttributes (givenServiceType ?? givenContractType);
+                       if (contracts.ContainsKey(givenContractType)) {
+                               exactContractType = givenContractType;
+                               sca = contracts[givenContractType];
+                       } else {
+                               foreach (Type t in contracts.Keys)
+                                       if (t.IsAssignableFrom(givenContractType)) {
+                                               if (sca != null)
+                                                       throw new InvalidOperationException("The contract type of " + givenContractType + " is ambiguous: can be either " + exactContractType + " or " + t);
+                                               exactContractType = t;
+                                               sca = contracts [t];
+                                       }
+                       }
+                       if (sca == null) {
+                               throw new InvalidOperationException (String.Format ("Attempted to get contract type from '{0}' which neither is a service contract nor does it inherit service contract.", givenContractType));
+                       }
+                       string name = sca.Name ?? exactContractType.Name;
+                       string ns = sca.Namespace ?? "http://tempuri.org/";
+
+                       ContractDescription cd =
+                               new ContractDescription (name, ns);
+                       cd.ContractType = exactContractType;
+                       cd.CallbackContractType = sca.CallbackContract;
+                       cd.SessionMode = sca.SessionMode;
+                       if (sca.ConfigurationName != null)
+                               cd.ConfigurationName = sca.ConfigurationName;
+                       else
+                               cd.ConfigurationName = exactContractType.FullName;
+                       if (sca.HasProtectionLevel)
+                               cd.ProtectionLevel = sca.ProtectionLevel;
+
+                       // FIXME: load Behaviors
+                       MethodInfo [] contractMethods = exactContractType.GetMethods ();
+                       MethodInfo [] serviceMethods = contractMethods;
+                       if (givenServiceType != null && exactContractType.IsInterface) {
+                               serviceMethods = givenServiceType.GetInterfaceMap (exactContractType).TargetMethods;
+                       }
+                       
+                       for (int i = 0; i < contractMethods.Length; ++i)
+                       {
+
+                               MethodInfo mi = contractMethods [i];
+                               OperationContractAttribute oca = GetOperationContractAttribute (mi);
+                               if (oca == null)
+                                       continue;
+                               MethodInfo end = null;
+                               if (oca.AsyncPattern) {
+                                       if (String.Compare ("Begin", 0, mi.Name,0, 5) != 0)
+                                               throw new InvalidOperationException ("For async operation contract patterns, the initiator method name must start with 'Begin'.");
+                                       end = givenContractType.GetMethod ("End" + mi.Name.Substring (5));
+                                       if (end == null)
+                                               throw new InvalidOperationException ("For async operation contract patterns, corresponding End method is required for each Begin method.");
+                                       if (GetOperationContractAttribute (end) != null)
+                                               throw new InvalidOperationException ("Async 'End' method must not have OperationContractAttribute. It is automatically treated as the EndMethod of the corresponding 'Begin' method.");
+                               }
+                               OperationDescription od = GetOrCreateOperation (cd, 
+                                                                                                                               mi, 
+                                                                                                                               serviceMethods [i], 
+                                                                                                                               oca, 
+                                                                                                                               end != null ? end.ReturnType : null);
+                               if (end != null)
+                                       od.EndMethod = end;
+                       }
+
+                       // FIXME: enable this when I found where this check is needed.
+                       /*
+                       if (cd.Operations.Count == 0)
+                               throw new InvalidOperationException (String.Format ("The service contract type {0} has no operation. At least one operation must exist.", contractType));
+                       */
+                       return cd;
+               }
+
+               static OperationDescription GetOrCreateOperation (
+                       ContractDescription cd, MethodInfo mi, MethodInfo serviceMethod,
+                       OperationContractAttribute oca,
+                       Type asyncReturnType)
+               {
+                       string name = oca.Name ?? (oca.AsyncPattern ? mi.Name.Substring (5) : mi.Name);
+
+                       OperationDescription od = null;
+                       foreach (OperationDescription iter in cd.Operations) {
+                               if (iter.Name == name) {
+                                       od = iter;
+                                       break;
+                               }
+                       }
+                       if (od == null) {
+                               od = new OperationDescription (name, cd);
+                               od.IsOneWay = oca.IsOneWay;
+                               if (oca.HasProtectionLevel)
+                                       od.ProtectionLevel = oca.ProtectionLevel;
+                               od.Messages.Add (GetMessage (od, mi, oca, true, null));
+                               if (!od.IsOneWay)
+                                       od.Messages.Add (GetMessage (od, mi, oca, false, asyncReturnType));
+                               cd.Operations.Add (od);
+                       }
+                       else if (oca.AsyncPattern && od.BeginMethod != null ||
+                                !oca.AsyncPattern && od.SyncMethod != null)
+                               throw new InvalidOperationException ("A contract cannot have two operations that have the identical names and different set of parameters.");
+
+                       if (oca.AsyncPattern)
+                               od.BeginMethod = mi;
+                       else
+                               od.SyncMethod = mi;
+                       od.IsInitiating = oca.IsInitiating;
+                       od.IsTerminating = oca.IsTerminating;
+
+                       if (mi != serviceMethod)
+                               foreach (object obj in mi.GetCustomAttributes (typeof (IOperationBehavior), true))
+                                       od.Behaviors.Add ((IOperationBehavior) obj);
+
+                       if (serviceMethod != null) {
+                               foreach (object obj in serviceMethod.GetCustomAttributes (typeof(IOperationBehavior),true))
+                                       od.Behaviors.Add ((IOperationBehavior) obj);
+                       }
+                       if (od.Behaviors.Find<OperationBehaviorAttribute>() == null)
+                               od.Behaviors.Add (new OperationBehaviorAttribute ());
+                       // FIXME: fill KnownTypes, Behaviors and Faults.
+
+                       return od;
+               }
+
+               static MessageDescription GetMessage (
+                       OperationDescription od, MethodInfo mi,
+                       OperationContractAttribute oca, bool isRequest,
+                       Type asyncReturnType)
+               {
+                       ContractDescription cd = od.DeclaringContract;
+                       ParameterInfo [] plist = mi.GetParameters ();
+                       Type messageType = null;
+                       string action = isRequest ? oca.Action : oca.ReplyAction;
+                       MessageContractAttribute mca;
+
+                       Type retType = asyncReturnType;
+                       if (!isRequest && retType == null)
+                               retType =  mi.ReturnType;
+
+                       // If the argument is only one and has [MessageContract]
+                       // then infer it as a typed messsage
+                       if (isRequest) {
+                               mca = plist.Length != 1 ? null :
+                                       GetMessageContractAttribute (plist [0].ParameterType);
+                               if (mca != null)
+                                       messageType = plist [0].ParameterType;
+                       }
+                       else {
+                               mca = GetMessageContractAttribute (retType);
+                               if (mca != null)
+                                       messageType = retType;
+                       }
+
+                       if (action == null)
+                               action = String.Concat (cd.Namespace, 
+                                       cd.Namespace.EndsWith ("/") ? "" : "/", cd.Name, "/",
+                                       od.Name, isRequest ? String.Empty : "Response");
+
+                       if (mca != null)
+                               return CreateMessageDescription (messageType, cd.Namespace, action, isRequest, mca);
+                       return CreateMessageDescription (oca, plist, od.Name, cd.Namespace, action, isRequest, retType, mi.ReturnTypeCustomAttributes);
+               }
+
+               public static MessageDescription CreateMessageDescription (
+                       Type messageType, string defaultNamespace, string action, bool isRequest, MessageContractAttribute mca)
+               {
+                       MessageDescription md = new MessageDescription (
+                               action, isRequest ? MessageDirection.Input :
+                               MessageDirection.Output);
+                       md.MessageType = MessageFilterOutByRef (messageType);
+                       if (mca.HasProtectionLevel)
+                               md.ProtectionLevel = mca.ProtectionLevel;
+
+                       MessageBodyDescription mb = md.Body;
+                       mb.WrapperName = mca.WrapperName ?? messageType.Name;
+                       mb.WrapperNamespace = mca.WrapperNamespace ?? defaultNamespace;
+
+                       int index = 0;
+                       foreach (MemberInfo bmi in messageType.GetMembers (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
+                               Type mtype = null;
+                               string mname = null;
+                               if (bmi is FieldInfo) {
+                                       FieldInfo fi = (FieldInfo) bmi;
+                                       mtype = fi.FieldType;
+                                       mname = fi.Name;
+                               }
+                               else if (bmi is PropertyInfo) {
+                                       PropertyInfo pi = (PropertyInfo) bmi;
+                                       mtype = pi.PropertyType;
+                                       mname = pi.Name;
+                               }
+                               else
+                                       continue;
+
+                               MessageBodyMemberAttribute mba = GetMessageBodyMemberAttribute (bmi);
+                               if (mba == null)
+                                       continue;
+
+                               MessagePartDescription pd = CreatePartCore (mba, mname, defaultNamespace);
+                               pd.Index = index++;
+                               pd.Type = MessageFilterOutByRef (mtype);
+                               pd.MemberInfo = bmi;
+                               mb.Parts.Add (pd);
+                       }
+
+                       // FIXME: fill headers and properties.
+                       return md;
+               }
+
+               public static MessageDescription CreateMessageDescription (
+                       OperationContractAttribute oca, ParameterInfo[] plist, string name, string defaultNamespace, string action, bool isRequest, Type retType, ICustomAttributeProvider retTypeAttributes)
+               {
+                       MessageDescription md = new MessageDescription (
+                               action, isRequest ? MessageDirection.Input :
+                               MessageDirection.Output);
+
+                       MessageBodyDescription mb = md.Body;
+                       mb.WrapperName = name + (isRequest ? String.Empty : "Response");
+                       mb.WrapperNamespace = defaultNamespace;
+
+                       // FIXME: anything to do for ProtectionLevel?
+
+                       // Parts
+                       int index = 0;
+                       foreach (ParameterInfo pi in plist) {
+                               // AsyncCallback and state are extraneous.
+                               if (oca.AsyncPattern && pi.Position == plist.Length - 2)
+                                       break;
+
+                               // They are ignored:
+                               // - out parameter in request
+                               // - neither out nor ref parameter in reply
+                               if (isRequest && pi.IsOut)
+                                       continue;
+                               if (!isRequest && !pi.IsOut && !pi.ParameterType.IsByRef)
+                                       continue;
+
+                               MessagePartDescription pd = CreatePartCore (GetMessageParameterAttribute (pi), pi.Name, defaultNamespace);
+                               pd.Index = index++;
+                               pd.Type = MessageFilterOutByRef (pi.ParameterType);
+                               mb.Parts.Add (pd);                      
+                       }
+
+                       // ReturnValue
+                       if (!isRequest) {
+                               MessagePartDescription mp = CreatePartCore (GetMessageParameterAttribute (retTypeAttributes), name + "Result", mb.WrapperNamespace);
+                               mp.Index = 0;
+                               mp.Type = retType;
+                               mb.ReturnValue = mp;
+                       }
+
+                       // FIXME: fill properties.
+
+                       return md;
+               }
+
+               public static void FillMessageBodyDescriptionByContract (
+                       Type messageType, MessageBodyDescription mb)
+               {
+               }
+
+               static MessagePartDescription CreatePartCore (
+                       MessageParameterAttribute mpa, string defaultName,
+                       string defaultNamespace)
+               {
+                       string pname = null;
+                       if (mpa != null && mpa.Name != null)
+                               pname = mpa.Name;
+                       if (pname == null)
+                               pname = defaultName;
+                       return new MessagePartDescription (pname, defaultNamespace);
+               }
+
+               static MessagePartDescription CreatePartCore (
+                       MessageBodyMemberAttribute mba, string defaultName,
+                       string defaultNamespace)
+               {
+                       string pname = null, pns = null;
+                       if (mba != null) {
+                               if (mba.Name != null)
+                                       pname = mba.Name;
+                               if (mba.Namespace != null)
+                                       pns = mba.Namespace;
+                       }
+                       if (pname == null)
+                               pname = defaultName;
+                       if (pns == null)
+                               pns = defaultNamespace;
+
+                       return new MessagePartDescription (pname, pns);
+               }
+
+               static Type MessageFilterOutByRef (Type type)
+               {
+                       return type == null ? null :
+                               type.IsByRef ? type.GetElementType () : type;
+               }
+
+               static MessageParameterAttribute GetMessageParameterAttribute (ICustomAttributeProvider provider)
+               {
+                       object [] attrs = provider.GetCustomAttributes (
+                               typeof (MessageParameterAttribute), true);
+                       return attrs.Length > 0 ? (MessageParameterAttribute) attrs [0] : null;
+               }
+
+               static MessageBodyMemberAttribute GetMessageBodyMemberAttribute (MemberInfo mi)
+               {
+                       object [] matts = mi.GetCustomAttributes (
+                               typeof (MessageBodyMemberAttribute), true);
+                       return matts.Length > 0 ? (MessageBodyMemberAttribute) matts [0] : null;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/DataContractSerializerMessageContractImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/DataContractSerializerMessageContractImporter.cs
new file mode 100644 (file)
index 0000000..0cb89ee
--- /dev/null
@@ -0,0 +1,264 @@
+//
+// DataContractSerializerMessageContractImporter.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//        Ankit Jain (jankit@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Text;
+using System.Web.Services.Description;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class DataContractSerializerMessageContractImporter
+               : IWsdlImportExtension
+       {
+               bool enabled = true;
+
+               public bool Enabled {
+                       get { return enabled; }
+                       set { enabled = value; }
+               }
+
+               void IWsdlImportExtension.BeforeImport (
+                       ServiceDescriptionCollection wsdlDocuments,
+                       XmlSchemaSet xmlSchemas,
+                       ICollection<XmlElement> policy)
+               {
+               }
+
+               void IWsdlImportExtension.ImportContract (WsdlImporter importer,
+                       WsdlContractConversionContext context)
+               {
+                       if (!enabled)
+                               return;
+
+                       PortType port_type = context.WsdlPortType;
+                       ContractDescription contract = context.Contract;
+                       int i, j;
+                       List<MessagePartDescription> parts = new List<MessagePartDescription> ();
+
+                       i = 0;
+                       foreach (Operation op in port_type.Operations) {
+                               OperationDescription opdescr = contract.Operations [i];
+
+                               j = 0;
+                               foreach (OperationMessage opmsg in op.Messages) {
+                                       //SM.MessageDescription
+                                       MessageDescription msgdescr = opdescr.Messages [j];
+
+                                       //OpMsg's corresponding WSMessage
+                                       Message msg = port_type.ServiceDescription.Messages [opmsg.Message.Name];
+
+                                       msgdescr.Body.WrapperNamespace = port_type.ServiceDescription.TargetNamespace;
+
+                                       if (opmsg is OperationOutput) {
+                                               //ReturnValue
+                                               msg = port_type.ServiceDescription.Messages [opmsg.Message.Name];
+                                               
+                                               resolveMessage (msg, msgdescr.Body, parts, importer);
+                                               if (parts.Count > 0) {
+                                                       msgdescr.Body.ReturnValue = parts [0];
+                                                       parts.Clear ();
+                                               }
+                                               continue;
+                                       }
+
+                                       /* OperationInput */
+                                       
+                                       /* Parts, MessagePartDescription */
+                                       resolveMessage (msg, msgdescr.Body, parts, importer);
+                                       foreach (MessagePartDescription p in parts)
+                                               msgdescr.Body.Parts.Add (p);
+                                       parts.Clear ();
+
+                                       j ++;
+                               }
+
+
+                               i ++;
+                       }
+
+               }
+
+               void resolveMessage (Message msg, MessageBodyDescription body, List<MessagePartDescription> parts, WsdlImporter importer)
+               {
+                       foreach (MessagePart part in msg.Parts) {
+                               if (part.Name == "parameters") {
+                                       if (!part.Element.IsEmpty) {
+                                               body.WrapperName = part.Element.Name;
+                                               resolveElement (part.Element, parts, importer, body.WrapperNamespace);
+                                       } else {
+                                               body.WrapperName = part.Type.Name;
+                                               resolveType (part.Type, parts, importer, body.WrapperNamespace);
+                                       }
+                               }
+                               //FIXME: non-parameters?
+                       }
+               }
+               
+               void resolveElement (QName qname, List<MessagePartDescription> parts, WsdlImporter importer, string ns)
+               {
+                       XmlSchemas xss = new XmlSchemas ();
+                       foreach (XmlSchema schema in importer.XmlSchemas.Schemas ())
+                               xss.Add (schema);
+                       XmlSchemaImporter schema_importer = new XmlSchemaImporter (xss);
+
+                       importer.XmlSchemas.Compile ();
+                       XmlSchemaElement element = (XmlSchemaElement) importer.XmlSchemas.GlobalElements [qname];
+                       if (element == null)
+                               //FIXME: What to do here?
+                               throw new Exception ("Could not resolve : " + qname.ToString ());
+
+                       resolveParticle (schema_importer, element, parts, ns, 2);
+               }
+
+               void resolveType (QName qname, List<MessagePartDescription> parts, WsdlImporter importer, string ns)
+               {
+                       /*foreach (XmlSchema xs in importer.Schemas)
+                               if (xs.Types [qname] != null)
+                                       return resolveParameters ((XmlSchemaElement) xs.Types [qname]., msgdescr, importer);
+
+                       //FIXME: What to do here?
+                       throw new Exception ("Could not resolve : " + qname.ToString ());*/
+                       throw new NotImplementedException ();
+               }
+
+               string GetCLRTypeName (QName qname)
+               {
+                       if (qname.Namespace != "http://www.w3.org/2001/XMLSchema")
+                               return null;
+
+                       switch (qname.Name) {
+                       case "anyURI":
+                               return "System.String";
+                       case "boolean":
+                               return "System.Boolean";
+
+                       /*FIXME: case "base64Binary":
+                       case "dateTime":
+                       case "duration":*/
+                       case "QName":
+                               return "System.String";
+                       case "decimal":
+                               return "System.Decimal";
+                       case "double":
+                               return "System.Double";
+                       case "float":
+                               return "System.Double";
+                       case "byte":
+                               return "System.SByte";
+                       case "short":
+                               return "System.Int16";
+                       case "int":
+                               return "System.Int32";
+                       case "long":
+                               return "System.Int64";
+                       case "unsignedByte":
+                               return "System.Byte";
+                       case "unsignedShort":
+                               return "System.UInt16";
+                       case "unsignedInt":
+                               return "System.UInt32";
+                       case "unsignedLong":
+                               return "System.UInt64";
+                       case "string":
+                               return "System.String";
+                       /* FIXME:
+                       case "anyType":
+                               return true;
+                       default:
+                               return false;*/
+                       }
+
+                       return null;
+               }
+
+               void resolveParticle (XmlSchemaImporter schema_importer, 
+                               XmlSchemaParticle particle, 
+                               List<MessagePartDescription> parts, 
+                               string ns, 
+                               int depth)
+               {
+                       if (particle is XmlSchemaGroupBase) {
+                               //sequence, 
+                               //FIXME: others?
+                               if (depth <= 0)
+                                       return;
+
+                               XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase;
+                               foreach (XmlSchemaParticle item in groupBase.Items)
+                                       resolveParticle (schema_importer, item, parts, ns, depth - 1);
+
+                               return;
+                       }
+
+                       XmlSchemaElement elem = particle as XmlSchemaElement;
+                       if (elem == null)
+                               return;
+
+                       MessagePartDescription msg_part = null;
+                       
+                       XmlSchemaComplexType ct = elem.ElementSchemaType as XmlSchemaComplexType;
+                       if (ct == null) {
+                               //Not a complex type
+                               XmlSchemaSimpleType simple = elem.ElementSchemaType as XmlSchemaSimpleType;
+                               msg_part = new MessagePartDescription (
+                                               elem.Name, ns);
+                               if (elem.SchemaTypeName.Namespace != XmlSchema.Namespace)
+                                       msg_part.XmlTypeMapping = schema_importer.ImportTypeMapping (elem.SchemaTypeName);
+                               msg_part.TypeName = new QName (GetCLRTypeName (elem.SchemaTypeName), "");
+                               parts.Add (msg_part);
+
+                               return;
+                       }
+
+                       if (depth > 0) {
+                               resolveParticle (schema_importer, ct.ContentTypeParticle, parts, ns, depth - 1);
+                               return;
+                       }
+
+                       //depth <= 0
+                       msg_part = new MessagePartDescription (elem.Name, ns);
+                       msg_part.XmlTypeMapping = schema_importer.ImportTypeMapping (elem.SchemaTypeName);
+                       msg_part.TypeName = elem.SchemaTypeName;
+
+                       parts.Add (msg_part);
+               }
+
+               void IWsdlImportExtension.ImportEndpoint (WsdlImporter importer,
+                       WsdlEndpointConversionContext context)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/DataContractSerializerOperationBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/DataContractSerializerOperationBehavior.cs
new file mode 100644 (file)
index 0000000..ba801cf
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// DataContractSerializerOperationBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public class DataContractSerializerOperationBehavior : IOperationBehavior, IWsdlExportExtension
+       {
+               DataContractFormatAttribute format;
+               OperationDescription operation;
+
+               public DataContractSerializerOperationBehavior (OperationDescription operation)
+               {
+                       format = new DataContractFormatAttribute ();
+                       this.operation = operation;
+               }
+
+               public DataContractSerializerOperationBehavior (
+                       OperationDescription operation,
+                       DataContractFormatAttribute dataContractFormatAttribute)
+               {
+                       this.format = dataContractFormatAttribute;
+                       this.operation = operation;
+               }
+
+               public DataContractFormatAttribute DataContractFormatAttribute {
+                       get { return format; }
+               }
+
+               void IOperationBehavior.AddBindingParameters (
+                       OperationDescription description,
+                       BindingParameterCollection parameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IOperationBehavior.ApplyDispatchBehavior (
+                       OperationDescription description,
+                       DispatchOperation dispatch)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IOperationBehavior.ApplyClientBehavior (
+                       OperationDescription description,
+                       ClientOperation proxy)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IOperationBehavior.Validate (
+                       OperationDescription description)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               //IWsdlExportExtension
+
+               void IWsdlExportExtension.ExportContract (WsdlExporter exporter,
+                       WsdlContractConversionContext context)
+               {
+               }
+
+               void IWsdlExportExtension.ExportEndpoint (WsdlExporter exporter,
+                       WsdlEndpointConversionContext context)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/FaultDescription.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/FaultDescription.cs
new file mode 100644 (file)
index 0000000..6621c18
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// FaultDescription.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.Reflection;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class FaultDescription
+       {
+               string action, name, ns;
+               Type detail_type;
+               bool has_protection_level;
+               ProtectionLevel protection_level;
+
+               public FaultDescription (string name)
+               {
+               }
+
+               public string Action {
+                       get { return action; }
+               }
+
+               public Type DetailType {
+                       get { return detail_type; }
+                       set { detail_type = value; }
+               }
+
+               public string Name {
+                       get { return name; }
+                       set { name = value; }
+               }
+
+               public string Namespace {
+                       get { return ns; }
+                       set { ns= value; }
+               }
+
+               public bool HasProtectionLevel {
+                       get { return has_protection_level; }
+               }
+
+               public ProtectionLevel ProtectionLevel {
+                       get { return protection_level; }
+                       set {
+                               protection_level = value;
+                               has_protection_level = true;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/FaultDescriptionCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/FaultDescriptionCollection.cs
new file mode 100644 (file)
index 0000000..b77c331
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// FaultDescriptionCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Description
+{
+       public class FaultDescriptionCollection
+               : Collection<FaultDescription>
+       {
+               internal FaultDescriptionCollection ()
+               {
+               }
+
+               public FaultDescription Find (string name)
+               {
+                       foreach (FaultDescription d in this)
+                               if (d.Name == name)
+                                       return d;
+                       return null;
+               }
+
+               public Collection<FaultDescription> FindAll (string name)
+               {
+                       Collection<FaultDescription> ret =
+                               new Collection<FaultDescription> ();
+                       foreach (FaultDescription d in this)
+                               if (d.Name == name)
+                                       ret.Add (d);
+                       return ret;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/HostedBindingBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/HostedBindingBehavior.cs
new file mode 100644 (file)
index 0000000..20b73cd
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// HostedBindingBehavior.cs.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       internal sealed class HostedBindingBehavior : IServiceBehavior
+       {
+               string virtual_path;
+
+               internal HostedBindingBehavior (string virtualPath)
+               {
+                       virtual_path = virtualPath;
+               }
+
+               public string VirtualPath {
+                       get { return virtual_path; }
+               }
+
+               void IServiceBehavior.AddBindingParameters (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase,
+                       Collection<ServiceEndpoint> endpoints,
+                       BindingParameterCollection parameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IServiceBehavior.ApplyDispatchBehavior (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IServiceBehavior.Validate (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IContractBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IContractBehavior.cs
new file mode 100644 (file)
index 0000000..9d12a23
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// IContractBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public interface IContractBehavior
+       {
+               void AddBindingParameters (
+                       ContractDescription description,
+                       ServiceEndpoint endpoint,
+                       BindingParameterCollection parameters);
+
+               void ApplyClientBehavior (
+                       ContractDescription description,
+                       ServiceEndpoint endpoint,
+                       ClientRuntime proxy);
+
+               void ApplyDispatchBehavior (
+                       ContractDescription description,
+                       ServiceEndpoint endpoint,
+                       DispatchRuntime dispatch);
+
+               void Validate (
+                       ContractDescription description,
+                       ServiceEndpoint endpoint);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IContractBehaviorAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IContractBehaviorAttribute.cs
new file mode 100644 (file)
index 0000000..c930ebc
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// IContractBehaviorAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public interface IContractBehaviorAttribute
+       {
+               Type TargetContract { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IEndpointBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IEndpointBehavior.cs
new file mode 100644 (file)
index 0000000..6eb47ec
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// IEndpointBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public interface IEndpointBehavior
+       {
+               void AddBindingParameters (ServiceEndpoint endpoint,
+                       BindingParameterCollection parameters);
+               void ApplyDispatchBehavior (ServiceEndpoint serviceEndpoint,
+                       EndpointDispatcher dispatcher);
+               void ApplyClientBehavior (ServiceEndpoint serviceEndpoint,
+                       ClientRuntime behavior);
+               void Validate (ServiceEndpoint serviceEndpoint);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IMetadataExchange.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IMetadataExchange.cs
new file mode 100644 (file)
index 0000000..0bb503f
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// IMetadataExchange.cs
+//
+// Author:
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Description
+{
+       [ServiceContract (Namespace = "http://schemas.microsoft.com/2006/04/mex", Name = "IMetadataExchange")]
+       public interface IMetadataExchange
+       {
+               [OperationContract (
+                       ReplyAction = "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse",
+                       Action = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get",
+                       AsyncPattern = true)]
+               IAsyncResult BeginGet (Message request,
+                               AsyncCallback callback,
+                               Object state);
+
+               Message EndGet (IAsyncResult result);
+
+               [OperationContract (
+                       ReplyAction = "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse",
+                       Action = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get",
+                       AsyncPattern = false)]
+               Message Get (Message request);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IOperationBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IOperationBehavior.cs
new file mode 100644 (file)
index 0000000..aa67812
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// IOperationBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public interface IOperationBehavior
+       {
+               void AddBindingParameters (
+                       OperationDescription description,
+                       BindingParameterCollection parameters);
+
+               void ApplyDispatchBehavior (
+                       OperationDescription description,
+                       DispatchOperation dispatch);
+
+               void ApplyClientBehavior (
+                       OperationDescription description,
+                       ClientOperation proxy);
+
+               void Validate (
+                       OperationDescription description);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IOperationContractGenerationExtension.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IOperationContractGenerationExtension.cs
new file mode 100644 (file)
index 0000000..156a18c
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// IOperationContractGenerationExtension.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Description
+{
+       public interface IOperationContractGenerationExtension
+       {
+               void GenerateOperation (
+                       OperationContractGenerationContext context);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IPolicyImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IPolicyImporter.cs
new file mode 100644 (file)
index 0000000..8615f89
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// IPolicyImportExtension.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.Web.Services.Description;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       public interface IPolicyImportExtension
+       {
+               void ImportPolicy (MetadataImporter importer,
+                       PolicyConversionContext context);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IServiceBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IServiceBehavior.cs
new file mode 100644 (file)
index 0000000..3910388
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// IServiceBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public interface IServiceBehavior
+       {
+               void AddBindingParameters (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase,
+                       Collection<ServiceEndpoint> endpoints,
+                       BindingParameterCollection parameters);
+
+               void ApplyDispatchBehavior (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase);
+
+               void Validate (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IServiceContractGenerationExtension.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IServiceContractGenerationExtension.cs
new file mode 100644 (file)
index 0000000..aa30089
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// IServiceContractGenerationExtension.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Description
+{
+       public interface IServiceContractGenerationExtension
+       {
+               void GenerateContract (
+                       ServiceContractGenerationContext context);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IWsdlExporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IWsdlExporter.cs
new file mode 100644 (file)
index 0000000..375b4ef
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// IWsdlExportExtension.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.Web.Services.Description;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       public interface IWsdlExportExtension
+       {
+               void ExportContract (WsdlExporter exporter,
+                       WsdlContractConversionContext context);
+
+               void ExportEndpoint (WsdlExporter exporter,
+                       WsdlEndpointConversionContext context);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IWsdlImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IWsdlImporter.cs
new file mode 100644 (file)
index 0000000..3137444
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// IWsdlImportExtension.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Web.Services.Description;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace System.ServiceModel.Description
+{
+       public interface IWsdlImportExtension
+       {
+               void BeforeImport (ServiceDescriptionCollection wsdlDocuments,
+                       XmlSchemaSet xmlSchemas, ICollection<XmlElement> policy);
+
+               void ImportContract (WsdlImporter importer,
+                       WsdlContractConversionContext contractContext);
+
+               void ImportEndpoint (WsdlImporter importer,
+                       WsdlEndpointConversionContext endpointContext);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/IpolicyExporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/IpolicyExporter.cs
new file mode 100644 (file)
index 0000000..14ee0b9
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// IPolicyExportExtension.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.Web.Services.Description;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       public interface IPolicyExportExtension
+       {
+               void ExportPolicy (MetadataExporter exporter,
+                       PolicyConversionContext context);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/LocalServiceSecuritySettings.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/LocalServiceSecuritySettings.cs
new file mode 100644 (file)
index 0000000..3b9d4e3
--- /dev/null
@@ -0,0 +1,134 @@
+//
+// LocalServiceSecuritySettings.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.Transactions;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Channels
+{
+       [MonoTODO]
+       public sealed class LocalServiceSecuritySettings
+       {
+               bool detect_replays;
+               TimeSpan max_clock_skew;
+               bool reconnect;
+               int replay_cache_size;
+               TimeSpan inactivity_timeout, cookie_lifetime,
+                       negotiation_timeout, replay_window, renewal_interval,
+                       rollover_interval, validity_duration;
+               Collection<Type> claim_types =
+                       new Collection<Type> ();
+               int max_sessions, max_negotiations, max_cached_cookies;
+               SecurityStateEncoder encoder;
+               bool send_fault;
+
+               public LocalServiceSecuritySettings ()
+               {
+               }
+
+               public bool DetectReplays {
+                       get { return detect_replays; }
+                       set { detect_replays = value; }
+               }
+
+               public TimeSpan InactivityTimeout {
+                       get { return inactivity_timeout; }
+                       set { inactivity_timeout = value; }
+               }
+
+               public TimeSpan IssuedCookieLifetime {
+                       get { return cookie_lifetime; }
+                       set { cookie_lifetime = value; }
+               }
+
+               public int MaxCachedCookies {
+                       get { return max_cached_cookies; }
+                       set { max_cached_cookies = value; }
+               }
+
+               public TimeSpan MaxClockSkew {
+                       get { return max_clock_skew; }
+                       set { max_clock_skew = value; }
+               }
+
+               public int MaxPendingSessions {
+                       get { return max_sessions; }
+                       set { max_sessions = value; }
+               }
+
+               public int MaxStatefulNegotiations {
+                       get { return max_negotiations; }
+                       set { max_negotiations = value; }
+               }
+
+               public TimeSpan NegotiationTimeout {
+                       get { return negotiation_timeout; }
+                       set { negotiation_timeout = value; }
+               }
+
+               public bool ReconnectTransportOnFailure {
+                       get { return reconnect; }
+                       set { reconnect = value; }
+               }
+
+               public int ReplayCacheSize {
+                       get { return replay_cache_size; }
+                       set { replay_cache_size = value; }
+               }
+
+               public TimeSpan ReplayWindow {
+                       get { return replay_window; }
+                       set { replay_window = value; }
+               }
+
+               public TimeSpan SessionKeyRenewalInterval {
+                       get { return renewal_interval; }
+                       set { renewal_interval = value; }
+               }
+
+               public TimeSpan SessionKeyRolloverInterval {
+                       get { return rollover_interval; }
+                       set { rollover_interval = value; }
+               }
+
+               public TimeSpan TimestampValidityDuration {
+                       get { return validity_duration; }
+                       set { validity_duration = value; }
+               }
+
+               public LocalServiceSecuritySettings Clone ()
+               {
+                       LocalServiceSecuritySettings other = (LocalServiceSecuritySettings) MemberwiseClone ();
+                       other.claim_types = new Collection<Type> (claim_types);
+                       return other;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageBodyDescription.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageBodyDescription.cs
new file mode 100644 (file)
index 0000000..afc9328
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// MessageBodyDescription.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class MessageBodyDescription
+       {
+               string wrapper_name, wrapper_ns;
+               MessagePartDescriptionCollection parts
+
+                       = new MessagePartDescriptionCollection ();
+               MessagePartDescription return_value;
+
+               public MessageBodyDescription ()
+               {
+               }
+
+               public MessagePartDescriptionCollection Parts {
+                       get { return parts; }
+                       internal set { parts = value; }
+               }
+
+               public MessagePartDescription ReturnValue {
+                       get { return return_value; }
+                       set { return_value = value; }
+               }
+
+               public string WrapperName {
+                       get { return wrapper_name; }
+                       set { wrapper_name = value; }
+               }
+
+               public string WrapperNamespace {
+                       get { return wrapper_ns; }
+                       set { wrapper_ns = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageDescription.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageDescription.cs
new file mode 100644 (file)
index 0000000..67aaa0c
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// MessageDescription.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       public class MessageDescription
+       {
+               string action;
+               MessageDirection direction;
+               MessagePropertyDescriptionCollection properties
+                       = new MessagePropertyDescriptionCollection ();
+               MessageBodyDescription body = new MessageBodyDescription ();
+               MessageHeaderDescriptionCollection headers
+                       = new MessageHeaderDescriptionCollection ();
+               Type message_type;
+               bool has_protection_level;
+               ProtectionLevel protection_level;
+
+               public MessageDescription (string action,
+                       MessageDirection direction)
+               {
+                       this.action = action;
+                       this.direction = direction;
+               }
+
+               public string Action {
+                       get { return action; }
+               }
+
+               public MessageBodyDescription Body {
+                       get { return body; }
+               }
+
+               public MessageDirection Direction {
+                       get { return direction; }
+               }
+
+               public MessageHeaderDescriptionCollection Headers {
+                       get { return headers; }
+               }
+
+               public bool HasProtectionLevel {
+                       get { return has_protection_level; }
+               }
+
+               public ProtectionLevel ProtectionLevel {
+                       get { return protection_level; }
+                       set {
+                               protection_level = value;
+                               has_protection_level = true;
+                       }
+               }
+
+               public Type MessageType {
+                       get { return message_type; }
+                       set { message_type = value; }
+               }
+
+               public MessagePropertyDescriptionCollection Properties {
+                       get { return properties; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageDescriptionCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageDescriptionCollection.cs
new file mode 100644 (file)
index 0000000..1699be1
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// MessageDescriptionCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class MessageDescriptionCollection : Collection<MessageDescription>
+       {
+               internal MessageDescriptionCollection ()
+               {
+               }
+
+               public MessageDescription Find (string action)
+               {
+                       foreach (MessageDescription md in this)
+                               if (md.Action == action)
+                                       return md;
+                       return null;
+               }
+
+               public Collection<MessageDescription> FindAll (string action)
+               {
+                       Collection<MessageDescription> list =
+                               new Collection<MessageDescription> ();
+                       foreach (MessageDescription md in this)
+                               if (md.Action == action)
+                                       list.Add (md);
+                       return list;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageHeaderDescription.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageHeaderDescription.cs
new file mode 100644 (file)
index 0000000..6abd13e
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// MessageHeaderDescription.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class MessageHeaderDescription : MessagePartDescription
+       {
+               string actor;
+               bool must_understand, relay, typed_header;
+
+               public MessageHeaderDescription (string name, string ns)
+                       : base (name, ns)
+               {
+               }
+
+               public string Actor {
+                       get { return actor; }
+                       set { actor = value; }
+               }
+
+               public bool MustUnderstand {
+                       get { return must_understand; }
+                       set { must_understand = value; }
+               }
+
+               public bool Relay {
+                       get { return relay; }
+                       set { relay = value; }
+               }
+
+               public bool TypedHeader {
+                       get { return typed_header; }
+                       set { typed_header = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageHeaderDescriptionCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessageHeaderDescriptionCollection.cs
new file mode 100644 (file)
index 0000000..d63b4d9
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// MessageHeaderDescriptionCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       public class MessageHeaderDescriptionCollection : KeyedCollection<XmlQualifiedName, MessageHeaderDescription>
+       {
+               internal MessageHeaderDescriptionCollection ()
+               {
+               }
+
+               protected override XmlQualifiedName
+                       GetKeyForItem (MessageHeaderDescription item)
+               {
+                       return new XmlQualifiedName (item.Name, item.Namespace);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePartDescription.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePartDescription.cs
new file mode 100644 (file)
index 0000000..6368564
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// MessagePartDescription.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.Runtime.Serialization;
+using System.Reflection;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class MessagePartDescription
+       {
+               int index;
+               MemberInfo member;
+               bool multiple;
+               Type type;
+               string name, ns;
+               bool has_protection_level;
+               ProtectionLevel protection_level;
+
+               private XmlQualifiedName xml_schema_type_name;
+               private XmlTypeMapping xml_type_mapping;
+               
+               public MessagePartDescription (string name, string ns)
+               {
+                       this.name = name;
+                       this.ns = ns;
+               }
+
+               public int Index {
+                       get { return index; }
+                       set { index = value; }
+               }
+
+               public MemberInfo MemberInfo {
+                       get { return member; }
+                       set { member = value; }
+               }
+
+               public string Name {
+                       get { return name; }
+               }
+
+               public string Namespace {
+                       get { return ns; }
+               }
+
+               public bool HasProtectionLevel {
+                       get { return has_protection_level; }
+               }
+
+               public ProtectionLevel ProtectionLevel {
+                       get { return protection_level; }
+                       set {
+                               protection_level = value;
+                               has_protection_level = true;
+                       }
+               }
+
+               public bool Multiple {
+                       get { return multiple; }
+                       set { multiple = value; }
+               }
+
+               public Type Type {
+                       get { return type; }
+                       set { type = value; }
+               }
+
+               internal XmlQualifiedName TypeName {
+                       get { return xml_schema_type_name; }
+                       set { xml_schema_type_name = value; }
+               }
+
+               internal XmlTypeMapping XmlTypeMapping {
+                       get { return xml_type_mapping; }
+                       set { xml_type_mapping = value; }
+               }
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePartDescriptionCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePartDescriptionCollection.cs
new file mode 100644 (file)
index 0000000..53a08c8
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// MessagePartDescriptionCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       public class MessagePartDescriptionCollection : KeyedCollection<XmlQualifiedName, MessagePartDescription>
+       {
+               internal MessagePartDescriptionCollection ()
+               {
+               }
+
+               protected override XmlQualifiedName
+                       GetKeyForItem (MessagePartDescription item)
+               {
+                       return new XmlQualifiedName (item.Name, item.Namespace);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePropertyDescription.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePropertyDescription.cs
new file mode 100644 (file)
index 0000000..947d7f3
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// MessagePropertyDescription.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class MessagePropertyDescription : MessagePartDescription
+       {
+               public MessagePropertyDescription (string name)
+                       : base (name, String.Empty)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePropertyDescriptionCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MessagePropertyDescriptionCollection.cs
new file mode 100644 (file)
index 0000000..d423a22
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// MessagePropertyDescriptionCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.Description
+{
+       public class MessagePropertyDescriptionCollection : KeyedCollection<string, MessagePropertyDescription>
+       {
+               internal MessagePropertyDescriptionCollection ()
+               {
+               }
+
+               protected override string GetKeyForItem (MessagePropertyDescription item)
+               {
+                       return item.Name;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataBundle.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataBundle.cs
new file mode 100644 (file)
index 0000000..32aed23
--- /dev/null
@@ -0,0 +1,117 @@
+//
+// MetadataSet.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       [XmlRoot ("Metadata", Namespace = "http://schemas.xmlsoap.org/ws/2004/09/mex")]
+       public class MetadataSet : IXmlSerializable
+       {
+               Collection<MetadataSection> sections
+                               = new Collection<MetadataSection> ();
+               Collection<XmlAttribute> attributes
+                               = new Collection<XmlAttribute> ();
+
+               public MetadataSet ()
+               {
+               }
+
+               public MetadataSet (IEnumerable<MetadataSection> sections)
+               {
+                       foreach (MetadataSection s in sections)
+                               this.sections.Add (s);
+               }
+
+               [XmlElement ("MetadataSection", Namespace = "http://schemas.xmlsoap.org/ws/2004/09/mex")]
+               public Collection<MetadataSection> MetadataSections {
+                       get { return sections; }
+               }
+
+               [XmlAnyAttribute]
+               public Collection<XmlAttribute> Attributes {
+                       get { return attributes; }
+               }
+
+               XmlSchema IXmlSerializable.GetSchema ()
+               {
+                       return null;
+               }
+
+               void IXmlSerializable.ReadXml (XmlReader reader)
+               {
+                       if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "Metadata" || 
+                                       reader.NamespaceURI != "http://schemas.xmlsoap.org/ws/2004/09/mex") 
+                               throw new InvalidOperationException (String.Format ("Unexpected : <{0} ..", reader.LocalName));
+
+                       /* Move to MetadataSections */
+                       reader.Read ();
+
+                       MetadataSectionSerializer xs = new MetadataSectionSerializer ();
+                       while (reader.NodeType == XmlNodeType.Element && reader.LocalName == "MetadataSection" &&
+                                       reader.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/09/mex") {
+                               MetadataSection ms = (MetadataSection) xs.Deserialize (reader);
+                               MetadataSections.Add (ms);
+                       }
+               }
+
+               void IXmlSerializable.WriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static MetadataSet ReadFrom (XmlReader reader)
+               {
+                       XmlSerializer xs = new XmlSerializer (typeof (MetadataSet));
+                       MetadataSet ms = (MetadataSet) xs.Deserialize (reader);
+
+                       return ms;
+               }
+
+               public void WriteTo (XmlWriter writer)
+               {
+                       writer.WriteStartElement ("Metadata", "http://schemas.xmlsoap.org/ws/2004/09/mex");
+
+                       writer.WriteAttributeString ("xmlns", "xsd", "http://www.w3.org/2000/xmlns/", XmlSchema.Namespace);
+                       writer.WriteAttributeString ("xmlns", "wsx", "http://www.w3.org/2000/xmlns/", MetadataSection.MetadataExchangeDialect);
+                       writer.WriteAttributeString ("xmlns", "xsi", "http://www.w3.org/2000/xmlns/", XmlSchema.InstanceNamespace);
+
+                       XmlSerializer serializer = MetadataSection.Serializer;
+                       foreach (MetadataSection section in MetadataSections)
+                               serializer.Serialize (writer, section);
+
+                       writer.WriteEndElement ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataConversionError.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataConversionError.cs
new file mode 100644 (file)
index 0000000..afa66b9
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// MetadataConversionError.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Configuration;
+
+namespace System.ServiceModel.Description
+{
+       public class MetadataConversionError
+       {
+               string msg;
+               bool warning;
+
+               public MetadataConversionError (string message)
+                       : this (message, false)
+               {
+               }
+
+               public MetadataConversionError (string message, bool isWarning)
+               {
+                       msg = message;
+                       warning = isWarning;
+               }
+
+               public bool IsWarning {
+                       get { return warning; }
+               }
+
+               public string Message {
+                       get { return msg; }
+               }
+
+               public override bool Equals (object other)
+               {
+                       MetadataConversionError e = other as MetadataConversionError;
+                       return e != null &&
+                               e.warning == warning &&
+                               e.msg == msg;
+               }
+
+               public override int GetHashCode ()
+               {
+                       return warning ?
+                               msg.GetHashCode () : - msg.GetHashCode ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataExchangeBindings.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataExchangeBindings.cs
new file mode 100644 (file)
index 0000000..44762fb
--- /dev/null
@@ -0,0 +1,63 @@
+//
+// MetadataExchangeBindings.cs
+//
+// Author:
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.ServiceModel.Channels;
+using System.Text;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public static class MetadataExchangeBindings
+       {
+               public static Binding CreateMexHttpBinding ()
+               {
+                       //FIXME: .net uses WSHttpBinding.. 
+                       return new CustomBinding (
+                               "MetadataExchangeHttpBinding",
+                               "http://schemas.microsoft.com/ws/2005/02/mex/bindings",
+                               new TextMessageEncodingBindingElement (
+                                       MessageVersion.Soap12WSAddressing10, 
+                                       Encoding.UTF8),
+                               new HttpTransportBindingElement ());
+               }
+
+               public static Binding CreateMexHttpsBinding ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static Binding CreateMexNamedPipeBinding ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static Binding CreateMexTcpBinding ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataExchangeClient.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataExchangeClient.cs
new file mode 100644 (file)
index 0000000..519e3c4
--- /dev/null
@@ -0,0 +1,155 @@
+//
+// MetadataExchangeClient.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Web.Services.Description;
+using System.Web.Services.Discovery;
+using System.Web.Services.Protocols;
+using System.Xml;
+using System.Xml.Serialization;
+using System.IO;
+using System.Net;
+using System.Text;
+
+using SMBinding = System.ServiceModel.Channels.Binding;
+using SMMessage = System.ServiceModel.Channels.Message;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class MetadataExchangeClient
+       {
+               string scheme;
+
+               EndpointAddress address;
+               SMBinding binding;
+
+               public MetadataExchangeClient ()
+               {
+                       //FIXME: Look for config element, implementing
+                       //      IMetadataExchange contract
+                       //      Use Channel<IMetadataExchange> .. ?
+                       
+                       throw new NotImplementedException ();
+               }
+
+               public MetadataExchangeClient (SMBinding mexBinding)
+               {
+                       binding = mexBinding;
+               }
+
+               public MetadataExchangeClient (EndpointAddress address)
+               {
+                       this.address = address;
+               }
+
+               public MetadataExchangeClient (string endpointConfigurationName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public MetadataExchangeClient (Uri address, MetadataExchangeClientMode mode)
+               {
+                       this.address = new EndpointAddress (address.AbsoluteUri);
+               }
+
+               public MetadataSet GetMetadata ()
+               {
+                       return GetMetadata (address);
+               }
+
+               public MetadataSet GetMetadata (EndpointAddress address)
+               {
+                       //FIXME: default mode?
+                       return GetMetadataInternal (address, MetadataExchangeClientMode.MetadataExchange);
+               }
+
+               public MetadataSet GetMetadata (Uri address, MetadataExchangeClientMode mode)
+               {
+                       return GetMetadataInternal (new EndpointAddress (address.AbsoluteUri), mode);
+               }
+
+               MetadataSet GetMetadataInternal (EndpointAddress address, MetadataExchangeClientMode mode)
+               {
+                       if (binding == null)
+                               binding = MetadataExchangeBindings.CreateMexHttpBinding ();
+
+                       MetadataProxy proxy = new MetadataProxy (binding, address);
+                       proxy.Open ();
+
+                       SMMessage msg = SMMessage.CreateMessage ( 
+                                       MessageVersion.Soap12WSAddressing10, 
+                                       "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get");
+
+                       msg.Headers.ReplyTo = new EndpointAddress (
+                                       "http://www.w3.org/2005/08/addressing/anonymous");
+                       //msg.Headers.From = new EndpointAddress ("http://localhost");
+                       msg.Headers.To = address.Uri;
+                       msg.Headers.MessageId = new UniqueId ();
+
+                       SMMessage ret;
+                       try {
+                               ret = proxy.Get (msg);
+                       } catch (Exception e) {
+                               throw new InvalidOperationException (
+                                               "Metadata contains a reference that cannot be resolved : " + address.Uri.AbsoluteUri, e);
+                       }
+
+                       return MetadataSet.ReadFrom (ret.GetReaderAtBodyContents ());
+               }
+       }
+       
+       internal class MetadataProxy : ClientBase<IMetadataExchange>, IMetadataExchange
+       {
+               public MetadataProxy (SMBinding binding, EndpointAddress address)
+                       : base (binding, address)
+               {
+               }
+
+               public SMMessage Get (SMMessage msg)
+               {
+                       return Channel.Get (msg);
+               }
+
+               public IAsyncResult BeginGet (SMMessage request, AsyncCallback callback , object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public SMMessage EndGet (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataExporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataExporter.cs
new file mode 100644 (file)
index 0000000..7c143d8
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// MetadataExporter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Web.Services.Description;
+using System.Xml;
+using System.Xml.Schema;
+
+using WSBinding = System.Web.Services.Description.Binding;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public abstract class MetadataExporter
+       {
+               internal MetadataExporter ()
+               {
+               }
+
+               public Collection<MetadataConversionError> Errors {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public Dictionary<Object,Object> State {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public abstract void ExportContract (ContractDescription contract);
+
+               public abstract void ExportEndpoint (ServiceEndpoint endpoint);
+
+               public abstract MetadataSet GetGeneratedMetadata ();
+
+               protected internal PolicyConversionContext ExportPolicy (
+                       ServiceEndpoint endpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataImporter.cs
new file mode 100644 (file)
index 0000000..6938b8f
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// MetadataImporter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Web.Services.Description;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public abstract class MetadataImporter
+       {
+               KeyedByTypeCollection<IPolicyImportExtension> policy_extensions;
+
+               internal MetadataImporter (IEnumerable<IPolicyImportExtension> policyImportExtensions)
+               {
+                       if (policyImportExtensions != null) {
+                               policy_extensions = new KeyedByTypeCollection<IPolicyImportExtension> (policyImportExtensions);
+                               return;
+                       }
+                       
+                       //FIXME: Complete the list
+                       policy_extensions = new KeyedByTypeCollection<IPolicyImportExtension> ();
+                       policy_extensions.Add (new TransportBindingElementImporter ());
+                       policy_extensions.Add (new MessageEncodingBindingElementImporter ());
+               }
+
+               public Collection<MetadataConversionError> Errors {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public KeyedByTypeCollection<IPolicyImportExtension> PolicyImportExtensions {
+                       get { return policy_extensions; }
+               }
+
+               public Dictionary<Object,Object> State {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public Dictionary<XmlQualifiedName,ContractDescription> KnownContracts {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public abstract Collection<ContractDescription> ImportAllContracts ();
+
+               public abstract ServiceEndpointCollection ImportAllEndpoints ();
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataLocation.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataLocation.cs
new file mode 100644 (file)
index 0000000..473322b
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// MetadataLocation.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       [XmlRoot ("Location", Namespace="http://schemas.xmlsoap.org/ws/2004/09/mex")]
+       public class MetadataLocation
+       {
+               public MetadataLocation ()
+               {
+               }
+
+               public MetadataLocation (string location)
+               {
+                       this.location = location;
+               }
+
+               string location;
+
+               [XmlText]
+               public string Location {
+                       get { return location; }
+                       set { location = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataReference.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataReference.cs
new file mode 100644 (file)
index 0000000..5b2910d
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// MetadataReference.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       [XmlRoot ("MetadataReference", Namespace = "http://schemas.xmlsoap.org/ws/2004/09/mex")]
+       public class MetadataReference : IXmlSerializable
+       {
+               EndpointAddress address;
+               AddressingVersion address_version;
+
+               public MetadataReference ()
+                       : this (null, null)
+               {
+               }
+
+               public MetadataReference (EndpointAddress address, AddressingVersion addressVersion)
+               {
+                       this.address = address;
+                       this.address_version = addressVersion;
+               }
+
+               public EndpointAddress Address {
+                       get { return address; }
+                       set { address = value; }
+               }
+
+               public AddressingVersion AddressVersion {
+                       get { return address_version; }
+                       set { address_version = value; }
+               }
+               
+               XmlSchema IXmlSerializable.GetSchema ()
+               {
+                       return null;
+               }
+
+               void IXmlSerializable.ReadXml (XmlReader reader)
+               {
+                       if (reader.NodeType != XmlNodeType.Element || 
+                               reader.LocalName != "MetadataReference" || 
+                               reader.NamespaceURI != "http://schemas.xmlsoap.org/ws/2004/09/mex") 
+                               throw new InvalidOperationException (String.Format ("Unexpected : <{0} ..", reader.LocalName));
+
+                       throw new NotImplementedException ("Implement me!");
+               }
+
+               void IXmlSerializable.WriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataResolver.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataResolver.cs
new file mode 100644 (file)
index 0000000..3d4fe08
--- /dev/null
@@ -0,0 +1,159 @@
+//
+// MetadataResolver.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Web.Services.Description;
+using System.Web.Services.Discovery;
+using System.Web.Services.Protocols;
+using System.Xml;
+using System.Xml.Serialization;
+using System.Net;
+using System.IO;
+using System.Text;
+
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public static class MetadataResolver
+       {
+               public static ServiceEndpointCollection Resolve (
+                               Type contract,
+                               EndpointAddress address)
+               {
+                       if (contract == null)
+                               throw new ArgumentNullException ("contract");
+
+                       return ResolveContracts (
+                                       new ContractDescription [] {ContractDescription.GetContract (contract)},
+                                       address, 
+                                       MetadataExchangeClientMode.MetadataExchange);
+               }
+
+               public static ServiceEndpointCollection Resolve (
+                               Type contract,
+                               Uri address,
+                               MetadataExchangeClientMode mode)
+               {
+                       return ResolveContracts (
+                                       new ContractDescription [] {ContractDescription.GetContract (contract)},
+                                       address, 
+                                       mode);
+               }
+
+               public static ServiceEndpointCollection Resolve (
+                               IEnumerable<ContractDescription> contracts,
+                               EndpointAddress address)
+               {
+                       return ResolveContracts (contracts, address, MetadataExchangeClientMode.MetadataExchange);
+               }
+
+               public static ServiceEndpointCollection Resolve (
+                               IEnumerable<ContractDescription> contracts,
+                               Uri address,
+                               MetadataExchangeClientMode mode)
+               {
+                       return ResolveContracts (contracts, address, mode);
+               }
+
+               public static ServiceEndpointCollection Resolve (
+                               IEnumerable<ContractDescription> contracts,
+                               EndpointAddress address,
+                               MetadataExchangeClient client)
+               {
+                       if (client == null)
+                               throw new ArgumentNullException ("client");
+
+                       /* FIXME: client is used for what? */
+                       return ResolveContracts (contracts, address, MetadataExchangeClientMode.MetadataExchange);
+               }
+
+               /* FIXME: What is the mode/client used for here? 
+                * According to the tests, address is used */
+               public static ServiceEndpointCollection Resolve (
+                               IEnumerable<ContractDescription> contracts,
+                               Uri address,
+                               MetadataExchangeClientMode mode,
+                               MetadataExchangeClient client)
+               {
+                       if (client == null)
+                               throw new ArgumentNullException ("client");
+
+                       return ResolveContracts (contracts, address, mode);
+               }
+
+               private static ServiceEndpointCollection ResolveContracts (
+                               IEnumerable<ContractDescription> contracts,
+                               Uri address,
+                               MetadataExchangeClientMode mode)
+               {
+                       if (address == null)
+                               throw new ArgumentNullException ("address");
+
+                       return ResolveContracts (contracts, new EndpointAddress (address), mode);
+               }
+
+               private static ServiceEndpointCollection ResolveContracts (
+                               IEnumerable<ContractDescription> contracts,
+                               EndpointAddress address,
+                               MetadataExchangeClientMode mode)
+               {
+                       if (contracts == null)
+                               throw new ArgumentNullException ("contracts");
+
+                       List<ContractDescription> list = new List<ContractDescription> (contracts);
+                       if (list.Count == 0)
+                               throw new ArgumentException ("There must be atleast one ContractDescription", "contracts");
+
+                       if (address == null)
+                               throw new ArgumentNullException ("address");
+
+                       MetadataExchangeClient client = new MetadataExchangeClient (address);
+                       MetadataSet metadata = client.GetMetadata ();
+                       WsdlImporter importer = new WsdlImporter (metadata);
+                       ServiceEndpointCollection endpoints = importer.ImportAllEndpoints ();
+                       
+                       ServiceEndpointCollection ret = new ServiceEndpointCollection ();
+
+                       foreach (ContractDescription contract in list) {
+                               Collection<ServiceEndpoint> colln = 
+                                       endpoints.FindAll (new QName (contract.Name, contract.Namespace));
+
+                               for (int i = 0; i < colln.Count; i ++)
+                                       ret.Add (colln [i]);
+                       }
+
+                       return ret;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataSection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataSection.cs
new file mode 100644 (file)
index 0000000..445155a
--- /dev/null
@@ -0,0 +1,137 @@
+//
+// MetadataSection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+using WSServiceDescription = System.Web.Services.Description.ServiceDescription;
+
+namespace System.ServiceModel.Description
+{
+       [XmlRoot ("MetadataSection", Namespace = "http://schemas.xmlsoap.org/ws/2004/09/mex")]
+       public class MetadataSection
+       {
+               string dialect;
+               string identifier;
+               object metadata;
+               Collection<XmlAttribute> attributes;
+               static MetadataSectionSerializer serializer;
+
+               static MetadataSection ()
+               {
+                       serializer = new MetadataSectionSerializer ();
+               }
+               
+               public MetadataSection ()
+                       : this (null, null, null)
+               {
+               }
+
+               public MetadataSection (string dialect, string identifier, object metadata)
+               {
+                       this.dialect = dialect;
+                       this.identifier = identifier;
+                       this.metadata = metadata;
+
+                       attributes = new Collection<XmlAttribute> ();
+               }
+
+               public static string MetadataExchangeDialect {
+                       get { return "http://schemas.xmlsoap.org/ws/2004/09/mex"; }
+               }
+
+               public static string PolicyDialect {
+                       get { return "http://schemas.xmlsoap.org/ws/2004/09/policy"; }
+               }
+
+               public static string ServiceDescriptionDialect {
+                       get { return "http://schemas.xmlsoap.org/wsdl/"; }
+               }
+
+               public static string XmlSchemaDialect {
+                       get { return "http://www.w3.org/2001/XMLSchema"; }
+               }
+
+               [XmlAttribute]
+               public string Dialect {
+                       get { return dialect; }
+                       set { dialect = value; }
+               }
+
+               [XmlAttribute]
+               public string Identifier {
+                       get { return identifier; }
+                       set { identifier = value; }
+               }
+
+               [XmlElement ("Location", Namespace = "http://schemas.xmlsoap.org/ws/2004/09/mex", Type = typeof (MetadataLocation), IsNullable = false)]
+               [XmlElement ("Metadata", Namespace = "http://schemas.xmlsoap.org/ws/2004/09/mex", Type = typeof (MetadataSet), IsNullable = false)]
+               [XmlElement ("schema", Namespace = "http://www.w3.org/2001/XMLSchema", Type = typeof (XmlSchema), IsNullable = false)]
+               [XmlElement ("definitions", Namespace = "http://schemas.xmlsoap.org/wsdl/", Type = typeof (System.Web.Services.Description.ServiceDescription), IsNullable = false)]
+               [XmlElement ("MetadataReference", Namespace = "http://schemas.xmlsoap.org/ws/2004/09/mex", Type = typeof (MetadataReference), IsNullable = false)]
+               [XmlAnyElement]
+               public object Metadata {
+                       get { return metadata; }
+                       set { metadata = value; }
+               }
+
+               [XmlAnyAttribute]
+               public Collection<XmlAttribute> Attributes {
+                       get { return attributes; }
+               }
+
+               internal static XmlSerializer Serializer {
+                       get { return serializer; }
+               }
+
+               public static MetadataSection CreateFromSchema (XmlSchema schema)
+               {
+                       return new MetadataSection (
+                               MetadataSection.XmlSchemaDialect,
+                               schema.TargetNamespace, schema);
+               }
+
+               public static MetadataSection CreateFromServiceDescription (
+                       WSServiceDescription serviceDescription)
+               {
+                       return new MetadataSection (
+                               MetadataSection.ServiceDescriptionDialect,
+                               serviceDescription.TargetNamespace, serviceDescription);
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataSectionSerializerBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MetadataSectionSerializerBase.cs
new file mode 100644 (file)
index 0000000..54d003c
--- /dev/null
@@ -0,0 +1,1164 @@
+using System;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+using System.Text;
+using System.Collections;
+using System.Globalization;
+
+namespace System.ServiceModel.Description
+{
+       internal class MetadataSectionReaderBase : XmlSerializationReader
+       {
+               public object ReadRoot_MetadataSection ()
+               {
+                       Reader.MoveToContent();
+                       if (Reader.LocalName != "MetadataSection" || Reader.NamespaceURI != "http://schemas.xmlsoap.org/ws/2004/09/mex")
+                               throw CreateUnknownNodeException();
+                       return ReadObject_MetadataSection (true, true);
+               }
+
+               public System.ServiceModel.Description.MetadataSection ReadObject_MetadataSection (bool isNullable, bool checkType)
+               {
+                       System.ServiceModel.Description.MetadataSection ob = null;
+                       if (isNullable && ReadNull()) return null;
+
+                       if (checkType) 
+                       {
+                               System.Xml.XmlQualifiedName t = GetXsiType();
+                               if (t == null)
+                               { }
+                               else if (t.Name != "MetadataSection" || t.Namespace != "http://schemas.xmlsoap.org/ws/2004/09/mex")
+                                       throw CreateUnknownTypeException(t);
+                       }
+
+                       ob = new System.ServiceModel.Description.MetadataSection ();
+
+                       Reader.MoveToElement();
+
+                       int anyAttributeIndex = 0;
+                       System.Collections.ObjectModel.Collection<System.Xml.XmlAttribute> anyAttributeArray = null;
+                       while (Reader.MoveToNextAttribute())
+                       {
+                               if (Reader.LocalName == "Dialect" && Reader.NamespaceURI == "") {
+                                       ob.@Dialect = Reader.Value;
+                               }
+                               else if (Reader.LocalName == "Identifier" && Reader.NamespaceURI == "") {
+                                       ob.@Identifier = Reader.Value;
+                               }
+                               else if (IsXmlnsAttribute (Reader.Name)) {
+                               }
+                               else {
+                                       System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute) Document.ReadNode(Reader);
+                                       if (((object)anyAttributeArray) == null)
+                                               anyAttributeArray = new System.Collections.ObjectModel.Collection<System.Xml.XmlAttribute>();
+                                       anyAttributeArray.Add (((System.Xml.XmlAttribute) attr));
+                                       anyAttributeIndex++;
+                               }
+                       }
+
+                       Reader.MoveToElement();
+                       if (Reader.IsEmptyElement) {
+                               Reader.Skip ();
+                               return ob;
+                       }
+
+                       Reader.ReadStartElement();
+                       Reader.MoveToContent();
+
+                       bool b0=false;
+
+                       while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
+                       {
+                               if (Reader.NodeType == System.Xml.XmlNodeType.Element) 
+                               {
+                                       if (Reader.LocalName == "schema" && Reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema" && !b0) {
+                                               b0 = true;
+                                               ob.@Metadata = ReadObject_XmlSchema (false, true);
+                                       }
+                                       else if (Reader.LocalName == "Metadata" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/09/mex" && !b0) {
+                                               b0 = true;
+                                               ob.@Metadata = ((System.ServiceModel.Description.MetadataSet) ReadSerializable (new System.ServiceModel.Description.MetadataSet ()));
+                                       }
+                                       else if (Reader.LocalName == "Location" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/09/mex" && !b0) {
+                                               b0 = true;
+                                               ob.@Metadata = ReadObject_MetadataLocation (false, true);
+                                       }
+                                       else if (Reader.LocalName == "MetadataReference" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/09/mex" && !b0) {
+                                               b0 = true;
+                                               ob.@Metadata = ((System.ServiceModel.Description.MetadataReference) ReadSerializable (new System.ServiceModel.Description.MetadataReference ()));
+                                       }
+                                       else if (Reader.LocalName == "definitions" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/" && !b0) {
+                                               b0 = true;
+                                               ob.@Metadata = ReadObject_ServiceDescription (false, true);
+                                       }
+                                       else {
+                                               UnknownNode (ob);
+                                       }
+                               }
+                               else
+                                       UnknownNode(ob);
+
+                               Reader.MoveToContent();
+                       }
+
+                       ReadEndElement();
+
+                       return ob;
+               }
+
+               public System.Xml.Schema.XmlSchema ReadObject_XmlSchema (bool isNullable, bool checkType)
+               {
+                       System.Xml.Schema.XmlSchema ob = null;
+                       ob = System.Xml.Schema.XmlSchema.Read (Reader, null); Reader.Read ();
+                       return ob;
+               }
+
+               public System.ServiceModel.Description.MetadataLocation ReadObject_MetadataLocation (bool isNullable, bool checkType)
+               {
+                       System.ServiceModel.Description.MetadataLocation ob = null;
+                       if (isNullable && ReadNull()) return null;
+
+                       if (checkType) 
+                       {
+                               System.Xml.XmlQualifiedName t = GetXsiType();
+                               if (t == null)
+                               { }
+                               else if (t.Name != "MetadataLocation" || t.Namespace != "http://schemas.xmlsoap.org/ws/2004/09/mex")
+                                       throw CreateUnknownTypeException(t);
+                       }
+
+                       ob = new System.ServiceModel.Description.MetadataLocation ();
+
+                       Reader.MoveToElement();
+
+                       while (Reader.MoveToNextAttribute())
+                       {
+                               if (IsXmlnsAttribute (Reader.Name)) {
+                               }
+                               else {
+                                       UnknownNode (ob);
+                               }
+                       }
+
+                       Reader.MoveToElement();
+                       if (Reader.IsEmptyElement) {
+                               Reader.Skip ();
+                               return ob;
+                       }
+
+                       Reader.ReadStartElement();
+                       Reader.MoveToContent();
+
+                       bool b1=false;
+
+                       while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
+                       {
+                               if (Reader.NodeType == System.Xml.XmlNodeType.Element) 
+                               {
+                                       UnknownNode (ob);
+                               }
+                               else if (Reader.NodeType == System.Xml.XmlNodeType.Text || Reader.NodeType == System.Xml.XmlNodeType.CDATA)
+                               {
+                                       ob.@Location = ReadString (ob.@Location);
+                               }
+                               else
+                                       UnknownNode(ob);
+
+                               Reader.MoveToContent();
+                       }
+
+                       ReadEndElement();
+
+                       return ob;
+               }
+
+               public System.Web.Services.Description.ServiceDescription ReadObject_ServiceDescription (bool isNullable, bool checkType)
+               {
+                       System.Web.Services.Description.ServiceDescription ob = null;
+                       ob = (System.Web.Services.Description.ServiceDescription) System.Web.Services.Description.ServiceDescription.Serializer.Deserialize (Reader); 
+                       return ob;
+               }
+
+               protected override void InitCallbacks ()
+               {
+               }
+
+               protected override void InitIDs ()
+               {
+               }
+
+       }
+
+       internal class MetadataSectionWriterBase : XmlSerializationWriter
+       {
+               const string xmlNamespace = "http://www.w3.org/2000/xmlns/";
+               public void WriteRoot_MetadataSection (object o)
+               {
+                       WriteStartDocument ();
+                       System.ServiceModel.Description.MetadataSection ob = (System.ServiceModel.Description.MetadataSection) o;
+                       TopLevelElement ();
+                       WriteObject_MetadataSection (ob, "MetadataSection", "http://schemas.xmlsoap.org/ws/2004/09/mex", true, false, true);
+               }
+
+               void WriteObject_MetadataSection (System.ServiceModel.Description.MetadataSection ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.ServiceModel.Description.MetadataSection))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("MetadataSection", "http://schemas.xmlsoap.org/ws/2004/09/mex");
+
+                       ICollection o2 = ob.@Attributes;
+                       if (o2 != null) {
+                               foreach (XmlAttribute o3 in o2)
+                                       if (o3.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o3, ob);
+                       }
+
+                       WriteAttribute ("Dialect", "", ob.@Dialect);
+                       WriteAttribute ("Identifier", "", ob.@Identifier);
+
+                       if (ob.@Metadata is System.ServiceModel.Description.MetadataReference) {
+                               WriteSerializable (((System.ServiceModel.Description.MetadataReference) ob.@Metadata), "MetadataReference", "http://schemas.xmlsoap.org/ws/2004/09/mex", false);
+                       }
+                       else if (ob.@Metadata is System.Web.Services.Description.ServiceDescription) {
+                               WriteObject_ServiceDescription (((System.Web.Services.Description.ServiceDescription) ob.@Metadata), "definitions", "http://schemas.xmlsoap.org/wsdl/", false, false, true);
+                       }
+                       else if (ob.@Metadata is System.Xml.Schema.XmlSchema) {
+                               WriteObject_XmlSchema (((System.Xml.Schema.XmlSchema) ob.@Metadata), "schema", "http://www.w3.org/2001/XMLSchema", false, false, true);
+                       }
+                       else if (ob.@Metadata is System.ServiceModel.Description.MetadataSet) {
+                               WriteSerializable (((System.ServiceModel.Description.MetadataSet) ob.@Metadata), "Metadata", "http://schemas.xmlsoap.org/ws/2004/09/mex", false);
+                       }
+                       else if (ob.@Metadata is System.ServiceModel.Description.MetadataLocation) {
+                               WriteObject_MetadataLocation (((System.ServiceModel.Description.MetadataLocation) ob.@Metadata), "Location", "http://schemas.xmlsoap.org/ws/2004/09/mex", false, false, true);
+                       }
+                       else if (ob.@Metadata is System.Xml.XmlElement) {
+                               WriteElementLiteral (((System.Xml.XmlElement) ob.@Metadata), "", "http://schemas.xmlsoap.org/ws/2004/09/mex", false, false);
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_ServiceDescription (System.Web.Services.Description.ServiceDescription ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       System.Web.Services.Description.ServiceDescription.Serializer.Serialize (Writer, ob);
+               }
+
+               void WriteObject_XmlSchema (System.Xml.Schema.XmlSchema ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       ob.Write (Writer);
+               }
+
+               void WriteObject_MetadataLocation (System.ServiceModel.Description.MetadataLocation ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.ServiceModel.Description.MetadataLocation))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("MetadataLocation", "http://schemas.xmlsoap.org/ws/2004/09/mex");
+
+                       WriteValue (ob.@Location);
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_Import (System.Web.Services.Description.Import ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.Import))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("Import", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o12 = ob.@ExtensibleAttributes;
+                       if (o12 != null) {
+                               foreach (XmlAttribute o13 in o12)
+                                       if (o13.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o13, ob);
+                       }
+
+                       WriteAttribute ("location", "", ob.@Location);
+                       WriteAttribute ("namespace", "", ob.@Namespace);
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o14 = ob.@DocumentationElement;
+                               if (o14 is XmlElement) {
+                               if ((o14.Name == "documentation" && o14.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o14.WriteTo (Writer);
+                                       WriteElementLiteral (o14, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o14.Name, o14.NamespaceURI);
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_Types (System.Web.Services.Description.Types ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.Types))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("Types", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o15 = ob.@ExtensibleAttributes;
+                       if (o15 != null) {
+                               foreach (XmlAttribute o16 in o15)
+                                       if (o16.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o16, ob);
+                       }
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o17 = ob.@DocumentationElement;
+                               if (o17 is XmlElement) {
+                               if ((o17.Name == "documentation" && o17.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o17.WriteTo (Writer);
+                                       WriteElementLiteral (o17, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o17.Name, o17.NamespaceURI);
+                       }
+                       if (ob.@Schemas != null) {
+                               for (int n18 = 0; n18 < ob.@Schemas.Count; n18++) {
+                                       WriteObject_XmlSchema (ob.@Schemas[n18], "schema", "http://www.w3.org/2001/XMLSchema", false, false, true);
+                               }
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_Message (System.Web.Services.Description.Message ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.Message))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("Message", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o19 = ob.@ExtensibleAttributes;
+                       if (o19 != null) {
+                               foreach (XmlAttribute o20 in o19)
+                                       if (o20.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o20, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o21 = ob.@DocumentationElement;
+                               if (o21 is XmlElement) {
+                               if ((o21.Name == "documentation" && o21.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o21.WriteTo (Writer);
+                                       WriteElementLiteral (o21, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o21.Name, o21.NamespaceURI);
+                       }
+                       if (ob.@Parts != null) {
+                               for (int n22 = 0; n22 < ob.@Parts.Count; n22++) {
+                                       WriteObject_MessagePart (ob.@Parts[n22], "part", "http://schemas.xmlsoap.org/wsdl/", false, false, true);
+                               }
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_PortType (System.Web.Services.Description.PortType ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.PortType))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("PortType", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o23 = ob.@ExtensibleAttributes;
+                       if (o23 != null) {
+                               foreach (XmlAttribute o24 in o23)
+                                       if (o24.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o24, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o25 = ob.@DocumentationElement;
+                               if (o25 is XmlElement) {
+                               if ((o25.Name == "documentation" && o25.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o25.WriteTo (Writer);
+                                       WriteElementLiteral (o25, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o25.Name, o25.NamespaceURI);
+                       }
+                       if (ob.@Operations != null) {
+                               for (int n26 = 0; n26 < ob.@Operations.Count; n26++) {
+                                       WriteObject_Operation (ob.@Operations[n26], "operation", "http://schemas.xmlsoap.org/wsdl/", false, false, true);
+                               }
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_Binding (System.Web.Services.Description.Binding ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.Binding))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("Binding", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o27 = ob.@ExtensibleAttributes;
+                       if (o27 != null) {
+                               foreach (XmlAttribute o28 in o27)
+                                       if (o28.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o28, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+                       WriteAttribute ("type", "", FromXmlQualifiedName (ob.@Type));
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o29 = ob.@DocumentationElement;
+                               if (o29 is XmlElement) {
+                               if ((o29.Name == "documentation" && o29.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o29.WriteTo (Writer);
+                                       WriteElementLiteral (o29, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o29.Name, o29.NamespaceURI);
+                       }
+                       if (ob.@Operations != null) {
+                               for (int n30 = 0; n30 < ob.@Operations.Count; n30++) {
+                                       WriteObject_OperationBinding (ob.@Operations[n30], "operation", "http://schemas.xmlsoap.org/wsdl/", false, false, true);
+                               }
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_Service (System.Web.Services.Description.Service ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.Service))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("Service", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o31 = ob.@ExtensibleAttributes;
+                       if (o31 != null) {
+                               foreach (XmlAttribute o32 in o31)
+                                       if (o32.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o32, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o33 = ob.@DocumentationElement;
+                               if (o33 is XmlElement) {
+                               if ((o33.Name == "documentation" && o33.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o33.WriteTo (Writer);
+                                       WriteElementLiteral (o33, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o33.Name, o33.NamespaceURI);
+                       }
+                       if (ob.@Ports != null) {
+                               for (int n34 = 0; n34 < ob.@Ports.Count; n34++) {
+                                       WriteObject_Port (ob.@Ports[n34], "port", "http://schemas.xmlsoap.org/wsdl/", false, false, true);
+                               }
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_MessagePart (System.Web.Services.Description.MessagePart ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.MessagePart))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("MessagePart", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o35 = ob.@ExtensibleAttributes;
+                       if (o35 != null) {
+                               foreach (XmlAttribute o36 in o35)
+                                       if (o36.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o36, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+                       WriteAttribute ("element", "", FromXmlQualifiedName (ob.@Element));
+                       WriteAttribute ("type", "", FromXmlQualifiedName (ob.@Type));
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o37 = ob.@DocumentationElement;
+                               if (o37 is XmlElement) {
+                               if ((o37.Name == "documentation" && o37.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o37.WriteTo (Writer);
+                                       WriteElementLiteral (o37, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o37.Name, o37.NamespaceURI);
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_Operation (System.Web.Services.Description.Operation ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.Operation))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("Operation", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o38 = ob.@ExtensibleAttributes;
+                       if (o38 != null) {
+                               foreach (XmlAttribute o39 in o38)
+                                       if (o39.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o39, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+                       if (ob.@ParameterOrderString != "") {
+                               WriteAttribute ("parameterOrder", "", ob.@ParameterOrderString);
+                       }
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o40 = ob.@DocumentationElement;
+                               if (o40 is XmlElement) {
+                               if ((o40.Name == "documentation" && o40.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o40.WriteTo (Writer);
+                                       WriteElementLiteral (o40, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o40.Name, o40.NamespaceURI);
+                       }
+                       if (ob.@Faults != null) {
+                               for (int n41 = 0; n41 < ob.@Faults.Count; n41++) {
+                                       WriteObject_OperationFault (ob.@Faults[n41], "fault", "http://schemas.xmlsoap.org/wsdl/", false, false, true);
+                               }
+                       }
+                       if (ob.@Messages != null) {
+                               for (int n42 = 0; n42 < ob.@Messages.Count; n42++) {
+                                       if (((object)ob.@Messages[n42]) == null) { }
+                                       else if (ob.@Messages[n42].GetType() == typeof(System.Web.Services.Description.OperationInput)) {
+                                               WriteObject_OperationInput (((System.Web.Services.Description.OperationInput) ob.@Messages[n42]), "input", "http://schemas.xmlsoap.org/wsdl/", false, false, true);
+                                       }
+                                       else if (ob.@Messages[n42].GetType() == typeof(System.Web.Services.Description.OperationOutput)) {
+                                               WriteObject_OperationOutput (((System.Web.Services.Description.OperationOutput) ob.@Messages[n42]), "output", "http://schemas.xmlsoap.org/wsdl/", false, false, true);
+                                       }
+                                       else throw CreateUnknownTypeException (ob.@Messages[n42]);
+                               }
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_OperationBinding (System.Web.Services.Description.OperationBinding ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.OperationBinding))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("OperationBinding", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o43 = ob.@ExtensibleAttributes;
+                       if (o43 != null) {
+                               foreach (XmlAttribute o44 in o43)
+                                       if (o44.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o44, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o45 = ob.@DocumentationElement;
+                               if (o45 is XmlElement) {
+                               if ((o45.Name == "documentation" && o45.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o45.WriteTo (Writer);
+                                       WriteElementLiteral (o45, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o45.Name, o45.NamespaceURI);
+                       }
+                       if (ob.@Faults != null) {
+                               for (int n46 = 0; n46 < ob.@Faults.Count; n46++) {
+                                       WriteObject_FaultBinding (ob.@Faults[n46], "fault", "http://schemas.xmlsoap.org/wsdl/", false, false, true);
+                               }
+                       }
+                       WriteObject_InputBinding (ob.@Input, "input", "http://schemas.xmlsoap.org/wsdl/", false, false, true);
+                       WriteObject_OutputBinding (ob.@Output, "output", "http://schemas.xmlsoap.org/wsdl/", false, false, true);
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_Port (System.Web.Services.Description.Port ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.Port))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("Port", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o47 = ob.@ExtensibleAttributes;
+                       if (o47 != null) {
+                               foreach (XmlAttribute o48 in o47)
+                                       if (o48.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o48, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+                       WriteAttribute ("binding", "", FromXmlQualifiedName (ob.@Binding));
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o49 = ob.@DocumentationElement;
+                               if (o49 is XmlElement) {
+                               if ((o49.Name == "documentation" && o49.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o49.WriteTo (Writer);
+                                       WriteElementLiteral (o49, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o49.Name, o49.NamespaceURI);
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_OperationFault (System.Web.Services.Description.OperationFault ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.OperationFault))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("OperationFault", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o50 = ob.@ExtensibleAttributes;
+                       if (o50 != null) {
+                               foreach (XmlAttribute o51 in o50)
+                                       if (o51.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o51, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+                       WriteAttribute ("message", "", FromXmlQualifiedName (ob.@Message));
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o52 = ob.@DocumentationElement;
+                               if (o52 is XmlElement) {
+                               if ((o52.Name == "documentation" && o52.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o52.WriteTo (Writer);
+                                       WriteElementLiteral (o52, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o52.Name, o52.NamespaceURI);
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_OperationInput (System.Web.Services.Description.OperationInput ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.OperationInput))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("OperationInput", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o53 = ob.@ExtensibleAttributes;
+                       if (o53 != null) {
+                               foreach (XmlAttribute o54 in o53)
+                                       if (o54.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o54, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+                       WriteAttribute ("message", "", FromXmlQualifiedName (ob.@Message));
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o55 = ob.@DocumentationElement;
+                               if (o55 is XmlElement) {
+                               if ((o55.Name == "documentation" && o55.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o55.WriteTo (Writer);
+                                       WriteElementLiteral (o55, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o55.Name, o55.NamespaceURI);
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_OperationOutput (System.Web.Services.Description.OperationOutput ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.OperationOutput))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("OperationOutput", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o56 = ob.@ExtensibleAttributes;
+                       if (o56 != null) {
+                               foreach (XmlAttribute o57 in o56)
+                                       if (o57.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o57, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+                       WriteAttribute ("message", "", FromXmlQualifiedName (ob.@Message));
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o58 = ob.@DocumentationElement;
+                               if (o58 is XmlElement) {
+                               if ((o58.Name == "documentation" && o58.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o58.WriteTo (Writer);
+                                       WriteElementLiteral (o58, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o58.Name, o58.NamespaceURI);
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_FaultBinding (System.Web.Services.Description.FaultBinding ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.FaultBinding))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("FaultBinding", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o59 = ob.@ExtensibleAttributes;
+                       if (o59 != null) {
+                               foreach (XmlAttribute o60 in o59)
+                                       if (o60.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o60, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o61 = ob.@DocumentationElement;
+                               if (o61 is XmlElement) {
+                               if ((o61.Name == "documentation" && o61.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o61.WriteTo (Writer);
+                                       WriteElementLiteral (o61, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o61.Name, o61.NamespaceURI);
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_InputBinding (System.Web.Services.Description.InputBinding ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.InputBinding))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("InputBinding", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o62 = ob.@ExtensibleAttributes;
+                       if (o62 != null) {
+                               foreach (XmlAttribute o63 in o62)
+                                       if (o63.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o63, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o64 = ob.@DocumentationElement;
+                               if (o64 is XmlElement) {
+                               if ((o64.Name == "documentation" && o64.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o64.WriteTo (Writer);
+                                       WriteElementLiteral (o64, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o64.Name, o64.NamespaceURI);
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               void WriteObject_OutputBinding (System.Web.Services.Description.OutputBinding ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
+               {
+                       if (((object)ob) == null)
+                       {
+                               if (isNullable)
+                                       WriteNullTagLiteral(element, namesp);
+                               return;
+                       }
+
+                       System.Type type = ob.GetType ();
+                       if (type == typeof(System.Web.Services.Description.OutputBinding))
+                       { }
+                       else {
+                               throw CreateUnknownTypeException (ob);
+                       }
+
+                       if (writeWrappingElem) {
+                               WriteStartElement (element, namesp, ob);
+                       }
+
+                       if (needType) WriteXsiType("OutputBinding", "http://schemas.xmlsoap.org/wsdl/");
+
+                       ICollection o65 = ob.@ExtensibleAttributes;
+                       if (o65 != null) {
+                               foreach (XmlAttribute o66 in o65)
+                                       if (o66.NamespaceURI != xmlNamespace)
+                                               WriteXmlAttribute (o66, ob);
+                       }
+
+                       WriteAttribute ("name", "", ob.@Name);
+
+                       if (ob.@DocumentationElement != null) {
+                               XmlNode o67 = ob.@DocumentationElement;
+                               if (o67 is XmlElement) {
+                               if ((o67.Name == "documentation" && o67.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/")) {
+                                       }
+                                       else o67.WriteTo (Writer);
+                                       WriteElementLiteral (o67, "", "", false, true);
+                               }
+                               else
+                                       throw CreateUnknownAnyElementException (o67.Name, o67.NamespaceURI);
+                       }
+                       if (writeWrappingElem) WriteEndElement (ob);
+               }
+
+               protected override void InitCallbacks ()
+               {
+               }
+
+       }
+
+
+       internal class BaseXmlSerializer : System.Xml.Serialization.XmlSerializer
+       {
+               protected override System.Xml.Serialization.XmlSerializationReader CreateReader () {
+                       return new MetadataSectionReaderBase ();
+               }
+
+               protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter () {
+                       return new MetadataSectionWriterBase ();
+               }
+
+               public override bool CanDeserialize (System.Xml.XmlReader xmlReader) {
+                       return true;
+               }
+       }
+
+       internal sealed class MetadataSectionSerializer : BaseXmlSerializer
+       {
+               protected override void Serialize (object obj, System.Xml.Serialization.XmlSerializationWriter writer) {
+                       ((MetadataSectionWriterBase)writer).WriteRoot_MetadataSection(obj);
+               }
+
+               protected override object Deserialize (System.Xml.Serialization.XmlSerializationReader reader) {
+                       return ((MetadataSectionReaderBase)reader).ReadRoot_MetadataSection();
+               }
+       }
+
+       internal class XmlSerializerContract : System.Xml.Serialization.XmlSerializerImplementation
+       {
+               System.Collections.Hashtable readMethods = null;
+               System.Collections.Hashtable writeMethods = null;
+               System.Collections.Hashtable typedSerializers = null;
+
+               public override System.Xml.Serialization.XmlSerializationReader Reader {
+                       get {
+                               return new MetadataSectionReaderBase();
+                       }
+               }
+
+               public override System.Xml.Serialization.XmlSerializationWriter Writer {
+                       get {
+                               return new MetadataSectionWriterBase();
+                       }
+               }
+
+               public override System.Collections.Hashtable ReadMethods {
+                       get {
+                               lock (this) {
+                                       if (readMethods == null) {
+                                               readMethods = new System.Collections.Hashtable ();
+                                               readMethods.Add (@"", @"ReadRoot_MetadataSection");
+                                       }
+                                       return readMethods;
+                               }
+                       }
+               }
+
+               public override System.Collections.Hashtable WriteMethods {
+                       get {
+                               lock (this) {
+                                       if (writeMethods == null) {
+                                               writeMethods = new System.Collections.Hashtable ();
+                                               writeMethods.Add (@"", @"WriteRoot_MetadataSection");
+                                       }
+                                       return writeMethods;
+                               }
+                       }
+               }
+
+               public override System.Collections.Hashtable TypedSerializers {
+                       get {
+                               lock (this) {
+                                       if (typedSerializers == null) {
+                                               typedSerializers = new System.Collections.Hashtable ();
+                                               typedSerializers.Add (@"", new MetadataSectionSerializer());
+                                       }
+                                       return typedSerializers;
+                               }
+                       }
+               }
+               public override bool CanSerialize (System.Type type) {
+                       if (type == typeof(System.ServiceModel.Description.MetadataSection)) return true;
+                       return false;
+               }
+       }
+
+}
+
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/MustUnderstandBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/MustUnderstandBehavior.cs
new file mode 100644 (file)
index 0000000..aeab570
--- /dev/null
@@ -0,0 +1,69 @@
+//
+// MustUnderstandBehavior.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public class MustUnderstandBehavior : IEndpointBehavior
+       {
+               bool validate;
+
+               public MustUnderstandBehavior (bool validate)
+               {
+                       this.validate = validate;
+               }
+
+               public bool ValidateMustUnderstand {
+                       get { return validate; }
+                       set { validate = value; }
+               }
+
+               void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint,
+                       BindingParameterCollection parameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IEndpointBehavior.ApplyDispatchBehavior (ServiceEndpoint endpoint,
+                       EndpointDispatcher dispatcher)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IEndpointBehavior.ApplyClientBehavior (ServiceEndpoint endpoint,
+                       ClientRuntime proxy)
+               {
+                       proxy.ValidateMustUnderstand = validate;
+               }
+
+               void IEndpointBehavior.Validate (ServiceEndpoint endpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/OperationContractGenerationContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/OperationContractGenerationContext.cs
new file mode 100644 (file)
index 0000000..841cf56
--- /dev/null
@@ -0,0 +1,111 @@
+//
+// OperationContractGenerationContext.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.CodeDom;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Configuration;
+using System.Web.Services.Description;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class OperationContractGenerationContext
+       {
+               public OperationContractGenerationContext (
+                       ServiceContractGenerator serviceContractGenerator,
+                       ServiceContractGenerationContext contract,
+                       OperationDescription operation,
+                       CodeTypeDeclaration declaringType,
+                       CodeMemberMethod method)
+                       : this (serviceContractGenerator, contract, operation,
+                               declaringType, false, method, null)
+               {
+               }
+
+               public OperationContractGenerationContext (
+                       ServiceContractGenerator serviceContractGenerator,
+                       ServiceContractGenerationContext contract,
+                       OperationDescription operation,
+                       CodeTypeDeclaration declaringType,
+                       CodeMemberMethod beginMethod,
+                       CodeMemberMethod endMethod)
+                       : this (serviceContractGenerator, contract, operation,
+                               declaringType, true, beginMethod, endMethod)
+               {
+               }
+
+               private OperationContractGenerationContext (
+                       ServiceContractGenerator serviceContractGenerator,
+                       ServiceContractGenerationContext contract,
+                       OperationDescription operation,
+                       CodeTypeDeclaration declaringType,
+                       bool isAsync,
+                       CodeMemberMethod method, // sync
+                       CodeMemberMethod endMethod) // async
+               {
+                       generator = serviceContractGenerator;
+                       this.contract = contract;
+                       this.operation = operation;
+                       declaring_type = declaringType;
+                       this.method = method;
+                       this.end_method = endMethod;
+                       is_async = isAsync;
+               }
+
+               bool is_async;
+               ServiceContractGenerator generator;
+               ServiceContractGenerationContext contract;
+               OperationDescription operation;
+               CodeTypeDeclaration declaring_type;
+               CodeMemberMethod method;
+               CodeMemberMethod end_method;
+
+               public ServiceContractGenerator ServiceContractGenerator {
+                       get { return generator; }
+               }
+               public ServiceContractGenerationContext Contract {
+                       get { return contract; }
+               }
+               public OperationDescription Operation {
+                       get { return operation; }
+               }
+               public CodeTypeDeclaration DeclaringType {
+                       get { return declaring_type; }
+               }
+               public CodeMemberMethod Method {
+                       get { return method; }
+               }
+               public CodeMemberMethod EndMethod {
+                       get { return end_method; }
+               }
+               public bool IsAsync {
+                       get { return is_async; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/OperationDescription.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/OperationDescription.cs
new file mode 100644 (file)
index 0000000..62e2870
--- /dev/null
@@ -0,0 +1,137 @@
+//
+// OperationDescription.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.Reflection;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Description
+{
+       public class OperationDescription
+       {
+               MethodInfo begin_method, end_method, sync_method;
+               FaultDescriptionCollection faults
+                       = new FaultDescriptionCollection ();
+               ContractDescription contract;
+               KeyedByTypeCollection<IOperationBehavior> behaviors
+                       = new KeyedByTypeCollection<IOperationBehavior> ();
+               bool is_initiating, is_oneway, is_terminating;
+               Collection<Type> known_types = new Collection<Type> ();
+               MessageDescriptionCollection messages
+                       = new MessageDescriptionCollection ();
+               string name;
+               ProtectionLevel protection_level;
+               bool has_protection_level;
+
+               public OperationDescription (string name,
+                       ContractDescription declaringContract)
+               {
+                       this.name = name;
+                       contract = declaringContract;
+                       is_initiating = true;
+               }
+
+               [MonoTODO]
+               public MethodInfo BeginMethod {
+                       get { return begin_method; }
+                       set { begin_method = value; }
+               }
+
+               [MonoTODO]
+               public KeyedByTypeCollection<IOperationBehavior> Behaviors {
+                       get { return behaviors; }
+               }
+
+               public ContractDescription DeclaringContract {
+                       get { return contract; }
+                       set { contract = value; }
+               }
+
+               [MonoTODO]
+               public MethodInfo EndMethod {
+                       get { return end_method; }
+                       set { end_method = value; }
+               }
+
+               [MonoTODO]
+               public FaultDescriptionCollection Faults {
+                       get { return faults; }
+               }
+
+               public bool HasProtectionLevel {
+                       get { return has_protection_level; }
+               }
+
+               public bool IsInitiating {
+                       get { return is_initiating; }
+                       set { is_initiating = value; }
+               }
+
+               public bool IsOneWay {
+                       get { return is_oneway; }
+                       // LAMESPEC: I believe there should be a setter since
+                       // otherwise OperationContractAttribute.set_IsOneWay() does not make sense.
+                       internal set { is_oneway = value; }
+               }
+
+               public bool IsTerminating {
+                       get { return is_terminating; }
+                       set { is_terminating = value; }
+               }
+
+               [MonoTODO]
+               public Collection<Type> KnownTypes {
+                       get { return known_types; }
+               }
+
+               [MonoTODO]
+               public MessageDescriptionCollection Messages {
+                       get { return messages; }
+               }
+
+               public string Name {
+                       get { return name; }
+               }
+
+               public ProtectionLevel ProtectionLevel {
+                       get { return protection_level; }
+                       set {
+                               protection_level = value;
+                               has_protection_level = true;
+                       }
+               }
+
+               public MethodInfo SyncMethod {
+                       get { return sync_method; }
+                       set { sync_method = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/OperationDescriptionCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/OperationDescriptionCollection.cs
new file mode 100644 (file)
index 0000000..5a0eae5
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// OperationDescriptionCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Description
+{
+       public class OperationDescriptionCollection
+               : Collection<OperationDescription>
+       {
+               internal OperationDescriptionCollection ()
+               {
+               }
+
+               public OperationDescription Find (string name)
+               {
+                       foreach (OperationDescription d in this)
+                               if (d.Name == name)
+                                       return d;
+                       return null;
+               }
+
+               public Collection<OperationDescription> FindAll (string name)
+               {
+                       Collection<OperationDescription> ret =
+                               new Collection<OperationDescription> ();
+                       foreach (OperationDescription d in this)
+                               if (d.Name == name)
+                                       ret.Add (d);
+                       return ret;
+               }
+
+               protected override void InsertItem (int index, OperationDescription item)
+               {
+                       if (Find (item.Name) == null)
+                               base.InsertItem (index, item);
+                       else
+                               throw new InvalidOperationException ("A contract cannot have two operations that have the identical names and different set of parameters.");
+               }
+
+               protected override void SetItem (int index, OperationDescription item)
+               {
+                       if (Find (item.Name) != null)
+                               base.RemoveItem (index);
+                       base.SetItem (index, item);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/PolicyAssertionCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/PolicyAssertionCollection.cs
new file mode 100644 (file)
index 0000000..60d03dc
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// PolicyAssertionCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       public class PolicyAssertionCollection
+               : Collection<XmlElement>
+       {
+               public PolicyAssertionCollection ()
+               {
+               }
+
+               public PolicyAssertionCollection (IEnumerable<XmlElement> list)
+                       : base (new List<XmlElement> (list))
+               {
+               }
+
+               [MonoTODO]
+               public bool Contains (string name, string ns)
+               {
+                       foreach (XmlElement el in this)
+                               if (el.LocalName == name && el.NamespaceURI == ns)
+                                       return true;
+                       return false;
+               }
+
+               [MonoTODO]
+               public XmlElement Find (string name, string ns)
+               {
+                       foreach (XmlElement el in this)
+                               if (el.LocalName == name && el.NamespaceURI == ns)
+                                       return el;
+                       return null;
+               }
+
+               [MonoTODO]
+               public Collection<XmlElement> FindAll (string name, string ns)
+               {
+                       Collection<XmlElement> ret =
+                               new Collection<XmlElement> ();
+                       foreach (XmlElement el in this)
+                               if (el.LocalName == name && el.NamespaceURI == ns)
+                                       ret.Add (el);
+                       return ret;
+               }
+
+               [MonoTODO]
+               public XmlElement Remove (string name, string ns)
+               {
+                       foreach (XmlElement el in this)
+                               if (el.LocalName == name && el.NamespaceURI == ns) {
+                                       Remove (el);
+                                       return el;
+                               }
+                       return null;
+               }
+
+               [MonoTODO]
+               public Collection<XmlElement> RemoveAll (string name, string ns)
+               {
+                       Collection<XmlElement> list = FindAll (name, ns);
+                       foreach (XmlElement el in list)
+                               Remove (el);
+                       return list;
+               }
+
+               [MonoTODO]
+               protected override void InsertItem (int index, XmlElement item)
+               {
+                       base.InsertItem (index, item);
+               }
+
+               [MonoTODO]
+               protected override void SetItem (int index, XmlElement item)
+               {
+                       base.SetItem (index, item);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/PolicyConversionContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/PolicyConversionContext.cs
new file mode 100644 (file)
index 0000000..368cab7
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// PolicyConversionContext.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       public abstract class PolicyConversionContext
+       {
+               protected PolicyConversionContext (ServiceEndpoint endpoint)
+               {
+               }
+
+               public abstract BindingElementCollection BindingElements { get; }
+
+               public ContractDescription Contract {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public abstract PolicyAssertionCollection GetBindingAssertions ();
+
+               public abstract PolicyAssertionCollection
+                       GetFaultBindingAssertions (FaultDescription fault);
+
+               public abstract PolicyAssertionCollection
+                       GetMessageBindingAssertions (MessageDescription message);
+
+               public abstract PolicyAssertionCollection
+                       GetOperationBindingAssertions (OperationDescription operation);
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/PolicyVersion.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/PolicyVersion.cs
new file mode 100644 (file)
index 0000000..7716692
--- /dev/null
@@ -0,0 +1,66 @@
+//\r
+// PolicyVersion.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Description\r
+{\r
+       public sealed class PolicyVersion\r
+       {\r
+               static PolicyVersion _policy12 = new PolicyVersion ("http://schemas.xmlsoap.org/ws/2004/09/policy");\r
+               static PolicyVersion _policy15 = new PolicyVersion ("http://www.w3.org/ns/ws-policy");\r
+\r
+               readonly string _namespace;\r
+\r
+               private PolicyVersion (string @namespace) {\r
+                       _namespace = @namespace;\r
+               }\r
+\r
+               public static PolicyVersion Default {\r
+                       get { return _policy12; }\r
+               }\r
+\r
+               public static PolicyVersion Policy12 {\r
+                       get { return _policy12; }\r
+               }\r
+\r
+               public static PolicyVersion Policy15 {\r
+                       get { return _policy15; }\r
+               }\r
+\r
+               public string Namespace {\r
+                       get { return _namespace; }\r
+               }\r
+\r
+               public override string ToString () {\r
+                       return Namespace;\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceAuthorizationBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceAuthorizationBehavior.cs
new file mode 100644 (file)
index 0000000..6108a34
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// ServiceAuthorizationBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.IdentityModel.Policy;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+using System.Web.Security;
+
+namespace System.ServiceModel.Description
+{
+       public sealed class ServiceAuthorizationBehavior : IServiceBehavior
+       {
+               bool impersonate;
+               PrincipalPermissionMode perm_mode =
+                       PrincipalPermissionMode.UseWindowsGroups; // funky default value
+               RoleProvider role_provider;
+               ServiceAuthorizationManager svc_auth_manager;
+               ReadOnlyCollection<IAuthorizationPolicy> ext_auth_policies;
+
+               public ServiceAuthorizationBehavior ()
+               {
+               }
+
+               public ReadOnlyCollection<IAuthorizationPolicy> ExternalAuthorizationPolicies {
+                       get { return ext_auth_policies; }
+                       set { ext_auth_policies = value; }
+               }
+
+               public bool ImpersonateCallerForAllOperations {
+                       get { return impersonate; }
+                       set { impersonate = value; }
+               }
+
+               public PrincipalPermissionMode PrincipalPermissionMode {
+                       get { return perm_mode; }
+                       set { perm_mode = value; }
+               }
+
+               public RoleProvider RoleProvider {
+                       get { return role_provider; }
+                       set { role_provider = value; }
+               }
+
+               public ServiceAuthorizationManager ServiceAuthorizationManager {
+                       get { return svc_auth_manager; }
+                       set { svc_auth_manager = value; }
+               }
+
+               void IServiceBehavior.AddBindingParameters (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase,
+                       Collection<ServiceEndpoint> endpoints,
+                       BindingParameterCollection parameters)
+               {
+               }
+
+               void IServiceBehavior.ApplyDispatchBehavior (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+               }
+
+               [MonoTODO]
+               void IServiceBehavior.Validate (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {                       
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceContractGenerationContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceContractGenerationContext.cs
new file mode 100644 (file)
index 0000000..18d8350
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// ServiceContractGenerationContext.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.CodeDom;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Configuration;
+using System.Web.Services.Description;
+
+namespace System.ServiceModel.Description
+{
+       public class ServiceContractGenerationContext
+       {
+               public ServiceContractGenerationContext (
+                       ServiceContractGenerator serviceContractGenerator,
+                       ContractDescription contract,
+                       CodeTypeDeclaration contractType)
+                       : this (serviceContractGenerator, contract, contractType, null)
+               {
+               }
+
+               public ServiceContractGenerationContext (
+                       ServiceContractGenerator serviceContractGenerator,
+                       ContractDescription contract,
+                       CodeTypeDeclaration contractType,
+                       CodeTypeDeclaration duplexCallbackType)
+               {
+                       generator = serviceContractGenerator;
+                       this.contract = contract;
+                       contract_type = contractType;
+                       duplex_callback_type = duplexCallbackType;
+               }
+
+               ServiceContractGenerator generator;
+               ContractDescription contract;
+               CodeTypeDeclaration contract_type;
+               CodeTypeDeclaration duplex_callback_type;
+               Collection<OperationContractGenerationContext> operations
+                       = new Collection<OperationContractGenerationContext> ();
+
+               public ServiceContractGenerator ServiceContractGenerator {
+                       get { return generator; }
+               }
+
+               public ContractDescription Contract {
+                       get { return contract; }
+               }
+
+               public CodeTypeDeclaration ContractType {
+                       get { return contract_type; }
+               }
+
+               public CodeTypeDeclaration DuplexCallbackType {
+                       get { return duplex_callback_type; }
+               }
+
+               public Collection<OperationContractGenerationContext> Operations {
+                       get { return operations; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceContractGenerator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceContractGenerator.cs
new file mode 100644 (file)
index 0000000..a2dbf19
--- /dev/null
@@ -0,0 +1,520 @@
+//
+// ServiceContractGenerator.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.CodeDom;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Configuration;
+using System.Reflection;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+using ConfigurationType = System.Configuration.Configuration;
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.ServiceModel.Description
+{
+       public class ServiceContractGenerator
+       {
+               CodeCompileUnit ccu;
+               ConfigurationType config;
+               Collection<MetadataConversionError> errors
+                       = new Collection<MetadataConversionError> ();
+               Dictionary<string,string> nsmappings
+                       = new Dictionary<string,string> ();
+               Dictionary<ContractDescription,Type> referenced_types
+                       = new Dictionary<ContractDescription,Type> ();
+               ServiceContractGenerationOptions options;
+               Dictionary<QName, QName> imported_names = null;
+
+               public ServiceContractGenerator ()
+                       : this (null, null)
+               {
+               }
+
+               public ServiceContractGenerator (CodeCompileUnit ccu)
+                       : this (ccu, null)
+               {
+               }
+
+               public ServiceContractGenerator (ConfigurationType config)
+                       : this (null, config)
+               {
+               }
+
+               public ServiceContractGenerator (CodeCompileUnit ccu, ConfigurationType config)
+               {
+                       if (ccu == null)
+                               this.ccu = new CodeCompileUnit ();
+                       else
+                               this.ccu = ccu;
+                       this.config = config;
+                       Options |= ServiceContractGenerationOptions.ChannelInterface | 
+                               ServiceContractGenerationOptions.ClientClass;
+               }
+
+               public ConfigurationType Configuration {
+                       get { return config; }
+               }
+
+               public Collection<MetadataConversionError> Errors {
+                       get { return errors; }
+               }
+
+               public Dictionary<string,string> NamespaceMappings {
+                       get { return nsmappings; }
+               }
+
+               public ServiceContractGenerationOptions Options {
+                       get { return options; }
+                       set { options = value; }
+               }
+
+               public Dictionary<ContractDescription,Type> ReferencedTypes {
+                       get { return referenced_types; }
+               }
+
+               public CodeCompileUnit TargetCompileUnit {
+                       get { return ccu; }
+               }
+
+               [MonoTODO]
+               public void GenerateBinding (Binding binding,
+                       out string bindingSectionName,
+                       out string configurationName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               #region Service Contract Type
+
+               // Those implementation classes are very likely to be split
+               // into different classes.
+
+               [MonoTODO]
+               public CodeTypeReference GenerateServiceContractType (
+                       ContractDescription contractDescription)
+               {
+                       CodeNamespace cns = GetNamespace (contractDescription.Namespace);
+                       imported_names = new Dictionary<QName, QName> ();
+                       try {
+                               return ExportInterface (contractDescription, cns);
+                       } finally {
+                               if ((Options & ServiceContractGenerationOptions.ClientClass) != 0)
+                                       GenerateProxyClass (contractDescription, cns);
+
+                               if ((Options & ServiceContractGenerationOptions.ChannelInterface) != 0)
+                                       GenerateChannelInterface (contractDescription, cns);
+                       }
+               }
+
+               CodeNamespace GetNamespace (string ns)
+               {
+                       if (ns == null)
+                               ns = String.Empty;
+                       foreach (CodeNamespace cns in ccu.Namespaces)
+                               if (cns.Name == ns)
+                                       return cns;
+                       CodeNamespace ncns = new CodeNamespace ();
+                       //ncns.Name = ns;
+                       ccu.Namespaces.Add (ncns);
+                       return ncns;
+               }
+
+               CodeTypeDeclaration GetTypeDeclaration (CodeNamespace cns, string name)
+               {
+                       foreach (CodeTypeDeclaration type in cns.Types)
+                               if (type.Name == name)
+                                       return type;
+                       return null;
+               }
+
+               void GenerateProxyClass (ContractDescription cd, CodeNamespace cns)
+               {
+                       string name = cd.Name + "Client";
+                       if (name [0] == 'I')
+                               name = name.Substring (1);
+                       CodeTypeDeclaration type = GetTypeDeclaration (cns, name);
+                       if (type != null)
+                               return; // already imported
+                       CodeTypeReference clientBase = new CodeTypeReference (typeof (ClientBase<int>).GetGenericTypeDefinition ());
+                       clientBase.TypeArguments.Add (new CodeTypeReference (cd.Name));
+                       type = new CodeTypeDeclaration (name);
+                       cns.Types.Add (type);
+                       type.TypeAttributes = TypeAttributes.Public;
+                       type.BaseTypes.Add (clientBase);
+                       type.BaseTypes.Add (new CodeTypeReference (cd.Name));
+
+                       // .ctor()
+                       CodeConstructor ctor = new CodeConstructor ();
+                       ctor.Attributes = MemberAttributes.Public;
+                       type.Members.Add (ctor);
+
+                       // .ctor(string endpointConfigurationName)
+                       ctor = new CodeConstructor ();
+                       ctor.Attributes = MemberAttributes.Public;
+                       ctor.Parameters.Add (
+                               new CodeParameterDeclarationExpression (
+                                       new CodeTypeReference (typeof (string)), "endpointConfigurationName"));
+                       ctor.BaseConstructorArgs.Add (
+                               new CodeArgumentReferenceExpression ("endpointConfigurationName"));
+                       type.Members.Add (ctor);
+
+                       // .ctor(string endpointConfigurationName, string remoteAddress)
+                       ctor = new CodeConstructor ();
+                       ctor.Attributes = MemberAttributes.Public;
+                       ctor.Parameters.Add (
+                               new CodeParameterDeclarationExpression (
+                                       new CodeTypeReference (typeof (string)), "endpointConfigurationName"));
+                       ctor.Parameters.Add (
+                               new CodeParameterDeclarationExpression (
+                                       new CodeTypeReference (typeof (string)), "remoteAddress"));
+                       ctor.BaseConstructorArgs.Add (
+                               new CodeArgumentReferenceExpression ("endpointConfigurationName"));
+                       ctor.BaseConstructorArgs.Add (
+                               new CodeArgumentReferenceExpression ("remoteAddress"));
+                       type.Members.Add (ctor);
+
+                       // .ctor(string endpointConfigurationName, EndpointAddress remoteAddress)
+                       ctor = new CodeConstructor ();
+                       ctor.Attributes = MemberAttributes.Public;
+                       ctor.Parameters.Add (
+                               new CodeParameterDeclarationExpression (
+                                       new CodeTypeReference (typeof (string)), "endpointConfigurationName"));
+                       ctor.Parameters.Add (
+                               new CodeParameterDeclarationExpression (
+                                       new CodeTypeReference (typeof (EndpointAddress)), "remoteAddress"));
+                       ctor.BaseConstructorArgs.Add (
+                               new CodeArgumentReferenceExpression ("endpointConfigurationName"));
+                       ctor.BaseConstructorArgs.Add (
+                               new CodeArgumentReferenceExpression ("remoteAddress"));
+                       type.Members.Add (ctor);
+
+                       // .ctor(Binding,EndpointAddress)
+                       ctor = new CodeConstructor ();
+                       ctor.Attributes = MemberAttributes.Public;
+                       ctor.Parameters.Add (
+                               new CodeParameterDeclarationExpression (
+                                       new CodeTypeReference (typeof (Binding)), "binding"));
+                       ctor.Parameters.Add (
+                               new CodeParameterDeclarationExpression (
+                                       new CodeTypeReference (typeof (EndpointAddress)), "endpoint"));
+                       ctor.BaseConstructorArgs.Add (
+                               new CodeArgumentReferenceExpression ("binding"));
+                       ctor.BaseConstructorArgs.Add (
+                               new CodeArgumentReferenceExpression ("endpoint"));
+                       type.Members.Add (ctor);
+
+                       // service contract methods
+                       AddImplementationMethods (type, cd);
+               }
+
+               void GenerateChannelInterface (ContractDescription cd, CodeNamespace cns)
+               {
+                       string name = cd.Name + "Channel";
+                       CodeTypeDeclaration type = GetTypeDeclaration (cns, name);
+                       if (type != null)
+                               return;
+
+                       type = new CodeTypeDeclaration ();
+                       type.Name = name;
+                       type.TypeAttributes = TypeAttributes.Interface | TypeAttributes.Public;
+                       cns.Types.Add (type);
+                       
+                       type.BaseTypes.Add (ExportInterface (cd, cns));
+                       type.BaseTypes.Add (new CodeTypeReference (typeof (System.ServiceModel.IClientChannel)));
+               }
+
+               CodeTypeReference ExportInterface (ContractDescription cd, CodeNamespace cns)
+               {
+                       CodeTypeDeclaration type = GetTypeDeclaration (cns, cd.Name);
+                       if (type != null)
+                               return new CodeTypeReference (type.Name);
+                       type = new CodeTypeDeclaration ();
+                       type.TypeAttributes = TypeAttributes.Interface;
+                       type.TypeAttributes |= TypeAttributes.Public;
+                       cns.Types.Add (type);
+                       type.Name = cd.Name;
+                       CodeAttributeDeclaration ad = 
+                               new CodeAttributeDeclaration (
+                                       new CodeTypeReference (
+                                               typeof (ServiceContractAttribute)));
+                       ad.Arguments.Add (new CodeAttributeArgument ("Namespace", new CodePrimitiveExpression (cd.Namespace)));
+                       type.CustomAttributes.Add (ad);
+                       AddOperationMethods (type, cd);
+
+                       return new CodeTypeReference (type.Name);
+               }
+
+               void AddOperationMethods (CodeTypeDeclaration type, ContractDescription cd)
+               {
+                       foreach (OperationDescription od in cd.Operations) {
+                               CodeMemberMethod cm = new CodeMemberMethod ();
+                               type.Members.Add (cm);
+                               cm.Name = od.Name;
+
+                               if (od.SyncMethod != null) {
+                                       ExportParameters (cm, od.SyncMethod.GetParameters ());
+                                       cm.ReturnType = new CodeTypeReference (od.SyncMethod.ReturnType);
+                               } else {
+                                       ExportMessages (od.Messages, cm, false);
+                               }
+
+                               // [OperationContract (Action = "...", ReplyAction = "..")]
+                               CodeAttributeDeclaration ad =
+                                       new CodeAttributeDeclaration (
+                                               new CodeTypeReference (
+                                                       typeof (OperationContractAttribute)));
+                               foreach (MessageDescription md in od.Messages) {
+                                       if (md.Direction == MessageDirection.Input)
+                                               ad.Arguments.Add (new CodeAttributeArgument ("Action", new CodePrimitiveExpression (md.Action)));
+                                       else
+                                               ad.Arguments.Add (new CodeAttributeArgument ("ReplyAction", new CodePrimitiveExpression (md.Action)));
+                               }
+                               cm.CustomAttributes.Add (ad);
+                       }
+               }
+
+               void ExportParameters (CodeMemberMethod method, ParameterInfo [] parameters)
+               {
+                       foreach (ParameterInfo pi in parameters)
+                               method.Parameters.Add (
+                                       new CodeParameterDeclarationExpression (
+                                               new CodeTypeReference (pi.ParameterType),
+                                               pi.Name));
+               }
+
+               void AddImplementationMethods (CodeTypeDeclaration type, ContractDescription cd)
+               {
+                       foreach (OperationDescription od in cd.Operations) {
+                               CodeMemberMethod cm = new CodeMemberMethod ();
+                               type.Members.Add (cm);
+                               cm.Name = od.Name;
+                               cm.Attributes = MemberAttributes.Public 
+                                               | MemberAttributes.Final;
+
+                               CodeExpression [] args = null;
+                               if (od.SyncMethod != null) {
+                                       ParameterInfo [] pars = od.SyncMethod.GetParameters ();
+                                       ExportParameters (cm, pars);
+                                       cm.ReturnType = new CodeTypeReference (od.SyncMethod.ReturnType);
+
+                                       args = new CodeExpression [pars.Length];
+                                       int i = 0;
+                                       foreach (ParameterInfo pi in pars)
+                                               args [i ++] = new CodeArgumentReferenceExpression (pi.Name);
+                               } else {
+                                       args = ExportMessages (od.Messages, cm, true);
+                               }
+
+                               CodeExpression call = new CodeMethodInvokeExpression (
+                                       new CodePropertyReferenceExpression (
+                                               new CodeBaseReferenceExpression (),
+                                               "Channel"),
+                                       cm.Name,
+                                       args);
+
+                               if (cm.ReturnType.BaseType == "System.Void")
+                                       cm.Statements.Add (new CodeExpressionStatement (call));
+                               else
+                                       cm.Statements.Add (new CodeMethodReturnStatement (call));
+                       }
+               }
+
+               private CodeExpression[] ExportMessages (MessageDescriptionCollection messages, CodeMemberMethod method, bool return_args)
+               {
+                       CodeExpression [] args = null;
+                       foreach (MessageDescription md in messages) {
+                               if (md.Direction == MessageDirection.Output) {
+                                       if (md.Body.ReturnValue != null) {
+                                               ExportDataContract (md.Body.ReturnValue.XmlTypeMapping);        
+                                               method.ReturnType = new CodeTypeReference (md.Body.ReturnValue.TypeName.Name);
+                                       }
+                                       continue;
+                               }
+
+                               if (return_args)
+                                       args = new CodeExpression [md.Body.Parts.Count];
+
+                               MessagePartDescriptionCollection parts = md.Body.Parts;
+                               for (int i = 0; i < parts.Count; i++) {
+                                       ExportDataContract (parts [i].XmlTypeMapping);  
+
+                                       method.Parameters.Add (
+                                               new CodeParameterDeclarationExpression (
+                                                       new CodeTypeReference (parts [i].TypeName.Name),
+                                                       parts [i].Name));
+
+                                       if (return_args)
+                                               args [i] = new CodeArgumentReferenceExpression (parts [i].Name);
+                               }
+                       }
+
+                       return args;
+               }
+
+               #endregion
+
+               [MonoTODO]
+               public CodeTypeReference GenerateServiceEndpoint (
+                       ServiceEndpoint endpoint,
+                       out ChannelEndpointElement channelElement)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               private void ExportDataContract (XmlTypeMapping mapping)
+               {
+                       if (mapping == null)
+                               return;
+
+                       QName qname = new QName (mapping.TypeName, mapping.Namespace);
+                       if (imported_names.ContainsKey (qname))
+                               return;
+
+                       CodeNamespace cns = new CodeNamespace ();
+
+                       XmlCodeExporter xce = new XmlCodeExporter (cns);
+                       xce.ExportTypeMapping (mapping);
+
+                       List <CodeTypeDeclaration> to_remove = new List <CodeTypeDeclaration> ();
+                       
+                       //Process the types just generated
+                       //FIXME: Iterate and assign the types to correct namespaces
+                       //At the end, add all those namespaces to the ccu
+                       foreach (CodeTypeDeclaration type in cns.Types) {
+                               string ns = GetXmlNamespace (type);
+                               if (ns == null)
+                                       //FIXME: do what here?
+                                       continue;
+
+                               QName type_name = new QName (type.Name, ns);
+                               if (imported_names.ContainsKey (type_name)) {
+                                       //Type got reemitted, so remove it!
+                                       to_remove.Add (type);
+                                       continue;
+                               }
+
+                               imported_names [type_name] = type_name;
+
+                               type.Comments.Clear ();
+                               //Custom Attributes
+                               type.CustomAttributes.Clear ();
+
+                               if (type.IsEnum)
+                                       continue;
+       
+                               type.CustomAttributes.Add (
+                                       new CodeAttributeDeclaration (
+                                               new CodeTypeReference ("System.CodeDom.Compiler.GeneratedCodeAttribute"),
+                                               new CodeAttributeArgument (new CodePrimitiveExpression ("System.Runtime.Serialization")),
+                                               new CodeAttributeArgument (new CodePrimitiveExpression ("3.0.0.0"))));
+                       
+                               type.CustomAttributes.Add (
+                                       new CodeAttributeDeclaration (
+                                               new CodeTypeReference ("System.Runtime.Serialization.DataContractAttribute")));
+
+                               //BaseType and interface
+                               type.BaseTypes.Add (new CodeTypeReference (typeof (object)));
+                               type.BaseTypes.Add (new CodeTypeReference ("System.Runtime.Serialization.IExtensibleDataObject"));
+
+                               foreach (CodeTypeMember mbr in type.Members) {
+                                       CodeMemberProperty p = mbr as CodeMemberProperty;
+                                       if (p == null)
+                                               continue;
+
+                                       if ((p.Attributes & MemberAttributes.Public) == MemberAttributes.Public) {
+                                               //FIXME: Clear all attributes or only XmlElementAttribute?
+                                               p.CustomAttributes.Clear ();
+                                               p.CustomAttributes.Add (new CodeAttributeDeclaration (
+                                                       new CodeTypeReference ("System.Runtime.Serialization.DataMemberAttribute")));
+
+                                               p.Comments.Clear ();
+                                       }
+                               }
+
+                               //Fields
+                               CodeMemberField field = new CodeMemberField (
+                                       new CodeTypeReference ("System.Runtime.Serialization.ExtensionDataObject"),
+                                       "extensionDataField");
+                               field.Attributes = MemberAttributes.Private | MemberAttributes.Final;
+                               type.Members.Add (field);
+
+                               //Property 
+                               CodeMemberProperty prop = new CodeMemberProperty ();
+                               prop.Type = new CodeTypeReference ("System.Runtime.Serialization.ExtensionDataObject");
+                               prop.Name = "ExtensionData";
+                               prop.Attributes = MemberAttributes.Public | MemberAttributes.Final;
+
+                               //Get
+                               prop.GetStatements.Add (new CodeMethodReturnStatement (
+                                       new CodeFieldReferenceExpression (
+                                       new CodeThisReferenceExpression (),
+                                       "extensionDataField")));
+
+                               //Set
+                               prop.SetStatements.Add (new CodeAssignStatement (
+                                       new CodeFieldReferenceExpression (
+                                       new CodeThisReferenceExpression (),
+                                       "extensionDataField"),
+                                       new CodePropertySetValueReferenceExpression ()));
+
+                               type.Members.Add (prop);
+                       }
+
+                       foreach (CodeTypeDeclaration type in to_remove)
+                               cns.Types.Remove (type);
+
+                       ccu.Namespaces.Add (cns);
+               }
+               
+               private string GetXmlNamespace (CodeTypeDeclaration type)
+               {
+                       foreach (CodeAttributeDeclaration attr in type.CustomAttributes) {
+                               if (attr.Name == "System.Xml.Serialization.XmlTypeAttribute" ||
+                                       attr.Name == "System.Xml.Serialization.XmlRootAttribute") {
+
+                                       foreach (CodeAttributeArgument arg in attr.Arguments)
+                                               if (arg.Name == "Namespace")
+                                                       return ((CodePrimitiveExpression)arg.Value).Value as string;
+
+                                       //Could not find Namespace arg!
+                                       return null;    
+                               }
+                       }
+                       
+                       return null;
+               }
+
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceCredentials.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceCredentials.cs
new file mode 100644 (file)
index 0000000..81c76c8
--- /dev/null
@@ -0,0 +1,137 @@
+//
+// ServiceCredentials.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public class ServiceCredentials
+               : SecurityCredentialsManager, IServiceBehavior
+       {
+               public ServiceCredentials ()
+               {
+               }
+
+               [MonoTODO]
+               protected ServiceCredentials (ServiceCredentials other)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               X509CertificateInitiatorServiceCredential initiator
+                       = new X509CertificateInitiatorServiceCredential ();
+               PeerCredential peer = new PeerCredential ();
+               X509CertificateRecipientServiceCredential recipient
+                       = new X509CertificateRecipientServiceCredential ();
+               UserNamePasswordServiceCredential userpass
+                       = new UserNamePasswordServiceCredential ();
+               WindowsServiceCredential windows
+                       = new WindowsServiceCredential ();
+               IssuedTokenServiceCredential issued_token =
+                       new IssuedTokenServiceCredential ();
+               SecureConversationServiceCredential secure_conversation =
+                       new SecureConversationServiceCredential ();
+
+               public X509CertificateInitiatorServiceCredential 
+                       ClientCertificate {
+                       get { return initiator; }
+               }
+
+               public IssuedTokenServiceCredential IssuedTokenAuthentication {
+                       get { return issued_token; }
+               }
+
+               public PeerCredential Peer {
+                       get { return peer; }
+               }
+
+               public SecureConversationServiceCredential SecureConversationAuthentication {
+                       get { return secure_conversation; }
+               }
+
+               public X509CertificateRecipientServiceCredential 
+                       ServiceCertificate {
+                       get { return recipient; }
+               }
+
+               public UserNamePasswordServiceCredential UserNameAuthentication {
+                       get { return userpass; }
+               }
+
+               public WindowsServiceCredential WindowsAuthentication {
+                       get { return windows; }
+               }
+
+               public ServiceCredentials Clone ()
+               {
+                       ServiceCredentials ret = CloneCore ();
+                       if (ret.GetType () != GetType ())
+                               throw new NotImplementedException ("CloneCore() must be implemented to return an instance of the same type in this custom ServiceCredentials type.");
+                       return ret;
+               }
+
+               protected virtual ServiceCredentials CloneCore ()
+               {
+                       return new ServiceCredentials (this);
+               }
+
+               public override SecurityTokenManager CreateSecurityTokenManager ()
+               {
+                       return new ServiceCredentialsSecurityTokenManager (this);
+               }
+
+               void IServiceBehavior.AddBindingParameters (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase,
+                       Collection<ServiceEndpoint> endpoints,
+                       BindingParameterCollection parameters)
+               {
+                       parameters.Add (this);
+               }
+
+               void IServiceBehavior.ApplyDispatchBehavior (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       // do nothing
+               }
+
+               void IServiceBehavior.Validate (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceDebugBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceDebugBehavior.cs
new file mode 100644 (file)
index 0000000..86aaecc
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// ServiceDebugBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public class ServiceDebugBehavior : IServiceBehavior
+       {
+               bool inc_details;
+               bool http_help_enabled = true;
+               bool https_help_enabled = true;
+               Uri http_help_url, https_help_url;
+
+               public ServiceDebugBehavior ()
+               {
+               }
+
+               public bool IncludeExceptionDetailInFaults {
+                       get { return inc_details; }
+                       set { inc_details = value; }
+               }
+
+               public bool HttpHelpPageEnabled {
+                       get { return http_help_enabled; }
+                       set { http_help_enabled = value; }
+               }
+
+               public Uri HttpHelpPageUrl {
+                       get { return http_help_url; }
+                       set { http_help_url = value; }
+               }
+
+               public bool HttpsHelpPageEnabled {
+                       get { return https_help_enabled; }
+                       set { https_help_enabled = value; }
+               }
+
+               public Uri HttpsHelpPageUrl {
+                       get { return https_help_url; }
+                       set { https_help_url = value; }
+               }
+
+               void IServiceBehavior.AddBindingParameters (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase,
+                       Collection<ServiceEndpoint> endpoints,
+                       BindingParameterCollection parameters)
+               {
+                       // do nothing
+               }
+
+               void IServiceBehavior.ApplyDispatchBehavior (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       ServiceMetadataExtension sme = ServiceMetadataExtension.EnsureServiceMetadataExtension (description, serviceHostBase);
+
+                       foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers)
+                               if (IncludeExceptionDetailInFaults) // may be set also in ServiceBehaviorAttribute
+                                       dispatcher.IncludeExceptionDetailInFaults = true;
+
+                       if (HttpHelpPageEnabled) {
+                               Uri uri = serviceHostBase.CreateUri ("http", HttpHelpPageUrl);
+                               if (uri != null)
+                                       ServiceMetadataExtension.EnsureServiceMetadataHttpChanelDispatcher (description, serviceHostBase, sme, uri);
+                       }
+
+                       if (HttpsHelpPageEnabled) {
+                               Uri uri = serviceHostBase.CreateUri ("https", HttpsHelpPageUrl);
+                               if (uri != null)
+                                       ServiceMetadataExtension.EnsureServiceMetadataHttpsChanelDispatcher (description, serviceHostBase, sme, uri);
+                       }
+               }
+
+               [MonoTODO]
+               void IServiceBehavior.Validate (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceDescription.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceDescription.cs
new file mode 100644 (file)
index 0000000..67b42d1
--- /dev/null
@@ -0,0 +1,134 @@
+//
+// ServiceDescription.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Description
+{
+       public class ServiceDescription
+       {
+               ServiceEndpointCollection endpoints = new ServiceEndpointCollection ();
+               KeyedByTypeCollection<IServiceBehavior> behaviors = new KeyedByTypeCollection<IServiceBehavior> ();
+               Type service_type;
+               object well_known;
+               string name, ns, config_name;
+
+               public ServiceDescription ()
+               {
+               }
+
+               public ServiceDescription (IEnumerable<ServiceEndpoint> endpoints)
+               {
+                       foreach (ServiceEndpoint se in endpoints)
+                               this.endpoints.Add (se);
+               }
+
+               public string ConfigurationName {
+                       get { return config_name; }
+                       set { config_name = value; }
+               }
+
+               public KeyedByTypeCollection<IServiceBehavior> Behaviors {
+                       get { return behaviors; }
+               }
+
+               public ServiceEndpointCollection Endpoints {
+                       get { return endpoints; }
+               }
+
+               public string Name {
+                       get { return name; }
+                       set { name = value; }
+               }
+
+               public string Namespace {
+                       get { return ns; }
+                       set { ns = value; }
+               }
+
+               public Type ServiceType {
+                       get { return service_type; }
+                       set { service_type = value; }
+               }
+
+               public static ServiceDescription GetService (Type type)
+               {
+                       // null Type is not rejected
+                       ServiceDescription sd = new ServiceDescription ();
+                       sd.ServiceType = type;
+                       return sd;
+               }
+
+               public static ServiceDescription GetService (object wellKnown)
+               {
+                       // null instance is not rejected
+                       ServiceDescription sd = new ServiceDescription ();
+                       sd.ServiceType = wellKnown != null ? wellKnown.GetType () : null;
+                       return sd;
+               }
+
+/*
+               internal ServiceEndpoint AddServiceEndpoint (Type contractType,
+                       Binding binding)
+               {
+                       return AddServiceEndpoint (contractType, binding, null);
+               }
+
+               internal ServiceEndpoint AddServiceEndpoint (
+                       Type contractType, Binding binding,
+                       EndpointAddress address)
+               {
+                       foreach (ServiceEndpoint i in Endpoints)
+                               if (i.Address.Equals (address) &&
+                                   i.Binding.Equals (binding) &&
+                                   i.Contract.ContractType == contractType)
+                                       return i;
+
+                       ContractDescription cd;
+                       if (!contracts.Contains (contractType)) {
+                               cd = ContractDescription.GetContract (contractType);
+                               contracts.Add (contractType,
+                                       cd);
+                       }
+                       else
+                               cd = contracts [contractType];
+
+                       ServiceEndpoint se = new ServiceEndpoint (
+                               cd, binding, address);
+
+                       Endpoints.Add (se);
+
+                       return se;
+               }
+*/
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpoint.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpoint.cs
new file mode 100644 (file)
index 0000000..3342c62
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// ServiceEndpoint.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Channels;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Description
+{
+       public class ServiceEndpoint
+       {
+               ContractDescription contract;
+               Binding binding;
+               EndpointAddress address;
+               KeyedByTypeCollection<IEndpointBehavior> behaviors;
+               Uri listen_uri;
+               ListenUriMode listen_mode;
+               string name;
+
+               public ServiceEndpoint (ContractDescription contract)
+                       : this (contract, null, null)
+               {
+               }
+
+               public ServiceEndpoint(ContractDescription contract,
+                       Binding binding, EndpointAddress address)
+               {
+                       if (contract == null)
+                               throw new ArgumentNullException ("contract");
+
+                       this.contract = contract;
+                       this.binding = binding;
+                       this.address = address;
+                       behaviors = new KeyedByTypeCollection<IEndpointBehavior> ();
+               }
+
+               public KeyedByTypeCollection<IEndpointBehavior> Behaviors {
+                       get { return behaviors; }
+               }
+
+               public ContractDescription Contract {
+                       get { return contract; }
+               }
+
+               public EndpointAddress Address {
+                       get { return address; }
+                       set { address = value; }
+               }
+
+               public Binding Binding {
+                       get { return binding; }
+                       set { binding = value; }
+               }
+
+               public Uri ListenUri {
+                       get { return listen_uri; }
+                       set { listen_uri = value; }
+               }
+
+               public ListenUriMode ListenUriMode {
+                       get { return listen_mode; }
+                       set { listen_mode = value; }
+               }
+
+               public string Name {
+                       get {
+                               if (name == null)
+                                       name = Binding.Name + "_" + Contract.Name;
+                               return name;
+                       }
+                       set { name = value; }
+               }
+
+               internal void Validate () {
+                       foreach (IContractBehavior b in Contract.Behaviors)
+                               b.Validate (Contract, this);
+                       foreach (IEndpointBehavior b in Behaviors)
+                               b.Validate (this);
+                       foreach (OperationDescription operation in Contract.Operations) {
+                               foreach (IOperationBehavior b in operation.Behaviors)
+                                       b.Validate (operation);
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpointCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceEndpointCollection.cs
new file mode 100644 (file)
index 0000000..58d0024
--- /dev/null
@@ -0,0 +1,126 @@
+//
+// ServiceEndpointCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       public class ServiceEndpointCollection : Collection<ServiceEndpoint>
+       {
+               internal ServiceEndpointCollection ()
+               {
+               }
+
+               public ServiceEndpoint Find (Type type)
+               {
+                       foreach (ServiceEndpoint e in this)
+                               if (e.Contract.ContractType == type)
+                                       return e;
+                       return null;
+               }
+
+               public ServiceEndpoint Find (Uri uri)
+               {
+                       foreach (ServiceEndpoint e in this)
+                               if (e.Address.Uri == uri)
+                                       return e;
+                       return null;
+               }
+
+               public ServiceEndpoint Find (XmlQualifiedName name)
+               {
+                       foreach (ServiceEndpoint e in this)
+                               if (e.Contract.Name == name.Name &&
+                                       e.Contract.Namespace == name.Namespace)
+                                       return e;
+                       return null;
+               }
+
+               public ServiceEndpoint Find (XmlQualifiedName contractName,
+                       XmlQualifiedName bindingName)
+               {
+                       foreach (ServiceEndpoint e in this)
+                               if (e.Contract.Name == contractName.Name &&
+                                       e.Contract.Namespace == contractName.Namespace &&
+                                       e.Binding.Name == bindingName.Name &&
+                                       e.Binding.Namespace == bindingName.Namespace)
+                                       return e;
+                       return null;
+               }
+
+               public ServiceEndpoint Find (Type contractType,
+                       XmlQualifiedName bindingName)
+               {
+                       foreach (ServiceEndpoint e in this)
+                               if (e.Contract.ContractType == contractType &&
+                                       e.Binding.Name == bindingName.Name &&
+                                       e.Binding.Namespace == bindingName.Namespace)
+                                       return e;
+                       return null;
+               }
+
+               public Collection<ServiceEndpoint> FindAll (Type contractType)
+               {
+                       Collection<ServiceEndpoint> list =
+                               new Collection<ServiceEndpoint> ();
+                       foreach (ServiceEndpoint e in this)
+                               if (e.Contract.ContractType == contractType)
+                                       list.Add (e);
+                       return list;
+               }
+
+               public Collection<ServiceEndpoint> FindAll (XmlQualifiedName name)
+               {
+                       Collection<ServiceEndpoint> list =
+                               new Collection<ServiceEndpoint> ();
+                       foreach (ServiceEndpoint e in this)
+                               if (e.Contract.Name == name.Name &&
+                                   e.Contract.Namespace == name.Namespace)
+                                       list.Add (e);
+                       return list;
+               }
+
+               [MonoTODO]
+               protected override void InsertItem (int index, ServiceEndpoint item)
+               {
+                       if (Find (new XmlQualifiedName (item.Contract.Name, item.Contract.Namespace)) == null)
+                               base.InsertItem (index, item);
+               }
+
+               [MonoTODO]
+               protected override void SetItem (int index, ServiceEndpoint item)
+               {
+                       if (Find (new XmlQualifiedName (item.Contract.Name, item.Contract.Namespace)) == null)
+                               base.SetItem (index, item);
+                       else
+                               base.RemoveItem (index);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataBehavior.cs
new file mode 100644 (file)
index 0000000..36f8398
--- /dev/null
@@ -0,0 +1,130 @@
+//
+// ServiceMetadataBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Ankit Jain  <jankit@novell.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class ServiceMetadataBehavior : IServiceBehavior
+       {
+               public const string MexContractName = "IMetadataExchange";
+
+               bool enable_http, enable_https;
+               Uri http_url, https_url, location;
+               MetadataExporter exporter;
+
+               public ServiceMetadataBehavior ()
+               {
+               }
+
+               public bool HttpGetEnabled {
+                       get { return enable_http; }
+                       set { enable_http = value; }
+               }
+
+               public bool HttpsGetEnabled {
+                       get { return enable_https; }
+                       set { enable_https = value; }
+               }
+
+               public MetadataExporter MetadataExporter {
+                       get { return exporter ?? (exporter = new WsdlExporter ()); }
+                       set { exporter = value; }
+               }
+
+               public Uri ExternalMetadataLocation {
+                       get { return location; }
+                       set { location = value; }
+               }
+
+               public Uri HttpGetUrl {
+                       get { return http_url; }
+                       set { http_url = value; }
+               }
+
+               public Uri HttpsGetUrl {
+                       get { return https_url; }
+                       set { https_url = value; }
+               }
+
+               [MonoTODO]
+               void IServiceBehavior.AddBindingParameters (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase,
+                       Collection<ServiceEndpoint> endpoints,
+                       BindingParameterCollection parameters)
+               {
+               }
+
+               void IServiceBehavior.ApplyDispatchBehavior (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase) {
+
+                       ServiceMetadataExtension sme = ServiceMetadataExtension.EnsureServiceMetadataExtension (description, serviceHostBase);
+
+                       //Find ChannelDispatcher for Mex, and add a MexInstanceContextProvider
+                       //to it
+                       foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers) {
+                               ChannelDispatcher cd = cdb as ChannelDispatcher;
+                               if (cd == null)
+                                       continue;
+
+                               foreach (EndpointDispatcher ed in cd.Endpoints) {
+                                       if (ed.ContractName == MexContractName)
+                                               ed.DispatchRuntime.InstanceContextProvider = new MexInstanceContextProvider (serviceHostBase);
+                               }
+                       }
+
+                       if (HttpGetEnabled) {
+                               Uri uri = serviceHostBase.CreateUri ("http", HttpGetUrl);
+                               if (uri != null)
+                                       ServiceMetadataExtension.EnsureServiceMetadataHttpChanelDispatcher (description, serviceHostBase, sme, uri);
+                       }
+
+                       if (HttpsGetEnabled) {
+                               Uri uri = serviceHostBase.CreateUri ("https", HttpsGetUrl);
+                               if (uri != null)
+                                       ServiceMetadataExtension.EnsureServiceMetadataHttpsChanelDispatcher (description, serviceHostBase, sme, uri);
+                       }
+               }
+
+               [MonoTODO]
+               void IServiceBehavior.Validate (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {                       
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataExtension.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceMetadataExtension.cs
new file mode 100644 (file)
index 0000000..5dc8af1
--- /dev/null
@@ -0,0 +1,305 @@
+//
+// ServiceMetadataExtension.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Ankit Jain <jankit@novell.com>
+//     Gonzalo Paniagua Javier (gonzalo@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.IO;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+using System.Web;
+using System.Web.Services;
+using System.Web.Services.Description;
+using System.Xml;
+using System.Xml.Schema;
+
+using WSServiceDescription = System.Web.Services.Description.ServiceDescription;
+using WSMessage = System.Web.Services.Description.Message;
+using SMMessage = System.ServiceModel.Channels.Message;
+
+
+namespace System.ServiceModel.Description
+{
+       public class ServiceMetadataExtension : IExtension<ServiceHostBase>
+       {
+               const string ServiceMetadataBehaviorHttpGetBinding = "ServiceMetadataBehaviorHttpGetBinding";
+
+               MetadataSet metadata;
+               ServiceHostBase owner;
+               Dictionary<Uri, ChannelDispatcherBase> _serviceMetadataChanelDispatchers;
+               
+               [MonoTODO]
+               public ServiceMetadataExtension ()
+               {
+               }
+
+               [MonoTODO]
+               public MetadataSet Metadata {
+                       get {
+                               if (metadata == null) {
+                                       MetadataExporter exporter = new WsdlExporter ();
+                                       foreach (ServiceEndpoint ep in owner.Description.Endpoints) {
+                                               if (ep.Contract.Name == ServiceMetadataBehavior.MexContractName)
+                                                       continue;
+
+                                               exporter.ExportEndpoint (ep);
+                                       }
+                                       metadata = exporter.GetGeneratedMetadata ();
+                               }
+                               return metadata;
+                       }
+               }
+
+               internal ServiceHostBase Owner {
+                       get { return owner; }
+               }
+
+               internal static ServiceMetadataExtension EnsureServiceMetadataExtension (ServiceDescription description, ServiceHostBase serviceHostBase) {
+                       ServiceMetadataExtension sme = serviceHostBase.Extensions.Find<ServiceMetadataExtension> ();
+                       if (sme == null) {
+                               sme = new ServiceMetadataExtension ();
+                               serviceHostBase.Extensions.Add (sme);
+                       }
+                       return sme;
+               }
+
+               internal static void EnsureServiceMetadataHttpChanelDispatcher (ServiceDescription description, ServiceHostBase serviceHostBase, ServiceMetadataExtension sme, Uri uri) {
+
+                       if (sme._serviceMetadataChanelDispatchers == null)
+                               sme._serviceMetadataChanelDispatchers = new Dictionary<Uri, ChannelDispatcherBase> ();
+                       else if (sme._serviceMetadataChanelDispatchers.ContainsKey (uri))
+                               return;
+
+                       CustomBinding cb = new CustomBinding (new BasicHttpBinding ())
+                       {
+                               Name = ServiceMetadataBehaviorHttpGetBinding,
+                       };
+                       cb.Elements.Find<MessageEncodingBindingElement> ().MessageVersion = MessageVersion.None;
+
+                       ServiceEndpoint se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IHttpGetHelpPageAndMetadataContract)), cb, new EndpointAddress (uri))
+                       {
+                               ListenUri = uri,
+                       };
+
+                       ChannelDispatcher channelDispatcher = serviceHostBase.BuildChannelDispatcher (se, new BindingParameterCollection ());
+
+                       channelDispatcher.Endpoints [0].DispatchRuntime.InstanceContextProvider = new SingletonInstanceContextProvider (new InstanceContext (serviceHostBase, new HttpGetWsdl (sme, uri)));
+
+                       sme._serviceMetadataChanelDispatchers.Add (uri, channelDispatcher);
+                       serviceHostBase.ChannelDispatchers.Add (channelDispatcher);
+               }
+
+               internal static void EnsureServiceMetadataHttpsChanelDispatcher (ServiceDescription description, ServiceHostBase serviceHostBase, ServiceMetadataExtension sme, Uri uri) {
+                       throw new NotImplementedException ();
+               }
+
+               void IExtension<ServiceHostBase>.Attach (ServiceHostBase owner)
+               {
+                       this.owner = owner;
+               }
+
+               [MonoTODO]
+               void IExtension<ServiceHostBase>.Detach (ServiceHostBase owner)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
+       [ServiceContract (Namespace = "http://schemas.microsoft.com/2006/04/http/metadata")]
+       interface IHttpGetHelpPageAndMetadataContract
+       {
+               [OperationContract (Action = "*", ReplyAction = "*")]
+               SMMessage Get (SMMessage req);
+       }
+
+       class HttpGetWsdl : IHttpGetHelpPageAndMetadataContract
+       {
+               ServiceMetadataExtension metadata_extn;
+               Uri base_uri;
+
+               Dictionary <string,WSServiceDescription> wsdl_documents = 
+                       new Dictionary<string, WSServiceDescription> ();
+               Dictionary <string, XmlSchema> schemas = 
+                       new Dictionary<string, XmlSchema> ();
+
+               public HttpGetWsdl (ServiceMetadataExtension metadata_extn, Uri base_uri)
+               {
+                       this.metadata_extn = metadata_extn;
+                       this.base_uri = base_uri;
+                       GetMetadata (metadata_extn.Owner);
+               }
+               
+               public SMMessage Get (SMMessage req)
+               {
+                       HttpRequestMessageProperty prop = (HttpRequestMessageProperty) req.Properties [HttpRequestMessageProperty.Name];
+
+                       NameValueCollection query_string = CreateQueryString (prop.QueryString);
+                       if (query_string == null || query_string.AllKeys.Length != 1)
+                               return CreateHelpPage (req);
+
+                       if (query_string [null] == "wsdl") {
+                               WSServiceDescription wsdl = GetWsdl ("wsdl");
+                               if (wsdl != null)
+                                       return CreateWsdlMessage (wsdl);
+                       } else if (query_string ["wsdl"] != null) {
+                               WSServiceDescription wsdl = GetWsdl (query_string ["wsdl"]);
+                               if (wsdl != null)
+                                       return CreateWsdlMessage (wsdl);
+                       } else if (query_string ["xsd"] != null) {
+                               XmlSchema schema = GetXmlSchema (query_string ["xsd"]);
+                               if (schema != null) {
+                                       //FIXME: Is this the correct way?
+                                       MemoryStream ms = new MemoryStream ();
+
+                                       schema.Write (ms);
+                                       ms.Seek (0, SeekOrigin.Begin);
+                                       SMMessage ret = SMMessage.CreateMessage (MessageVersion.None, "", XmlReader.Create (ms));
+
+                                       return ret;
+                               }
+                       }
+
+                       return CreateHelpPage (req);
+               }
+
+               /* Code from HttpListenerRequest */
+               NameValueCollection CreateQueryString (string query)
+               {
+                       NameValueCollection query_string = new NameValueCollection ();
+                       if (query == null || query.Length == 0)
+                               return null;
+
+                       string [] components = query.Split ('&');
+                       foreach (string kv in components) {
+                               int pos = kv.IndexOf ('=');
+                               if (pos == -1) {
+                                       query_string.Add (null, HttpUtility.UrlDecode (kv));
+                               } else {
+                                       string key = HttpUtility.UrlDecode (kv.Substring (0, pos));
+                                       string val = HttpUtility.UrlDecode (kv.Substring (pos + 1));
+
+                                       query_string.Add (key, val);
+                               }
+                       }
+
+                       return query_string;
+               }
+
+               SMMessage CreateHelpPage (SMMessage request)
+               {
+                       //FIXME Check for ServiceDebugBehavior.HttpHelpPage
+                       //else do what? Check
+                       throw new NotImplementedException ();
+               }
+
+               SMMessage CreateWsdlMessage (WSServiceDescription wsdl)
+               {
+                       MemoryStream ms = new MemoryStream ();
+                       XmlWriter xw = XmlWriter.Create (ms);
+
+                       WSServiceDescription.Serializer.Serialize (xw, wsdl);
+                       ms.Seek (0, SeekOrigin.Begin);
+                       return SMMessage.CreateMessage (MessageVersion.None, "", XmlReader.Create (ms));
+               }
+
+               void GetMetadata (ServiceHostBase host)
+               {
+                       MetadataSet metadata = metadata_extn.Metadata;
+                       int xs_i = 0, wsdl_i = 0;
+
+                       //Dictionary keyed by namespace
+                       StringDictionary wsdl_strings = new StringDictionary ();
+                       StringDictionary xsd_strings = new StringDictionary ();
+
+                       foreach (MetadataSection section in metadata.MetadataSections) {
+                               string key;
+
+                               XmlSchema xs = section.Metadata as XmlSchema;
+                               if (xs != null) {
+                                       key = String.Format ("xsd{0}", xs_i ++);
+                                       schemas [key] = xs;
+                                       xsd_strings [xs.TargetNamespace] = key;
+                                       continue;
+                               }
+
+                               WSServiceDescription wsdl = section.Metadata as WSServiceDescription;
+                               if (wsdl == null)
+                                       continue;
+
+                               //if (wsdl.TargetNamespace == "http://tempuri.org/")
+                               if (wsdl.Services.Count > 0)
+                                       key = "wsdl";
+                               else
+                                       key = String.Format ("wsdl{0}", wsdl_i ++);
+
+                               wsdl_documents [key] = wsdl;
+                               wsdl_strings [wsdl.TargetNamespace] = key;
+                       }
+                       
+                       string base_url = base_uri.ToString ();
+                       foreach (WSServiceDescription wsdl in wsdl_documents.Values) {
+                               foreach (Import import in wsdl.Imports) {
+                                       if (!String.IsNullOrEmpty (import.Location))
+                                               continue;
+
+                                       import.Location = String.Format ("{0}?wsdl={1}", base_url, wsdl_strings [import.Namespace]);
+                               }
+
+                               foreach (XmlSchema schema in wsdl.Types.Schemas) {
+                                       foreach (XmlSchemaObject obj in schema.Includes) {
+                                               XmlSchemaImport imp = obj as XmlSchemaImport;
+                                               if (imp == null || imp.SchemaLocation != null)
+                                                       continue;
+
+                                               imp.SchemaLocation = String.Format ("{0}?xsd={1}", base_url, xsd_strings [imp.Namespace]);
+                                       }
+                               }
+                       }
+
+               }
+               
+               WSServiceDescription GetWsdl (string which)
+               {
+                       WSServiceDescription wsdl;
+                       wsdl_documents.TryGetValue (which, out wsdl);
+                       return wsdl;
+               }
+               
+               XmlSchema GetXmlSchema (string which)
+               {
+                       XmlSchema schema;
+                       schemas.TryGetValue (which, out schema);
+                       return schema;
+               }
+
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceSecurityAuditBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceSecurityAuditBehavior.cs
new file mode 100644 (file)
index 0000000..04ce6a8
--- /dev/null
@@ -0,0 +1,85 @@
+//
+// ServiceSecurityAuditBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public sealed class ServiceSecurityAuditBehavior : IServiceBehavior
+       {
+               AuditLogLocation audit_log_loc;
+               bool suppress_failure;
+               AuditLevel msg_audit_level, svc_audit_level;
+
+               public AuditLogLocation AuditLogLocation {
+                       get { return audit_log_loc; }
+                       set { audit_log_loc = value; }
+               }
+
+               public AuditLevel MessageAuthenticationAuditLevel {
+                       get { return msg_audit_level; }
+                       set { msg_audit_level = value; }
+               }
+
+               public AuditLevel ServiceAuthorizationAuditLevel {
+                       get { return svc_audit_level; }
+                       set { svc_audit_level = value; }
+               }
+
+               public bool SuppressAuditFailure {
+                       get { return suppress_failure; }
+                       set { suppress_failure = value; }
+               }
+
+               void IServiceBehavior.AddBindingParameters (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase,
+                       Collection<ServiceEndpoint> endpoints,
+                       BindingParameterCollection parameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IServiceBehavior.ApplyDispatchBehavior (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IServiceBehavior.Validate (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceThrottlingBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceThrottlingBehavior.cs
new file mode 100644 (file)
index 0000000..e3357f8
--- /dev/null
@@ -0,0 +1,82 @@
+//
+// ServiceThrottlingBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       public class ServiceThrottlingBehavior : IServiceBehavior
+       {
+               public ServiceThrottlingBehavior ()
+               {
+               }
+
+               int max_calls, max_conn, max_instance;
+
+               public int MaxConcurrentCalls {
+                       get { return max_calls; }
+                       set { max_calls = value; }
+               }
+
+               public int MaxConnections {
+                       get { return max_conn; }
+                       set { max_conn = value; }
+               }
+
+               public int MaxInstances {
+                       get { return max_instance; }
+                       set { max_instance = value; }
+               }
+
+               void IServiceBehavior.AddBindingParameters (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase,
+                       Collection<ServiceEndpoint> endpoints,
+                       BindingParameterCollection parameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IServiceBehavior.ApplyDispatchBehavior (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IServiceBehavior.Validate (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceTimeoutsBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ServiceTimeoutsBehavior.cs
new file mode 100644 (file)
index 0000000..ea9be9d
--- /dev/null
@@ -0,0 +1,62 @@
+//\r
+// ServiceTimeoutsElement.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Description\r
+{\r
+       class ServiceTimeoutsBehavior : IServiceBehavior\r
+       {\r
+               public TimeSpan TransactionTimeout {\r
+                       get;\r
+                       set;\r
+               }\r
+\r
+               public ServiceTimeoutsBehavior (TimeSpan timeout) {\r
+                       TransactionTimeout = timeout;\r
+               }\r
+\r
+               #region IServiceBehavior Members\r
+\r
+               void IServiceBehavior.AddBindingParameters (ServiceDescription description, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection parameters) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               void IServiceBehavior.ApplyDispatchBehavior (ServiceDescription description, ServiceHostBase serviceHostBase) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               void IServiceBehavior.Validate (ServiceDescription description, ServiceHostBase serviceHostBase) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               #endregion\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/SynchronousReceiveBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/SynchronousReceiveBehavior.cs
new file mode 100644 (file)
index 0000000..710afde
--- /dev/null
@@ -0,0 +1,58 @@
+//\r
+// SynchronousReceiveBehavior.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Description\r
+{\r
+       [MonoTODO]\r
+       public class SynchronousReceiveBehavior : IEndpointBehavior\r
+       {\r
+               #region IEndpointBehavior Members\r
+\r
+               void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection parameters) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               void IEndpointBehavior.ApplyDispatchBehavior (ServiceEndpoint serviceEndpoint, System.ServiceModel.Dispatcher.EndpointDispatcher dispatcher) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               void IEndpointBehavior.ApplyClientBehavior (ServiceEndpoint serviceEndpoint, System.ServiceModel.Dispatcher.ClientRuntime behavior) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               void IEndpointBehavior.Validate (ServiceEndpoint serviceEndpoint) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               #endregion\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/TransactedBatchingBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/TransactedBatchingBehavior.cs
new file mode 100644 (file)
index 0000000..0a07e20
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// TransactedBatchingBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class TransactedBatchingBehavior : IEndpointBehavior
+       {
+               int max_batch_size;
+
+               public TransactedBatchingBehavior (int maxBatchSize)
+               {
+                       max_batch_size = maxBatchSize;
+               }
+
+               public int MaxBatchSize {
+                       get { return max_batch_size; }
+                       set { max_batch_size = value; }
+               }
+
+               void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint,
+                       BindingParameterCollection parameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IEndpointBehavior.ApplyDispatchBehavior (ServiceEndpoint serviceEndpoint,
+                       EndpointDispatcher dispatcher)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IEndpointBehavior.ApplyClientBehavior (ServiceEndpoint serviceEndpoint,
+                       ClientRuntime behavior)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IEndpointBehavior.Validate (ServiceEndpoint serviceEndpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/TypedMessageConverter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/TypedMessageConverter.cs
new file mode 100644 (file)
index 0000000..3285eb1
--- /dev/null
@@ -0,0 +1,144 @@
+//
+// TypedMessageConverter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+using System.Runtime.Serialization;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Description
+{
+       internal class DefaultTypedMessageConverter : TypedMessageConverter
+       {
+               IClientMessageFormatter formatter;
+
+               public DefaultTypedMessageConverter (IClientMessageFormatter formatter)
+               {
+                       this.formatter = formatter;
+               }
+
+               public override object FromMessage (Message message)
+               {
+                       return formatter.DeserializeReply (message, null);
+               }
+
+               public override Message ToMessage (object typedMessage)
+               {
+                       return ToMessage (typedMessage, MessageVersion.Default);
+               }
+
+               public override Message ToMessage (
+                       object typedMessage, MessageVersion version)
+               {
+                       return formatter.SerializeRequest (version, new object [] {typedMessage});
+               }
+       }
+
+       public abstract class TypedMessageConverter
+       {
+               internal const string TempUri = "http://tempuri.org/";
+
+               protected TypedMessageConverter ()
+               {
+               }
+
+               public static TypedMessageConverter Create (
+                       Type type, string action)
+               {
+                       return Create (type, action, TempUri);
+               }
+
+               public static TypedMessageConverter Create (
+                       Type type, string action,
+                       string defaultNamespace)
+               {
+                       return Create (type, action, defaultNamespace, (DataContractFormatAttribute)null);
+               }
+
+               public static TypedMessageConverter Create (
+                       Type type, string action,
+                       DataContractFormatAttribute formatterAttribute)
+               {
+                       return Create (type, action, TempUri, formatterAttribute);
+               }
+
+               public static TypedMessageConverter Create (
+                       Type type,
+                       string action, string defaultNamespace,
+                       DataContractFormatAttribute formatterAttribute)
+               {
+                       return new DefaultTypedMessageConverter (
+                               new DataContractMessagesFormatter (
+                                       MessageContractToMessagesDescription (type, defaultNamespace, action),
+                                       formatterAttribute));
+               }
+
+               public static TypedMessageConverter Create (
+                       Type type, string action,
+                       XmlSerializerFormatAttribute formatterAttribute)
+               {
+                       return Create (type, action, TempUri, formatterAttribute);
+               }
+
+               public static TypedMessageConverter Create (
+                       Type type, string action, string defaultNamespace,
+                       XmlSerializerFormatAttribute formatterAttribute)
+               {
+                       return new DefaultTypedMessageConverter (
+                               new XmlMessagesFormatter (
+                                       MessageContractToMessagesDescription (type, defaultNamespace, action),
+                                       formatterAttribute));
+               }
+
+               public abstract object FromMessage (Message message);
+
+               public abstract Message ToMessage (object typedMessage);
+
+               public abstract Message ToMessage (object typedMessage, MessageVersion version);
+
+               static MessageDescriptionCollection MessageContractToMessagesDescription (
+                       Type src, string defaultNamespace, string action)
+               {
+                       MessageContractAttribute mca =
+                               ContractDescriptionGenerator.GetMessageContractAttribute (src);
+
+                       if (mca == null)
+                               throw new ArgumentException (String.Format ("Type {0} and its ancestor types do not have MessageContract attribute.", src));
+
+                       MessageDescriptionCollection messages = new MessageDescriptionCollection ();
+                       messages.Add (ContractDescriptionGenerator.CreateMessageDescription (src, defaultNamespace, action, true, mca));
+                       messages.Add (ContractDescriptionGenerator.CreateMessageDescription (src, defaultNamespace, action, false, mca));
+                       return messages;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/WSTrustMessageConverters.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/WSTrustMessageConverters.cs
new file mode 100644 (file)
index 0000000..05d3e55
--- /dev/null
@@ -0,0 +1,430 @@
+//
+// WSTrustMessageConverters.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2006-2007 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Security.Cryptography;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Description
+{
+       class WSTrustRequestSecurityTokenReader : IDisposable
+       {
+               WstRequestSecurityToken req = new WstRequestSecurityToken ();
+               XmlDictionaryReader reader;
+               SecurityTokenSerializer serializer;
+
+               public WSTrustRequestSecurityTokenReader (XmlDictionaryReader reader, SecurityTokenSerializer serializer)
+               {
+                       this.reader = reader;
+                       this.serializer = serializer;
+               }
+
+               public WstRequestSecurityToken Value {
+                       get { return req; }
+               }
+
+               string LineInfo ()
+               {
+                       IXmlLineInfo li = reader as IXmlLineInfo;
+                       return li != null && li.HasLineInfo () ?
+                               String.Format ("({0},{1})", li.LineNumber, li.LinePosition) : String.Empty;
+               }
+
+               public void Dispose ()
+               {
+                       reader.Close ();
+               }
+
+               public WstRequestSecurityToken Read ()
+               {
+                       reader.MoveToContent ();
+                       req.Context = reader.GetAttribute ("Context");
+                       reader.ReadStartElement ("RequestSecurityToken", Constants.WstNamespace);
+                       do {
+                               reader.MoveToContent ();
+                               switch (reader.NodeType) {
+                               case XmlNodeType.EndElement:
+                                       reader.Read (); // consume RequestSecurityToken end element.
+                                       return req;
+                               case XmlNodeType.Element:
+                                       ReadTokenContent ();
+                                       break;
+                               default:
+                                       throw new XmlException (String.Format ("Unexpected request XML {0} node, name {1}{2}", reader.NodeType, reader.Name, LineInfo ()));
+                               }
+                       } while (true);
+               }
+
+               void ReadTokenContent ()
+               {
+                       switch (reader.NamespaceURI) {
+                       case Constants.WstNamespace:
+                               switch (reader.LocalName) {
+                               case "RequestType":
+                                       req.RequestType = reader.ReadElementContentAsString ();
+                                       return;
+                               case "Entropy":
+                                       ReadEntropy ();
+                                       return;
+                               case "KeySize":
+                                       req.KeySize = reader.ReadElementContentAsInt ();
+                                       return;
+                               case "KeyType":
+                                       req.KeyType = reader.ReadElementContentAsString ();
+                                       return;
+                               case "TokenType":
+                                       string tokenType = reader.ReadElementContentAsString ();
+                                       if (tokenType != Constants.WsscContextToken)
+                                               throw new SecurityTokenException (String.Format ("Unexpected TokenType: {0}", tokenType));
+                                       return;
+                               case "ComputedKeyAlgorithm":
+                                       req.ComputedKeyAlgorithm = reader.ReadElementContentAsString ();
+                                       return;
+                               case "BinaryExchange":
+                                       ReadBinaryExchange ();
+                                       return;
+                               }
+                               break;
+                       case Constants.WspNamespace:
+                               switch (reader.LocalName) {
+                               case "AppliesTo":
+                                       ReadAppliesTo ();
+                                       return;
+                               }
+                               break;
+                       }
+                       throw new XmlException (String.Format ("Unexpected RequestSecurityToken content element. Name is {0} and namespace URI is {1}{2}", reader.Name, reader.NamespaceURI, LineInfo ()));
+               }
+
+               protected void ReadBinaryExchange ()
+               {
+                       if (reader.IsEmptyElement)
+                               throw new XmlException (String.Format ("Binary content is expected in 'BinaryExchange' element.{0}", LineInfo ()));
+                       WstBinaryExchange b = new WstBinaryExchange (reader.GetAttribute ("ValueType"));
+                       b.EncodingType = reader.GetAttribute ("EncodingType");
+                       b.Value = Convert.FromBase64String (reader.ReadElementContentAsString ());
+                       req.BinaryExchange = b;
+               }
+
+               void ReadEntropy ()
+               {
+                       if (reader.IsEmptyElement)
+                               throw new XmlException (String.Format ("WS-Trust Entropy element is empty.{2}", LineInfo ()));
+                       reader.ReadStartElement ("Entropy", Constants.WstNamespace);
+                       reader.MoveToContent ();
+
+                       req.Entropy = serializer.ReadToken (reader, null);
+                       // after reading a token, </Entropy> should follow.
+                       reader.MoveToContent ();
+                       reader.ReadEndElement ();
+               }
+
+               void ReadAppliesTo ()
+               {
+                       WspAppliesTo aTo = new WspAppliesTo ();
+
+                       if (reader.IsEmptyElement)
+                               throw new XmlException (String.Format ("WS-Policy AppliesTo element is empty.{2}", LineInfo ()));
+                       reader.ReadStartElement ();
+                       reader.MoveToContent ();
+                       reader.ReadStartElement ("EndpointReference", Constants.WsaNamespace);
+                       reader.MoveToContent ();
+                       WsaEndpointReference er = new WsaEndpointReference ();
+                       er.Address = reader.ReadElementContentAsString ("Address", Constants.WsaNamespace);
+                       reader.MoveToContent ();
+                       reader.ReadEndElement (); // </EndpointReference>
+                       aTo.EndpointReference = er;
+                       reader.MoveToContent ();
+                       reader.ReadEndElement (); // </wsp:AppliesTo>
+                       req.AppliesTo = aTo;
+               }
+       }
+
+       // FIXME: it might be extraneous - currently used only for IssuedToken
+       class WstRequestSecurityTokenWriter : BodyWriter
+       {
+               WstRequestSecurityToken value;
+               SecurityTokenSerializer serializer;
+
+               public WstRequestSecurityTokenWriter (WstRequestSecurityToken value, SecurityTokenSerializer serializer)
+                       : base (true)
+               {
+                       this.value = value;
+                       this.serializer = serializer;
+               }
+
+               protected override void OnWriteBodyContents (XmlDictionaryWriter w)
+               {
+                       w.WriteStartElement ("RequestSecurityToken", Constants.WstNamespace);
+                       w.WriteEndElement ();
+               }
+       }
+
+       class WSTrustRequestSecurityTokenResponseReader : IDisposable
+       {
+               string negotiation_type;
+               WstRequestSecurityTokenResponse res;
+               XmlDictionaryReader reader;
+               SecurityTokenSerializer serializer;
+               SecurityTokenResolver resolver;
+
+               public WSTrustRequestSecurityTokenResponseReader (
+                       string negotiationType,
+                       XmlDictionaryReader reader,
+                       SecurityTokenSerializer serializer,
+                       SecurityTokenResolver resolver)
+               {
+                       this.negotiation_type = negotiationType;
+                       this.reader = reader;
+                       this.serializer = serializer;
+                       this.resolver = resolver;
+                       res = new WstRequestSecurityTokenResponse (serializer);
+               }
+
+               public WstRequestSecurityTokenResponse Value {
+                       get { return res; }
+               }
+
+               string LineInfo ()
+               {
+                       IXmlLineInfo li = reader as IXmlLineInfo;
+                       return li != null && li.HasLineInfo () ?
+                               String.Format ("({0},{1})", li.LineNumber, li.LinePosition) : String.Empty;
+               }
+
+               public void Dispose ()
+               {
+                       reader.Close ();
+               }
+
+               public WstRequestSecurityTokenResponse Read ()
+               {
+                       reader.MoveToContent ();
+                       res.Context = reader.GetAttribute ("Context");
+                       reader.ReadStartElement ("RequestSecurityTokenResponse", Constants.WstNamespace);
+                       do {
+                               reader.MoveToContent ();
+                               switch (reader.NodeType) {
+                               case XmlNodeType.EndElement:
+                                       reader.Read (); // consume RequestSecurityTokenResponse end element.
+                                       return res;
+                               case XmlNodeType.Element:
+                                       ReadTokenContent ();
+                                       break;
+                               default:
+                                       throw new XmlException (String.Format ("Unexpected request XML {0} node, name {1}{2}", reader.NodeType, reader.Name, LineInfo ()));
+                               }
+                       } while (true);
+               }
+
+               void ReadTokenContent ()
+               {
+                       switch (reader.NamespaceURI) {
+                       case Constants.WstNamespace:
+                               switch (reader.LocalName) {
+                               case "RequestedSecurityToken":
+                                       res.RequestedSecurityToken = (SecurityContextSecurityToken) ReadToken ();
+                                       return;
+                               case "RequestedProofToken":
+#if true // FIXME: we can't handle it right now
+                                       string ens = EncryptedXml.XmlEncNamespaceUrl;
+                                       reader.Read ();
+                                       reader.ReadStartElement ("EncryptedKey", ens);
+                                       string alg = reader.GetAttribute ("Algorithm");
+                                       bool isEmpty = reader.IsEmptyElement;
+                                       reader.ReadStartElement ("EncryptionMethod", ens);
+                                       if (alg != negotiation_type)
+                                               throw new XmlException (String.Format ("EncryptionMethod '{0}' is not supported in RequestedProofToken.", alg));
+                                       if (!isEmpty)
+                                               reader.ReadEndElement ();
+                                       reader.ReadStartElement ("CipherData", ens);
+                                       reader.ReadStartElement ("CipherValue", ens);
+                                       byte [] pt = reader.ReadContentAsBase64 ();
+                                       res.RequestedProofToken = pt;
+                                       reader.ReadEndElement ();
+                                       reader.ReadEndElement ();
+                                       reader.ReadEndElement ();// EncryptedKey
+                                       reader.ReadEndElement ();// RPT
+#else
+                                       reader.Read ();
+                                       reader.MoveToContent ();
+                                       if (serializer.CanReadToken (reader))
+                                               res.RequestedProofToken = serializer.ReadToken (reader, resolver);
+                                       else
+                                               res.RequestedProofToken = serializer.ReadKeyIdentifierClause (reader);
+                                       reader.ReadEndElement ();
+#endif
+                                       return;
+                               case "BinaryExchange":
+                                       ReadBinaryExchange ();
+                                       return;
+                               case "TokenType":
+                                       res.TokenType = reader.ReadElementContentAsString ();
+                                       return;
+                               case "Lifetime":
+                                       ReadLifetime ();
+                                       return;
+                               case "KeySize":
+                                       res.KeySize = reader.ReadElementContentAsInt ();
+                                       return;
+                               case "RequestedAttachedReference":
+                                       res.RequestedAttachedReference = ReadTokenReference ();
+                                       return;
+                               case "RequestedUnattachedReference":
+                                       res.RequestedUnattachedReference = ReadTokenReference ();
+                                       return;
+                               case "Authenticator":
+                                       ReadAuthenticator ();
+                                       return;
+                               }
+                               break;
+                       }
+                       throw new XmlException (String.Format ("Unexpected RequestSecurityTokenResponse content element. Name is {0} and namespace URI is {1} {2}", reader.Name, reader.NamespaceURI, LineInfo ()));
+               }
+
+               void ReadAuthenticator ()
+               {
+                       if (reader.IsEmptyElement)
+                               throw new XmlException (String.Format ("WS-Trust 'Authenticator' element is expected to have contents. {0}", LineInfo ()));
+                       reader.Read ();
+                       reader.MoveToContent ();
+                       res.Authenticator = Convert.FromBase64String (reader.ReadElementContentAsString ("CombinedHash", Constants.WstNamespace));
+                       reader.ReadEndElement ();
+               }
+
+               void ReadLifetime ()
+               {
+                       WstLifetime lt = new WstLifetime ();
+                       res.Lifetime = lt;
+                       if (reader.IsEmptyElement)
+                               throw new XmlException (String.Format ("WS-Trust 'Lifetime' element is expected to have contents. {0}", LineInfo ()));
+                       reader.Read ();
+                       while (true) {
+                               reader.MoveToContent ();
+                               if (reader.NodeType != XmlNodeType.Element)
+                                       break;
+                               if (reader.NamespaceURI == Constants.WsuNamespace) {
+                                       switch (reader.LocalName) {
+                                       case "Created":
+                                               lt.Created = XmlConvert.ToDateTime (reader.ReadElementContentAsString (), XmlDateTimeSerializationMode.RoundtripKind);
+                                               continue;
+                                       case "Expires":
+                                               lt.Expires = XmlConvert.ToDateTime (reader.ReadElementContentAsString (), XmlDateTimeSerializationMode.RoundtripKind);
+                                               continue;
+                                       }
+                               }
+                               throw new XmlException (String.Format ("Unexpected Lifetime content. Name is {0} and namespace URI is {1} {2}", reader.Name, reader.NamespaceURI, LineInfo ()));
+                       }
+                       reader.ReadEndElement ();
+               }
+
+               SecurityToken ReadToken ()
+               {
+                       if (reader.IsEmptyElement)
+                               throw new XmlException (String.Format ("Security token body is expected in '{0}' element. {1}", reader.LocalName, LineInfo ()));
+                       reader.Read ();
+                       reader.MoveToContent ();
+                       SecurityToken token = serializer.ReadToken (reader, resolver);
+                       reader.ReadEndElement ();
+                       return token;
+               }
+
+               SecurityKeyIdentifierClause ReadTokenReference ()
+               {
+                       if (reader.IsEmptyElement)
+                               throw new XmlException (String.Format ("Content is expected in 'RequestedAttachedReference' element. {0}", LineInfo ()));
+                       reader.Read ();
+                       SecurityKeyIdentifierClause ret = serializer.ReadKeyIdentifierClause (reader);
+                       reader.ReadEndElement ();
+                       return ret;
+               }
+
+               void ReadBinaryExchange ()
+               {
+                       if (reader.IsEmptyElement)
+                               throw new XmlException (String.Format ("Binary content is expected in 'BinaryExchange' element.{0}", LineInfo ()));
+                       WstBinaryExchange b = new WstBinaryExchange (reader.GetAttribute ("ValueType"));
+                       b.EncodingType = reader.GetAttribute ("EncodingType");
+                       b.Value = Convert.FromBase64String (reader.ReadElementContentAsString ());
+                       res.BinaryExchange = b;
+               }
+       }
+
+       // FIXME: it might be extraneous - currently unused
+       internal class WstRequestSecurityTokenResponseWriter : BodyWriter
+       {
+               WstRequestSecurityTokenResponse res;
+               SecurityTokenSerializer serializer;
+
+               public WstRequestSecurityTokenResponseWriter (WstRequestSecurityTokenResponse res, SecurityTokenSerializer serializer)
+                       : base (true)
+               {
+                       this.res = res;
+                       this.serializer = serializer;
+               }
+
+               protected override void OnWriteBodyContents (XmlDictionaryWriter writer)
+               {
+try {
+                       writer.WriteStartElement ("RequestSecurityTokenResponse", Constants.WstNamespace);
+
+                       // RequestedSecurityToken
+                       writer.WriteStartElement ("RequestedSecurityToken", Constants.WstNamespace);
+
+                       serializer.WriteToken (writer, res.RequestedSecurityToken);
+
+                       writer.WriteEndElement ();
+
+/*
+                       // Entropy
+                       writer.WriteStartElement ("Entropy", Constants.WstNamespace);
+                       // FIXME: keep generated key
+                       serializer.WriteToken (writer,
+                               new BinarySecretSecurityToken (Rijndael.Create ().Key));
+                       writer.WriteEndElement ();
+*/
+
+                       writer.WriteEndElement ();
+} catch (Exception ex) {
+Console.WriteLine (ex);
+throw;
+}
+               }
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/WSTrustSTSContract.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/WSTrustSTSContract.cs
new file mode 100644 (file)
index 0000000..2032c28
--- /dev/null
@@ -0,0 +1,323 @@
+//
+// WSTrustSTSContract.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections.ObjectModel;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Net.Security;
+using System.Runtime.Serialization;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       internal class WSTrustSecurityTokenServiceProxy
+               : ClientBase<IWSTrustSecurityTokenService>, IWSTrustSecurityTokenService
+       {
+               public WSTrustSecurityTokenServiceProxy (Binding binding, EndpointAddress address)
+                       : base (binding, address)
+               {
+               }
+
+               public Message Issue (Message request)
+               {
+                       return Channel.Issue (request);
+               }
+
+               public Message IssueReply (Message request)
+               {
+                       return Channel.IssueReply (request);
+               }
+
+               public Message Renew (Message request)
+               {
+                       return Channel.Issue (request);
+               }
+
+               public Message Cancel (Message request)
+               {
+                       return Channel.Issue (request);
+               }
+
+               public Message Validate (Message request)
+               {
+                       return Channel.Issue (request);
+               }
+       }
+
+       [ServiceContract]
+       internal interface IWSTrustSecurityTokenService
+       {
+               [OperationContract (Action = Constants.WstIssueAction, ReplyAction = Constants.WstIssueReplyAction, ProtectionLevel = ProtectionLevel.EncryptAndSign)]
+               Message Issue (Message request);
+
+               [OperationContract (Action = Constants.WstIssueReplyAction, ReplyAction = Constants.WstIssueReplyAction, ProtectionLevel = ProtectionLevel.EncryptAndSign)] // needed for token negotiation reply
+               Message IssueReply (Message request);
+
+               [OperationContract (Action = Constants.WstRenewAction, ReplyAction = Constants.WstRenewReplyAction, ProtectionLevel = ProtectionLevel.EncryptAndSign)]
+               Message Renew (Message request);
+
+               [OperationContract (Action = Constants.WstCancelAction, ReplyAction = Constants.WstCancelReplyAction, ProtectionLevel = ProtectionLevel.EncryptAndSign)]
+               Message Cancel (Message request);
+
+               [OperationContract (Action = Constants.WstValidateAction, ReplyAction = Constants.WstValidateReplyAction, ProtectionLevel = ProtectionLevel.EncryptAndSign)]
+               Message Validate (Message request);
+
+               // FIXME: do we need KET here?
+       }
+
+       class WstRequestSecurityToken : WstRequestSecurityTokenBase
+       {
+               protected override void OnWriteBodyContents (XmlDictionaryWriter w)
+               {
+                       w.WriteStartElement ("t", "RequestSecurityToken", Constants.WstNamespace);
+                       WriteBodyContentsCore (w);
+                       w.WriteEndElement ();
+               }
+       }
+
+       class WstRequestSecurityTokenResponse : WstRequestSecurityTokenBase
+       {
+               SecurityTokenSerializer serializer;
+
+               public WstRequestSecurityTokenResponse (SecurityTokenSerializer serializer)
+               {
+                       this.serializer = serializer;
+               }
+
+               public string TokenType;
+
+               public SecurityContextSecurityToken RequestedSecurityToken;
+
+               public SecurityKeyIdentifierClause RequestedAttachedReference;
+
+               public SecurityKeyIdentifierClause RequestedUnattachedReference;
+
+               public object RequestedProofToken;
+
+               public WstLifetime Lifetime;
+
+               public byte [] Authenticator;
+
+               // it only supports negotiation so far ...
+               protected override void OnWriteBodyContents (XmlDictionaryWriter w)
+               {
+                       string ns = Constants.WstNamespace;
+                       string nsu = Constants.WsuNamespace;
+                       w.WriteStartElement ("t", "RequestSecurityTokenResponse", ns);
+                       w.WriteXmlnsAttribute ("u", nsu);
+                       w.WriteAttributeString ("Context", Context);
+                       if (Authenticator != null) {
+                               w.WriteStartElement ("t", "Authenticator", ns);
+                               w.WriteStartElement ("t", "CombinedHash", ns);
+                               w.WriteBase64 (Authenticator, 0, Authenticator.Length);
+                               w.WriteEndElement ();
+                               w.WriteEndElement ();
+                       }
+                       if (TokenType != null)
+                               w.WriteElementString ("t", "TokenType", ns, TokenType);
+                       if (RequestedSecurityToken != null) {
+                               w.WriteStartElement ("t", "RequestedSecurityToken", ns);
+                               serializer.WriteToken (w, RequestedSecurityToken);
+                               w.WriteEndElement ();
+                       }
+                       if (RequestedAttachedReference != null) {
+                               w.WriteStartElement ("t", "RequestedAttachedReference", ns);
+                               serializer.WriteKeyIdentifierClause (w, RequestedAttachedReference);
+                               w.WriteEndElement ();
+                       }
+                       if (RequestedUnattachedReference != null) {
+                               w.WriteStartElement ("t", "RequestedUnattachedReference", ns);
+                               serializer.WriteKeyIdentifierClause (w, RequestedUnattachedReference);
+                               w.WriteEndElement ();
+                       }
+                       if (RequestedProofToken != null) {
+                               w.WriteStartElement ("t", "RequestedProofToken", ns);
+                               if (RequestedProofToken is SecurityToken)
+                                       serializer.WriteToken (w, (SecurityToken) RequestedProofToken);
+                               else if (RequestedProofToken is SecurityKeyIdentifierClause)
+                                       serializer.WriteKeyIdentifierClause (w, (SecurityKeyIdentifierClause) RequestedProofToken);
+                               else {
+                                       string ens = EncryptedXml.XmlEncNamespaceUrl;
+                                       w.WriteStartElement ("e", "EncryptedKey", ens);
+                                       w.WriteStartElement ("EncryptionMethod", ens);
+                                       w.WriteAttributeString ("Algorithm", Constants.WstTlsnegoProofTokenType);
+                                       w.WriteEndElement ();
+                                       w.WriteStartElement ("CipherData", ens);
+                                       w.WriteStartElement ("CipherValue", ens);
+                                       byte [] base64 = (byte []) RequestedProofToken;
+                                       w.WriteBase64 (base64, 0, base64.Length);
+                                       w.WriteEndElement ();
+                                       w.WriteEndElement ();
+                                       w.WriteEndElement ();
+                               }
+                               w.WriteEndElement ();
+                       }
+                       if (Lifetime != null) {
+                               w.WriteStartElement ("t", "Lifetime", ns);
+                               if (Lifetime.Created != DateTime.MinValue)
+                                       w.WriteElementString ("Created", nsu, XmlConvert.ToString (Lifetime.Created.ToUniversalTime (), Constants.LifetimeFormat));
+                               if (Lifetime.Expires != DateTime.MaxValue)
+                                       w.WriteElementString ("Expires", nsu, XmlConvert.ToString (Lifetime.Expires.ToUniversalTime (), Constants.LifetimeFormat));
+                               w.WriteEndElement ();
+                       }
+                       //w.WriteElementString ("t", "KeySize", ns, XmlConvert.ToString (KeySize));
+                       if (BinaryExchange != null)
+                               BinaryExchange.WriteTo (w);
+                       w.WriteEndElement ();
+               }
+       }
+
+       abstract class WstRequestSecurityTokenBase : BodyWriter
+       {
+               protected WstRequestSecurityTokenBase ()
+                       : base (true)
+               {
+               }
+
+               protected void WriteBodyContentsCore (XmlDictionaryWriter w)
+               {
+                       string ns = Constants.WstNamespace;
+                       w.WriteAttributeString ("Context", Context);
+                       w.WriteElementString ("t", "TokenType", ns, Constants.WsscContextToken);
+                       w.WriteElementString ("t", "RequestType", ns, Constants.WstIssueRequest);
+                       w.WriteElementString ("t", "KeySize", ns, XmlConvert.ToString (KeySize));
+                       if (BinaryExchange != null)
+                               BinaryExchange.WriteTo (w);
+               }
+
+               public string Context = "uuid-" + Guid.NewGuid (); // UniqueId()-"urn:"
+               public string RequestType;
+               public WspAppliesTo AppliesTo;
+
+               public SecurityToken Entropy;
+
+               public int KeySize = 256;
+               public string KeyType;
+               public string ComputedKeyAlgorithm;
+
+               public WstBinaryExchange BinaryExchange;
+       }
+
+       class WstRequestSecurityTokenResponseCollection : BodyWriter
+       {
+               public WstRequestSecurityTokenResponseCollection ()
+                       : base (true)
+               {
+               }
+
+               Collection<WstRequestSecurityTokenResponse> responses =
+                       new Collection<WstRequestSecurityTokenResponse> ();
+
+               public Collection<WstRequestSecurityTokenResponse> Responses {
+                       get { return responses; }
+               }
+
+               protected override void OnWriteBodyContents (XmlDictionaryWriter w)
+               {
+                       w.WriteStartElement ("t", "RequestSecurityTokenResponseCollection", Constants.WstNamespace);
+                       foreach (WstRequestSecurityTokenResponse r in Responses)
+                               r.WriteBodyContents (w);
+                       w.WriteEndElement ();
+               }
+
+               public void Read (string negotiationType, XmlDictionaryReader r, SecurityTokenSerializer serializer, SecurityTokenResolver resolver)
+               {
+                       r.MoveToContent ();
+                       r.ReadStartElement ("RequestSecurityTokenResponseCollection", Constants.WstNamespace);
+                       while (true) {
+                               r.MoveToContent ();
+                               if (r.NodeType != XmlNodeType.Element)
+                                       break;
+                               WSTrustRequestSecurityTokenResponseReader rstrr = new WSTrustRequestSecurityTokenResponseReader (negotiationType, r, serializer, resolver);
+                               rstrr.Read ();
+                               responses.Add (rstrr.Value);
+                       }
+                       r.ReadEndElement ();
+               }
+       }
+
+       class WstLifetime
+       {
+               public DateTime Created = DateTime.MinValue;
+
+               public DateTime Expires = DateTime.MaxValue;
+       }
+
+       class WstEntropy
+       {
+               public object Token;
+       }
+
+       class WspAppliesTo
+       {
+               public WsaEndpointReference EndpointReference;
+       }
+
+       class WsaEndpointReference
+       {
+               public string Address;
+       }
+
+       class WstBinarySecret
+       {
+               public string Id;
+
+               public string Type;
+
+               public string Value;
+       }
+
+       class WstBinaryExchange
+       {
+               public WstBinaryExchange (string valueType)
+               {
+                       ValueType = valueType;
+               }
+
+               public string ValueType;
+
+               public string EncodingType = Constants.WssBase64BinaryEncodingType;
+
+               public byte [] Value;
+
+               public void WriteTo (XmlWriter w)
+               {
+                       w.WriteStartElement ("t", "BinaryExchange", Constants.WstNamespace);
+                       w.WriteAttributeString ("ValueType", ValueType);
+                       w.WriteAttributeString ("EncodingType", EncodingType);
+                       w.WriteString (Convert.ToBase64String (Value));
+                       w.WriteEndElement ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/WebServiceHelper.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/WebServiceHelper.cs
new file mode 100644 (file)
index 0000000..8100105
--- /dev/null
@@ -0,0 +1,180 @@
+//
+// System.Web.Services.Protocols.WebServiceHelper.cs
+//
+// Author:
+//   Lluis Sanchez Gual (lluis@ximian.com)
+//
+// Copyright (C) Ximian, Inc. 2003
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if USE_DEPRECATED
+
+using System;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+using System.Web.Services.Protocols;
+using System.Web.Services.Description;
+using System.Collections.Generic;
+
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Description
+{
+       //Original file: WebServiceHelper.cs
+       internal class WebServiceHelper
+       {
+               public const string SoapEnvelopeNamespace = "http://www.w3.org/2003/05/soap-envelope";
+               public const string AddressingNamespace = "http://www.w3.org/2005/08/addressing";
+
+               public static MetadataSet ReadTransferGetResponse (XmlTextReader xmlReader, SoapHeaderDirection dir, 
+                               out SoapHeaderCollection headers, out AddressHeaderCollection addressHeaders)
+               {
+                       SoapReflectionImporter sri = new SoapReflectionImporter ();
+                       XmlSerializer bodySerializer = new XmlSerializer (sri.ImportTypeMapping (typeof (SoapHeader)));
+               
+                       xmlReader.MoveToContent ();
+                       xmlReader.ReadStartElement ("Envelope", WebServiceHelper.SoapEnvelopeNamespace);
+
+                       headers = ReadHeaders (xmlReader, out addressHeaders);
+                       xmlReader.MoveToContent ();
+
+                       xmlReader.ReadStartElement ("Body", WebServiceHelper.SoapEnvelopeNamespace);
+                       
+                       /*if (xmlReader.LocalName == "Fault" && xmlReader.NamespaceURI == SoapEnvelopeNamespace)
+                               bodySerializer = Fault.Serializer;
+
+                       body = bodySerializer.Deserialize (xmlReader);*/
+
+                       MetadataSet ms = MetadataSet.ReadFrom (xmlReader);
+                       return ms;
+               }
+
+               static SoapHeaderCollection ReadHeaders (XmlTextReader xmlReader, out AddressHeaderCollection addressHeaders)
+               {
+                       SoapHeaderCollection headers = new SoapHeaderCollection ();
+                       List<AddressHeader> addressList = new List<AddressHeader> ();
+                       
+                       xmlReader.Read ();
+                       while (! (xmlReader.NodeType == XmlNodeType.Element && xmlReader.LocalName == "Body" && 
+                                               xmlReader.NamespaceURI == SoapEnvelopeNamespace))
+                       {
+                               /* FIXME: Use some deserializer for AddressHeaders,
+                                * EndpointReference is a complex header..
+                                * Validate 'Action', 'RelatesTo'
+                                */
+                               if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.NamespaceURI == AddressingNamespace && 
+                                       !xmlReader.IsEmptyElement)
+                               {
+                                       //WS-Addressing headers
+                                       
+                                       /* FIXME: attributes? 
+                                       while (xmlReader.MoveToNextAttribute ()) {
+                                       }*/
+
+                                       xmlReader.ReadStartElement ();
+                                       xmlReader.MoveToContent ();
+                                       string content = xmlReader.ReadContentAsString ();
+                                       
+                                       //FIXME: Use AddressHeaderSerializer
+                                       AddressHeader ah = AddressHeader.CreateAddressHeader (xmlReader.Name, AddressingNamespace, 
+                                                       content);
+
+                                       addressList.Add (ah);
+                                       xmlReader.ReadEndElement ();
+                               }
+                               else
+                                       //FIXME: Other headers?
+                                       xmlReader.Skip ();
+                       }
+
+                       addressHeaders = new AddressHeaderCollection (addressList);
+                       
+                       return headers;
+               }
+               
+               class HeaderSerializationHelper
+               {
+                       SoapHeaderCollection headers;
+                       XmlSerializer headerSerializer;
+                       
+                       public HeaderSerializationHelper (XmlSerializer headerSerializer)
+                       {
+                               this.headers = new SoapHeaderCollection ();
+                               this.headerSerializer = headerSerializer;
+                       }
+                       
+                       public SoapHeaderCollection Deserialize (XmlTextReader xmlReader)
+                       {
+                               try {
+                                       headerSerializer.UnknownElement += new XmlElementEventHandler (OnAddUnknownHeader);
+                                       object[] headerArray = (object[]) headerSerializer.Deserialize (xmlReader);
+                                       foreach (SoapHeader h in headerArray)
+                                               if (h != null) headers.Add (h);
+                                       return headers;
+                               } finally {
+                                       headerSerializer.UnknownElement -= new XmlElementEventHandler (OnAddUnknownHeader);
+                               }
+                       }
+                       
+                       void OnAddUnknownHeader (object sender, XmlElementEventArgs e)
+                       {
+                               SoapUnknownHeader su = new SoapUnknownHeader ();
+                               su.Element = e.Element;
+                               headers.Add (su);
+                       }
+               }
+
+               public static void InvalidOperation (string message, WebResponse response, Encoding enc)
+               {
+                       if (response == null)
+                               throw new InvalidOperationException (message);
+
+                       if (enc == null)
+                               enc = Encoding.UTF8;
+
+                       StringBuilder sb = new StringBuilder ();
+                       sb.Append (message);
+                       if (response.ContentLength > 0) {
+                               sb.Append ("\r\nResponse error message:\r\n--\r\n");
+
+                               try {
+                                       StreamReader resp = new StreamReader (response.GetResponseStream (), enc);
+                                       sb.Append (resp.ReadToEnd ());
+                               } catch (Exception) {
+                               }
+                       }
+
+                       throw new InvalidOperationException (sb.ToString ());
+               }
+       }
+
+
+}
+
+#endif
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlContractConversionContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlContractConversionContext.cs
new file mode 100644 (file)
index 0000000..387d1f4
--- /dev/null
@@ -0,0 +1,82 @@
+//
+// WsdlContractConversionContext.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.Web.Services.Description;
+using System.Xml;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class WsdlContractConversionContext
+       {
+               ContractDescription contract;
+               PortType port_type;
+
+               internal WsdlContractConversionContext (ContractDescription contract, PortType portType)
+               {
+                       this.contract = contract;
+                       this.port_type = portType;
+               }
+
+               public ContractDescription Contract {
+                       get { return contract; }
+               }
+
+               public PortType WsdlPortType {
+                       get { return port_type; }
+               }
+
+               public MessageDescription GetMessageDescription (
+                       OperationMessage operationMessage)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public Operation GetOperation (OperationDescription operation)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public OperationDescription GetOperationDescription (
+                       Operation operation)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public OperationMessage GetOperationMessage (
+                       MessageDescription message)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlEndpointConversionContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlEndpointConversionContext.cs
new file mode 100644 (file)
index 0000000..da253dd
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// WsdlEndpointConversionContext.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.Web.Services.Description;
+using System.Xml;
+
+using WSBinding = System.Web.Services.Description.Binding;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class WsdlEndpointConversionContext
+       {
+               WsdlContractConversionContext context;
+               ServiceEndpoint endpoint;
+               Port port;
+               WSBinding wsdl_binding;
+
+               internal WsdlEndpointConversionContext (WsdlContractConversionContext context, ServiceEndpoint endpoint, Port port, WSBinding wsdlBinding)
+               {
+                       this.context = context;
+                       this.endpoint = endpoint;
+                       this.port = port;
+                       this.wsdl_binding = wsdlBinding;
+               }
+
+               public WsdlContractConversionContext ContractConversionContext {
+                       get { return context; }
+               }
+
+               public ServiceEndpoint Endpoint {
+                       get { return endpoint; }
+               }
+
+               public WSBinding WsdlBinding {
+                       get { return wsdl_binding; }
+               }
+
+               public Port WsdlPort {
+                       get { return port; }
+               }
+
+               public MessageBinding GetMessageBinding (
+                       MessageDescription message)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public MessageDescription GetMessageDescription (
+                       MessageBinding message)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public OperationBinding GetOperationBinding (
+                       OperationDescription operation)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public OperationDescription GetOperationDescription (
+                       OperationBinding operation)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlExporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlExporter.cs
new file mode 100644 (file)
index 0000000..10a4fe2
--- /dev/null
@@ -0,0 +1,546 @@
+//
+// WsdlExporter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Ankit Jain <JAnkit@novell.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Web.Services.Description;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+using System.Runtime.Serialization;
+
+using SMBinding = System.ServiceModel.Channels.Binding;
+using SMMessage = System.ServiceModel.Channels.Message;
+
+using WSServiceDescription = System.Web.Services.Description.ServiceDescription;
+using WSBinding = System.Web.Services.Description.Binding;
+using WSMessage = System.Web.Services.Description.Message;
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class WsdlExporter : MetadataExporter
+       {
+               private MetadataSet metadata;
+               private ServiceDescriptionCollection wsdl_colln;
+               private XsdDataContractExporter xsd_exporter;
+               private Hashtable exported_contracts;
+
+               public override MetadataSet GetGeneratedMetadata ()
+               {
+                       if (metadata != null)
+                               return metadata;
+
+                       metadata = new MetadataSet ();
+                       foreach (WSServiceDescription sd in GeneratedWsdlDocuments)
+                               metadata.MetadataSections.Add (
+                                       MetadataSection.CreateFromServiceDescription (sd));
+
+                       foreach (XmlSchema xs in GeneratedXmlSchemas.Schemas ())
+                               metadata.MetadataSections.Add (
+                                       MetadataSection.CreateFromSchema (xs));
+                               
+                       return metadata;
+               }
+
+               public override void ExportContract (ContractDescription contract)
+               {
+                       ExportContractInternal (contract);      
+               }
+
+               List<IWsdlExportExtension> ExportContractInternal (ContractDescription contract)
+               {
+                       QName qname = new QName (contract.Name, contract.Namespace);
+                       if (ExportedContracts.ContainsKey (qname))
+                               throw new ArgumentException (String.Format (
+                                       "A ContractDescription with Namespace : {0} and Name : {1} has already been exported.", 
+                                       contract.Namespace, contract.Name));
+
+                       WSServiceDescription sd = GetServiceDescription (contract.Namespace);
+
+                       List<IWsdlExportExtension> extensions = new List<IWsdlExportExtension> ();
+                       foreach (IWsdlExportExtension extn in contract.Behaviors.FindAll<IWsdlExportExtension> ())
+                               extensions.Add (extn);
+
+                       XmlDocument xdoc = new XmlDocument ();
+
+                       PortType ws_port = new PortType ();
+                       ws_port.Name = contract.Name;
+
+                       foreach (OperationDescription sm_op in contract.Operations) {
+                               Operation ws_op = new Operation ();
+                               ws_op.Name = sm_op.Name;
+
+                               foreach (MessageDescription sm_md in sm_op.Messages) {
+                                       //OperationMessage
+                                       OperationMessage ws_opmsg;
+                                       WSMessage ws_msg = new WSMessage ();
+                                       MessagePart ws_msgpart;
+                                       if (sm_md.Direction == MessageDirection.Input) {
+                                               ws_opmsg = new OperationInput ();
+                                               ws_msg.Name = String.Concat (ws_port.Name, "_", ws_op.Name, "_", "InputMessage");
+                                               ws_msgpart = ExportMessageBodyDescription (sm_md.Body, ws_op.Name, sd.TargetNamespace);
+                                       } else {
+                                               ws_opmsg = new OperationOutput ();
+                                               ws_msg.Name = String.Concat (ws_port.Name, "_", ws_op.Name, "_", "OutputMessage");
+                                               ws_msgpart = ExportMessageBodyDescription (sm_md.Body, ws_op.Name + "Response", sd.TargetNamespace);
+                                       }
+                                       ws_msg.Parts.Add (ws_msgpart);  
+
+                                       /* FIXME: Faults */
+
+                                       //Action
+                                       XmlAttribute attr = xdoc.CreateAttribute ("wsaw", "Action", "http://www.w3.org/2006/05/addressing/wsdl");
+                                       attr.Value = sm_md.Action;
+                                       ws_opmsg.ExtensibleAttributes = new XmlAttribute [] { attr };
+                                       
+                                       //FIXME: Set .Input & .Output
+
+                                       ws_opmsg.Message = new QName (ws_msg.Name, sd.TargetNamespace);
+                                       ws_op.Messages.Add (ws_opmsg);
+                                       sd.Messages.Add (ws_msg);
+                               }
+
+                               ws_port.Operations.Add (ws_op);
+
+                               foreach (IWsdlExportExtension extn in sm_op.Behaviors.FindAll<IWsdlExportExtension> ())
+                                       extensions.Add (extn);
+                       }
+
+                       //Add Imports for <types
+                       XmlSchema xs_import = new XmlSchema ();
+                       xs_import.TargetNamespace = String.Concat (
+                                       contract.Namespace, 
+                                       contract.Namespace.EndsWith ("/") ? "" : "/",
+                                       "Imports");
+                       foreach (XmlSchema schema in GeneratedXmlSchemas.Schemas ()) {
+                               XmlSchemaImport imp = new XmlSchemaImport ();
+                               imp.Namespace = schema.TargetNamespace;
+                               xs_import.Includes.Add (imp);
+                       }
+                       sd.Types.Schemas.Add (xs_import);
+
+                       sd.PortTypes.Add (ws_port);
+                       ExportedContracts [qname] = contract;
+
+                       WsdlContractConversionContext context = new WsdlContractConversionContext (contract, ws_port);
+                       foreach (IWsdlExportExtension extn in extensions)
+                               extn.ExportContract (this, context);
+
+                       return extensions;
+               }
+
+               public override void ExportEndpoint (ServiceEndpoint endpoint)
+               {
+                       List<IWsdlExportExtension> extensions = ExportContractInternal (endpoint.Contract);
+                       
+                       //FIXME: Namespace
+                       WSServiceDescription sd = GetServiceDescription ("http://tempuri.org/");
+                       if (sd.TargetNamespace != endpoint.Contract.Namespace) {
+                               sd.Namespaces.Add ("i0", endpoint.Contract.Namespace);
+
+                               //Import
+                               Import import = new Import ();
+                               import.Namespace = endpoint.Contract.Namespace;
+
+                               sd.Imports.Add (import);
+                       }
+                       
+                       if (endpoint.Binding == null)
+                               throw new ArgumentException (String.Format (
+                                       "Binding for ServiceEndpoint named '{0}' is null",
+                                       endpoint.Name));
+
+                       bool msg_version_none =
+                               endpoint.Binding.MessageVersion != null &&
+                               endpoint.Binding.MessageVersion.Equals (MessageVersion.None);
+                       //ExportBinding
+                       WSBinding ws_binding = new WSBinding ();
+                       
+                       //<binding name = .. 
+                       ws_binding.Name = String.Concat (endpoint.Binding.Name, "_", endpoint.Contract.Name);
+
+                       //<binding type = ..
+                       ws_binding.Type = new QName (endpoint.Contract.Name, endpoint.Contract.Namespace);
+                       sd.Bindings.Add (ws_binding);
+
+                       if (!msg_version_none) {
+                               SoapBinding soap_binding = new SoapBinding ();
+                               soap_binding.Transport = SoapBinding.HttpTransport;
+                               soap_binding.Style = SoapBindingStyle.Document;
+                               ws_binding.Extensions.Add (soap_binding);
+                       }
+
+                       //      <operation
+                       foreach (OperationDescription sm_op in endpoint.Contract.Operations){
+                               OperationBinding op_binding = new OperationBinding ();
+                               op_binding.Name = sm_op.Name;
+
+                               //FIXME: Move to IWsdlExportExtension .. ?
+                               foreach (MessageDescription sm_md in sm_op.Messages) {
+                                       if (sm_md.Direction == MessageDirection.Input) {
+                                               //<input
+                                               InputBinding in_binding = new InputBinding ();
+
+                                               if (!msg_version_none) {
+                                                       SoapBodyBinding soap_body_binding = new SoapBodyBinding ();
+                                                       soap_body_binding.Use = SoapBindingUse.Literal;
+                                                       in_binding.Extensions.Add (soap_body_binding);
+
+                                                       //Set Action
+                                                       //<operation > <soap:operation soapAction .. >
+                                                       SoapOperationBinding soap_operation_binding = new SoapOperationBinding ();
+                                                       soap_operation_binding.SoapAction = sm_md.Action;
+                                                       soap_operation_binding.Style = SoapBindingStyle.Document;
+                                                       op_binding.Extensions.Add (soap_operation_binding);
+                                               }
+
+                                               op_binding.Input = in_binding;
+                                       } else {
+                                               //<output
+                                               OutputBinding out_binding = new OutputBinding ();
+
+                                               if (!msg_version_none) {
+                                                       SoapBodyBinding soap_body_binding = new SoapBodyBinding ();
+                                                       soap_body_binding.Use = SoapBindingUse.Literal;
+                                                       out_binding.Extensions.Add (soap_body_binding);
+                                               }
+                                               
+                                               op_binding.Output = out_binding;
+                                       }
+                               }
+
+                               ws_binding.Operations.Add (op_binding);
+                       }
+
+                       //Add <service
+                       Port ws_port = ExportService (sd, ws_binding, endpoint.Address, msg_version_none);
+
+                       //Call IWsdlExportExtension.ExportEndpoint
+                       WsdlContractConversionContext contract_context = new WsdlContractConversionContext (
+                               endpoint.Contract, sd.PortTypes [endpoint.Contract.Name]);
+                       WsdlEndpointConversionContext endpoint_context = new WsdlEndpointConversionContext (
+                               contract_context, endpoint, ws_port, ws_binding);
+
+                       foreach (IWsdlExportExtension extn in extensions)
+                               extn.ExportEndpoint (this, endpoint_context);
+
+                               
+               }
+
+               Port ExportService (WSServiceDescription sd, WSBinding ws_binding, EndpointAddress address, bool msg_version_none)
+               {
+                       if (address == null)
+                               return null;
+
+                       Service ws_svc = GetService (sd, "service");
+                       sd.Name = "service";
+
+                               Port ws_port = new Port ();
+                               ws_port.Name = ws_binding.Name;
+                               ws_port.Binding = new QName (ws_binding.Name, sd.TargetNamespace);
+
+                               if (!msg_version_none) {
+                                       SoapAddressBinding soap_addr = new SoapAddressBinding ();
+                                       soap_addr.Location = address.Uri.AbsoluteUri;
+
+                                       ws_port.Extensions.Add (soap_addr);
+                               }
+
+                       ws_svc.Ports.Add (ws_port);
+
+                       return ws_port;
+               }
+
+               Service GetService (WSServiceDescription sd, string name)
+               {
+                       Service svc = sd.Services [name];
+                       if (svc != null)
+                               return svc;
+
+                       svc = new Service ();
+                       svc.Name = name;
+                       sd.Services.Add (svc);
+
+                       return svc;
+               }
+
+               WSServiceDescription GetServiceDescription (string ns)
+               {
+                       foreach (WSServiceDescription sd in GeneratedWsdlDocuments) {
+                               if (sd.TargetNamespace == ns)
+                                       return sd;
+                       }
+
+                       WSServiceDescription ret = new WSServiceDescription ();
+                       ret.TargetNamespace = ns;
+                       ret.Namespaces = GetNamespaces (ns);
+                       GeneratedWsdlDocuments.Add (ret);
+
+                       metadata = null;
+
+                       return ret;
+               }
+
+               public ServiceDescriptionCollection GeneratedWsdlDocuments {
+                       get {
+                               if (wsdl_colln == null)
+                                       wsdl_colln = new ServiceDescriptionCollection ();
+                               return wsdl_colln;
+                       }
+               }
+
+               public XmlSchemaSet GeneratedXmlSchemas {
+                       get { return XsdExporter.Schemas; }
+               }
+
+               public void ExportEndpoints (
+                       IEnumerable<ServiceEndpoint> endpoints,
+                       XmlQualifiedName name)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               XsdDataContractExporter XsdExporter {
+                       get {
+                               if (xsd_exporter == null)
+                                       xsd_exporter = new XsdDataContractExporter ();
+
+                               return xsd_exporter;
+                       }
+               }
+
+               Hashtable ExportedContracts {
+                       get {
+                               if (exported_contracts == null)
+                                       exported_contracts = new Hashtable ();
+                               return exported_contracts;
+                       }
+               }
+               
+               XmlSerializerNamespaces GetNamespaces (string target_namespace)
+               {
+                       XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces ();
+
+                       namespaces.Add ("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+                       namespaces.Add ("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
+                       namespaces.Add ("soapenc", "http://schemas.xmlsoap.org/soap/encoding/");
+                       namespaces.Add ("tns", target_namespace);
+                       namespaces.Add ("wsa", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
+                       namespaces.Add ("wsp", "http://schemas.xmlsoap.org/ws/2004/09/policy");
+                       namespaces.Add ("wsap", "http://schemas.xmlsoap.org/ws/2004/08/addressing/policy");
+                       namespaces.Add ("msc", "http://schemas.microsoft.com/ws/2005/12/wsdl/contract");
+                       namespaces.Add ("wsaw", "http://www.w3.org/2006/05/addressing/wsdl");
+                       namespaces.Add ("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/");
+                       namespaces.Add ("wsa10", "http://www.w3.org/2005/08/addressing");
+                       namespaces.Add ("wsdl", "http://schemas.xmlsoap.org/wsdl/");
+
+                       return namespaces;
+               }
+
+               MessagePart ExportMessageBodyDescription (MessageBodyDescription msgbody, string name, string ns)
+               {
+                       MessagePart msgpart = new MessagePart ();
+                       string part_name = IsTypeMessage (msgbody);
+
+                       if (part_name != null) {
+                               msgpart.Name = part_name;
+                               msgpart.Type = ExportTypeMessage (); //FIXME: Cache this
+                       } else {
+                               msgpart.Name = "parameters";
+                               msgpart.Element = ExportParameters (msgbody, name, ns);
+                       }
+                       return msgpart;
+               }
+
+               /* Sets the @name if the param or return type is SMMessage */
+               string IsTypeMessage (MessageBodyDescription msgbody)
+               {
+                       MessagePartDescription part = null;
+
+                       if (msgbody.Parts.Count == 0)
+                               part = msgbody.ReturnValue;
+                       else if (msgbody.Parts.Count == 1)
+                               part = msgbody.Parts [0];
+
+                       if (part != null && (part.Type.FullName == typeof (SMMessage).FullName))
+                               return part.Name;
+
+                       return null;
+               }
+
+               QName ExportParameters (MessageBodyDescription msgbody, string name, string ns)
+               {
+                       XmlSchema xs = GetSchema (ns);
+                       //FIXME: Extract to a HasElement method ?
+                       foreach (XmlSchemaObject o in xs.Items) {
+                               XmlSchemaElement e = o as XmlSchemaElement;
+                               if (e == null)
+                                       continue;
+
+                               if (e.Name == name)
+                                       throw new InvalidOperationException (String.Format (
+                                               "Message element named '{0}:{1}' has already been exported.",
+                                               ns, name));
+                       }
+                               
+                       //Create the element for "parameters"
+                       XmlSchemaElement schema_element = new XmlSchemaElement ();
+                       schema_element.Name = name;
+
+                       XmlSchemaComplexType complex_type = new XmlSchemaComplexType ();
+                       //Generate Sequence representing the message/parameters
+                       //FIXME: MessageContractAttribute
+               
+                       XmlSchemaSequence sequence = new XmlSchemaSequence ();
+                       XmlSchemaElement element = null;
+
+                       if (msgbody.ReturnValue == null) {
+                               //parameters
+                               foreach (MessagePartDescription part in msgbody.Parts) {
+                                       if (part.Type == null)
+                                               //FIXME: Eg. when WsdlImporter is used to import a wsdl
+                                               throw new NotImplementedException ();
+                                       
+                                       element = GetSchemaElementForPart (part, xs);
+                                       sequence.Items.Add (element);
+                               }
+                       } else {
+                               //ReturnValue
+                               if (msgbody.ReturnValue.Type != typeof (void)) {
+                                       element = GetSchemaElementForPart (msgbody.ReturnValue, xs);
+                                       sequence.Items.Add (element);
+                               }
+                       }
+
+                       complex_type.Particle = sequence;
+                       schema_element.SchemaType = complex_type;
+
+                       xs.Items.Add (schema_element);
+                       GeneratedXmlSchemas.Reprocess (xs);
+
+                       return new QName (schema_element.Name, xs.TargetNamespace);
+               }
+
+               //Exports <xs:type for SMMessage
+               //FIXME: complex type for this can be made static
+               QName ExportTypeMessage ()
+               {
+                       XmlSchema xs = GetSchema ("http://schemas.microsoft.com/Message");
+                       QName qname = new QName ("MessageBody", xs.TargetNamespace);
+
+                       foreach (XmlSchemaObject o in xs.Items) {
+                               XmlSchemaComplexType ct = o as XmlSchemaComplexType;
+                               if (ct == null)
+                                       continue;
+
+                               if (ct.Name == "MessageBody")
+                                       //Already exported
+                                       return qname;
+                       }
+
+                       XmlSchemaComplexType complex_type = new XmlSchemaComplexType ();
+                       complex_type.Name = "MessageBody";
+                       XmlSchemaSequence sequence = new XmlSchemaSequence ();
+
+                       XmlSchemaAny any = new XmlSchemaAny ();
+                       any.MinOccurs = 0;
+                       any.MaxOccursString = "unbounded";
+                       any.Namespace = "##any";
+
+                       sequence.Items.Add (any);
+                       complex_type.Particle = sequence;
+
+                       xs.Items.Add (complex_type);
+                       GeneratedXmlSchemas.Reprocess (xs);
+                       
+                       return qname;
+               }
+
+               XmlSchemaElement GetSchemaElementForPart (MessagePartDescription part, XmlSchema schema)
+               {
+                       XmlSchemaElement element = new XmlSchemaElement ();
+
+                       element.Name = part.Name;
+                       XsdExporter.Export (part.Type);
+                       element.SchemaTypeName = XsdExporter.GetSchemaTypeName (part.Type);
+                       AddImport (schema, element.SchemaTypeName.Namespace);
+
+                       //FIXME: nillable, minOccurs
+                       if (XsdExporter.GetSchemaType (part.Type) is XmlSchemaComplexType ||
+                               part.Type == typeof (string))
+                               element.IsNillable = true;
+                       element.MinOccurs = 0;
+
+                       return element;
+               }
+
+               //FIXME: Replace with a dictionary ?
+               void AddImport (XmlSchema schema, string ns)
+               {
+                       if (ns == XmlSchema.Namespace || schema.TargetNamespace == ns)
+                               return;
+
+                       foreach (XmlSchemaObject o in schema.Includes) {
+                               XmlSchemaImport import = o as XmlSchemaImport;
+                               if (import == null)
+                                       continue;
+                               if (import.Namespace == ns)
+                                       return;
+                       }
+
+                       XmlSchemaImport imp = new XmlSchemaImport ();
+                       imp.Namespace = ns;
+                       schema.Includes.Add (imp);
+               }
+
+               XmlSchema GetSchema (string ns)
+               {
+                       ICollection colln = GeneratedXmlSchemas.Schemas (ns);
+                       if (colln.Count > 0) { 
+                               if (colln.Count > 1)
+                                       throw new Exception ("More than 1 schema found for ns = " + ns);
+                               //FIXME: HORRIBLE!
+                               foreach (object o in colln)
+                                       return (o as XmlSchema);
+                       }
+
+                       XmlSchema schema = new XmlSchema ();
+                       schema.TargetNamespace = ns;
+                       schema.ElementFormDefault = XmlSchemaForm.Qualified;
+                       GeneratedXmlSchemas.Add (schema);
+
+                       return schema;
+               }
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/WsdlImporter.cs
new file mode 100644 (file)
index 0000000..be1039e
--- /dev/null
@@ -0,0 +1,297 @@
+//
+// WsdlImporter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Ankit Jain <jankit@novell.com>  
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Web.Services.Description;
+using System.Xml;
+using System.Xml.Schema;
+
+using SMBinding = System.ServiceModel.Channels.Binding;
+using WSServiceDescription = System.Web.Services.Description.ServiceDescription;
+using WSBinding = System.Web.Services.Description.Binding;
+using WSMessage = System.Web.Services.Description.Message;
+using QName = System.Xml.XmlQualifiedName;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class WsdlImporter : MetadataImporter
+       {
+               ServiceDescriptionCollection wsdl_documents;
+               XmlSchemaSet xmlschemas;
+               List<XmlElement> policies; /* ?? */
+               MetadataSet metadata;
+
+               KeyedByTypeCollection<IWsdlImportExtension> wsdl_extensions;
+                       
+               //Imported
+               Collection<ContractDescription> contracts = null;
+               ServiceEndpointCollection endpoint_colln = null;
+
+               public WsdlImporter (
+                       MetadataSet metadata,
+                       IEnumerable<IPolicyImportExtension> policyImportExtensions,
+                       IEnumerable<IWsdlImportExtension> wsdlImportExtensions)
+                       : base (policyImportExtensions)
+               {
+                       if (metadata == null)
+                               throw new ArgumentNullException ("metadata");
+                       
+                       if (wsdlImportExtensions == null) {
+                               wsdl_extensions = new KeyedByTypeCollection<IWsdlImportExtension> ();
+
+                               wsdl_extensions.Add (new StandardBindingImporter ());
+                               wsdl_extensions.Add (new TransportBindingElementImporter ());
+                               //wsdl_extensions.Add (new MessageEncodingBindingElementImporter ());
+                               wsdl_extensions.Add (new XmlSerializerMessageContractImporter ());
+                               wsdl_extensions.Add (new DataContractSerializerMessageContractImporter ());
+                       } else {
+                               wsdl_extensions = new KeyedByTypeCollection<IWsdlImportExtension> (wsdlImportExtensions);
+                       }
+
+                       this.metadata = metadata;
+                       this.wsdl_documents = new ServiceDescriptionCollection ();
+                       this.xmlschemas = new XmlSchemaSet ();
+                       this.policies = new List<XmlElement> ();
+
+                       foreach (MetadataSection ms in metadata.MetadataSections) {
+                               if (ms.Dialect == MetadataSection.ServiceDescriptionDialect &&
+                                       ms.Metadata.GetType () == typeof (WSServiceDescription))
+                                       wsdl_documents.Add ((WSServiceDescription) ms.Metadata);
+                               else
+                               if (ms.Dialect == MetadataSection.XmlSchemaDialect &&
+                                       ms.Metadata.GetType () == typeof (XmlSchema))
+                                       xmlschemas.Add ((XmlSchema) ms.Metadata);
+                       }
+               }
+
+               public WsdlImporter (MetadataSet metadata)
+                       : this (metadata, null, null)
+               {
+               }
+
+               public ServiceDescriptionCollection WsdlDocuments {
+                       get { return wsdl_documents; }
+               }
+
+               public KeyedByTypeCollection <IWsdlImportExtension> WsdlImportExtensions {
+                       get { return wsdl_extensions; }
+               }
+
+               public XmlSchemaSet XmlSchemas {
+                       get { return xmlschemas; }
+               }
+
+               public Collection<SMBinding> ImportAllBindings ()
+               {
+                       Collection<SMBinding> bindings = new Collection<SMBinding> ();
+
+                       foreach (WSServiceDescription sd in wsdl_documents)
+                               foreach (WSBinding binding in sd.Bindings)
+                                       bindings.Add (ImportBinding (binding));
+
+                       return bindings;
+               }
+
+               public SMBinding ImportBinding (WSBinding binding)
+               {
+                       /* Default, CustomBinding.. */
+                       CustomBinding smbinding = new CustomBinding ();
+
+                       foreach (IWsdlImportExtension extension in wsdl_extensions)
+                               extension.BeforeImport (wsdl_documents, xmlschemas, policies);
+
+                       smbinding.Name = binding.Name;
+                       smbinding.Namespace = binding.ServiceDescription.TargetNamespace;
+
+                       //FIXME: Added by MessageEncodingBindingElementConverter.ImportPolicy
+                       smbinding.Elements.Add (new TextMessageEncodingBindingElement ());
+
+                       /*ImportContract
+                       PortType portType = null;
+                       foreach (WSServiceDescription sd in wsdl_documents) {
+                               portType = sd.PortTypes [binding.Type.Name];
+                               if (portType != null)
+                                       break;
+                       }
+
+                       //FIXME: if portType == null
+                       */
+                       
+                       // FIXME: ImportContract here..
+
+                       return smbinding;
+               }
+
+               public override Collection<ContractDescription> ImportAllContracts ()
+               {
+                       if (contracts != null)
+                               return contracts;
+
+                       contracts = new Collection<ContractDescription> ();
+
+                       foreach (WSServiceDescription sd in wsdl_documents) {
+                               foreach (PortType pt in sd.PortTypes)
+                                       contracts.Add (ImportContract (pt));
+                       }
+
+                       return contracts;
+               }
+
+               public override ServiceEndpointCollection ImportAllEndpoints ()
+               {
+                       if (endpoint_colln != null)
+                               return endpoint_colln;
+
+                       endpoint_colln = new ServiceEndpointCollection ();
+
+                       foreach (IWsdlImportExtension extension in wsdl_extensions) {
+                               extension.BeforeImport (wsdl_documents, xmlschemas, policies);
+                       }
+
+                       foreach (WSServiceDescription wsd in wsdl_documents)
+                               foreach (Service service in wsd.Services)
+                                       foreach (Port port in service.Ports)
+                                               endpoint_colln.Add (ImportEndpoint (port));
+
+                       return endpoint_colln;
+               }
+
+               public ContractDescription ImportContract (PortType wsdlPortType)
+               {
+                       foreach (IWsdlImportExtension extension in wsdl_extensions) {
+                               extension.BeforeImport (wsdl_documents, xmlschemas, policies);
+                       }
+
+                       ContractDescription cd = new ContractDescription (wsdlPortType.Name, wsdlPortType.ServiceDescription.TargetNamespace);
+
+                       foreach (Operation op in wsdlPortType.Operations) {
+                               OperationDescription op_descr = new OperationDescription (op.Name, cd);
+
+                               foreach (OperationMessage opmsg in op.Messages) {
+                                       /* OperationMessageCollection */
+                                       MessageDescription msg_descr;
+                                       MessageDirection dir = MessageDirection.Input;
+                                       string action = "";
+
+                                       if (opmsg.GetType () == typeof (OperationInput))
+                                               dir = MessageDirection.Input;
+                                       else if (opmsg.GetType () == typeof (OperationOutput))
+                                               dir = MessageDirection.Output;
+                                       /* FIXME: OperationFault--> OperationDescription.Faults ? */
+
+                                       if (opmsg.ExtensibleAttributes != null) {
+                                               for (int i = 0; i < opmsg.ExtensibleAttributes.Length; i++) {
+                                                       if (opmsg.ExtensibleAttributes [i].LocalName == "Action" &&
+                                                               opmsg.ExtensibleAttributes [i].NamespaceURI == "http://www.w3.org/2006/05/addressing/wsdl")
+                                                               /* addressing:Action */
+                                                               action = opmsg.ExtensibleAttributes [i].Value;
+                                                       /* FIXME: other attributes ? */
+                                               }
+                                       }
+
+                                       msg_descr = new MessageDescription (action, dir);
+                                       /* FIXME: Headers ? */
+
+                                       op_descr.Messages.Add (msg_descr);
+                               }
+
+                               cd.Operations.Add (op_descr);
+                       }
+
+                       WsdlContractConversionContext context = new WsdlContractConversionContext (cd, wsdlPortType);
+                       foreach (IWsdlImportExtension extension in wsdl_extensions)
+                               extension.ImportContract (this, context);
+
+                       return cd;
+               }
+
+               public ServiceEndpoint ImportEndpoint (Port wsdlPort)
+               {
+                       foreach (IWsdlImportExtension extension in wsdl_extensions) {
+                               extension.BeforeImport (wsdl_documents, xmlschemas, policies);
+                       }
+
+                       //Get the corresponding contract
+                       //via the PortType
+                       WSBinding wsb = wsdlPort.Service.ServiceDescription.Bindings [wsdlPort.Binding.Name];
+                       if (wsb == null)
+                               //FIXME
+                               throw new Exception (String.Format ("Binding named {0} not found.", wsdlPort.Binding.Name));
+
+                       SMBinding binding = ImportBinding (wsb);
+
+                       PortType port_type = null;
+                       foreach (WSServiceDescription sd in wsdl_documents) {
+                               port_type = sd.PortTypes [wsb.Type.Name];
+                               if (port_type != null)
+                                       break;
+                       }
+
+                       if (port_type == null)
+                               //FIXME
+                               throw new Exception (String.Format ("PortType named {0} not found.", wsb.Type.Name));
+
+                       ContractDescription contract = ImportContract (port_type);
+                       ServiceEndpoint sep = new ServiceEndpoint (contract);
+
+                       sep.Binding = binding;
+
+                       WsdlContractConversionContext contract_context = new WsdlContractConversionContext (contract, port_type);
+                       WsdlEndpointConversionContext endpoint_context = new WsdlEndpointConversionContext (
+                                       contract_context, sep, wsdlPort, wsb);
+
+                       foreach (IWsdlImportExtension extension in wsdl_extensions)
+                               extension.ImportEndpoint (this, endpoint_context);
+
+                       return sep;
+               }
+
+               public ServiceEndpointCollection ImportEndpoints (
+                       WSBinding binding)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public ServiceEndpointCollection ImportEndpoints (
+                       PortType portType)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public ServiceEndpointCollection ImportEndpoints (
+                       Service service)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/XmlSerializerMessageContractImporter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/XmlSerializerMessageContractImporter.cs
new file mode 100644 (file)
index 0000000..fe489d9
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// XmlSerializerMessageContractImporter.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Text;
+using System.Web.Services.Description;
+using System.Xml;
+using System.Xml.Schema;
+
+namespace System.ServiceModel.Description
+{
+       [MonoTODO]
+       public class XmlSerializerMessageContractImporter
+               : IWsdlImportExtension
+       {
+               void IWsdlImportExtension.BeforeImport (
+                       ServiceDescriptionCollection wsdlDocuments,
+                       XmlSchemaSet xmlSchemas,
+                       ICollection<XmlElement> policy)
+               {
+               }
+
+               void IWsdlImportExtension.ImportContract (WsdlImporter importer,
+                       WsdlContractConversionContext context)
+               {
+               }
+
+               void IWsdlImportExtension.ImportEndpoint (WsdlImporter importer,
+                       WsdlEndpointConversionContext context)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/XmlSerializerOperationBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/XmlSerializerOperationBehavior.cs
new file mode 100644 (file)
index 0000000..5b5361f
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// XmlSerializerOperationBehavior.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Description
+{
+       public class XmlSerializerOperationBehavior
+               : IOperationBehavior, IWsdlExportExtension
+       {
+               XmlSerializerFormatAttribute format;
+               OperationDescription operation;
+
+               public XmlSerializerOperationBehavior (
+                       OperationDescription operation)
+                       : this (operation, null)
+               {
+               }
+
+               public XmlSerializerOperationBehavior (
+                       OperationDescription operation,
+                       XmlSerializerFormatAttribute format)
+               {
+                       if (format == null)
+                               format = new XmlSerializerFormatAttribute ();
+                       this.format = format;
+                       this.operation = operation;
+               }
+
+               [MonoTODO]
+               public Collection<XmlMapping> GetXmlMappings ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public XmlSerializerFormatAttribute XmlSerializerFormatAttribute {
+                       get { return format; }
+               }
+
+               void IOperationBehavior.AddBindingParameters (
+                       OperationDescription description,
+                       BindingParameterCollection parameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IOperationBehavior.ApplyDispatchBehavior (
+                       OperationDescription description,
+                       DispatchOperation dispatch)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IOperationBehavior.ApplyClientBehavior (
+                       OperationDescription description,
+                       ClientOperation proxy)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IOperationBehavior.Validate (
+                       OperationDescription description)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IWsdlExportExtension.ExportContract (
+                       WsdlExporter exporter,
+                       WsdlContractConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IWsdlExportExtension.ExportEndpoint (WsdlExporter exporter,
+                       WsdlEndpointConversionContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Diagnostics/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel.Diagnostics/ChangeLog
new file mode 100644 (file)
index 0000000..c107d3d
--- /dev/null
@@ -0,0 +1,3 @@
+2006-06-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PerformanceCounterScope.cs : new namespace/type in June CTP.
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Diagnostics/PerformanceCounterScope.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Diagnostics/PerformanceCounterScope.cs
new file mode 100644 (file)
index 0000000..71daf76
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// PerformanceCounterScope.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Diagnostics
+{
+       public enum PerformanceCounterScope {
+               Off,
+               ServiceOnly,
+               All
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ActionMessageFilter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ActionMessageFilter.cs
new file mode 100644 (file)
index 0000000..07ecb26
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// System.ServiceModel.ActionMessageFilter.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher {
+       [DataContract]
+       public class ActionMessageFilter : MessageFilter
+       {
+               ReadOnlyCollection<string> actions;
+
+               public ActionMessageFilter (params string [] actions)
+               {
+                       if (actions == null)
+                               throw new ArgumentNullException ("actions");
+
+                       // remove duplicates
+                       List<string> l = new List<string> ();
+
+                       foreach (string action in actions) {
+                               if (action == null)
+                                       throw new ArgumentNullException ("actions");
+                               if (l.Contains (action) == false)
+                                       l.Add (action);
+                       }
+
+                       this.actions = new ReadOnlyCollection<string> (l);
+               }
+
+               protected internal override IMessageFilterTable<FilterData> CreateFilterTable<FilterData> ()
+               {
+                       return new ActionMessageFilterTable<FilterData> ();
+               }
+
+               public override bool Match (Message message)
+               {
+                       foreach (string action in actions)
+                               if (message.Headers.Action == action || action == "*")
+                                       return true;
+
+                       return false;
+               }
+
+               public override bool Match (MessageBuffer buffer)
+               {
+                       bool retval;
+                       Message m = buffer.CreateMessage ();
+                       retval = Match (m);
+                       m.Close ();
+                       
+                       return retval;
+               }
+
+               public ReadOnlyCollection<string> Actions {
+                       get { return actions; }
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ActionMessageFilterTable.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ActionMessageFilterTable.cs
new file mode 100644 (file)
index 0000000..02b74b6
--- /dev/null
@@ -0,0 +1,186 @@
+//
+// System.ServiceModel.ActionMessageFilterTable.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher {
+
+       [DataContract]
+       internal class ActionMessageFilterTable<TFilterData>
+               : IMessageFilterTable<TFilterData>, 
+                 IDictionary<MessageFilter,TFilterData>,
+                 ICollection<KeyValuePair<MessageFilter, TFilterData>>, 
+                 IEnumerable<KeyValuePair<MessageFilter,TFilterData>>, 
+                 IEnumerable
+       {
+               Dictionary<MessageFilter, TFilterData> table;
+               
+               public ActionMessageFilterTable ()
+               {
+                       table = new Dictionary<MessageFilter, TFilterData> ();
+               }
+
+               public void Add (KeyValuePair<MessageFilter, TFilterData> item)
+               {
+                       table.Add (item.Key, item.Value);
+               }
+
+               public void Add (ActionMessageFilter filter, TFilterData data)
+               {
+                       table.Add (filter, data);
+               }
+
+               public void Add (MessageFilter filter, TFilterData data)
+               {
+                       table.Add (filter, data);
+               }
+
+               public void Clear ()
+               {
+                       table.Clear ();
+               }
+
+               public bool Contains (KeyValuePair<MessageFilter, TFilterData> item)
+               {
+                       return table.ContainsKey (item.Key);
+               }
+
+               public bool ContainsKey (MessageFilter filter)
+               {
+                       return table.ContainsKey (filter);
+               }
+
+               public void CopyTo (KeyValuePair<MessageFilter, TFilterData> [] array, int index)
+               {
+                       ((ICollection<KeyValuePair<MessageFilter, TFilterData>>) table).CopyTo (array, index);
+               }
+
+               public IEnumerator<KeyValuePair<MessageFilter, TFilterData>> GetEnumerator ()
+               {
+                       return ((ICollection<KeyValuePair<MessageFilter, TFilterData>>) table).GetEnumerator ();
+               }
+
+               public bool GetMatchingFilter (Message message, out MessageFilter result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingFilter (MessageBuffer buffer, out MessageFilter result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingFilters (Message message, ICollection<MessageFilter> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingFilters (MessageBuffer buffer, ICollection<MessageFilter> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValue (Message message, out TFilterData data)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValue (MessageBuffer buffer, out TFilterData data)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValues (Message message, ICollection<TFilterData> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValues (MessageBuffer buffer, ICollection<TFilterData> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool Remove (ActionMessageFilter filter)
+               {
+                       if (filter == null)
+                               throw new ArgumentNullException ("filter is null.");
+
+                       return table.Remove (filter);
+               }
+
+               public bool Remove (MessageFilter filter)
+               {
+                       if (filter == null)
+                               throw new ArgumentNullException ("filter is null.");
+
+                       return table.Remove (filter);
+               }
+
+               public bool Remove (KeyValuePair<MessageFilter, TFilterData> item)
+               {
+                       return table.Remove (item.Key);
+               }
+
+               IEnumerator IEnumerable.GetEnumerator ()
+               {
+                       return table.GetEnumerator ();
+               }
+
+               public bool TryGetValue (MessageFilter filter, out TFilterData data)
+               {
+                       if (table.ContainsKey (filter)){
+                               data = table [filter];
+                               return true;
+                       }
+
+                       data = default (TFilterData);
+                       return false;
+               }
+
+               public int Count { get { return table.Count; }}
+
+               public bool IsReadOnly { get { return false; }}
+
+               public TFilterData this [MessageFilter filter] {
+                       get { return table [filter]; }
+                       set { table [filter] = value; }
+               }
+
+               public ICollection<MessageFilter> Keys {
+                       get { return table.Keys; }
+               }
+
+               public ICollection<TFilterData> Values {
+                       get { return table.Values; }
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs
new file mode 100644 (file)
index 0000000..bb712c6
--- /dev/null
@@ -0,0 +1,407 @@
+//
+// DefaultMessageOperationFormatter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Eyal Alaluf <eyala@mainsoft.com>
+//
+// Copyright (C) 2005-2007 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2008 Mainsoft Co. http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel.Dispatcher
+{
+       internal abstract class BaseMessagesFormatter
+               : IDispatchMessageFormatter, IClientMessageFormatter
+       {
+               MessageDescriptionCollection messages;
+               bool isAsync;
+               ParameterInfo [] requestMethodParams;
+               ParameterInfo [] replyMethodParams;
+
+               public BaseMessagesFormatter (MessageDescriptionCollection messages)
+               {
+                       this.messages = messages;
+               }
+
+               public BaseMessagesFormatter (OperationDescription desc)
+                       : this (desc.Messages)
+               {
+                       if (desc.SyncMethod != null)
+                       {
+                               isAsync = false;
+                               requestMethodParams = replyMethodParams = desc.SyncMethod.GetParameters ();
+                               return;
+                       }
+                       isAsync = true;
+                       ParameterInfo [] methodParams = desc.BeginMethod.GetParameters ();
+                       requestMethodParams = new ParameterInfo [methodParams.Length - 2];
+                       Array.Copy (methodParams, requestMethodParams, requestMethodParams.Length);
+                       methodParams = desc.EndMethod.GetParameters ();
+                       replyMethodParams = new ParameterInfo [methodParams.Length - 1];
+                       Array.Copy (methodParams, replyMethodParams, replyMethodParams.Length);
+               }
+
+               public static BaseMessagesFormatter Create (OperationDescription desc)
+               {
+                       MethodInfo attrProvider = desc.SyncMethod ?? desc.BeginMethod;
+                       object [] attrs = attrProvider.GetCustomAttributes (typeof (XmlSerializerFormatAttribute), false);
+                       if (attrs != null && attrs.Length > 0)
+                               return new XmlMessagesFormatter (desc, (XmlSerializerFormatAttribute) attrs [0]);
+
+                       attrs = attrProvider.GetCustomAttributes (typeof (DataContractFormatAttribute), false);
+                       DataContractFormatAttribute dataAttr = null;
+                       if (attrs != null && attrs.Length > 0)
+                               dataAttr = (DataContractFormatAttribute) attrs [0];
+                       return new DataContractMessagesFormatter (desc, dataAttr);
+               }
+
+               protected abstract Message PartsToMessage (
+                       MessageDescription md, MessageVersion version, string action, object [] parts);
+               protected abstract object [] MessageToParts (MessageDescription md, Message message);
+
+               public Message SerializeRequest (
+                       MessageVersion version, object [] parameters)
+               {
+                       MessageDescription md = null;
+                       foreach (MessageDescription mdi in messages)
+                               if (mdi.Direction == MessageDirection.Input)
+                                       md = mdi;
+
+                       object [] parts = CreatePartsArray (md.Body);
+                       if (md.MessageType != null)
+                               MessageObjectToParts (md, parameters [0], parts);
+                       else {
+                               int index = 0;
+                               foreach (ParameterInfo pi in requestMethodParams)
+                                       if (!pi.IsOut)
+                                               parts [index++] = parameters [pi.Position];
+                       }
+                       return PartsToMessage (md, version, md.Action, parts);
+               }
+
+               public Message SerializeReply (
+                       MessageVersion version, object [] parameters, object result)
+               {
+                       // use_response_converter
+
+                       MessageDescription md = null;
+                       foreach (MessageDescription mdi in messages)
+                               if (mdi.Direction == MessageDirection.Output)
+                                       md = mdi;
+
+                       object [] parts = CreatePartsArray (md.Body);
+                       if (md.MessageType != null)
+                               MessageObjectToParts (md, result, parts);
+                       else {
+                               if (HasReturnValue (md.Body))
+                                       parts [0] = result;
+                               int index = ParamsOffset (md.Body);
+                               foreach (ParameterInfo pi in replyMethodParams)
+                                       if (pi.IsOut || pi.ParameterType.IsByRef)
+                                               parts [index++] = parameters [pi.Position];
+                       }
+                       string action = version.Addressing == AddressingVersion.None ? null : md.Action;
+                       return PartsToMessage (md, version, action, parts);
+               }
+
+               public void DeserializeRequest (Message message, object [] parameters)
+               {
+                       string action = message.Headers.Action;
+                       MessageDescription md = messages.Find (action);
+                       if (md == null)
+                               throw new ActionNotSupportedException (String.Format ("Action '{0}' is not supported by this operation.", action));
+
+                       object [] parts = MessageToParts (md, message);
+                       if (md.MessageType != null) {
+                               parameters [0] = Activator.CreateInstance (md.MessageType, true);
+                               PartsToMessageObject (md, parts, parameters [0]);
+                       }
+                       else
+                       {
+                               int index = 0;
+                               foreach (ParameterInfo pi in requestMethodParams)
+                                       if (!pi.IsOut)
+                                               parameters [pi.Position] = parts [index++];
+                       }
+               }
+
+               public object DeserializeReply (Message message, object [] parameters)
+               {
+                       MessageDescription md = null;
+                       foreach (MessageDescription mdi in messages)
+                               if (mdi.Direction == MessageDirection.Output)
+                                       md = mdi;
+
+                       object [] parts = MessageToParts (md, message);
+                       if (md.MessageType != null) {
+                               object msgObject = Activator.CreateInstance (md.MessageType, true);
+                               PartsToMessageObject (md, parts, msgObject);
+                               return msgObject;
+                       }
+                       else {
+                               int index = ParamsOffset (md.Body);
+                               foreach (ParameterInfo pi in requestMethodParams)
+                                       if (pi.IsOut || pi.ParameterType.IsByRef)
+                                               parameters [pi.Position] = parts [index++];
+                               return HasReturnValue (md.Body) ? parts [0] : null;
+                       }
+               }
+
+               void PartsToMessageObject (MessageDescription md, object [] parts, object msgObject)
+               {
+                       foreach (MessagePartDescription partDesc in md.Body.Parts)
+                               if (partDesc.MemberInfo is FieldInfo)
+                                       ((FieldInfo) partDesc.MemberInfo).SetValue (msgObject, parts [partDesc.Index]);
+                               else
+                                       ((PropertyInfo) partDesc.MemberInfo).SetValue (msgObject, parts [partDesc.Index], null);
+               }
+
+               void MessageObjectToParts (MessageDescription md, object msgObject, object [] parts)
+               {
+                       foreach (MessagePartDescription partDesc in md.Body.Parts)
+                               if (partDesc.MemberInfo is FieldInfo)
+                                       parts [partDesc.Index] = ((FieldInfo) partDesc.MemberInfo).GetValue (msgObject);
+                               else
+                                       parts [partDesc.Index] = ((PropertyInfo) partDesc.MemberInfo).GetValue (msgObject, null);
+               }
+
+               internal static bool HasReturnValue (MessageBodyDescription desc)
+               {
+                       return desc.ReturnValue != null && desc.ReturnValue.Type != typeof (void);
+               }
+
+               protected static int ParamsOffset (MessageBodyDescription desc)
+               {
+                       return HasReturnValue (desc) ? 1 : 0;
+               }
+
+               protected static object [] CreatePartsArray (MessageBodyDescription desc)
+               {
+                       if (HasReturnValue (desc))
+                               return new object [desc.Parts.Count + 1];
+                       return new object [desc.Parts.Count];
+               }
+       }
+
+       class XmlMessagesFormatter : BaseMessagesFormatter
+       {
+               XmlSerializerFormatAttribute attr;
+               Dictionary<MessageBodyDescription,XmlSerializer> bodySerializers
+                       = new Dictionary<MessageBodyDescription,XmlSerializer> ();
+
+               public XmlMessagesFormatter (OperationDescription desc, XmlSerializerFormatAttribute attr)
+                       : base (desc)
+               {
+                       this.attr = attr;
+               }
+
+               public XmlMessagesFormatter (MessageDescriptionCollection messages, XmlSerializerFormatAttribute attr)
+                       : base (messages)
+               {
+                       this.attr = attr;
+               }
+
+               private XmlReflectionMember CreateReflectionMember (MessagePartDescription partDesc, bool isReturnValue)
+               {
+                       XmlReflectionMember m = new XmlReflectionMember ();
+                       m.IsReturnValue = isReturnValue;
+                       m.MemberName = partDesc.Name;
+                       m.MemberType = partDesc.Type;
+                       return m;
+               }
+
+               protected override Message PartsToMessage (
+                       MessageDescription md, MessageVersion version, string action, object [] parts)
+               {
+                       return Message.CreateMessage (version, action, new XmlBodyWriter (GetSerializer (md.Body), parts));
+               }
+
+               protected override object [] MessageToParts (MessageDescription md, Message message)
+               {
+                       if (message.IsEmpty)
+                               return null;
+                               
+                       XmlDictionaryReader r = message.GetReaderAtBodyContents ();
+                       return (object []) GetSerializer (md.Body).Deserialize (r);
+               }
+
+               // FIXME: Handle ServiceKnownTypes
+               XmlSerializer GetSerializer (MessageBodyDescription desc)
+               {
+                       if (bodySerializers.ContainsKey (desc))
+                               return bodySerializers [desc];
+
+                       int count = desc.Parts.Count + (HasReturnValue (desc) ? 1 : 0);
+                       XmlReflectionMember [] members = new XmlReflectionMember [count];
+
+                       int ind = 0;
+                       if (HasReturnValue (desc))
+                               members [ind++] = CreateReflectionMember (desc.ReturnValue, true);
+
+                       foreach (MessagePartDescription partDesc in desc.Parts)
+                               members [ind++] = CreateReflectionMember (partDesc, false);
+
+                       // FIXME: Register known types into xmlImporter.
+                       XmlReflectionImporter xmlImporter = new XmlReflectionImporter ();
+                       XmlMembersMapping [] partsMapping = new XmlMembersMapping [1];
+                       partsMapping [0] = xmlImporter.ImportMembersMapping (desc.WrapperName, desc.WrapperNamespace, members, true);
+                       bodySerializers [desc] = XmlSerializer.FromMappings (partsMapping) [0];
+                       return bodySerializers [desc];
+               }
+
+               class XmlBodyWriter : BodyWriter
+               {
+                       XmlSerializer serializer;
+                       object body;
+
+                       public XmlBodyWriter (XmlSerializer serializer, object parts)
+                               : base (false)
+                       {
+                               this.serializer = serializer;
+                               this.body = parts;
+                       }
+
+                       [MonoTODO]
+                       protected override BodyWriter OnCreateBufferedCopy (int maxBufferSize)
+                       {
+                               throw new NotSupportedException ();
+                       }
+
+                       protected override void OnWriteBodyContents (XmlDictionaryWriter writer)
+                       {
+                               serializer.Serialize (writer, body);
+                       }
+               }
+       }
+
+       class DataContractMessagesFormatter : BaseMessagesFormatter
+       {
+               DataContractFormatAttribute attr;
+
+               public DataContractMessagesFormatter (OperationDescription desc, DataContractFormatAttribute attr)
+                       : base (desc)
+               {
+                       this.attr = attr;
+               }
+
+               public DataContractMessagesFormatter (MessageDescriptionCollection messages, DataContractFormatAttribute attr)
+                       : base (messages)
+               {
+                       this.attr = attr;
+               }
+
+               Dictionary<MessagePartDescription, XmlObjectSerializer> serializers
+                       = new Dictionary<MessagePartDescription,XmlObjectSerializer> ();
+
+               protected override Message PartsToMessage (
+                       MessageDescription md, MessageVersion version, string action, object [] parts)
+               {
+                       return Message.CreateMessage (version, action, new DataContractBodyWriter (md.Body, this, parts));
+               }
+
+               protected override object [] MessageToParts (
+                       MessageDescription md, Message message)
+               {
+                       if (message.IsEmpty)
+                               return null;
+
+                       int offset = ParamsOffset (md.Body);
+                       object [] parts = CreatePartsArray (md.Body);
+
+                       XmlDictionaryReader r = message.GetReaderAtBodyContents ();
+                       if (md.Body.WrapperName != null)
+                               r.ReadStartElement (md.Body.WrapperName, md.Body.WrapperNamespace);
+
+                       for (r.MoveToContent (); r.NodeType == XmlNodeType.Element; r.MoveToContent ()) {
+                               XmlQualifiedName key = new XmlQualifiedName (r.LocalName, r.NamespaceURI);
+                               MessagePartDescription rv = md.Body.ReturnValue;
+                               if (rv != null && rv.Name == key.Name && rv.Namespace == key.Namespace)
+                                       parts [0] = GetSerializer (md.Body.ReturnValue).ReadObject (r);
+                               else if (md.Body.Parts.Contains (key)) {
+                                       MessagePartDescription p = md.Body.Parts [key];
+                                       parts [p.Index + offset] = GetSerializer (p).ReadObject (r);
+                               }
+                               else // Skip unknown elements
+                                       r.Skip ();
+                       }
+
+                       if (md.Body.WrapperName != null && !r.EOF)
+                               r.ReadEndElement ();
+
+                       return parts;
+               }
+
+               // FIXME: Handle ServiceKnownTypes
+               XmlObjectSerializer GetSerializer (MessagePartDescription partDesc)
+               {
+                       if (!serializers.ContainsKey (partDesc))
+                               serializers [partDesc] = new DataContractSerializer (
+                                       partDesc.Type, partDesc.Name, partDesc.Namespace);
+                       return serializers [partDesc];
+               }
+
+               class DataContractBodyWriter : BodyWriter
+               {
+                       MessageBodyDescription desc;
+                       object [] parts;
+                       DataContractMessagesFormatter parent;
+
+                       public DataContractBodyWriter (MessageBodyDescription desc, DataContractMessagesFormatter parent, object [] parts)
+                               : base (false)
+                       {
+                               this.desc = desc;
+                               this.parent = parent;
+                               this.parts = parts;
+                       }
+
+                       protected override void OnWriteBodyContents (XmlDictionaryWriter writer)
+                       {
+                               int offset = HasReturnValue (desc) ? 1 : 0;
+                               if (desc.WrapperName != null)
+                                       writer.WriteStartElement (desc.WrapperName, desc.WrapperNamespace);
+                               if (HasReturnValue (desc))
+                                       WriteMessagePart (writer, desc, desc.ReturnValue, parts [0]);
+                               foreach (MessagePartDescription partDesc in desc.Parts)
+                                       WriteMessagePart (writer, desc, partDesc, parts [partDesc.Index + offset]);
+                               if (desc.WrapperName != null)
+                                       writer.WriteEndElement ();
+                       }
+
+                       void WriteMessagePart (
+                               XmlDictionaryWriter writer, MessageBodyDescription desc, MessagePartDescription partDesc, object obj)
+                       {
+                               parent.GetSerializer (partDesc).WriteObject (writer, obj);
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessor.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessor.cs
new file mode 100644 (file)
index 0000000..a2ba265
--- /dev/null
@@ -0,0 +1,84 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.ServiceModel;\r
+using System.ServiceModel.Channels;\r
+using System.ServiceModel.Security;\r
+using System.ServiceModel.Security.Tokens;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       internal class BaseRequestProcessor\r
+       {\r
+               HandlersChain initialize_handlers_chain = new HandlersChain();\r
+               HandlersChain process_handlers_chain = new HandlersChain ();\r
+               HandlersChain error_handlers_chain = new HandlersChain ();\r
+               HandlersChain finalize_handlers_chain = new HandlersChain ();\r
+\r
+               protected BaseRequestProcessor () { }\r
+\r
+               protected virtual void ProcessRequest (MessageProcessingContext mrc)\r
+               {\r
+                       initialize_handlers_chain.ProcessRequestChain (mrc);\r
+\r
+                       using (new OperationContextScope (mrc.OperationContext)) {\r
+                               try {\r
+                                       process_handlers_chain.ProcessRequestChain (mrc);\r
+                               }\r
+                               catch (Exception e) {\r
+                                       Console.WriteLine ("Exception " + e.Message + " " + e.StackTrace);\r
+                                       mrc.ProcessingException = e;\r
+                                       error_handlers_chain.ProcessRequestChain (mrc);\r
+                               }\r
+                               finally {\r
+                                       finalize_handlers_chain.ProcessRequestChain (mrc);\r
+                               }\r
+                       }\r
+               }\r
+\r
+               public HandlersChain InitializeChain\r
+               {\r
+                       get { return initialize_handlers_chain; }\r
+               }\r
+\r
+               public HandlersChain ProcessingChain\r
+               {\r
+                       get { return process_handlers_chain; }\r
+               }\r
+\r
+               public HandlersChain ErrorChain\r
+               {\r
+                       get { return error_handlers_chain; }\r
+               }\r
+\r
+               public HandlersChain FinalizationChain\r
+               {\r
+                       get { return finalize_handlers_chain; }\r
+               }               \r
+       }\r
+\r
+       internal class HandlersChain\r
+       {\r
+               BaseRequestProcessorHandler chain;\r
+\r
+               public void ProcessRequestChain (MessageProcessingContext mrc)\r
+               {\r
+                       if (chain != null)\r
+                               chain.ProcessRequestChain (mrc);\r
+               }\r
+\r
+               public HandlersChain AddHandler (BaseRequestProcessorHandler handler)\r
+               {\r
+                       if (chain == null) {\r
+                               chain = handler;\r
+                       }\r
+                       else {\r
+                               BaseRequestProcessorHandler current = chain;\r
+                               while (current.Next != null)\r
+                                       current = current.Next;\r
+                               current.Next = handler;\r
+                       }\r
+                       return this;\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessorHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseRequestProcessorHandler.cs
new file mode 100644 (file)
index 0000000..b4e8954
--- /dev/null
@@ -0,0 +1,28 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel;\r
+using System.ServiceModel.Channels;\r
+\r
+namespace System.ServiceModel.Dispatcher \r
+{      \r
+       internal abstract class BaseRequestProcessorHandler \r
+       {\r
+               BaseRequestProcessorHandler next;               \r
+\r
+               public virtual void ProcessRequestChain (MessageProcessingContext mrc)\r
+               {\r
+                       if (!ProcessRequest (mrc) && next != null ) {                           \r
+                               next.ProcessRequestChain (mrc);\r
+                       }\r
+               }\r
+\r
+               public BaseRequestProcessorHandler Next\r
+               {\r
+                       get { return next; }\r
+                       set { next = value; }\r
+               }\r
+\r
+               protected abstract bool ProcessRequest (MessageProcessingContext mrc);\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog
new file mode 100644 (file)
index 0000000..7c4614f
--- /dev/null
@@ -0,0 +1,432 @@
+2008-06-18  Noam Lampert <noaml@mainsoft.com>
+
+       * ChannelDispatcher.cs: Avoid aborting host process on faulty input message.
+
+2008-05-22  Noam Lampert <noaml@mainsoft.com>
+
+       * OperationInvokeHandler.cs: Only return fault reply when TargetInvocation occured (not other internal
+         errors. Serlialize the correct (inner) exception.
+         
+2008-05-22  Roei Erez  <roeie@mainsoft.com>
+       * fix ContractDescription.GetContract implementation
+       * Refactor Request processing
+       * Add support for message inspectors
+       * Add support for InstanceContextProvider & InstanceProvider, including lifecycles events
+       like: ReleaseServiceInstance, Open, Close...
+       * Add relevant test cases.
+
+2008-05-01  Eyal Alaluf <eyala@mainsoft.com>
+
+       * BaseMessagesFormatter.cs: Handle methods with out parameters that return
+         void.
+       * DispatchOperation.cs, IOperationInvoker.cs: Simplify method invocation.
+
+2008-04-22  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * DispatchOperation.cs: removed dependency on OperationDescription, 
+       allows usage of custom channel dispatcher without endpoint was explicitly 
+       built
+
+2008-04-22  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * MexInstanceContextProvider.cs - remove unused code.
+
+2008-04-21  Roei Erez <roeie@mainsoft.com>
+
+       * ChannelDispatcher.cs - Change order of Dispatcher shutdown
+
+2008-04-17  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * ChannelDispatcher.cs, EndpointDispatcher.cs: removed dependency on 
+       ServiceDescription/ServiceEndpoint, allows usage of channel dispatcher
+       without endpoint was explicitly built
+       * EndpointDispatcher.cs: Filters lazy evaluation, refactored
+       communication processing, logic moved to channel dispatcher
+
+2008-04-17  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * ActionMessageFilter.cs: fixed Match, match for "*" action
+
+2008-04-17  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * DispatchOperation.cs: fixed ProcessRequest, fault message creation
+
+2008-04-10  Eyal Alaluf <eyala@mainsoft.com>
+
+       * DefaultMessageOperationFormatter.cs: Moved to BaseMessagesFormatter.cs.
+       * BaseMessagesFormatter.cs: Refactored so typed messages uses the classes
+         defined here instead of the other way around.
+         Added support for by-ref and out parameters.
+         Added support for XmlSerializerFormat serializaters..
+       * DispatchOperation.cs, ClientOperation.cs: Use BaseMessagesFormatter.Create
+
+2008-04-09  Roei Erez <roeie@mainsoft.com>
+
+       * Remove unused nethod from previous commit
+
+2008-04-08  Roei Erez <roeie@mainsoft.com>
+
+       * ChannelDispatcher.cs
+         - fix 'Attach' logic
+         - Add support for Endpoints property
+         - Remove the hack of 'endpoint_dispatcher' field
+       * ChannelDispatcherCollection.cs
+         - Add support for 'Attach' 'Detach'
+       * EndpointDispatcher.cs
+         - By default create MatchAllMessageFilter.
+
+2008-02-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointDispatcher.cs : we don't need AddressFilter workaround
+         from Feb. 14 anymore.
+
+2008-02-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointDispatcher.cs : after service method call, apply outgoing
+         headers and properties to the returned message.
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs : populate DispatchOperations before applying
+         IEndpointBehaviors so that those behaviors can modify dispatch
+         operations.
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchOperation.cs : Action may be null. For such cases, use 
+         MessageDirection to determine the message description.
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressMessageFilter.cs : implement Match(MessageBuffer).
+         Use ordinal string comparison.
+       * PrefixEndpointAddressMessageFilter.cs : implement Match() (both).
+
+2008-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointDispatcher.cs : moved AddressFilter application only when
+         DispatchOperation was not selected (it is sort of workaround).
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs : Fixed SerializeReply() for
+         message contract type to process result, not the parameter.
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SingletonInstanceContextProvider.cs : new.
+
+2007-08-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs : dependent changes on
+         message serializer and deserializer.
+
+2007-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs :
+         use it for deserialization as well.
+
+2007-03-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs : consider message contracts
+         during message serialization/deserialization.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointDispatcher.cs : now dispatcher-side foundation for token
+         negotiation is ready. Handle negotiation message on its own way.
+       * DispatchOperation.cs : instead of returning irrelevant SOAP Fault,
+         simply raise an error and let FaultConverter do better work.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointDispatcher.cs : use ErrorHandlers when error was raised.
+         Handle exceptions to make into SOAP Fault, using FaultConverter.
+       * ChannelDispatcher.cs : simply get ServiceEndpoint at Attach().
+       * ChannelDispatcherBase.cs : removed MonoTODOs.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs, DispatchRuntime.cs, EndpointDispatcher.cs :
+         moved most of request/input processing to EndpointDispatcher.cs.
+         Also, ChannelDispatcher now contains code for behavior
+         initialization.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs : some cosmetic refactoring on error handling
+         with comments.
+
+2006-12-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs, DispatchRuntime.cs, DispatchOperation.cs :
+         Support OperationContext and OperationContextScope with
+         ServiceRuntimeChannel as its .ctor() input.
+
+2006-12-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchRuntime.cs : raise an error when the DispatchOperation
+         returned null Message.
+
+2006-10-18  Ankit Jain  <jankit@novell.com>
+
+       * MexInstanceContextProvider.cs (HttpGetInstanceContextProvider): New.
+       * DispatchOperation.cs (DoProcessRequest): InstanceContext returned by
+       the provider can be null.
+       * EndpointAddressMessageFilter.cs (Match): Handle IncludeHostNameInComparison.
+
+2006-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchOperation.cs : slightly improved exception message.
+
+2006-10-06  Ankit Jain  <jankit@novell.com>
+
+       * ChannelDispatcher.cs (ListenerLoopManager.StartLoopCore):
+       ReceiveRequest can return null.
+
+2006-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntime.cs : added MaxFaultSize.
+
+2006-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs : don't reject anonymous and null To.
+
+2006-10-04  Ankit Jain  <jankit@novell.com>
+
+       * ChannelDispatcher.cs (ListenerLoopManager.StartLoopCore): Reply with a 
+       Fault message if message's To doesn't match the endpoint.
+       (ListenerLoopManager.CreateDestinationUnreachable): New.
+       * IInstanceContextProvider.cs: New.
+       * MexInstanceContextProvider.cs: New. InstanceContextProvider for
+       MetadataExchange.
+       (MetadataExchange): Implementation of IMetadataExchange.
+       * DispatchRuntime.cs (InstanceContextProvider): Add missing property.
+       * DispatchOperation.cs (DoProcessRequest): Use InstanceContextProvider
+       if available to obtain service instance.
+       * EndpointDispatcher.cs (.ctor): Set AddressFilter to EndpointAddressMessageFilter.
+       * EndpointAddressMessageFilter.cs (Match): Implement.
+
+2006-10-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntime.cs : added InteractiveChannelInitializer.
+
+2006-09-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchOperation.cs : removed extra comment.
+
+2006-09-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchOperation.cs : workaround to send exception detail.
+
+2006-09-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ICallContextInitializer.cs : new file.
+       * DispatchOperation.cs : use above.
+         Not sure if it works correctly though.
+
+2006-08-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchOperation.cs : when there is an error during
+         ProcessRequest(), wrap the exception with MessageFault and return
+         a fault message.
+
+2006-08-10  Duncan Mak  <duncan@novell.com>
+
+       * ExceptionHandler.cs: New file.
+
+       * ServiceThrottle.cs (MaxConnections): Renamed to
+       MaxConcurrentSessions.
+       (MaxInstances): Renamed to MaxConcurrentInstances.
+
+2006-07-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IInteractiveChannelInitializer.cs : new file.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IErrorHandler.cs : API updates.
+
+2006-07-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchRuntime.cs :
+         it was selecting UnhandledOperation unexpectedly.
+       * DispatchOperation.cs : added FIXME comment.
+
+2006-07-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs : Remove hack for non-
+         (de)serializing Message-based methods. They are now moved to
+         ClientBase and ServiceHostBase to explicitly set
+         [Serialize|Deserialize][Request|Reply].
+
+2006-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs : don't omit action on
+         SerializeRequest. Do it in SerializeReply.
+
+2006-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs : When addressing version is
+         None, then omit reply action. This logic is moved from MessageImpl.
+
+2006-07-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs :
+         return message, not parameter[0]. Removed some extra FIXMEs.
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs : when the parameter is
+         Message and the return type is Message, then do not use
+         XmlObjectSerializer.
+
+2006-07-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PrefixEndpointAddressMessageFilter.cs, FaultContractInfo.cs :
+         new types in June CTP.
+       * ISharedInstanceSessionLifetime.cs:
+         removed in June CTP.
+       * ChannelDispatcher.cs, MatchAllMessageFilter.cs, DispatchRuntime.cs,
+         DispatchOperation.cs, ClientRuntime.cs, MatchNoneMessageFilter.cs,
+         ClientOperation.cs, ActionMessageFilterTable.cs,
+         EndpointAddressMessageFilterTable.cs :
+         several minor fixes for June CTP.
+
+2006-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchOperation.cs : MessageFault.DefaultAction vanished.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IClientFormatter.cs, IClientMessageFormatter.cs,
+         IDispatchFormatter.cs, IDispatchMessageFormatter.cs :
+         renamed former to latter, for each.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs, DispatchRuntime.cs :
+         IRequestContext -> RequestContext.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs, IDispatchFormatter.cs,
+         DefaultMessageOperationFormatter.cs, IClientFormatter.cs,
+         DispatchOperation.cs, ClientOperation.cs :
+         some June CTP updates.
+
+2006-06-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs : implement SerializeRequest()
+         and DeserializeReply(). Now simple ClientBase<T> sample is working.
+
+2006-06-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientOperation.cs : added GetFormatter() to support message
+         serialization/deserialization.
+       * DispatchOperation.cs : made some internal members private
+         (they are exposed extraneously). Commented out debugging code.
+
+2006-06-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs : In SerializeReply(), use
+         custom BodyWriter() and use MessagePartDescription names. Now
+         return value and other (ref/out) parameters could be equivalently
+         serialized (at this method; to support them more love is needed).
+
+2006-06-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs :
+         Action for response is null (though it is likely conditional).
+
+2006-06-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultMessageOperationFormatter.cs :
+         true DeserializeReply implementation using Message.CreateMessage()
+         with DataContractSerializer (not complete though).
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs, DispatchOperation.cs,
+         ChannelDispatcherBase.cs :
+         some updated API fixes.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointDispatcher.cs : moved from Sys.ServiceModel.
+
+2006-04-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntime.cs : some minor collection instantiation and comments.
+
+2006-04-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchOperation.cs : Implemented internal MessageVersion.
+         hacked instance provision by using Activator.CreateInstance.
+       * DefaultMessageOperationFormatter.cs : fixed DeserializeRequest to
+         be functional. Implemented SerializeReply.
+
+2006-04-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchOperation.cs : return SOAP fault message for nonexistent
+         request Action.
+       * DefaultMessageOperationFormatter.cs : implemented
+         DeserializeRequest(), though there is no working example.
+
+2006-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchOperation.cs : implemented logic to acquire
+         OperationDescription. Added code for default IDispatchFormatter
+         implementation.
+       * DispatchRuntime.cs : fix warning.
+       * DefaultMessageOperationFormatter.cs : new file, for default
+         IDispatchFormatter implementation (not done yet).
+       * ChannelDispatcher.cs : create EndpointDispatcher in Attach and
+         bind to this instance.
+
+2006-03-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcherCollection.cs : added parameterless ctor().
+       * ChannelDispatcher.cs DispatchRuntime.cs DispatchOperation.cs :
+         Set some initial field values as proved in unit tests.
+         Request/input processing is still ongoing.
+
+2006-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs
+         DispatchRuntime.cs
+         DispatchOperation.cs : added request/input processing code.
+
+2006-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs : Get "AcceptChannel" method without ambiguity.
+
+2006-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs : Added request-processing code.
+
+2006-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDispatcher.cs : implement Attach() and Detach() more to work.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchBehavior.cs : 
+         Dependent fixes for System.IdentityModel reorgainzation.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FilterNodeQuotaExceededException.cs
+         FilterInvalidBodyAccessException.cs DispatchBehavior.cs
+         DispatchOperation.cs NavigatorInvalidBodyAccessException.cs
+         MatchNoneFilter.cs ActionFilter.cs
+         MultipleFilterMatchesException.cs Filter.cs
+         IInstanceContextInitializer.cs XPathFilter.cs
+         IDispatchOperationSelector.cs MatchAllFilter.cs
+         ActionFilterTable.cs EndpointAddressFilter.cs FilterTable.cs
+         EndpointFilterTable.cs XPathMessageContext.cs
+         IEndpointDispatcher.cs ProxyBehavior.cs
+         ProxyOperation.cs XPathFilterTable.cs
+         EndpointAddressFilterTable.cs InvalidBodyAccessException.cs
+         IFilterTable.cs IOperationInvoker.cs :
+         moved from System.ServiceModel due to the API changes.
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs
new file mode 100644 (file)
index 0000000..dc6c3f8
--- /dev/null
@@ -0,0 +1,532 @@
+//
+// ChannelDispatcher.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Reflection;
+using System.ServiceModel.Channels;
+using System.Threading;
+using System.Transactions;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public class ChannelDispatcher : ChannelDispatcherBase
+       {
+               ServiceHostBase host;
+
+               string binding_name;            
+               Collection<IErrorHandler> error_handlers
+                       = new Collection<IErrorHandler> ();
+               IChannelListener listener;
+               IDefaultCommunicationTimeouts timeouts;
+               MessageVersion message_version;
+               bool receive_sync, include_exception_detail_in_faults,
+                       manual_addressing, is_tx_receive;
+               int max_tx_batch_size;
+               SynchronizedCollection<IChannelInitializer> initializers
+                       = new SynchronizedCollection<IChannelInitializer> ();
+               IsolationLevel tx_isolation_level;
+               TimeSpan tx_timeout;
+               ServiceThrottle throttle;
+
+               Guid identifier = Guid.NewGuid ();
+               ManualResetEvent async_event = new ManualResetEvent (false);
+               EndpointListenerAsyncResult async_result;
+
+               ListenerLoopManager loop_manager;
+               SynchronizedCollection<EndpointDispatcher> _endpoints;
+
+               [MonoTODO ("get binding info from config")]
+               public ChannelDispatcher (IChannelListener listener)                    
+               {
+                       if (listener == null)
+                               throw new ArgumentNullException ("listener");
+                       Init (listener, null, null);
+               }
+
+               public ChannelDispatcher (
+                       IChannelListener listener, string bindingName)
+                       : this (listener, bindingName, 
+                               DefaultCommunicationTimeouts.Instance)
+               {
+               }
+
+               public ChannelDispatcher (
+                       IChannelListener listener, string bindingName,
+                       IDefaultCommunicationTimeouts timeouts)
+               {
+               if (listener == null)
+                               throw new ArgumentNullException ("listener");
+                       if (bindingName == null)
+                               throw new ArgumentNullException ("bindingName");
+                       if (timeouts == null)
+                               throw new ArgumentNullException ("timeouts");
+                       Init (listener, bindingName, timeouts);
+               }
+
+               private void Init (IChannelListener listener, string bindingName,
+                       IDefaultCommunicationTimeouts timeouts) {
+                       this.listener = listener;
+                       this.binding_name = bindingName;
+                       this.timeouts = timeouts;
+                       _endpoints = new SynchronizedCollection<EndpointDispatcher> ();
+               }
+
+               public string BindingName {
+                       get { return binding_name; }
+               }
+
+               public SynchronizedCollection<IChannelInitializer> ChannelInitializers {
+                       get { return initializers; }
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return timeouts.CloseTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return timeouts.OpenTimeout; }
+               }
+
+               public Collection<IErrorHandler> ErrorHandlers {
+                       get { return error_handlers; }
+               }
+
+               public SynchronizedCollection<EndpointDispatcher> Endpoints {
+                       get {                           
+                               return _endpoints;
+                       }
+               }
+
+               [MonoTODO]
+               public bool IsTransactedAccept {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public bool IsTransactedReceive {
+                       get { return is_tx_receive; }
+                       set { is_tx_receive = value; }
+               }
+
+               public bool ManualAddressing {
+                       get { return manual_addressing; }
+                       set { manual_addressing = value; }
+               }
+
+               public int MaxTransactedBatchSize {
+                       get { return max_tx_batch_size; }
+                       set { max_tx_batch_size = value; }
+               }
+
+               public override ServiceHostBase Host {
+                       get { return host; }
+               }
+
+               public override IChannelListener Listener {
+                       get { return listener; }
+               }
+
+               public MessageVersion MessageVersion {
+                       get { return message_version; }
+                       set { message_version = value; }
+               }
+
+               public bool ReceiveSynchronously {
+                       get { return receive_sync; }
+                       set { receive_sync = value; }
+               }
+
+               public bool IncludeExceptionDetailInFaults {
+                       get { return include_exception_detail_in_faults; }
+                       set { include_exception_detail_in_faults = value; }
+               }
+
+               public ServiceThrottle ServiceThrottle {
+                       get { return throttle; }
+                       set { throttle = value; }
+               }
+
+               public IsolationLevel TransactionIsolationLevel {
+                       get { return tx_isolation_level; }
+                       set { tx_isolation_level = value; }
+               }
+
+               public TimeSpan TransactionTimeout {
+                       get { return tx_timeout; }
+                       set { tx_timeout = value; }
+               }
+
+               protected internal override void Attach (ServiceHostBase host)
+               {
+                       this.host = host;
+               }               
+
+               public override void CloseInput ()
+               {
+                       if (State == CommunicationState.Closed)
+                               return;
+                       try {
+                               try {
+                                       listener.Close ();
+                               } finally {
+                                       listener = null;
+                               }
+                       } finally {
+                               if (async_result != null)
+                                       async_result.Complete (false);
+                       }
+               }
+
+               protected internal override void Detach (ServiceHostBase host)
+               {                       
+                       this.host = null;                       
+               }
+
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       async_event.Reset ();
+                       async_result = new CloseAsyncResult (
+                               async_event, identifier, timeout,
+                               callback, state);
+                       return async_result;
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       async_event.Reset ();
+                       async_result = new OpenAsyncResult (
+                               async_event, identifier, timeout,
+                               callback, state);
+                       return async_result;
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       ProcessClose (timeout);
+               }
+
+               protected override void OnClosed ()
+               {
+                       if (host != null)
+                               host.ChannelDispatchers.Remove (this);
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       if (result == null)
+                               throw new ArgumentNullException ("result");
+                       OpenAsyncResult or = result as OpenAsyncResult;
+                       if (or == null)
+                               throw new ArgumentException ("Pass an IAsyncResult instance that is returned from BeginOpen().");
+                       CloseInput ();
+                       or.AsyncWaitHandle.WaitOne ();
+               }
+
+               [MonoTODO ("this is not a real async method.")]
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       if (result == null)
+                               throw new ArgumentNullException ("result");
+                       OpenAsyncResult or = result as OpenAsyncResult;
+                       if (or == null)
+                               throw new ArgumentException ("Pass an IAsyncResult instance that is returned from BeginOpen().");
+                       or.AsyncWaitHandle.WaitOne ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       ProcessOpen (timeout);
+               }
+
+               [MonoTODO ("what to do here?")]
+               protected override void OnOpening ()
+               {
+               }
+
+               [MonoTODO ("what to do here?")]
+               protected override void OnOpened ()
+               {
+               }
+
+               void ProcessClose (TimeSpan timeout)
+               {
+                       if (loop_manager != null)
+                               loop_manager.Stop ();
+                       CloseInput ();
+               }
+
+               void ProcessOpen (TimeSpan timeout)
+               {
+                       if (Host == null || MessageVersion == null)
+                               throw new InvalidOperationException ("Service host is not attached to this ChannelDispatcher.");                        
+                       try {
+                               // FIXME: hack, just to make it runnable
+                               listener.Open (timeout);
+                               loop_manager = new ListenerLoopManager (this);
+                               loop_manager.Start ();
+                       } finally {
+                               if (async_result != null)
+                                       async_result.Complete (false);
+                       }
+               }
+
+               bool IsMessageMatchesEndpointDispatcher (Message req, EndpointDispatcher endpoint)
+               {
+                       Uri to = req.Headers.To;
+                       if (to == null)
+                               return false;
+                       if (to.AbsoluteUri == Constants.WsaAnonymousUri)
+                               return false;
+                       return endpoint.AddressFilter.Match (req) && endpoint.ContractFilter.Match (req);
+               }
+                
+               void HandleError (Exception ex)
+               {
+                       foreach (IErrorHandler handler in ErrorHandlers)
+                               if (handler.HandleError (ex))
+                                       break;
+               }
+
+               class ListenerLoopManager
+               {
+                       ChannelDispatcher owner;
+                       AutoResetEvent handle;
+                       IReplyChannel reply;
+                       IInputChannel input;
+                       bool loop;
+                       Thread loop_thread;
+
+                       public ListenerLoopManager (ChannelDispatcher owner)
+                       {
+                               this.owner = owner;
+                               MethodInfo mi = owner.Listener.GetType ().GetMethod ("AcceptChannel", Type.EmptyTypes);
+                               object channel = mi.Invoke (owner.Listener, new object [0]);
+                               reply = channel as IReplyChannel;
+                               input = channel as IInputChannel;
+                       }
+
+                       public void Start ()
+                       {
+                               if (loop_thread == null)
+                                       loop_thread = new Thread (new ThreadStart (StartLoop));
+                               loop_thread.Start ();
+                       }
+
+                       public void Stop ()
+                       {
+                               StopLoop ();
+                               owner.Listener.Close ();
+                               if (loop_thread.IsAlive)
+                                       loop_thread.Abort ();
+                               loop_thread = null;
+                       }
+
+                       void StartLoop ()
+                       {
+                               try {
+                                       StartLoopCore ();
+                               } catch (ThreadAbortException) {
+                                       Thread.ResetAbort ();
+                               }
+                       }
+
+                       void StartLoopCore ()
+                       {
+                               loop = true;
+
+                               // FIXME: use async WaitForBlah() method so
+                               // that we can stop them at our own will.
+                               
+                               //FIXME: The logic here should be entirely different as follows:
+                               //1. Get the message
+                               //2. Get the appropriate EndPointDispatcher that can handle the message
+                               //   which is done using the filters (AddressFilter, ContractFilter).
+                               //3. Let the appropriate endpoint handle the request.
+
+                               if (reply != null) {
+                                       while (loop) {
+                                               if (reply.WaitForRequest (owner.timeouts.ReceiveTimeout))                                                       
+                                                       ProcessRequest ();
+                                       }
+                               } else if (input != null) {
+                                       while (loop) {
+                                               if (input.WaitForMessage (owner.timeouts.ReceiveTimeout))
+                                                       ProcessInput ();
+                                       }
+                               }
+                       }
+
+                       void sendEndpointNotFound (RequestContext rc, EndpointNotFoundException ex) 
+                       {
+                               try {
+
+                                       MessageVersion version = rc.RequestMessage.Version;
+                                       FaultCode fc = new FaultCode ("DestinationUnreachable", version.Addressing.Namespace);
+                                       Message res = Message.CreateMessage (version, fc, "error occured", rc.RequestMessage.Headers.Action);
+                                       rc.Reply (res);
+                               }
+                               catch (Exception e) { }
+                       }
+
+                       void ProcessRequest ()
+                       {
+                               RequestContext rc = null;
+                               try {
+                                       rc = reply.ReceiveRequest (owner.timeouts.ReceiveTimeout);
+                                       if (rc == null)
+                                               throw new InvalidOperationException ("The reply channel didn't return RequestContext");
+
+                                       EndpointDispatcher candidate = FindEndpointDispatcher (rc.RequestMessage);
+                                       new InputOrReplyRequestProcessor (candidate.DispatchRuntime, reply, owner.timeouts).
+                                               ProcessReply (rc);
+                               }
+                               catch (EndpointNotFoundException ex) {
+                                       sendEndpointNotFound (rc, ex);
+                               }
+                       }
+
+                       void ProcessInput ()
+                       {
+                               Message message = input.Receive ();
+                               EndpointDispatcher candidate = null;
+
+                               try {
+                                       candidate = FindEndpointDispatcher (message);
+                                       new InputOrReplyRequestProcessor (candidate.DispatchRuntime, reply, owner.timeouts).
+                                               ProcessInput(message);
+                               }
+                               catch (EndpointNotFoundException ex) {
+                                       // silently ignore
+                               }
+                       }
+
+                       EndpointDispatcher FindEndpointDispatcher (Message message) {
+                               EndpointDispatcher candidate = null;
+                               for (int i = 0; i < owner.Endpoints.Count; i++) {
+                                       if (owner.IsMessageMatchesEndpointDispatcher (message, owner.Endpoints [i])) {
+                                               candidate = owner.Endpoints [i];
+                                               break;
+                                       }
+                               }
+                               if (candidate == null)
+                                       throw new EndpointNotFoundException (String.Format ("The request message has the target '{0}' which is not reachable in this service contract", message.Headers.To));
+                               return candidate;
+                       }
+
+                       void StopLoop ()
+                       {
+                               loop = false;
+                               // FIXME: send manual stop for reply or input channel.
+                       }
+               }
+
+               #region AsyncResult classes
+
+               class CloseAsyncResult : EndpointListenerAsyncResult
+               {
+                       public CloseAsyncResult (ManualResetEvent asyncEvent,
+                               Guid identifier, TimeSpan timeout,
+                               AsyncCallback callback, object state)
+                               : base (asyncEvent, identifier, timeout,
+                                       callback, state)
+                       {
+                       }
+               }
+
+               class OpenAsyncResult : EndpointListenerAsyncResult
+               {
+                       public OpenAsyncResult (ManualResetEvent asyncEvent,
+                               Guid identifier, TimeSpan timeout,
+                               AsyncCallback callback, object state)
+                               : base (asyncEvent, identifier, timeout,
+                                       callback, state)
+                       {
+                       }
+               }
+
+               abstract class EndpointListenerAsyncResult : IAsyncResult
+               {
+                       ManualResetEvent async_event;
+                       Guid identifier;
+                       TimeSpan timeout;
+                       AsyncCallback callback;
+                       object state;
+                       bool completed, completed_async;
+
+                       public EndpointListenerAsyncResult (
+                               ManualResetEvent asyncEvent,
+                               Guid identifier, TimeSpan timeout,
+                               AsyncCallback callback, object state)
+                       {
+                               async_event = asyncEvent;
+                               this.identifier = identifier;
+                               this.timeout = timeout;
+                               this.callback = callback;
+                               this.state = state;
+                       }
+
+                       public WaitHandle AsyncWaitHandle {
+                               get { return async_event; }
+                       }
+
+                       public bool IsCompleted {
+                               get { return completed; }
+                       }
+
+                       public TimeSpan Timeout {
+                               get { return timeout; }
+                       }
+
+                       public void Complete (bool async)
+                       {
+                               completed_async = async;
+                               if (callback != null)
+                                       callback (this);
+                               async_event.Set ();
+                       }
+
+                       public object AsyncState {
+                               get { return state; }
+                       }
+
+                       public bool CompletedSynchronously {
+                               get { return completed_async; }
+                       }
+               }
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcherBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcherBase.cs
new file mode 100644 (file)
index 0000000..d9130ab
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// ChannelDispatcherBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Reflection;
+using System.ServiceModel.Channels;
+using System.Threading;
+using System.ServiceModel;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public abstract class ChannelDispatcherBase : CommunicationObject
+       {
+               public abstract IChannelListener Listener { get; }
+
+               public abstract ServiceHostBase Host { get; }
+
+               protected internal virtual void Attach (ServiceHostBase host)
+               {
+               }
+
+               public virtual void CloseInput ()
+               {
+               }
+
+               protected internal virtual void Detach (ServiceHostBase host)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcherCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcherCollection.cs
new file mode 100644 (file)
index 0000000..1a0461b
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// ChannelDispatcherCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public class ChannelDispatcherCollection
+               : SynchronizedCollection<ChannelDispatcherBase>
+       {
+               private ServiceHostBase _service;
+
+               internal ChannelDispatcherCollection (ServiceHostBase service)
+               {
+                       _service = service;
+               }
+
+               internal ChannelDispatcherCollection (
+                       ChannelDispatcherBase [] listeners)
+                       : base (listeners)
+               {
+               }
+
+               [MonoTODO ("What to do here?")]
+               protected override void ClearItems ()
+               {                       
+                       ChannelDispatcherBase[] channels = this.InnerList.ToArray ();
+                       base.ClearItems ();
+                       foreach (ChannelDispatcherBase c in channels)
+                               c.Detach (_service);
+               }
+
+               internal List<ChannelDispatcherBase> InnerList {
+                       get { return Items; }
+               }
+
+               [MonoTODO ("What to do here?")]
+               protected override void InsertItem (int index, ChannelDispatcherBase item)
+               {
+                       item.Attach (_service);
+                       base.InsertItem (index, item);                  
+               }
+
+               [MonoTODO ("What to do here?")]
+               protected override void RemoveItem (int index)
+               {
+                       ChannelDispatcherBase removed = this [index];
+                       base.RemoveItem (index);
+                       removed.Detach (_service);
+                       
+               }
+
+               [MonoTODO ("What to do here?")]
+               protected override void SetItem (int index, ChannelDispatcherBase item)
+               {
+                       item.Attach (_service);
+                       base.SetItem (index, item);                     
+               }               
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ClientOperation.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ClientOperation.cs
new file mode 100644 (file)
index 0000000..d486f31
--- /dev/null
@@ -0,0 +1,171 @@
+//
+// ClientOperation.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [MonoTODO]
+       public sealed class ClientOperation
+       {
+               internal class ClientOperationCollection :
+                       SynchronizedKeyedCollection<string, ClientOperation>
+               {
+                       protected override string GetKeyForItem (ClientOperation o)
+                       {
+                               return o.Name;
+                       }
+               }
+
+               ClientRuntime parent;
+               string name, action, reply_action;
+               MethodInfo sync_method, begin_method, end_method;
+               bool deserialize_reply = true, serialize_request = true;
+               bool is_initiating, is_terminating, is_oneway;
+               IClientMessageFormatter formatter, actual_formatter;
+               SynchronizedCollection<IParameterInspector> inspectors
+                       = new SynchronizedCollection<IParameterInspector> ();
+
+               public ClientOperation (ClientRuntime parent,
+                       string name, string action)
+               {
+                       this.parent = parent;
+                       this.name = name;
+                       this.action = action;
+               }
+
+               public ClientOperation (ClientRuntime parent,
+                       string name, string action, string replyAction)
+               {
+                       this.parent = parent;
+                       this.name = name;
+                       this.action = action;
+                       this.reply_action = replyAction;
+               }
+
+               public string Action {
+                       get { return action; }
+               }
+
+               public string ReplyAction {
+                       get { return reply_action; }
+               }
+
+               public MethodInfo BeginMethod {
+                       get { return begin_method; }
+                       set { begin_method = value; }
+               }
+
+               public bool DeserializeReply {
+                       get { return deserialize_reply; }
+                       set { deserialize_reply = value; }
+               }
+
+               public MethodInfo EndMethod {
+                       get { return end_method; }
+                       set { end_method = value; }
+               }
+
+               public SynchronizedCollection<FaultContractInfo> FaultContractInfos {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public IClientMessageFormatter Formatter {
+                       get { return formatter; }
+                       set { formatter = value; }
+               }
+
+               public bool IsInitiating {
+                       get { return is_initiating; }
+                       set { is_initiating = value; }
+               }
+
+               public bool IsOneWay {
+                       get { return is_oneway; }
+                       set { is_oneway = value; }
+               }
+
+               public bool IsTerminating {
+                       get { return is_terminating; }
+                       set { is_terminating = value; }
+               }
+
+               public string Name {
+                       get { return name; }
+               }
+
+               public SynchronizedCollection<IParameterInspector> ParameterInspectors {
+                       get { return inspectors; }
+               }
+
+               public ClientRuntime Parent {
+                       get { return parent; }
+               }
+
+               public bool SerializeRequest {
+                       get { return serialize_request; }
+                       set { serialize_request = value; }
+               }
+
+               public MethodInfo SyncMethod {
+                       get { return sync_method; }
+                       set { sync_method = value; }
+               }
+
+               OperationDescription Description {
+                       get {
+                               // FIXME: ContractDescription should be acquired from elsewhere.
+                               ContractDescription cd = ContractDescription.GetContract (Parent.ContractClientType);
+                               OperationDescription od = cd.Operations.Find (Name);
+                               if (od == null) {
+                                       if (Name == "*")
+                                               throw new Exception (String.Format ("INTERNAL ERROR: Contract {0} in namespace {1} does not contain Operations.", Parent.ContractName, Parent.ContractNamespace));
+                                       else
+                                               throw new Exception (String.Format ("INTERNAL ERROR: Operation {0} was not found.", Name));
+                               }
+                               return od;
+                       }
+               }
+
+               internal IClientMessageFormatter GetFormatter ()
+               {
+                       if (actual_formatter == null) {
+                               if (Formatter != null)
+                                       actual_formatter = Formatter;
+                               else
+                                       actual_formatter = BaseMessagesFormatter.Create (Description);
+                       }
+                       return actual_formatter;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ClientRuntime.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ClientRuntime.cs
new file mode 100644 (file)
index 0000000..6b7fcc4
--- /dev/null
@@ -0,0 +1,139 @@
+//
+// ClientRuntime.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public sealed class ClientRuntime
+       {
+               Type callback, contract;
+               SynchronizedCollection<IChannelInitializer> channel_initializers
+                       = new SynchronizedCollection<IChannelInitializer> ();
+               SynchronizedCollection<IInteractiveChannelInitializer> interactive_channel_initializers
+                       = new SynchronizedCollection<IInteractiveChannelInitializer> ();
+               DispatchRuntime dispatch;
+               SynchronizedCollection<IClientMessageInspector> inspectors
+                       = new SynchronizedCollection<IClientMessageInspector> ();
+               ClientOperation.ClientOperationCollection operations
+                       = new ClientOperation.ClientOperationCollection ();
+               IClientOperationSelector selector;
+               Uri via;
+               bool validate, manual_addressing;
+               string contract_name, contract_ns;
+               int max_fault_size = 0x10000; // FIXME: not verified.
+
+               // .ctor() for DispatchRuntime.CallbackClientRuntime
+               internal ClientRuntime (DispatchRuntime parent)
+               {
+                       // maybe it could be null, for non-duplex channels.
+                       this.dispatch = parent;
+                       contract_name = dispatch.EndpointDispatcher.ContractName;
+                       contract_ns = dispatch.EndpointDispatcher.ContractNamespace;
+               }
+
+               // .ctor() for Clients
+               internal ClientRuntime (ServiceEndpoint endpoint)
+               {
+                       contract_name = endpoint.Contract.Name;
+                       contract_ns = endpoint.Contract.Namespace;
+               }
+
+               public Type CallbackClientType {
+                       get { return callback; }
+                       set { callback = value; }
+               }
+
+               public SynchronizedCollection<IChannelInitializer> ChannelInitializers {
+                       get { return channel_initializers; }
+               }
+
+               public SynchronizedCollection<IInteractiveChannelInitializer> InteractiveChannelInitializers {
+                       get { return interactive_channel_initializers;}
+               }
+
+               public string ContractName {
+                       get { return contract_name; }
+               }
+
+               public string ContractNamespace {
+                       get { return contract_ns; }
+               }
+
+               
+               public Type ContractClientType {
+                       get { return contract; }
+                       set { contract = value; }
+               }
+
+               public DispatchRuntime CallbackDispatchRuntime {
+                       get { return dispatch; }
+               }
+
+               public SynchronizedCollection<IClientMessageInspector> MessageInspectors {
+                       get { return inspectors; }
+               }
+
+               public SynchronizedKeyedCollection<string,ClientOperation> Operations {
+                       get { return operations; }
+               }
+
+               public bool ManualAddressing {
+                       get { return manual_addressing; }
+                       set { manual_addressing = value; }
+               }
+
+               public int MaxFaultSize {
+                       get { return max_fault_size; }
+                       set { max_fault_size = value; }
+               }
+
+               public IClientOperationSelector OperationSelector {
+                       get { return selector; }
+                       set { selector = value; }
+               }
+
+               public bool ValidateMustUnderstand {
+                       get { return validate; }
+                       set { validate = value; }
+               }
+
+               public Uri Via {
+                       get { return via; }
+                       set { via = value; }
+               }
+
+               [MonoTODO]
+               public ClientOperation UnhandledClientOperation {
+                       get { throw new NotImplementedException (); }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DataContractSerializerServiceBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DataContractSerializerServiceBehavior.cs
new file mode 100644 (file)
index 0000000..b52715a
--- /dev/null
@@ -0,0 +1,73 @@
+//\r
+// DataContractSerializerServiceBehavior.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel.Description;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       class DataContractSerializerServiceBehavior : IEndpointBehavior\r
+       {\r
+               public bool IgnoreExtensionDataObject {\r
+                       get;\r
+                       set;\r
+               }\r
+\r
+               public int MaxItemsInObjectGraph {\r
+                       get;\r
+                       set;\r
+               }\r
+\r
+               public DataContractSerializerServiceBehavior (bool ignoreExtensionDataObject, int maxItemsInObjectGraph) {\r
+                       IgnoreExtensionDataObject = ignoreExtensionDataObject;\r
+                       MaxItemsInObjectGraph = maxItemsInObjectGraph;\r
+               }\r
+\r
+               #region IEndpointBehavior Members\r
+\r
+               void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection parameters) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               void IEndpointBehavior.ApplyDispatchBehavior (ServiceEndpoint serviceEndpoint, EndpointDispatcher dispatcher) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               void IEndpointBehavior.ApplyClientBehavior (ServiceEndpoint serviceEndpoint, ClientRuntime behavior) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               void IEndpointBehavior.Validate (ServiceEndpoint serviceEndpoint) {\r
+                       throw new NotImplementedException ();\r
+               }\r
+\r
+               #endregion\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DefaultInstanceContextProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DefaultInstanceContextProvider.cs
new file mode 100644 (file)
index 0000000..f8c104b
--- /dev/null
@@ -0,0 +1,27 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       class DefaultInstanceContextProvider : IInstanceContextProvider\r
+       {               \r
+\r
+               public InstanceContext GetExistingInstanceContext (System.ServiceModel.Channels.Message message, IContextChannel channel) {\r
+                       return null;\r
+               }\r
+\r
+               public void InitializeInstanceContext (InstanceContext instanceContext, System.ServiceModel.Channels.Message message, IContextChannel channel) {\r
+                       \r
+               }\r
+\r
+               public bool IsIdle (InstanceContext instanceContext) {\r
+                       return true;\r
+               }\r
+\r
+               public void NotifyIdle (InstanceContextIdleCallback callback, InstanceContext instanceContext) {\r
+                       \r
+               }\r
+       \r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchOperation.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchOperation.cs
new file mode 100644 (file)
index 0000000..33a1125
--- /dev/null
@@ -0,0 +1,179 @@
+//
+// DispatchOperation.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [MonoTODO]
+       public sealed class DispatchOperation
+       {
+               internal class DispatchOperationCollection :
+                       SynchronizedKeyedCollection<string, DispatchOperation>
+               {
+                       protected override string GetKeyForItem (DispatchOperation o)
+                       {
+                               return o.Name;
+                       }
+               }
+
+               DispatchRuntime parent;
+               string name, action, reply_action;
+               bool serialize_reply = true, deserialize_request = true,
+                       is_oneway, is_terminating,
+                       release_after_call, release_before_call,
+                       tx_auto_complete, tx_required;
+               ImpersonationOption impersonation;
+               IDispatchMessageFormatter formatter, actual_formatter;
+               IOperationInvoker invoker;
+               SynchronizedCollection<IParameterInspector> inspectors
+                       = new SynchronizedCollection<IParameterInspector> ();
+               SynchronizedCollection<FaultContractInfo> fault_contract_infos
+                       = new SynchronizedCollection<FaultContractInfo> ();
+               SynchronizedCollection<ICallContextInitializer> ctx_initializers
+                       = new SynchronizedCollection<ICallContextInitializer> ();
+
+               public DispatchOperation (DispatchRuntime parent,
+                       string name, string action)
+               {
+                       if (parent == null)
+                               throw new ArgumentNullException ("parent");
+                       if (name == null)
+                               throw new ArgumentNullException ("name");
+                       // action could be null
+
+                       is_oneway = true;
+                       this.parent = parent;
+                       this.name = name;
+                       this.action = action;
+               }
+
+               public DispatchOperation (DispatchRuntime parent,
+                       string name, string action, string replyAction)
+                       : this (parent, name, action)
+               {
+                       // replyAction could be null
+                       is_oneway = false;
+                       reply_action = replyAction;
+               }
+
+               public string Action {
+                       get { return action; }
+               }
+
+               public SynchronizedCollection<ICallContextInitializer> CallContextInitializers {
+                       get { return ctx_initializers; }
+               }
+
+               public bool DeserializeRequest {
+                       get { return deserialize_request; }
+                       set { deserialize_request = value; }
+               }
+
+               public SynchronizedCollection<FaultContractInfo> FaultContractInfos {
+                       get { return fault_contract_infos; }
+               }
+
+               public IDispatchMessageFormatter Formatter {
+                       get { return formatter; }
+                       set {
+                               formatter = value;
+                               actual_formatter = null;
+                       }
+               }
+
+               public ImpersonationOption Impersonation {
+                       get { return impersonation; }
+                       set { impersonation = value; }
+               }
+
+               public IOperationInvoker Invoker {
+                       get { return invoker; }
+                       set { invoker = value; }
+               }
+
+               public bool IsOneWay {
+                       get { return is_oneway; }
+               }
+
+               public bool IsTerminating {
+                       get { return is_terminating; }
+                       set { is_terminating = value; }
+               }
+
+               public string Name {
+                       get { return name; }
+               }
+
+               public SynchronizedCollection<IParameterInspector> ParameterInspectors {
+                       get { return inspectors; }
+               }
+
+               public DispatchRuntime Parent {
+                       get { return parent; }
+               }
+
+               public bool ReleaseInstanceAfterCall {
+                       get { return release_after_call; }
+                       set { release_after_call = value; }
+               }
+
+               public bool ReleaseInstanceBeforeCall {
+                       get { return release_before_call; }
+                       set { release_before_call = value; }
+               }
+
+               public string ReplyAction {
+                       get { return reply_action; }
+               }
+
+               public bool SerializeReply {
+                       get { return serialize_reply; }
+                       set { serialize_reply = value; }
+               }
+
+               public bool TransactionAutoComplete {
+                       get { return tx_auto_complete; }
+                       set { tx_auto_complete = value; }
+               }
+
+               public bool TransactionRequired {
+                       get { return tx_required; }
+                       set { tx_required = value; }
+               }
+
+               MessageVersion MessageVersion {
+                       get { return Parent.ChannelDispatcher.MessageVersion; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchRuntime.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchRuntime.cs
new file mode 100644 (file)
index 0000000..d68e9b9
--- /dev/null
@@ -0,0 +1,225 @@
+//
+// DispatchRuntime.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Reflection;
+using System.IdentityModel.Policy;
+using System.ServiceModel.Channels;
+using System.Text;
+using System.Threading;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.Web.Security;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [MonoTODO]
+       public sealed class DispatchRuntime
+       {
+               EndpointDispatcher endpoint_dispatcher;
+               AuditLogLocation audit_log_location;
+               bool automatic_input_session_shutdown = true;
+               bool suppress_audio_failure = true;
+               bool completes_tx_on_close, ignore_tx_msg_props, inpersonate;
+               bool release_tx_complete;
+               ClientRuntime callback_client_runtime;
+               ConcurrencyMode concurrency_mode;
+               InstanceContext instance_context;
+               IInstanceProvider instance_provider;
+               IInstanceContextProvider instance_context_provider;
+               AuditLevel msg_auth_audit_level, svc_auth_audit_level;
+               IDispatchOperationSelector operation_selector;
+               PrincipalPermissionMode perm_mode =
+                       PrincipalPermissionMode.UseWindowsGroups;
+               SynchronizationContext sync_context;
+               Type type;
+               DispatchOperation unhandled_dispatch_oper;
+               RoleProvider role_provider;
+               ServiceAuthorizationManager auth_manager;
+
+               SynchronizedCollection<IInputSessionShutdown>
+                       shutdown_handlers =
+                       new SynchronizedCollection<IInputSessionShutdown> ();
+               SynchronizedCollection<IInstanceContextInitializer> 
+                       inst_ctx_initializers =
+                       new SynchronizedCollection<IInstanceContextInitializer> ();
+               SynchronizedCollection<IDispatchMessageInspector>
+                       msg_inspectors =
+                       new SynchronizedCollection<IDispatchMessageInspector> ();
+               DispatchOperation.DispatchOperationCollection operations =
+                       new DispatchOperation.DispatchOperationCollection ();
+               ReadOnlyCollection<IAuthorizationPolicy> ext_auth_policies;
+
+
+               internal DispatchRuntime (EndpointDispatcher dispatcher)
+               {
+                       endpoint_dispatcher = dispatcher;
+                       // FIXME: is this really created at any time?
+                       callback_client_runtime = new ClientRuntime (this);
+                       unhandled_dispatch_oper = new DispatchOperation (
+                               this, "*", "*", "*");
+                       instance_context_provider = new DefaultInstanceContextProvider ();
+               }
+
+               public AuditLogLocation SecurityAuditLogLocation {
+                       get { return audit_log_location; }
+                       set { audit_log_location = value; }
+               }
+
+               public bool AutomaticInputSessionShutdown {
+                       get { return automatic_input_session_shutdown; }
+                       set { automatic_input_session_shutdown = value; }
+               }
+
+               public ChannelDispatcher ChannelDispatcher {
+                       get { return endpoint_dispatcher.ChannelDispatcher; }
+               }
+
+               public ConcurrencyMode ConcurrencyMode {
+                       get { return concurrency_mode; }
+                       set { concurrency_mode = value; }
+               }
+
+               public EndpointDispatcher EndpointDispatcher {
+                       get { return endpoint_dispatcher; }
+               }
+
+               [MonoTODO] // needs update when we can explore Duplex channels.
+               public ClientRuntime CallbackClientRuntime {
+                       get { return callback_client_runtime; }
+               }
+
+               public ReadOnlyCollection<IAuthorizationPolicy> ExternalAuthorizationPolicies {
+                       get { return ext_auth_policies; }
+                       set { ext_auth_policies = value; }
+               }
+
+               public bool IgnoreTransactionMessageProperty {
+                       get { return ignore_tx_msg_props; }
+                       set { ignore_tx_msg_props = value; }
+               }
+
+               public bool ImpersonateCallerForAllOperations {
+                       get { return inpersonate; }
+                       set { inpersonate = value; }
+               }
+
+               public SynchronizedCollection<IInputSessionShutdown> 
+                       InputSessionShutdownHandlers {
+                       get { return shutdown_handlers; }
+               }
+
+               public SynchronizedCollection<IInstanceContextInitializer> InstanceContextInitializers {
+                       get { return inst_ctx_initializers; }
+               }
+
+               public IInstanceProvider InstanceProvider {
+                       get { return instance_provider; }
+                       set { instance_provider = value; }
+               }
+
+               public IInstanceContextProvider InstanceContextProvider {
+                       get { return instance_context_provider; }
+                       set { instance_context_provider = value; }
+               }
+
+               public AuditLevel MessageAuthenticationAuditLevel {
+                       get { return msg_auth_audit_level; }
+                       set { msg_auth_audit_level = value; }
+               }
+
+               public SynchronizedCollection<IDispatchMessageInspector> MessageInspectors {
+                       get { return msg_inspectors; }
+               }
+
+               public SynchronizedKeyedCollection<string,DispatchOperation> Operations {
+                       get { return operations; }
+               }
+
+               public IDispatchOperationSelector OperationSelector {
+                       get { return operation_selector; }
+                       set { operation_selector = value; }
+               }
+
+               public PrincipalPermissionMode PrincipalPermissionMode {
+                       get { return perm_mode; }
+                       set { perm_mode = value; }
+               }
+
+               public bool ReleaseServiceInstanceOnTransactionComplete {
+                       get { return release_tx_complete; }
+                       set { release_tx_complete = value; }
+               }
+
+               public RoleProvider RoleProvider {
+                       get { return role_provider; }
+                       set { role_provider = value; }
+               }
+
+               public AuditLevel ServiceAuthorizationAuditLevel {
+                       get { return svc_auth_audit_level; }
+                       set { svc_auth_audit_level = value; }
+               }
+
+               public ServiceAuthorizationManager ServiceAuthorizationManager {
+                       get { return auth_manager; }
+                       set { auth_manager = value; }
+               }
+
+               public InstanceContext SingletonInstanceContext {
+                       get { return instance_context; }
+                       set { instance_context = value; }
+               }
+
+               public bool SuppressAuditFailure {
+                       get { return suppress_audio_failure; }
+                       set { suppress_audio_failure = value; }
+               }
+
+               public SynchronizationContext SynchronizationContext {
+                       get { return sync_context; }
+                       set { sync_context = value; }
+               }
+
+               public bool TransactionAutoCompleteOnSessionClose {
+                       get { return completes_tx_on_close; }
+                       set { completes_tx_on_close = value; }
+               }
+
+               public Type Type {
+                       get { return type; }
+                       set { type = value; }
+               }
+
+               public DispatchOperation UnhandledDispatchOperation {
+                       get { return unhandled_dispatch_oper; }
+                       set { unhandled_dispatch_oper = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointAddressMessageFilter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointAddressMessageFilter.cs
new file mode 100644 (file)
index 0000000..49ce570
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// EndpointAddressMessageFilter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public class EndpointAddressMessageFilter : MessageFilter
+       {
+               EndpointAddress address;
+               bool cmp_host;
+
+               public EndpointAddressMessageFilter (EndpointAddress address)
+                       : this (address, false)
+               {
+               }
+
+               public EndpointAddressMessageFilter (EndpointAddress address,
+                       bool includeHostNameInComparison)
+               {
+                       this.address = address;
+                       cmp_host = includeHostNameInComparison;
+               }
+
+               public EndpointAddress Address {
+                       get { return address; }
+               }
+
+               public bool IncludeHostNameInComparison {
+                       get { return cmp_host; }
+               }
+
+               [MonoTODO]
+               protected internal override IMessageFilterTable<FilterData>
+                       CreateFilterTable<FilterData> ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override bool Match (Message message)
+               {
+                       Uri to = message.Headers.To;
+                       bool path = ((String.CompareOrdinal (to.AbsolutePath, address.Uri.AbsolutePath) == 0) && 
+                                       (to.Port == address.Uri.Port));
+                       bool host = IncludeHostNameInComparison
+                                       ? (String.CompareOrdinal (to.Host, address.Uri.Host) == 0)
+                                       : true;
+
+                       return path && host;
+               }
+
+               public override bool Match (MessageBuffer messageBuffer)
+               {
+                       if (messageBuffer == null)
+                               throw new ArgumentNullException ("messageBuffer");
+                       return Match (messageBuffer.CreateMessage ());
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointAddressMessageFilterTable.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointAddressMessageFilterTable.cs
new file mode 100644 (file)
index 0000000..2f7d274
--- /dev/null
@@ -0,0 +1,192 @@
+//
+// EndpointAddressMessageFilterTable.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       internal class EndpointAddressMessageFilterTable<TFilterData>
+               : IDictionary<MessageFilter,TFilterData>,
+                 IMessageFilterTable<TFilterData>,
+                 IEnumerable,
+                 ICollection<KeyValuePair<MessageFilter,TFilterData>>,
+                 IEnumerable<KeyValuePair<MessageFilter,TFilterData>>
+       {
+               Dictionary<MessageFilter,TFilterData> dict
+                       = new Dictionary<MessageFilter,TFilterData> ();
+
+               public EndpointAddressMessageFilterTable ()
+               {
+               }
+
+               public TFilterData this [MessageFilter key] {
+                       get { return dict [key]; }
+                       set { dict [key] = value; }
+               }
+
+               public int Count {
+                       get { return dict.Count; }
+               }
+
+               public bool IsReadOnly {
+                       get { return false; }
+               }
+
+               public ICollection<MessageFilter> Keys {
+                       get { return dict.Keys; }
+               }
+
+               public ICollection<TFilterData> Values {
+                       get { return dict.Values; }
+               }
+
+               public void Add (KeyValuePair<MessageFilter,TFilterData> item)
+               {
+                       dict.Add (item.Key, item.Value);
+               }
+
+               [MonoTODO]
+               public void Add (EndpointAddressMessageFilter filter, TFilterData data)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void Add (MessageFilter filter, TFilterData data)
+               {
+                       dict.Add (filter, data);
+               }
+
+               public void Clear ()
+               {
+                       dict.Clear ();
+               }
+
+               public bool Contains (KeyValuePair<MessageFilter,TFilterData> item)
+               {
+                       return dict.ContainsKey (item.Key) &&
+                               dict [item.Key].Equals (item.Value);
+               }
+
+               public bool ContainsKey (MessageFilter key)
+               {
+                       return dict.ContainsKey (key);
+               }
+
+               public void CopyTo (KeyValuePair<MessageFilter,TFilterData> [] array, int index)
+               {
+                       if (index < 0 || dict.Count >= array.Length - index)
+                               throw new ArgumentOutOfRangeException ("index");
+                       foreach (KeyValuePair<MessageFilter,TFilterData> item in dict)
+                               array [index++] = item;
+               }
+
+               public IEnumerator<KeyValuePair<MessageFilter,TFilterData>> GetEnumerator ()
+               {
+                       return dict.GetEnumerator ();
+               }
+
+               IEnumerator IEnumerable.GetEnumerator ()
+               {
+                       return GetEnumerator ();
+               }
+
+               public bool GetMatchingFilter (Message message, out MessageFilter result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingFilter (MessageBuffer buffer, out MessageFilter result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingFilters (Message message, ICollection<MessageFilter> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingFilters (MessageBuffer buffer, ICollection<MessageFilter> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValue (Message message, out TFilterData data)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValue (MessageBuffer buffer, out TFilterData data)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValues (Message message, ICollection<TFilterData> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValues (MessageBuffer buffer, ICollection<TFilterData> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool Remove (KeyValuePair<MessageFilter,TFilterData> item)
+               {
+                       if (dict.ContainsKey (item.Key) && dict [item.Key].Equals (item.Value)) {
+                               dict.Remove (item.Key);
+                               return true;
+                       }
+                       return false;
+               }
+
+               public bool Remove (EndpointAddressMessageFilter filter)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool Remove (MessageFilter filter)
+               {
+                       return dict.Remove (filter);
+               }
+
+               public bool TryGetValue (MessageFilter filter, out TFilterData filterData)
+               {
+                       if (dict.ContainsKey (filter)) {
+                               filterData = dict [filter];
+                               return true;
+                       } else {
+                               filterData = default (TFilterData);
+                               return false;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs
new file mode 100644 (file)
index 0000000..eecb102
--- /dev/null
@@ -0,0 +1,115 @@
+//
+// EndpointDispatcher.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Reflection;
+using System.ServiceModel.Description;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security.Tokens;
+using System.Text;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public class EndpointDispatcher
+       {
+               EndpointAddress address;
+               string contract_name, contract_ns;
+               ChannelDispatcher channel_dispatcher;
+               MessageFilter address_filter;
+               MessageFilter contract_filter;
+               int filter_priority;
+               DispatchRuntime dispatch_runtime;
+
+               // Umm, this API is ugly, since it or its members will
+               // anyways require ServiceEndpoint, those arguments are
+               // likely to be replaced by ServiceEndpoint (especially
+               // considering about possible EndpointAddress inconsistency).
+               public EndpointDispatcher (EndpointAddress address,
+                       string contractName, string contractNamespace)
+               {
+                       if (contractName == null)
+                               throw new ArgumentNullException ("contractName");
+                       if (contractNamespace == null)
+                               throw new ArgumentNullException ("contractNamespace");
+                       if (address == null)
+                               throw new ArgumentNullException ("address");
+
+                       this.address = address;
+                       contract_name = contractName;
+                       contract_ns = contractNamespace;
+
+                       dispatch_runtime = new DispatchRuntime (this);
+               }
+
+               public DispatchRuntime DispatchRuntime {
+                       get { return dispatch_runtime; }
+               }
+
+               public string ContractName {
+                       get { return contract_name; }
+               }
+
+               public string ContractNamespace {
+                       get { return contract_ns; }
+               }
+
+               public ChannelDispatcher ChannelDispatcher {
+                       get { return channel_dispatcher; }
+                       internal set { channel_dispatcher = value; }
+               }
+
+               public MessageFilter AddressFilter {
+                       get { return address_filter ?? (address_filter = new EndpointAddressMessageFilter (EndpointAddress)); }
+                       set {
+                               if (value == null)
+                                       throw new ArgumentNullException ("value");
+                               address_filter = value;
+                       }
+               }
+
+               public MessageFilter ContractFilter {
+                       get { return contract_filter ?? (contract_filter = new MatchAllMessageFilter ()); }
+                       set {
+                               if (value == null)
+                                       throw new ArgumentNullException ("value");
+                               contract_filter = value;
+                       }
+               }
+
+               public EndpointAddress EndpointAddress {
+                       get { return address; }
+               }
+
+               public int FilterPriority {
+                       get { return filter_priority; }
+                       set { filter_priority = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ErrorProcessingHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ErrorProcessingHandler.cs
new file mode 100644 (file)
index 0000000..7241975
--- /dev/null
@@ -0,0 +1,31 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel.Channels;\r
+using System.ServiceModel;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       internal class ErrorProcessingHandler : BaseRequestProcessorHandler\r
+       {\r
+               protected override bool ProcessRequest (MessageProcessingContext mrc)\r
+               {\r
+                       Exception ex = mrc.ProcessingException;\r
+                       DispatchRuntime dispatchRuntime = mrc.OperationContext.EndpointDispatcher.DispatchRuntime;\r
+                       \r
+                       //invoke all user handlers\r
+                       ChannelDispatcher channelDispatcher = dispatchRuntime.ChannelDispatcher;\r
+                       foreach (IErrorHandler handler in channelDispatcher.ErrorHandlers)\r
+                               if (handler.HandleError (ex))\r
+                                       break;\r
+\r
+                       FaultConverter fc = FaultConverter.GetDefaultFaultConverter (dispatchRuntime.ChannelDispatcher.MessageVersion);\r
+                       Message res = null;                     \r
+                       if (!fc.TryCreateFaultMessage (ex, out res))\r
+                               throw ex;\r
+                       mrc.ReplyMessage = res;\r
+                       mrc.Reply (true);\r
+                       return false;\r
+               }               \r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ExceptionHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ExceptionHandler.cs
new file mode 100644 (file)
index 0000000..ed5cdd8
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// ExceptionHandler.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.ConstrainedExecution;
+
+namespace System.ServiceModel.Dispatcher {
+
+       public abstract class ExceptionHandler
+       {
+               static ExceptionHandler async_handler;
+               static ExceptionHandler always_handler = new AlwaysHandler ();
+               static ExceptionHandler transport_handler = new AlwaysHandler ();
+
+               protected ExceptionHandler () {}
+
+               public static ExceptionHandler AlwaysHandle {
+                       get { return always_handler; }
+               }
+
+               class AlwaysHandler : ExceptionHandler
+               {
+                       public AlwaysHandler () {}
+
+                       public override bool HandleException (Exception e)
+                       {
+                               return true;
+                       }
+               }
+
+               public static ExceptionHandler AsynchronousThreadExceptionHandler {
+
+                       [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
+                       get { return async_handler; }
+
+                       set { async_handler = value; }
+               }
+
+               public static ExceptionHandler TransportExceptionHandler {
+                       get { return transport_handler; }
+                       set { transport_handler = value; }
+               }
+
+               public abstract bool HandleException (Exception e);
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/FaultContractInfo.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/FaultContractInfo.cs
new file mode 100644 (file)
index 0000000..4c58b78
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// FaultContractInfo.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public class FaultContractInfo
+       {
+               string action;
+               Type detail;
+
+               public FaultContractInfo (string action, Type detail)
+               {
+               }
+
+               public string Action {
+                       get { return action; }
+               }
+
+               public Type Detail {
+                       get { return detail; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/FilterInvalidBodyAccessException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/FilterInvalidBodyAccessException.cs
new file mode 100644 (file)
index 0000000..faa7b6c
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// System.ServiceModel.FilterInvalidBodyAccessException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [Serializable]
+       public class FilterInvalidBodyAccessException : InvalidBodyAccessException
+       {
+               Collection<MessageFilter> filters;
+
+               public FilterInvalidBodyAccessException () : base ("Not allowed to navigate to body.") {}
+               public FilterInvalidBodyAccessException (string msg) : base (msg) {}
+               public FilterInvalidBodyAccessException (string msg, Exception inner) : base (msg, inner) {}            
+               protected FilterInvalidBodyAccessException (SerializationInfo info, StreamingContext context)
+                       : base (info, context) {}
+
+               public FilterInvalidBodyAccessException (string msg, Collection<MessageFilter> filters)
+                       : base (msg)
+               {
+                       this.filters = filters;
+               }
+
+               public FilterInvalidBodyAccessException (string msg, Exception inner, Collection<MessageFilter> filters)
+                       : base (msg, inner)
+               {
+                       this.filters = filters;
+               }
+               
+               public Collection<MessageFilter> Filters { get { return filters; } }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/FinalizeProcessingHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/FinalizeProcessingHandler.cs
new file mode 100644 (file)
index 0000000..89c6d4f
--- /dev/null
@@ -0,0 +1,25 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel.Channels;\r
+using System.ServiceModel;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       internal class FinalizeProcessingHandler : BaseRequestProcessorHandler\r
+       {\r
+               protected override bool ProcessRequest (MessageProcessingContext mrc)\r
+               {\r
+                       FinishRequest (mrc);\r
+                       return false;\r
+               }\r
+\r
+               void FinishRequest (MessageProcessingContext mrc)\r
+               {                               \r
+                       if (mrc.Operation != null &&  mrc.Operation.ReleaseInstanceAfterCall) {\r
+                               mrc.InstanceContext.ReleaseServiceInstance ();\r
+                       }\r
+                       mrc.InstanceContext.CloseIfIdle ();                     \r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ICallContextInitializer.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ICallContextInitializer.cs
new file mode 100644 (file)
index 0000000..91dc1cc
--- /dev/null
@@ -0,0 +1,42 @@
+//
+// ICallContextInitializer.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+
+       public interface ICallContextInitializer
+       {
+               object BeforeInvoke (
+                       InstanceContext instanceContext,
+                       IClientChannel channel,
+                       Message message);
+
+               void AfterInvoke (object correlationState);
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IChannelInitializer.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IChannelInitializer.cs
new file mode 100644 (file)
index 0000000..21a6e08
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// IChannelInitializer.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Dispatcher
+{
+
+       public interface IChannelInitializer
+       {
+               void Initialize (IClientChannel channel);
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IClientMessageFormatter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IClientMessageFormatter.cs
new file mode 100644 (file)
index 0000000..7c0afae
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// IClientMessageFormatter.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IClientMessageFormatter
+       {
+               object DeserializeReply (Message message, object [] paremeters);
+               Message SerializeRequest (MessageVersion version, object [] inputs);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IClientMessageInspector.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IClientMessageInspector.cs
new file mode 100644 (file)
index 0000000..5e331a0
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// IProxyMessageInspector.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IClientMessageInspector
+       {
+               void AfterReceiveReply (ref Message message, object correlationState);
+               object BeforeSendRequest (ref Message message, IClientChannel channel);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IClientOperationSelector.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IClientOperationSelector.cs
new file mode 100644 (file)
index 0000000..336908b
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// IClientOperationSelector.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Reflection;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IClientOperationSelector
+       {
+               bool AreParametersRequiredForSelection { get; }
+               string SelectOperation (MethodBase method, object [] parameters);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IDispatchMessageFormatter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IDispatchMessageFormatter.cs
new file mode 100644 (file)
index 0000000..ca36777
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// IDispatchMessageFormatter.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IDispatchMessageFormatter
+       {
+               void DeserializeRequest (Message message, object [] parameters);
+               Message SerializeReply (MessageVersion version, object [] parameters, object result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IDispatchMessageInspector.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IDispatchMessageInspector.cs
new file mode 100644 (file)
index 0000000..b9c278c
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// IDispatchMessageInspector.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IDispatchMessageInspector
+       {
+               object AfterReceiveRequest (ref Message message,
+                       IClientChannel channel, InstanceContext context);
+               void BeforeSendReply (ref Message message, object instance);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IDispatchOperationSelector.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IDispatchOperationSelector.cs
new file mode 100644 (file)
index 0000000..04441f0
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// IDispatchOperationSelector.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IDispatchOperationSelector
+       {
+               string SelectOperation (ref Message msg);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IErrorHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IErrorHandler.cs
new file mode 100644 (file)
index 0000000..f9b2f10
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// IErrorHandler.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IErrorHandler
+       {
+               bool HandleError (Exception exception);
+               void ProvideFault (Exception exception, MessageVersion version,
+                       ref Message fault);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInputSessionShutdown.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInputSessionShutdown.cs
new file mode 100644 (file)
index 0000000..749edbb
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// IInputSessionShutdown.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IInputSessionShutdown
+       {
+               void ChannelFaulted (IDuplexContextChannel channel);
+               void DoneReceiving (IDuplexContextChannel channel);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInstanceContextInitializer.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInstanceContextInitializer.cs
new file mode 100644 (file)
index 0000000..d3887da
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// IInstanceContextInitializer.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IInstanceContextInitializer
+       {
+               void Initialize (InstanceContext context, Message message);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInstanceContextProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInstanceContextProvider.cs
new file mode 100644 (file)
index 0000000..14d8421
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// IInstanceContextProvider.cs
+//
+// Author:
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IInstanceContextProvider
+       {
+               InstanceContext GetExistingInstanceContext (Message message, IContextChannel channel);
+               void InitializeInstanceContext (InstanceContext instanceContext, Message message, IContextChannel channel);
+               bool IsIdle (InstanceContext instanceContext);
+               void NotifyIdle (InstanceContextIdleCallback callback, InstanceContext instanceContext);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInstanceProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInstanceProvider.cs
new file mode 100644 (file)
index 0000000..eb93926
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// IInstanceProvider.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IInstanceProvider
+       {
+               object GetInstance (InstanceContext context);
+               object GetInstance (InstanceContext context, Message message);
+               void ReleaseInstance (InstanceContext context, object instance);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInteractiveChannelInitializer.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IInteractiveChannelInitializer.cs
new file mode 100644 (file)
index 0000000..a1e2e81
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// IInteractiveChannelInitializer.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Dispatcher
+{
+
+       public interface IInteractiveChannelInitializer
+       {
+               IAsyncResult BeginDisplayInitializationUI (
+                       IClientChannel channel,
+                       AsyncCallback callback,
+                       object state);
+
+               void EndDisplayInitializationUI (IAsyncResult result);
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IMessageFilterTable.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IMessageFilterTable.cs
new file mode 100644 (file)
index 0000000..5e185ac
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// System.ServiceModel.IMessageFilterTable.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+
+       public interface IMessageFilterTable<TFilterData>
+               : IDictionary<MessageFilter,TFilterData>,
+                 ICollection<KeyValuePair<MessageFilter, TFilterData>>,
+                 IEnumerable<KeyValuePair<MessageFilter,TFilterData>>,
+                 IEnumerable
+       {
+               bool GetMatchingFilter (Message message, out MessageFilter result);
+               bool GetMatchingFilter (MessageBuffer buffer, out MessageFilter result);
+
+               bool GetMatchingFilters (Message message, ICollection<MessageFilter> results);
+               bool GetMatchingFilters (MessageBuffer buffer, ICollection<MessageFilter> results);
+
+               bool GetMatchingValue (Message message, out TFilterData data);
+               bool GetMatchingValue (MessageBuffer buffer, out TFilterData data);
+
+               bool GetMatchingValues (Message message, ICollection<TFilterData> results);
+               bool GetMatchingValues (MessageBuffer buffer, ICollection<TFilterData> results);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IOperationInvoker.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IOperationInvoker.cs
new file mode 100644 (file)
index 0000000..048a47b
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// IOperationInvoker.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IOperationInvoker
+       {
+               bool IsSynchronous { get; }
+               object [] AllocateParameters ();
+               object Invoke (object instance, object [] inputs);
+               IAsyncResult InvokeBegin (object instance, object [] inputs, 
+                       AsyncCallback callback, object state);
+               object InvokeEnd (object instance, out object [] outputs, IAsyncResult result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IParameterInspector.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/IParameterInspector.cs
new file mode 100644 (file)
index 0000000..ec801d5
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// IParameterInspector.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public interface IParameterInspector
+       {
+               void AfterCall (string operationName, object [] outputs,
+                       object returnValue, object correlationState);
+               object BeforeCall (string operationName, object [] inputs);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InitializingHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InitializingHandler.cs
new file mode 100644 (file)
index 0000000..3ccb409
--- /dev/null
@@ -0,0 +1,37 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel.Channels;\r
+using System.ServiceModel;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       internal class InitializingHandler : BaseRequestProcessorHandler\r
+       {\r
+               protected override bool ProcessRequest (MessageProcessingContext mrc)\r
+               {\r
+                       InstanceContext ictx = CreateInstanceContext (mrc);\r
+                       mrc.InstanceContext = ictx;\r
+                       mrc.OperationContext.InstanceContext = ictx;\r
+                       return false;\r
+               }\r
+\r
+               InstanceContext CreateInstanceContext (MessageProcessingContext mrc)\r
+               {\r
+                       InstanceContext iCtx = null;\r
+                       DispatchRuntime dispatchRuntime = mrc.OperationContext.EndpointDispatcher.DispatchRuntime;\r
+                       IInstanceContextProvider p = dispatchRuntime.InstanceContextProvider;\r
+\r
+                       if (p != null) {\r
+                               iCtx = p.GetExistingInstanceContext (mrc.IncomingMessage, mrc.OperationContext.Channel);\r
+                       }\r
+                       if (iCtx == null) {\r
+                               ServiceHostBase host = dispatchRuntime.ChannelDispatcher.Host;\r
+                               iCtx = new InstanceContext (dispatchRuntime.ChannelDispatcher.Host, null, false);\r
+                       }\r
+\r
+                       iCtx.Behavior = new InstanceBehavior (dispatchRuntime);\r
+                       return iCtx;\r
+               }               \r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InputOrReplyRequestProcessor.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InputOrReplyRequestProcessor.cs
new file mode 100644 (file)
index 0000000..bedec4e
--- /dev/null
@@ -0,0 +1,69 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.ServiceModel;\r
+using System.ServiceModel.Channels;\r
+using System.ServiceModel.Security;\r
+using System.ServiceModel.Security.Tokens;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       internal class InputOrReplyRequestProcessor : BaseRequestProcessor\r
+       {\r
+               DispatchRuntime dispatch_runtime;\r
+               IChannel reply_or_input;\r
+               IDefaultCommunicationTimeouts communication_timeouts;\r
+\r
+               public InputOrReplyRequestProcessor (DispatchRuntime runtime, IChannel replyOrInput, IDefaultCommunicationTimeouts timeouts)\r
+               {\r
+                       Init (runtime, reply_or_input, timeouts);\r
+\r
+                       //initialization\r
+                       InitializeChain.AddHandler (new InitializingHandler ());\r
+\r
+                       //processing\r
+                       ProcessingChain.AddHandler (new PostReceiveRequestHandler ()).\r
+                                                       AddHandler(new SecurityHandler ()).\r
+                                                       AddHandler(new OperationInvokerHandler ()).\r
+                                                       AddHandler(new ReplyHandler ());                        \r
+\r
+                       //errors\r
+                       ErrorChain.AddHandler (new ErrorProcessingHandler ());\r
+\r
+                       //finalize\r
+                       FinalizationChain.AddHandler (new FinalizeProcessingHandler ());\r
+               }\r
+\r
+               void Init (DispatchRuntime runtime, IChannel replyOrInput, IDefaultCommunicationTimeouts timeouts)\r
+               {\r
+                       dispatch_runtime = runtime;\r
+                       reply_or_input = replyOrInput;\r
+                       communication_timeouts = timeouts;\r
+               }\r
+\r
+               public void ProcessInput (Message message)\r
+               {\r
+                       OperationContext opcx = CreateOperationContext (message);\r
+                       ProcessRequest (new MessageProcessingContext (opcx));\r
+               }\r
+\r
+               public void ProcessReply (RequestContext rc)\r
+               {\r
+                       OperationContext opcx = CreateOperationContext (rc.RequestMessage);\r
+                       opcx.RequestContext = rc;\r
+                       ProcessRequest (new MessageProcessingContext (opcx));\r
+               }\r
+\r
+               OperationContext CreateOperationContext (Message incoming)\r
+               {\r
+                       ServiceRuntimeChannel contextChannel = new ServiceRuntimeChannel (reply_or_input,\r
+                                                                                                       dispatch_runtime.ChannelDispatcher.DefaultOpenTimeout,\r
+                                                                                                       dispatch_runtime.ChannelDispatcher.DefaultCloseTimeout);\r
+                       OperationContext opCtx = new OperationContext (contextChannel);\r
+                       opCtx.IncomingMessage = incoming;\r
+                       opCtx.EndpointDispatcher = dispatch_runtime.EndpointDispatcher;\r
+                       opCtx.CommunicationTimeouts = communication_timeouts;\r
+                       return opCtx;\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InstanceBehavior.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InstanceBehavior.cs
new file mode 100644 (file)
index 0000000..fe441b2
--- /dev/null
@@ -0,0 +1,54 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.ServiceModel;\r
+using System.ServiceModel.Dispatcher;\r
+using System.ServiceModel.Channels;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       internal class InstanceBehavior\r
+       {\r
+               DispatchRuntime dispatch_runtime;\r
+\r
+               internal InstanceBehavior (DispatchRuntime runtime) {\r
+                       dispatch_runtime = runtime;\r
+               }\r
+\r
+               internal void Initialize (InstanceContext iCtx) {\r
+                       Message message = OperationContext.Current.IncomingMessage;\r
+                       IContextChannel channel = OperationContext.Current.Channel;\r
+                       if (dispatch_runtime.InstanceContextProvider != null) {\r
+                               dispatch_runtime.InstanceContextProvider.InitializeInstanceContext (iCtx,\r
+                                                                                                       message,\r
+                                                                                                       channel);\r
+                       }\r
+                       foreach (IInstanceContextInitializer init in dispatch_runtime.InstanceContextInitializers)\r
+                               init.Initialize (iCtx, message);                                        \r
+               }\r
+\r
+               internal object GetServiceInstance (InstanceContext ctx, Message m, ref bool createdByUserProvider) {\r
+                       if (dispatch_runtime.InstanceProvider != null) {\r
+                               createdByUserProvider = true;\r
+                               return dispatch_runtime.InstanceProvider.GetInstance (ctx, m);\r
+                       }\r
+                       createdByUserProvider = false;\r
+                       return Activator.CreateInstance (\r
+                               dispatch_runtime.ChannelDispatcher.Host.Description.ServiceType);                       \r
+               }\r
+\r
+               internal IInstanceContextProvider InstanceContextProvider {\r
+                       get {\r
+                               return dispatch_runtime.InstanceContextProvider;\r
+                       }\r
+               }\r
+\r
+               internal void ReleaseServiceInstance (InstanceContext ctx, object impl) \r
+               {\r
+                       if (ctx.IsUserProvidedInstance) {\r
+                               dispatch_runtime.InstanceProvider.ReleaseInstance (ctx, impl);\r
+                               \r
+                       }\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InstanceContextIdleCallback.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InstanceContextIdleCallback.cs
new file mode 100644 (file)
index 0000000..9d46d27
--- /dev/null
@@ -0,0 +1,32 @@
+//
+// InstanceContextIdleCallback.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public delegate void InstanceContextIdleCallback (InstanceContext context);
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InvalidBodyAccessException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/InvalidBodyAccessException.cs
new file mode 100644 (file)
index 0000000..2c34c3c
--- /dev/null
@@ -0,0 +1,42 @@
+//
+// System.ServiceModel.InvalidBodyAccessException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [Serializable]
+       public abstract class InvalidBodyAccessException : SystemException
+       {
+               protected InvalidBodyAccessException (string msg) : base (msg) {}
+               protected InvalidBodyAccessException (string msg, Exception inner) : base (msg, inner) {}
+               protected InvalidBodyAccessException (SerializationInfo info, StreamingContext context)
+                       : base (info, context) {}
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MatchAllMessageFilter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MatchAllMessageFilter.cs
new file mode 100644 (file)
index 0000000..4f0aa6b
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// System.ServiceModel.MatchAllMessageFilter.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+
+       [DataContract]
+       public class MatchAllMessageFilter : MessageFilter
+       {
+               public MatchAllMessageFilter () {}
+
+               public override bool Match (Message message)
+               {
+                       // as documented
+                       return true; 
+               }
+
+               public override bool Match (MessageBuffer buffer)
+               {
+                       // as documented
+                       return true; 
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MatchNoneMessageFilter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MatchNoneMessageFilter.cs
new file mode 100644 (file)
index 0000000..3272144
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// System.ServiceModel.MatchNoneMessageFilter.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+
+       [DataContract]
+       public class MatchNoneMessageFilter : MessageFilter
+       {
+               public MatchNoneMessageFilter () {}
+
+               public override bool Match (Message message)
+               {
+                       // as documented
+                       return false; 
+               }
+
+               public override bool Match (MessageBuffer buffer)
+               {
+                       // as documented
+                       return false; 
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageFilter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageFilter.cs
new file mode 100644 (file)
index 0000000..cf5ab33
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// System.ServiceModel.MessageFilter.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Runtime.Serialization;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [DataContract]
+       [KnownType (typeof (MatchNoneMessageFilter))]
+       [KnownType (typeof (ActionMessageFilter))]
+       [KnownType (typeof (MatchAllMessageFilter))]
+       [KnownType (typeof (XPathMessageFilter))]
+       public abstract class MessageFilter
+       {
+               protected MessageFilter () {}
+
+               protected internal virtual IMessageFilterTable<FilterData> CreateFilterTable<FilterData> ()
+               {
+                       return new MessageFilterTable<FilterData> ();
+               }
+
+               public abstract bool Match (Message message);
+               public abstract bool Match (MessageBuffer buffer);
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageFilterNodeQuotaExceededException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageFilterNodeQuotaExceededException.cs
new file mode 100644 (file)
index 0000000..50b526a
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// System.ServiceModel.MessageFilterException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [Serializable]
+       public class MessageFilterException : CommunicationException
+       {
+               Collection<MessageFilter> filters;
+
+               public MessageFilterException () : this ("MessageFilter node quota exceeded.") {}
+               public MessageFilterException (string msg) : base (msg) {}
+               public MessageFilterException (string msg, Exception inner) : base (msg, inner) {}              
+               protected MessageFilterException (SerializationInfo info, StreamingContext context)
+                       : base (info, context) {}
+
+               public MessageFilterException (string msg, Collection<MessageFilter> filters)
+                       : base (msg)
+               {
+                       this.filters = filters;
+               }
+
+               public MessageFilterException (string msg, Exception inner, Collection<MessageFilter> filters)
+                       : base (msg, inner)
+               {
+                       this.filters = filters;
+               }
+               
+               public Collection<MessageFilter> Filters { get { return filters; } }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageFilterTable.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageFilterTable.cs
new file mode 100644 (file)
index 0000000..b0f4021
--- /dev/null
@@ -0,0 +1,251 @@
+//
+// System.ServiceModel.MessageFilterTable.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [DataContract]
+       public class MessageFilterTable<TFilterData> : IMessageFilterTable<TFilterData>, IDictionary<MessageFilter,TFilterData>,
+               ICollection<KeyValuePair<MessageFilter, TFilterData>>, IEnumerable<KeyValuePair<MessageFilter,TFilterData>>, IEnumerable
+       {
+
+               int default_priority;
+               Dictionary<MessageFilter, TFilterData> table;
+               Dictionary<MessageFilter, int> priority_list;
+               
+               public MessageFilterTable ()
+                       : this (0) {} // 0 is the default
+
+               public MessageFilterTable (int default_priority)
+               {
+                       this.default_priority = default_priority;
+                       table = new Dictionary<MessageFilter, TFilterData> ();
+                       priority_list = new Dictionary<MessageFilter, int> ();
+               }
+
+               public void Add (KeyValuePair<MessageFilter, TFilterData> item)
+               {
+                       this.Add (item.Key, item.Value, default_priority);
+               }
+
+               public void Add (MessageFilter filter, TFilterData data)
+               {
+                       this.Add (filter, data, default_priority);
+               }
+
+               public void Add (MessageFilter filter, TFilterData data, int priority)
+               {
+                       table.Add (filter, data);
+                       priority_list.Add (filter, priority);
+               }
+
+               public void Clear ()
+               {
+                       table.Clear ();
+                       priority_list.Clear ();
+               }
+
+               public bool Contains (KeyValuePair<MessageFilter, TFilterData> item)
+               {
+                       return ContainsKey (item.Key);
+               }
+
+               public bool ContainsKey (MessageFilter filter)
+               {
+                       return table.ContainsKey (filter);
+               }
+
+               public void CopyTo (KeyValuePair<MessageFilter, TFilterData> [] array, int index)
+               {
+                       ((ICollection) table).CopyTo (array, index);
+               }
+
+               protected virtual IMessageFilterTable<TFilterData> CreateFilterTable (MessageFilter filter)
+               {
+                       return filter.CreateFilterTable<TFilterData> ();
+               }
+
+               public IEnumerator<KeyValuePair<MessageFilter, TFilterData>> GetEnumerator ()
+               {
+                       return table.GetEnumerator ();
+               }
+
+               public int GetPriority (MessageFilter filter)
+               {
+                       return priority_list [filter];
+               }
+
+               public bool GetMatchingFilter (Message message, out MessageFilter result)
+               {
+                       if (message == null)
+                               throw new ArgumentNullException ("message is null");
+                       result = null;
+
+                       int count = 0;
+                       foreach (MessageFilter f in table.Keys) {
+                               if (!f.Match (message))
+                                       continue;
+
+                               if (count > 1)
+                                       throw new MultipleFilterMatchesException (
+                                           "More than one filter matches.");
+
+                               count++;
+                               result = f;
+                       }
+                       return count == 1;
+               }
+
+               public bool GetMatchingFilter (MessageBuffer buffer, out MessageFilter result)
+               {
+                       return GetMatchingFilter (buffer.CreateMessage (), out result);
+               }
+
+               [MonoTODO ("Consider priority")]                
+               public bool GetMatchingFilters (Message message, ICollection<MessageFilter> results)
+               {
+                       if (message == null)
+                               throw new ArgumentNullException ("message is null.");
+
+                       int count = 0;
+                       foreach (MessageFilter f in table.Keys)
+                               if (f.Match (message)) {
+                                       results.Add (f);
+                                       count++;
+                               }
+                       return count != 0;
+               }
+
+               public bool GetMatchingFilters (MessageBuffer buffer, ICollection<MessageFilter> results)
+               {
+                       return GetMatchingFilters (buffer.CreateMessage (), results);
+               }
+
+               [MonoTODO ("Consider priority")]
+               public bool GetMatchingValue (Message message, out TFilterData data)
+               {
+                       if (message == null)
+                               throw new ArgumentNullException ("message is null");
+                       data = default (TFilterData);
+
+                       int count = 0;
+                       foreach (MessageFilter f in table.Keys) {
+                               if (!f.Match (message))
+                                       continue;
+
+                               if (count > 1)
+                                       throw new MultipleFilterMatchesException (
+                                           "More than one filter matches.");
+
+                               count++;
+                               data = table [f];
+                       }
+                       return count == 1;
+               }
+
+               public bool GetMatchingValue (MessageBuffer buffer, out TFilterData data)
+               {
+                       return GetMatchingValue (buffer.CreateMessage (), out data);
+               }
+
+               public bool GetMatchingValues (Message message, ICollection<TFilterData> results)
+               {
+                       if (message == null)
+                               throw new ArgumentNullException ("message is null.");
+
+                       int count = 0;
+                       foreach (MessageFilter f in table.Keys)
+                               if (f.Match (message)) {
+                                       results.Add (table [f]);
+                                       count++;
+                               }
+                       return count != 0;
+               }
+
+               public bool GetMatchingValues (MessageBuffer buffer, ICollection<TFilterData> results)
+               {
+                       return GetMatchingValues (buffer.CreateMessage (), results);
+               }
+
+               public bool Remove (MessageFilter filter)
+               {
+                       if (filter == null)
+                               throw new ArgumentNullException ("filter is null.");
+
+                       if (!table.ContainsKey (filter))
+                               return false;
+                       
+                       table.Remove (filter);
+                       priority_list.Remove (filter);
+                       return true;
+               }
+
+               public bool Remove (KeyValuePair<MessageFilter, TFilterData> item)
+               {
+                       return Remove (item.Key);
+               }
+
+               IEnumerator IEnumerable.GetEnumerator ()
+               {
+                       return (IEnumerator) table.GetEnumerator ();
+               }
+
+               public bool TryGetValue (MessageFilter filter, out TFilterData data)
+               {
+                       return table.TryGetValue (filter, out data);
+               }
+
+               public int Count { get { return table.Count; } }
+
+               [DataMember]
+               public int DefaultPriority {
+                       get { return default_priority; }
+                       set { default_priority = value; }
+               }
+
+               public bool IsReadOnly { get { return false; } }
+
+               public TFilterData this [MessageFilter filter] {
+                       get { return table [filter]; }
+                       set { table [filter] = value; }
+               }
+
+               public ICollection<MessageFilter> Keys {
+                       get { return table.Keys; }
+               }
+
+               public ICollection<TFilterData> Values {
+                       get { return table.Values; }
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageProcessingContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MessageProcessingContext.cs
new file mode 100644 (file)
index 0000000..578ab41
--- /dev/null
@@ -0,0 +1,148 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel;\r
+using System.ServiceModel.Channels;\r
+\r
+namespace System.ServiceModel.Dispatcher \r
+{\r
+       internal class MessageProcessingContext \r
+       {\r
+               OperationContext operation_context;\r
+               RequestContext request_context;\r
+               Message incoming_message;\r
+               IDefaultCommunicationTimeouts timeouts;\r
+\r
+               Message reply_message;          \r
+               InstanceContext instance_context;               \r
+               Exception processingException;\r
+               DispatchOperation operation;\r
+               UserEventsHandler user_events_handler;          \r
+\r
+               public MessageProcessingContext (OperationContext opCtx)\r
+               {\r
+                       operation_context = opCtx;\r
+                       request_context = opCtx.RequestContext;\r
+                       incoming_message = opCtx.IncomingMessage;\r
+                       timeouts = opCtx.CommunicationTimeouts;\r
+                       user_events_handler = new UserEventsHandler (this);\r
+               }\r
+\r
+               public DispatchOperation Operation\r
+               {\r
+                       get { return operation; }\r
+                       set { operation = value; }\r
+               }\r
+\r
+               public Exception ProcessingException\r
+               {\r
+                       get { return processingException; }\r
+                       set { processingException = value; }\r
+               }\r
+               \r
+               public Message ReplyMessage\r
+               {\r
+                       get { return reply_message; }\r
+                       set { reply_message = value; }\r
+               }\r
+\r
+               public IDefaultCommunicationTimeouts CommunicationTimeouts\r
+               {\r
+                       get { return timeouts; }\r
+                       set { timeouts = value; }\r
+               }               \r
+\r
+               public InstanceContext InstanceContext\r
+               {\r
+                       get { return instance_context; }\r
+                       set { instance_context = value; }\r
+               }\r
+\r
+               public Message IncomingMessage\r
+               {\r
+                       get { return incoming_message; }\r
+                       set { incoming_message = value; }\r
+               }\r
+\r
+               public RequestContext RequestContext\r
+               {\r
+                       get { return request_context; }\r
+                       set { request_context = value; }\r
+               }\r
+\r
+               public OperationContext OperationContext\r
+               {\r
+                       get { return operation_context; }\r
+                       set { operation_context = value; }\r
+               }\r
+\r
+               public UserEventsHandler EventsHandler\r
+               {\r
+                       get { return user_events_handler; }\r
+                       set { user_events_handler = value; }\r
+               }\r
+\r
+               public void Reply (bool useTimeout)\r
+               {\r
+                       EventsHandler.BeforeSendReply ();\r
+                       if (useTimeout)\r
+                               RequestContext.Reply (ReplyMessage, CommunicationTimeouts.SendTimeout);\r
+                       else\r
+                               RequestContext.Reply (ReplyMessage);\r
+               }               \r
+       }\r
+\r
+       #region user events implementation\r
+\r
+       internal class UserEventsHandler\r
+       {\r
+               MessageProcessingContext request_context;\r
+               DispatchRuntime dispatch_runtime;\r
+               IClientChannel channel;\r
+               object [] msg_inspectors_states;\r
+               object [] callcontext_initializers_states;\r
+\r
+               public UserEventsHandler (MessageProcessingContext mrc)\r
+               {\r
+                       request_context = mrc;\r
+                       dispatch_runtime = mrc.OperationContext.EndpointDispatcher.DispatchRuntime;\r
+                       msg_inspectors_states = new object [dispatch_runtime.MessageInspectors.Count];\r
+                       channel = request_context.OperationContext.Channel as IClientChannel;\r
+               }\r
+\r
+               public void AfterReceiveRequest ()\r
+               {\r
+                       Message message = request_context.IncomingMessage;\r
+\r
+                       for (int i = 0; i < dispatch_runtime.MessageInspectors.Count; ++i)\r
+                               msg_inspectors_states [i] = dispatch_runtime.MessageInspectors [i].AfterReceiveRequest (\r
+                                          ref message, channel, request_context.InstanceContext);\r
+                       request_context.IncomingMessage = message;\r
+\r
+               }\r
+\r
+               public void BeforeSendReply ()\r
+               {\r
+                       Message toBeChanged = request_context.ReplyMessage;\r
+                       for (int i = 0; i < dispatch_runtime.MessageInspectors.Count; ++i)\r
+                               dispatch_runtime.MessageInspectors [i].BeforeSendReply (ref toBeChanged, msg_inspectors_states [i]);\r
+               }\r
+\r
+               public void BeforeInvoke (DispatchOperation operation)\r
+               {\r
+                       callcontext_initializers_states = new object [operation.CallContextInitializers.Count];\r
+                       for (int i = 0; i < callcontext_initializers_states.Length; ++i)\r
+                               callcontext_initializers_states [i] = operation.CallContextInitializers [i].BeforeInvoke (\r
+                                       request_context.InstanceContext, channel, request_context.IncomingMessage);\r
+\r
+               }\r
+\r
+               public void AfterInvoke (DispatchOperation operation)\r
+               {\r
+                       for (int i = 0; i < callcontext_initializers_states.Length; ++i)\r
+                               operation.CallContextInitializers [i].AfterInvoke (callcontext_initializers_states [i]);\r
+               }\r
+       }\r
+\r
+       #endregion\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MexInstanceContextProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MexInstanceContextProvider.cs
new file mode 100644 (file)
index 0000000..27407f1
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// MexInstanceContextProvider.cs
+//
+// Author:
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Description;
+using System.ServiceModel.Channels;
+using System.Xml;
+using System.IO;
+
+namespace System.ServiceModel.Dispatcher
+{
+       internal class MexInstanceContextProvider : IInstanceContextProvider
+       {
+               InstanceContext ctx;
+
+               public MexInstanceContextProvider (ServiceHostBase service_host)
+               {
+                       foreach (IServiceBehavior beh in service_host.Description.Behaviors) {
+                               ServiceMetadataBehavior mex_beh = beh as ServiceMetadataBehavior;
+                               if (mex_beh == null)
+                                       continue;
+
+                               MetadataExchange mex_instance = new MetadataExchange (mex_beh);
+                               ctx = new InstanceContext (mex_instance);
+                               break;
+                       }
+                       //if (ctx == null)
+               }
+               
+               public InstanceContext GetExistingInstanceContext (Message message, IContextChannel channel)
+               {
+                       if (message.Headers.Action != "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get")
+                               return null;
+
+                       return ctx;
+               }
+
+               public void InitializeInstanceContext (InstanceContext instanceContext, Message message, IContextChannel channel)
+               {
+               }
+
+               public bool IsIdle (InstanceContext instanceContext)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void NotifyIdle (InstanceContextIdleCallback callback, InstanceContext instanceContext)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       class MetadataExchange : IMetadataExchange
+       {
+               ServiceMetadataBehavior beh;
+               
+               public MetadataExchange (ServiceMetadataBehavior beh)
+               {
+                       this.beh = beh;
+               }
+
+               public Message Get (Message request)
+               {
+                       UniqueId id = request.Headers.MessageId;
+
+                       MemoryStream ms = new MemoryStream ();
+                       XmlWriterSettings xws = new XmlWriterSettings ();
+                       xws.OmitXmlDeclaration = true;
+                       
+                       using (XmlWriter xw = XmlWriter.Create (ms, xws))
+                               beh.MetadataExporter.GetGeneratedMetadata ().WriteTo (xw);
+
+                       ms.Seek (0, SeekOrigin.Begin);
+                       XmlReader xr = XmlReader.Create (ms);
+
+                       Message ret = Message.CreateMessage (request.Version,
+                               "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse",
+                               xr);
+                       ret.Headers.RelatesTo = id;
+
+                       return ret;
+               }
+
+               public IAsyncResult BeginGet (Message request, AsyncCallback cb, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public Message EndGet (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MultipleMessageFilterMatchesException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/MultipleMessageFilterMatchesException.cs
new file mode 100644 (file)
index 0000000..b33c0fd
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// System.ServiceModel.MultipleFilterMatchesException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [Serializable]
+       public class MultipleFilterMatchesException : SystemException
+       {
+               Collection<MessageFilter> filters;
+
+               public MultipleFilterMatchesException () : base () {}
+               public MultipleFilterMatchesException (string msg) : base (msg) {}
+               public MultipleFilterMatchesException (string msg, Exception inner) : base (msg, inner) {}              
+               protected MultipleFilterMatchesException (SerializationInfo info, StreamingContext context)
+                       : base (info, context) {}
+
+               public MultipleFilterMatchesException (string msg, Collection<MessageFilter> filters)
+                       : base (msg)
+               {
+                       this.filters = filters;
+               }
+
+               public MultipleFilterMatchesException (string msg, Exception inner, Collection<MessageFilter> filters)
+                       : base (msg, inner)
+               {
+                       this.filters = filters;
+               }
+               
+               public Collection<MessageFilter> Filters { get { return filters; } }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/NavigatorInvalidBodyAccessException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/NavigatorInvalidBodyAccessException.cs
new file mode 100644 (file)
index 0000000..08d3b19
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// System.ServiceModel.NavigatorInvalidBodyAccessException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [Serializable]
+       public class NavigatorInvalidBodyAccessException : InvalidBodyAccessException
+       {
+               public NavigatorInvalidBodyAccessException () : base ("Not allowed to navigate to body.") {}
+               public NavigatorInvalidBodyAccessException (string msg) : base (msg) {}
+               public NavigatorInvalidBodyAccessException (string msg, Exception inner) : base (msg, inner) {}
+               protected NavigatorInvalidBodyAccessException (SerializationInfo info, StreamingContext context)
+                       : base (info, context) {}
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationContextScopeHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationContextScopeHandler.cs
new file mode 100644 (file)
index 0000000..77c7fd8
--- /dev/null
@@ -0,0 +1,21 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       internal class OperationContextScopeHandler : BaseRequestProcessorHandler\r
+       {\r
+               public override void ProcessRequestChain (MessageProcessingContext mrc)\r
+               {\r
+                       using (new OperationContextScope (mrc.OperationContext)) {\r
+                               base.ProcessRequestChain (mrc);\r
+                       }\r
+               }\r
+\r
+               protected override bool ProcessRequest (MessageProcessingContext mrc)\r
+               {\r
+                       return false;\r
+               }               \r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationInvokerHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/OperationInvokerHandler.cs
new file mode 100644 (file)
index 0000000..8014cd8
--- /dev/null
@@ -0,0 +1,144 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel.Channels;\r
+using System.ServiceModel;\r
+using System.Reflection;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       internal class OperationInvokerHandler : BaseRequestProcessorHandler\r
+       {\r
+               protected override bool ProcessRequest (MessageProcessingContext mrc)\r
+               {                       \r
+                       RequestContext rc = mrc.RequestContext;\r
+                       DispatchRuntime dispatchRuntime = mrc.OperationContext.EndpointDispatcher.DispatchRuntime;\r
+                       DispatchOperation operation = GetOperation (mrc.IncomingMessage, dispatchRuntime);\r
+                       mrc.Operation = operation;\r
+                       try {                           \r
+                               DoProcessRequest (mrc);\r
+                               if (!operation.Invoker.IsSynchronous)\r
+                                       return true;\r
+                       } catch (TargetInvocationException ex) {\r
+                               mrc.ReplyMessage = BuildExceptionMessage (mrc.IncomingMessage, ex.InnerException, \r
+                                       dispatchRuntime.ChannelDispatcher.IncludeExceptionDetailInFaults);\r
+                       }\r
+                       return false;\r
+               }\r
+\r
+               void DoProcessRequest (MessageProcessingContext mrc)\r
+               {\r
+                       DispatchOperation operation = mrc.Operation;\r
+                       Message req = mrc.IncomingMessage;\r
+                       object instance = mrc.InstanceContext.GetServiceInstance(req);\r
+                       object [] parameters;                   \r
+                       BuildInvokeParams (mrc, out parameters);\r
+\r
+                       if (operation.Invoker.IsSynchronous) {\r
+                               object result = operation.Invoker.Invoke (instance, parameters);\r
+                               HandleInvokeResult (mrc, parameters, result);\r
+                       } else {// asynchronous\r
+                               InvokeAsynchronous (mrc, instance, parameters);\r
+                       }                       \r
+               }\r
+\r
+               void InvokeAsynchronous (MessageProcessingContext mrc, object instance, object [] parameters)\r
+               {\r
+                       DispatchOperation operation = mrc.Operation;\r
+                       DispatchRuntime dispatchRuntime = mrc.OperationContext.EndpointDispatcher.DispatchRuntime;\r
+                       operation.Invoker.InvokeBegin (instance, parameters,\r
+                                       delegate (IAsyncResult res) {                                           \r
+                                               try {\r
+                                                       object result;\r
+                                                       result = operation.Invoker.InvokeEnd (instance, out parameters, res);\r
+                                                       HandleInvokeResult (mrc, parameters, result);\r
+                                                       mrc.Reply (true);\r
+                                               } catch (Exception ex) {\r
+                                                       mrc.ReplyMessage = BuildExceptionMessage (mrc.IncomingMessage, ex, dispatchRuntime.ChannelDispatcher.IncludeExceptionDetailInFaults);\r
+                                                       mrc.Reply (false);\r
+                                               }                               \r
+                                       },\r
+                                       null);                  \r
+               }\r
+\r
+               DispatchOperation GetOperation (Message input, DispatchRuntime dispatchRuntime)\r
+               {\r
+                       if (dispatchRuntime.OperationSelector != null) {\r
+                               string name = dispatchRuntime.OperationSelector.SelectOperation (ref input);\r
+                               foreach (DispatchOperation d in dispatchRuntime.Operations)\r
+                                       if (d.Name == name)\r
+                                               return d;\r
+                       } else {\r
+                               string action = input.Headers.Action;\r
+                               foreach (DispatchOperation d in dispatchRuntime.Operations)\r
+                                       if (d.Action == action)\r
+                                               return d;\r
+                       }\r
+                       return dispatchRuntime.UnhandledDispatchOperation;\r
+               }\r
+\r
+               void HandleInvokeResult (MessageProcessingContext mrc, object [] outputs, object result)\r
+               {\r
+                       DispatchOperation operation = mrc.Operation;\r
+                       mrc.EventsHandler.AfterInvoke (operation);\r
+\r
+                       Message res = null;\r
+                       if (operation.SerializeReply)\r
+                               res = operation.Formatter.SerializeReply (\r
+                                       mrc.OperationContext.EndpointDispatcher.ChannelDispatcher.MessageVersion, outputs, result);\r
+                       else\r
+                               res = (Message) result;\r
+                       res.Headers.CopyHeadersFrom (mrc.OperationContext.OutgoingMessageHeaders);\r
+                       res.Properties.CopyProperties (mrc.OperationContext.OutgoingMessageProperties);\r
+                       mrc.ReplyMessage = res;\r
+               }\r
+\r
+               Message CreateActionNotSupported (Message req)\r
+               {\r
+                       FaultCode fc = new FaultCode (\r
+                               req.Version.Addressing.ActionNotSupported,\r
+                               req.Version.Addressing.Namespace);\r
+                       // FIXME: set correct namespace URI\r
+                       return Message.CreateMessage (req.Version, fc,\r
+                               String.Format ("action '{0}' is not supported in this service contract.", req.Headers.Action), String.Empty);\r
+               }\r
+\r
+               void BuildInvokeParams (MessageProcessingContext mrc, out object [] parameters)\r
+               {\r
+                       DispatchOperation operation = mrc.Operation;\r
+                       EnsureValid (operation);\r
+\r
+                       if (operation.DeserializeRequest) {\r
+                               parameters = operation.Invoker.AllocateParameters ();\r
+                               operation.Formatter.DeserializeRequest (mrc.IncomingMessage, parameters);\r
+                       } else\r
+                               parameters = new object [] { mrc.IncomingMessage };\r
+\r
+                       mrc.EventsHandler.BeforeInvoke (operation);\r
+               }\r
+\r
+               Message BuildExceptionMessage (Message req, Exception ex, bool includeDetailsInFault)\r
+               {                       \r
+                       // FIXME: set correct name\r
+                       FaultCode fc = new FaultCode (\r
+                               "InternalServiceFault",\r
+                               req.Version.Addressing.Namespace);\r
+\r
+\r
+                       if (includeDetailsInFault) {\r
+                               return Message.CreateMessage (req.Version, fc, ex.Message, new ExceptionDetail (ex), req.Headers.Action);\r
+                       }\r
+                       string faultString =\r
+                               @"The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the &lt;serviceDebug&gt; configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.";\r
+                       return Message.CreateMessage (req.Version, fc, faultString, req.Headers.Action);\r
+               }\r
+\r
+               void EnsureValid (DispatchOperation operation)\r
+               {\r
+                       if (operation.Invoker == null)\r
+                               throw new InvalidOperationException ("DispatchOperation requires Invoker.");\r
+                       if ((operation.DeserializeRequest || operation.SerializeReply) && operation.Formatter == null)\r
+                               throw new InvalidOperationException ("The DispatchOperation '" + operation.Name + "' requires Formatter, since DeserializeRequest and SerializeReply are not both false.");\r
+               }               \r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/PostReceiveRequestHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/PostReceiveRequestHandler.cs
new file mode 100644 (file)
index 0000000..b15581f
--- /dev/null
@@ -0,0 +1,31 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel.Channels;\r
+using System.ServiceModel;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       internal class PostReceiveRequestHandler : BaseRequestProcessorHandler\r
+       {\r
+               protected override bool ProcessRequest (MessageProcessingContext mrc)\r
+               {\r
+                       Message incomingMessage = mrc.IncomingMessage;\r
+                       EnsureInstanceContextOpen (mrc.InstanceContext);\r
+                       AfterReceiveRequest (ref incomingMessage, mrc);\r
+                       mrc.IncomingMessage = incomingMessage;\r
+                       return false;\r
+               }\r
+\r
+               void AfterReceiveRequest (ref Message message, MessageProcessingContext mrc)\r
+               {\r
+                       mrc.EventsHandler.AfterReceiveRequest ();\r
+               }\r
+\r
+               void EnsureInstanceContextOpen (InstanceContext ictx)\r
+               {\r
+                       if (ictx.State != CommunicationState.Opened)\r
+                               ictx.Open ();\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/PrefixEndpointAddressMessageFilter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/PrefixEndpointAddressMessageFilter.cs
new file mode 100644 (file)
index 0000000..719dff4
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// PrefixEndpointAddressMessageFilter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Globalization;
+using System.ServiceModel.Channels;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Dispatcher
+{
+       public class PrefixEndpointAddressMessageFilter : MessageFilter
+       {
+               EndpointAddress address;
+               bool cmp_host;
+
+               public PrefixEndpointAddressMessageFilter (EndpointAddress address)
+                       : this (address, false)
+               {
+               }
+
+               public PrefixEndpointAddressMessageFilter (EndpointAddress address,
+                       bool includeHostNameInComparison)
+               {
+                       this.address = address;
+                       cmp_host = includeHostNameInComparison;
+               }
+
+               public EndpointAddress Address {
+                       get { return address; }
+               }
+
+               public bool IncludeHostNameInComparison {
+                       get { return cmp_host; }
+               }
+
+               [MonoTODO]
+               protected internal override IMessageFilterTable<FilterData>
+                       CreateFilterTable<FilterData> ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override bool Match (Message message)
+               {
+                       Uri to = message.Headers.To;
+                       bool path = ((CultureInfo.InvariantCulture.CompareInfo.IsPrefix (to.AbsolutePath, address.Uri.AbsolutePath, CompareOptions.Ordinal)) && 
+                                       (to.Port == address.Uri.Port));
+                       bool host = IncludeHostNameInComparison
+                                       ? (String.CompareOrdinal (to.Host, address.Uri.Host) == 0)
+                                       : true;
+
+                       return path && host;
+               }
+
+               public override bool Match (MessageBuffer messageBuffer)
+               {
+                       if (messageBuffer == null)
+                               throw new ArgumentNullException ("messageBuffer");
+                       return Match (messageBuffer.CreateMessage ());
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ReplyHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ReplyHandler.cs
new file mode 100644 (file)
index 0000000..91c6712
--- /dev/null
@@ -0,0 +1,17 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel.Channels;\r
+using System.ServiceModel;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       internal class ReplyHandler : BaseRequestProcessorHandler\r
+       {\r
+               protected override bool ProcessRequest (MessageProcessingContext mrc)\r
+               {                       \r
+                       mrc.Reply (true);\r
+                       return false;                   \r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/SecurityHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/SecurityHandler.cs
new file mode 100644 (file)
index 0000000..9a375f6
--- /dev/null
@@ -0,0 +1,42 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel.Channels;\r
+using System.ServiceModel;\r
+using System.ServiceModel.Security.Tokens;\r
+\r
+namespace System.ServiceModel.Dispatcher\r
+{\r
+       internal class SecurityHandler : BaseRequestProcessorHandler\r
+       {\r
+               protected override bool ProcessRequest (MessageProcessingContext mrc)\r
+               {\r
+                       DispatchRuntime dispatch_runtime = mrc.OperationContext.EndpointDispatcher.DispatchRuntime;\r
+                       Message negoResponce = null;\r
+                       // process WS-Trust based negotiation\r
+                       MessageSecurityBindingSupport support =\r
+                               dispatch_runtime.ChannelDispatcher.Listener.GetProperty<MessageSecurityBindingSupport> ();\r
+                       if (support != null && mrc.IncomingMessage.Headers.FindHeader ("Security", Constants.WssNamespace) < 0) {\r
+                               CommunicationSecurityTokenAuthenticator nego =\r
+                                       support.TokenAuthenticator as CommunicationSecurityTokenAuthenticator;\r
+                               if (nego != null)\r
+                                       negoResponce = nego.Communication.ProcessNegotiation (mrc.IncomingMessage);\r
+                       }\r
+\r
+                       if (negoResponce == null)\r
+                               return false;\r
+                       \r
+                       ReplyNegoResponse (mrc, negoResponce);\r
+                       return true;\r
+\r
+               }\r
+\r
+               void ReplyNegoResponse (MessageProcessingContext mrc, Message negoResponse)\r
+               {\r
+                       negoResponse.Headers.CopyHeadersFrom (mrc.OperationContext.OutgoingMessageHeaders);\r
+                       negoResponse.Properties.CopyProperties (mrc.OperationContext.OutgoingMessageProperties);                        \r
+                       mrc.RequestContext.Reply (negoResponse, mrc.CommunicationTimeouts.SendTimeout);\r
+                       return;\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/SeekableXPathNavigator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/SeekableXPathNavigator.cs
new file mode 100644 (file)
index 0000000..cac0bf9
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// System.ServiceModel.EndpointAddress.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Xml;
+using System.Xml.XPath;
+
+namespace System.ServiceModel.Dispatcher
+{
+
+       public abstract class SeekableXPathNavigator : XPathNavigator
+       {
+               protected SeekableXPathNavigator () {}
+
+               public abstract XmlNodeOrder ComparePosition (long first, long second);
+               public abstract string GetLocalName (long node_position);
+               public abstract string GetName (long node_position);
+               public abstract string GetNamespace (long node_position);
+               public abstract XPathNodeType GetNodeType (long node_position);
+               public abstract string GetValue (long node_position);
+
+               public abstract long CurrentPosition { get; set; }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ServiceThrottle.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ServiceThrottle.cs
new file mode 100644 (file)
index 0000000..c2a66ae
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// ServiceThrottle.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+namespace System.ServiceModel.Dispatcher
+{
+       [MonoTODO]
+       public sealed class ServiceThrottle
+       {
+               internal ServiceThrottle ()
+               {
+               }
+
+               int max_call, max_session, max_instance;
+
+               public int MaxConcurrentCalls {
+                       get { return max_call; }
+                       set { max_call = value; }
+               }
+
+               public int MaxConcurrentSessions {
+                       get { return max_session; }
+                       set { max_session = value; }
+               }
+
+               public int MaxConcurrentInstances {
+                       get { return max_instance; }
+                       set { max_instance = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/SingletonInstanceContextProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/SingletonInstanceContextProvider.cs
new file mode 100644 (file)
index 0000000..358b315
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// SingletonInstanceContextProvider.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Dispatcher
+{
+       internal class SingletonInstanceContextProvider : IInstanceContextProvider
+       {
+               InstanceContext ctx;
+
+               public SingletonInstanceContextProvider (InstanceContext context)
+               {
+                       this.ctx = context;
+               }
+
+               public InstanceContext GetExistingInstanceContext (Message message, IContextChannel channel)
+               {
+                       return ctx;
+               }
+
+               public void InitializeInstanceContext (InstanceContext instanceContext, Message message, IContextChannel channel)
+               {
+                       // FIXME: what to do here?
+               }
+
+               public bool IsIdle (InstanceContext instanceContext)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+
+               public void NotifyIdle (InstanceContextIdleCallback callback, InstanceContext instanceContext)
+               {
+                       // FIXME: implement
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathMessageContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathMessageContext.cs
new file mode 100644 (file)
index 0000000..434f459
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// XPathMessageContext.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Xml;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [MonoTODO]
+       public class XPathMessageContext : XsltContext
+       {
+               public XPathMessageContext ()
+                       : base ()
+               {
+               }
+
+               public XPathMessageContext (NameTable nameTable)
+                       : base (nameTable)
+               {
+               }
+
+               [MonoTODO]
+               public override bool Whitespace {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public override int CompareDocument (string uri1, string uri2)
+               {
+                       return String.CompareOrdinal (uri1, uri2);
+               }
+
+               [MonoTODO]
+               public override bool PreserveWhitespace (XPathNavigator node)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override IXsltContextFunction ResolveFunction (
+                       string prefix, string name, XPathResultType [] argTypes)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override IXsltContextVariable ResolveVariable (
+                       string prefix, string name)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathMessageFilter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathMessageFilter.cs
new file mode 100644 (file)
index 0000000..17a612b
--- /dev/null
@@ -0,0 +1,193 @@
+//
+// XPathMessageFilter.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+using System.Xml.XPath;
+using System.Xml.Xsl;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [MonoTODO]
+       [XmlRoot ("XPathMessageFilter", Namespace = "http://schemas.microsoft.com/serviceModel/2004/05/xpathfilter")]
+       [XmlSchemaProvider ("StaticGetSchema")]
+       public class XPathMessageFilter : MessageFilter, IXmlSerializable
+       {
+               public static XmlSchemaType StaticGetSchema (XmlSchemaSet schemas)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               XmlNamespaceManager namespaces;
+               int node_quota;
+               string xpath;
+               XPathExpression expr;
+
+               public XPathMessageFilter ()
+               {
+               }
+
+               public XPathMessageFilter (string xpath)
+               {
+                       Initialize (xpath, null);
+               }
+
+               public XPathMessageFilter (string xpath, XmlNamespaceManager namespaces)
+               {
+                       Initialize (xpath, namespaces);
+               }
+
+               public XPathMessageFilter (string xpath, XsltContext namespaces)
+               {
+                       Initialize (xpath, namespaces);
+               }
+
+               [MonoTODO]
+               public XPathMessageFilter (XmlReader reader)
+                       : this (reader, (XmlNamespaceManager) null)
+               {
+               }
+
+               [MonoTODO]
+               public XPathMessageFilter (XmlReader reader, XmlNamespaceManager namespaces)
+               {
+                       Initialize (reader.ReadString (), namespaces);
+               }
+
+               [MonoTODO]
+               public XPathMessageFilter (XmlReader reader, XsltContext namespaces)
+               {
+                       Initialize (reader.ReadString (), namespaces);
+               }
+
+               private void Initialize (string xpath, XmlNamespaceManager nsmgr)
+               {
+                       this.xpath = xpath;
+                       namespaces = nsmgr;
+               }
+
+               public XmlNamespaceManager Namespaces {
+                       get { return namespaces; }
+               }
+
+               public int NodeQuota {
+                       get { return node_quota; }
+                       set { node_quota = value; }
+               }
+
+               public string XPath {
+                       get { return xpath; }
+               }
+
+               protected internal override IMessageFilterTable<FilterData> CreateFilterTable<FilterData> ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool Match (Message message)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool Match (MessageBuffer messageBuffer)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool Match (SeekableXPathNavigator navigator)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool Match (XPathNavigator navigator)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void TrimToSize ()
+               {
+                       expr = null;
+                       throw new NotImplementedException ();
+               }
+
+               public void WriteXPathTo (XmlWriter writer,
+                       string prefix, string localName, string ns,
+                       bool writeNamespaces)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected virtual XmlSchema OnGetSchema ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected virtual void OnReadXml (XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected virtual void OnWriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected void ReadXPath (XmlReader reader,
+                       XmlNamespaceManager namespaces)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected void WriteXPath (XmlWriter writer,
+                       IXmlNamespaceResolver resolver)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               XmlSchema IXmlSerializable.GetSchema ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IXmlSerializable.ReadXml (XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IXmlSerializable.WriteXml (XmlWriter writer)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathMessageFilterTable.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathMessageFilterTable.cs
new file mode 100644 (file)
index 0000000..b65b4e9
--- /dev/null
@@ -0,0 +1,216 @@
+//
+// XPathMessageFilterTable.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+using System.Xml.XPath;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [DataContract]
+       public class XPathMessageFilterTable<TFilterData>
+               : IDictionary<MessageFilter,TFilterData>,
+                 IMessageFilterTable<TFilterData>,
+                 IEnumerable,
+                 ICollection<KeyValuePair<MessageFilter,TFilterData>>,
+                 IEnumerable<KeyValuePair<MessageFilter,TFilterData>>
+       {
+               Dictionary<MessageFilter,TFilterData> dict
+                       = new Dictionary<MessageFilter,TFilterData> ();
+
+               int quota;
+
+               [MonoTODO]
+               public XPathMessageFilterTable ()
+                       : this (int.MaxValue)
+               {
+               }
+
+               public XPathMessageFilterTable (int quota)
+               {
+                       this.quota = quota;
+               }
+
+               [DataMember]
+               public int NodeQuota {
+                       get { return quota; }
+                       set { quota = value; }
+               }
+
+               public TFilterData this [MessageFilter key] {
+                       get { return dict [key]; }
+                       set { dict [key] = value; }
+               }
+
+               public int Count {
+                       get { return dict.Count; }
+               }
+
+               public bool IsReadOnly {
+                       get { return false; }
+               }
+
+               public ICollection<MessageFilter> Keys {
+                       get { return dict.Keys; }
+               }
+
+               public ICollection<TFilterData> Values {
+                       get { return dict.Values; }
+               }
+
+               public void Add (KeyValuePair<MessageFilter,TFilterData> item)
+               {
+                       dict.Add (item.Key, item.Value);
+               }
+
+               [MonoTODO]
+               public void Add (XPathMessageFilter filter, TFilterData data)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void Add (MessageFilter filter, TFilterData data)
+               {
+                       dict.Add (filter, data);
+               }
+
+               public void Clear ()
+               {
+                       dict.Clear ();
+               }
+
+               public bool Contains (KeyValuePair<MessageFilter,TFilterData> item)
+               {
+                       return dict.ContainsKey (item.Key) &&
+                               dict [item.Key].Equals (item.Value);
+               }
+
+               public bool ContainsKey (MessageFilter key)
+               {
+                       return dict.ContainsKey (key);
+               }
+
+               public void CopyTo (KeyValuePair<MessageFilter,TFilterData> [] array, int index)
+               {
+                       if (index < 0 || dict.Count >= array.Length - index)
+                               throw new ArgumentOutOfRangeException ("index");
+                       foreach (KeyValuePair<MessageFilter,TFilterData> item in dict)
+                               array [index++] = item;
+               }
+
+               public IEnumerator<KeyValuePair<MessageFilter,TFilterData>> GetEnumerator ()
+               {
+                       return dict.GetEnumerator ();
+               }
+
+               IEnumerator IEnumerable.GetEnumerator ()
+               {
+                       return GetEnumerator ();
+               }
+
+               public bool GetMatchingFilter (Message message, out MessageFilter result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingFilter (MessageBuffer buffer, out MessageFilter result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingFilters (Message message, ICollection<MessageFilter> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingFilters (MessageBuffer buffer, ICollection<MessageFilter> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValue (Message message, out TFilterData data)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValue (MessageBuffer buffer, out TFilterData data)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValues (Message message, ICollection<TFilterData> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool GetMatchingValues (MessageBuffer buffer, ICollection<TFilterData> results)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool Remove (KeyValuePair<MessageFilter,TFilterData> item)
+               {
+                       if (dict.ContainsKey (item.Key) && dict [item.Key].Equals (item.Value)) {
+                               dict.Remove (item.Key);
+                               return true;
+                       }
+                       return false;
+               }
+
+               public bool Remove (XPathMessageFilter filter)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public bool Remove (MessageFilter filter)
+               {
+                       return dict.Remove (filter);
+               }
+
+               public bool TryGetValue (MessageFilter filter, out TFilterData filterData)
+               {
+                       if (dict.ContainsKey (filter)) {
+                               filterData = dict [filter];
+                               return true;
+                       } else {
+                               filterData = default (TFilterData);
+                               return false;
+                       }
+               }
+
+               [MonoTODO]
+               public void TrimToSize ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathNavigatorException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XPathNavigatorException.cs
new file mode 100644 (file)
index 0000000..365a7be
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// System.ServiceModel.XPathNavigatorException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.Xml.XPath;
+
+namespace System.ServiceModel.Dispatcher
+{
+       [Serializable]
+       public class XPathNavigatorException : XPathException
+       {
+               public XPathNavigatorException () : this ("Navigator node quota exceeded") {}
+               public XPathNavigatorException (string msg) : base (msg) {}
+               public XPathNavigatorException (string msg, Exception inner)
+                       : base (msg, inner) {}          
+               protected XPathNavigatorException (SerializationInfo info,
+                                                           StreamingContext context)
+                       : base (info, context) {}
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/ChangeLog
new file mode 100644 (file)
index 0000000..e84a1cf
--- /dev/null
@@ -0,0 +1,6 @@
+2007-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MsmqIntegrationMessageProperty.cs MsmqIntegrationBinding.cs
+         MsmqMessage.cs MsmqIntegrationBindingElement.cs
+         MsmqIntegrationSecurity.cs : new stubs.
+
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationBinding.cs
new file mode 100644 (file)
index 0000000..fc1d38b
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// MsmqIntegrationBinding.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Xml;
+
+namespace System.ServiceModel.MsmqIntegration
+{
+       public class MsmqIntegrationBinding : MsmqBindingBase
+       {
+               MsmqIntegrationSecurity security;
+               MsmqMessageSerializationFormat format;
+
+               public MsmqIntegrationBinding ()
+                       : this (MsmqIntegrationSecurityMode.None)
+               {
+               }
+
+               public MsmqIntegrationBinding (MsmqIntegrationSecurityMode securityMode)
+               {
+                       security = new MsmqIntegrationSecurity ();
+                       security.Mode = securityMode;
+               }
+
+               [MonoTODO]
+               public MsmqIntegrationBinding (string configurationName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public MsmqIntegrationSecurity Security {
+                       get { return security; }
+               }
+
+               public MsmqMessageSerializationFormat SerializationFormat {
+                       get { return format; }
+                       set { format = value; }
+               }
+
+               [MonoTODO]
+               public override BindingElementCollection CreateBindingElements ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationBindingElement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationBindingElement.cs
new file mode 100644 (file)
index 0000000..142dcff
--- /dev/null
@@ -0,0 +1,92 @@
+//
+// MsmqIntegrationBindingElement.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.MsmqIntegration
+{
+       public sealed class MsmqIntegrationBindingElement : MsmqBindingElementBase
+       {
+               MsmqMessageSerializationFormat format;
+               Type [] target_types;
+
+               public MsmqIntegrationBindingElement ()
+               {
+               }
+
+               public MsmqMessageSerializationFormat SerializationFormat {
+                       get { return format; }
+                       set { format = value; }
+               }
+
+               public override string Scheme {
+                       get { return "net.msmq"; }
+               }
+
+               public Type[] TargetSerializationTypes {
+                       get { return target_types; }
+                       set { target_types = value; }
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return (MsmqIntegrationBindingElement) MemberwiseClone ();
+               }
+
+               [MonoTODO]
+               public override bool CanBuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override bool CanBuildChannelListener<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationMessageProperty.cs b/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationMessageProperty.cs
new file mode 100644 (file)
index 0000000..184a3f7
--- /dev/null
@@ -0,0 +1,151 @@
+//
+// MsmqIntegrationMessageProperty.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Messaging;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+using SMessage = System.ServiceModel.Channels.Message;
+
+namespace System.ServiceModel.MsmqIntegration
+{
+       public sealed class MsmqIntegrationMessageProperty
+       {
+               public const string Name = "MsmqIntegrationMessageProperty";
+
+               public MsmqIntegrationMessageProperty ()
+               {
+               }
+
+               [MonoTODO]
+               public static MsmqIntegrationMessageProperty Get (SMessage message)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               AcknowledgeTypes? ack_type;
+               Acknowledgment? ack;
+               Uri adm_queue, dst_queue, res_queue;
+               int? app_specific, body_type;
+               DateTime? arrived_time, sent_time;
+               bool? authenticated;
+               object body;
+               string correlation_id, id, label;
+               byte [] extension, sender_id;
+               MessageType? msg_type;
+               MessagePriority? priority;
+               TimeSpan? ttrq;
+
+               public AcknowledgeTypes? AcknowledgeType {
+                       get { return ack_type; }
+                       set { ack_type = value; }
+               }
+
+               public Acknowledgment? Acknowledgment {
+                       get { return ack; }
+               }
+               
+               public Uri AdministrationQueue {
+                       get { return adm_queue; }
+                       set { adm_queue = value; }
+               }
+
+               public int? AppSpecific {
+                       get { return app_specific; }
+                       set { app_specific = value; }
+               }
+
+               public DateTime? ArrivedTime {
+                       get { return arrived_time; }
+               }
+
+               public bool? Authenticated {
+                       get { return authenticated; }
+               }
+
+               public object Body {
+                       get { return body; }
+                       set { body = value; }
+               }
+
+               public int? BodyType {
+                       get { return body_type; }
+                       set { body_type = value; }
+               }
+
+               public string CorrelationId {
+                       get { return correlation_id; }
+                       set { correlation_id = value; }
+               }
+
+               public Uri DestinationQueue {
+                       get { return dst_queue; }
+               }
+
+               public byte [] Extension {
+                       get { return extension; }
+                       set { extension = value; }
+               }
+
+               public string Id {
+                       get { return id; }
+               }
+
+               public string Label {
+                       get { return label; }
+                       set { label = value; }
+               }
+
+               public MessageType? MessageType {
+                       get { return msg_type; }
+               }
+
+               public MessagePriority? Priority {
+                       get { return priority; }
+                       set { priority = value; }
+               }
+
+               public Uri ResponseQueue {
+                       get { return res_queue; }
+                       set { res_queue = value; }
+               }
+
+               public byte [] SenderId {
+                       get { return sender_id; }
+               }
+
+               public DateTime? SentTime {
+                       get { return sent_time; }
+               }
+
+               public TimeSpan? TimeToReachQueue {
+                       get { return ttrq; }
+                       set { ttrq = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationSecurity.cs b/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqIntegrationSecurity.cs
new file mode 100644 (file)
index 0000000..5c9a4fb
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// MsmqIntegrationSecurity.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.MsmqIntegration
+{
+       public sealed class MsmqIntegrationSecurity
+       {
+               MsmqIntegrationSecurityMode mode;
+               MsmqTransportSecurity transport = new MsmqTransportSecurity ();
+
+               public MsmqIntegrationSecurityMode Mode {
+                       get { return mode; }
+                       set { mode = value; }
+               }
+
+               public MsmqTransportSecurity Transport {
+                       get { return transport; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqMessage.cs b/mcs/class/System.ServiceModel/System.ServiceModel.MsmqIntegration/MsmqMessage.cs
new file mode 100644 (file)
index 0000000..b9a7630
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// MsmqMessage.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Messaging;
+using System.ServiceModel;
+
+namespace System.ServiceModel.MsmqIntegration
+{
+       [MessageContract]
+       public sealed class MsmqMessage<T>
+       {
+               AcknowledgeTypes? ack_type;
+               Acknowledgment? ack;
+               Uri adm_queue, dst_queue, res_queue;
+               int? app_specific, body_type;
+               DateTime? arrived_time, sent_time;
+               bool? authenticated;
+               T body;
+               string correlation_id, id, label;
+               byte [] extension, sender_id;
+               MessageType? msg_type;
+               MessagePriority? priority;
+               TimeSpan? ttrq;
+
+               public MsmqMessage (T body)
+               {
+                       this.body = body;
+               }
+
+               public AcknowledgeTypes? AcknowledgeType {
+                       get { return ack_type; }
+                       set { ack_type = value; }
+               }
+
+               public Acknowledgment? Acknowledgment {
+                       get { return ack; }
+               }
+               
+               public Uri AdministrationQueue {
+                       get { return adm_queue; }
+                       set { adm_queue = value; }
+               }
+
+               public int? AppSpecific {
+                       get { return app_specific; }
+                       set { app_specific = value; }
+               }
+
+               public DateTime? ArrivedTime {
+                       get { return arrived_time; }
+               }
+
+               public bool? Authenticated {
+                       get { return authenticated; }
+               }
+
+               public T Body {
+                       get { return body; }
+                       set { body = value; }
+               }
+
+               public int? BodyType {
+                       get { return body_type; }
+                       set { body_type = value; }
+               }
+
+               public string CorrelationId {
+                       get { return correlation_id; }
+                       set { correlation_id = value; }
+               }
+
+               public Uri DestinationQueue {
+                       get { return dst_queue; }
+               }
+
+               public byte [] Extension {
+                       get { return extension; }
+                       set { extension = value; }
+               }
+
+               public string Id {
+                       get { return id; }
+               }
+
+               public string Label {
+                       get { return label; }
+                       set { label = value; }
+               }
+
+               public MessageType? MessageType {
+                       get { return msg_type; }
+               }
+
+               public MessagePriority? Priority {
+                       get { return priority; }
+                       set { priority = value; }
+               }
+
+               public Uri ResponseQueue {
+                       get { return res_queue; }
+                       set { res_queue = value; }
+               }
+
+               public byte [] SenderId {
+                       get { return sender_id; }
+               }
+
+               public DateTime? SentTime {
+                       get { return sent_time; }
+               }
+
+               public TimeSpan? TimeToReachQueue {
+                       get { return ttrq; }
+                       set { ttrq = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ChangeLog
new file mode 100644 (file)
index 0000000..c6fde85
--- /dev/null
@@ -0,0 +1,63 @@
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * RegisterInfo.cs : marcos would have never thought that this is
+         the source of message xml incompatibility.
+
+2007-08-19 Marcos Cobena (marcoscobena@gmail.com)
+
+       * PeerCustomResolverSettings.cs, RefreshInfo.cs, RefreshResponseInfo.cs, 
+       ServiceSettingsResponseInfo.cs, UnregisterInfo.cs, UpdateInfo.cs: Bunch of updates.
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PeerCustomResolverSettings.cs : this class too.
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PeerResolverSettings.cs : there is nothing actually supported in
+         this class, so don't forget MonoTODOs.
+
+2007-08-17 Marcos Cobena (marcoscobena@gmail.com)
+
+       * CustomPeerResolverService.cs: Updated to dependency types.
+       * RegisterInfo.cs, RegisterResponseInfo.cs, ResolveInfo.cs, 
+       ResolveResponseInfo.cs, UnregisterInfo.cs: Updated to produce same messages as .NET does.
+
+2007-08-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * RegisterInfo.cs : rewritten. Fixed broken approach to static
+         object and eliminated duplicate fields. Use DataMember on Guid
+         field directly.
+
+2007-08-16 Marcos Cobena (marcoscobena@gmail.com)
+
+       * PeerReferralPolicy.cs: Moved and updated here from AllEnums.cs.
+       * PeerResolverMode.cs: Updated API.
+       * RefreshResult.cs: Updated API.
+       * RegisterInfo.cs: Almost finished, minus HasBody().
+
+2007-07-24 Marcos Cobena (marcoscobena@gmail.com)
+
+       * CustomPeerResolverService.cs, IPeerResolverContract.cs, RegisterInfo.cs, ResolveInfo.cs: Minor changes.
+       * RegisterResponseInfo.cs: Implemented.
+
+2007-06-28 Marcos Cobena (marcoscobena@gmail.com)
+
+       * CustomPeerResolverService.cs : Minor fixes for working against tests.
+       * New classes initial implementations.
+
+2007-05-18 Marcos Cobena (marcoscobena@gmail.com)
+
+       * IPeerResolverContract.cs
+         CustomPeerResolverService.cs : Minor fixes. IPeerResolverContract 
+         works fine now with attributes.
+
+2007-05-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IPeerResolverContract.cs CustomPeerResolverService.cs :
+         whitespaces should be replaced with tabs.
+
+2007-05-04 Marcos Cobena (marcoscobena@gmail.com)
+
+       * IPeerResolverContract.cs
+         CustomPeerResolverService.cs : Initial implementations.
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/CustomPeerResolverService.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/CustomPeerResolverService.cs
new file mode 100644 (file)
index 0000000..3d61171
--- /dev/null
@@ -0,0 +1,192 @@
+// 
+// CustomPeerResolverService.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System.Collections.Generic;
+using System.Transactions;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       // FIXME: TransactionTimeout must be null by-default.
+       [ServiceBehavior (AutomaticSessionShutdown = true, ConcurrencyMode = ConcurrencyMode.Multiple, 
+                         InstanceContextMode = InstanceContextMode.Single, ReleaseServiceInstanceOnTransactionComplete = true, 
+                         TransactionIsolationLevel = IsolationLevel.Unspecified, /*TransactionTimeout = null, */
+                         UseSynchronizationContext = false, ValidateMustUnderstand = true)]
+       public class CustomPeerResolverService : IPeerResolverContract
+       {
+               TimeSpan cleanup_interval;
+               bool control_shape;
+               bool opened;
+               // Maybe it's worth to change List<T> for a better distributed and faster collection.
+               List<Node> mesh = new List<Node> ();
+               object mesh_lock = new object ();
+               TimeSpan refresh_interval;
+
+               public CustomPeerResolverService ()
+               {
+                       cleanup_interval = new TimeSpan (0, 1, 0);
+                       control_shape = false;
+                       opened = false;
+                       refresh_interval = new TimeSpan (0, 10, 0);
+               }
+
+               [MonoTODO ("To check for InvalidOperationException")]
+               public TimeSpan CleanupInterval {
+                       get { return cleanup_interval; }
+                       set {
+                               if ((value < TimeSpan.Zero) || (value > TimeSpan.MaxValue))
+                                       throw new ArgumentOutOfRangeException (
+                                       "The interval is either zero or greater than max value.");
+
+                               cleanup_interval = value;
+                       }
+               }
+
+               public bool ControlShape {
+                       get { return control_shape; }
+                       set { control_shape = value; }
+               }
+
+               [MonoTODO ("To check for InvalidOperationException")]
+               public TimeSpan RefreshInterval {
+                       get { return refresh_interval; }
+                       set {
+                               if ((value < TimeSpan.Zero) || (value > TimeSpan.MaxValue))
+                                       throw new ArgumentOutOfRangeException (
+                                       "The interval is either zero or greater than max value.");
+
+                               refresh_interval = value;
+                       }
+               }
+
+               [MonoTODO]
+               public virtual void Close ()
+               {
+                       if (! opened)
+                               throw new InvalidOperationException ("The service has never been opened or it was closed by a previous call to this method.");
+               }
+
+               [MonoTODO]
+               public virtual ServiceSettingsResponseInfo GetServiceSettings ()
+               {
+                       if (! opened)
+                               throw new InvalidOperationException ("The service has never been opened or it was closed previously.");
+               
+//                     return new ServiceSettingsResponseInfo ();
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public virtual void Open ()
+               {
+                       if ((cleanup_interval == TimeSpan.Zero) || (refresh_interval == TimeSpan.Zero))
+                               throw new ArgumentException ("Cleanup interval or refresh interval are set to a time span interval of zero.");
+
+                       if (opened)
+                               throw new InvalidOperationException ("The service has been started by a previous call to this method.");
+                       
+                       opened = true;
+               }
+
+               [MonoTODO]
+               public virtual RefreshResponseInfo Refresh (RefreshInfo refreshInfo)
+               {
+                       if (refreshInfo == null)
+                               throw new ArgumentException ("Refresh info cannot be null.");
+                       
+                       if (! opened)
+                               throw new InvalidOperationException ("The service has never been opened or it was closed previously.");
+                       
+//                     return new RefreshResponseInfo ();
+                       throw new NotImplementedException ();
+               }
+
+               public virtual RegisterResponseInfo Register (RegisterInfo registerInfo)
+               {
+                       if (registerInfo == null)
+                               throw new ArgumentException ("Register info cannot be null.");
+                       
+                       if (! opened)
+                               throw new InvalidOperationException ("The service has never been opened or it was closed previously.");
+                       
+                       return Register (registerInfo.ClientId, registerInfo.MeshId, registerInfo.NodeAddress);
+               }
+
+               [MonoTODO]
+               public virtual RegisterResponseInfo Register (Guid clientId, 
+                       string meshId, 
+                       PeerNodeAddress address)
+               {
+                       Node n = new Node ();
+                       RegisterResponseInfo rri = new RegisterResponseInfo ();
+                       
+                       if (ControlShape) {
+                               // FIXME: To update mesh node here.
+                               lock (mesh_lock)
+                               {
+                                       mesh.Add (n);
+//                                     Console.WriteLine ("{0}, {1}, {2}", clientId, meshId, address);
+                               }
+                       }
+                       
+                       return rri;
+               }
+
+               [MonoTODO]
+               public virtual ResolveResponseInfo Resolve (ResolveInfo resolveInfo)
+               {
+                       ResolveResponseInfo rri = new ResolveResponseInfo ();
+                       
+                       if (resolveInfo == null)
+                               throw new ArgumentException ("Resolve info cannot be null.");
+                       
+                       if (! opened)
+                               throw new InvalidOperationException ("The service has never been opened or it was closed previously.");
+                       
+                       if (ControlShape)
+                       {
+                               // FIXME: To resolve address here.
+                       }
+                       
+                       return rri;
+               }
+
+               [MonoTODO]
+               public virtual void Unregister (UnregisterInfo unregisterInfo)
+               {
+                       if (unregisterInfo == null)
+                               throw new ArgumentException ("Unregister info cannot be null.");
+                       
+                       if (! opened)
+                               throw new InvalidOperationException ("The service has never been opened or it was closed previously.");
+                       
+                       if (ControlShape)
+                       {
+                               // FIXME: To remove node from mesh here.
+                       }
+               }
+
+               [MonoTODO]
+               public virtual RegisterResponseInfo Update (UpdateInfo updateInfo)
+               {
+                       if (updateInfo == null)
+                               throw new ArgumentException ("Update info cannot be null.");
+                       
+                       if (! opened)
+                               throw new InvalidOperationException ("The service has never been opened or it was closed previously.");
+                       
+//                     return new RegisterResponseInfo ();
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       internal class Node
+       {
+               
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/IPeerResolverContract.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/IPeerResolverContract.cs
new file mode 100644 (file)
index 0000000..b8333c9
--- /dev/null
@@ -0,0 +1,39 @@
+// 
+// IPeerResolverContract.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+namespace System.ServiceModel.PeerResolvers
+{
+       [ServiceContract (Name = "IPeerResolverContract", Namespace = "http://schemas.microsoft.com/net/2006/05/peer/resolver")]
+       public interface IPeerResolverContract
+       {
+               [OperationContract (IsOneWay = false, Name = "GetServiceInfo", 
+                                   Action = "http://schemas.microsoft.com/net/2006/05/peer/resolver/GetServiceSettings", 
+                                   ReplyAction = "http://schemas.microsoft.com/net/2006/05/peer/resolver/GetServiceSettingsResponse")]
+               ServiceSettingsResponseInfo GetServiceSettings ();
+               [OperationContract (IsOneWay = false, Name = "Refresh", 
+                                   Action = "http://schemas.microsoft.com/net/2006/05/peer/resolver/Refresh", 
+                                   ReplyAction = "http://schemas.microsoft.com/net/2006/05/peer/resolver/RefreshResponse")]
+               RefreshResponseInfo Refresh (RefreshInfo refreshInfo);
+               [OperationContract (IsOneWay = false, Name = "Register", 
+                                   Action = "http://schemas.microsoft.com/net/2006/05/peer/resolver/Register", 
+                                   ReplyAction = "http://schemas.microsoft.com/net/2006/05/peer/resolver/RegisterResponse")]
+               RegisterResponseInfo Register (RegisterInfo registerInfo);
+               [OperationContract (IsOneWay = false, Name = "Resolve", 
+                                   Action = "http://schemas.microsoft.com/net/2006/05/peer/resolver/Resolve", 
+                                   ReplyAction = "http://schemas.microsoft.com/net/2006/05/peer/resolver/ResolveResponse")]
+               ResolveResponseInfo Resolve (ResolveInfo resolveInfo);
+               [OperationContract (IsOneWay = false, Name = "Unregister", 
+                                   Action = "http://schemas.microsoft.com/net/2006/05/peer/resolver/Unregister")]
+               void Unregister (UnregisterInfo unregisterInfo);
+               [OperationContract (IsOneWay = false, Name = "Update", 
+                                   Action = "http://schemas.microsoft.com/net/2006/05/peer/resolver/Update", 
+                                   ReplyAction = "http://schemas.microsoft.com/net/2006/05/peer/resolver/UpdateResponse")]
+               RegisterResponseInfo Update (UpdateInfo updateInfo);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerCustomResolverSettings.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerCustomResolverSettings.cs
new file mode 100644 (file)
index 0000000..2ce3379
--- /dev/null
@@ -0,0 +1,47 @@
+// 
+// PeerCustomResolverSettings.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       public class PeerCustomResolverSettings
+       {
+               EndpointAddress address;
+               Binding binding;
+               PeerResolver resolver;
+               
+               public PeerCustomResolverSettings()
+               {
+               }
+               
+               [MonoTODO]
+               public EndpointAddress Address {
+                       get { return address; }
+                       set { address = value; }
+               }
+               
+               [MonoTODO]
+               public Binding Binding {
+                       get { return binding; }
+                       set { binding = value; }
+               }
+               
+               public bool IsBindingSpecified {
+                       get { return Binding != null; }
+               }
+               
+               [MonoTODO]
+               public PeerResolver Resolver {
+                       get { return resolver; }
+                       set { resolver = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerReferralPolicy.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerReferralPolicy.cs
new file mode 100644 (file)
index 0000000..25a9713
--- /dev/null
@@ -0,0 +1,18 @@
+// 
+// PeerReferralPolicy.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+namespace System.ServiceModel.PeerResolvers
+{
+       public enum PeerReferralPolicy
+       {
+               Service, 
+               Share, 
+               DoNotShare
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerResolverMode.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerResolverMode.cs
new file mode 100644 (file)
index 0000000..999cb51
--- /dev/null
@@ -0,0 +1,19 @@
+// 
+// PeerResolverMode.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       public enum PeerResolverMode {
+               Auto, 
+               Pnrp, 
+               Custom
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerResolverSettings.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/PeerResolverSettings.cs
new file mode 100644 (file)
index 0000000..9db100b
--- /dev/null
@@ -0,0 +1,43 @@
+// 
+// PeerResolverSettings.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System;
+using System.ServiceModel.PeerResolvers;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       public class PeerResolverSettings
+       {
+               PeerCustomResolverSettings custom = new PeerCustomResolverSettings ();
+               // FIXME: Is it really by default Auto?
+               PeerResolverMode mode = PeerResolverMode.Auto;
+               PeerReferralPolicy referral_policy;
+               
+               public PeerResolverSettings ()
+               {
+               }
+               
+               [MonoTODO]
+               public PeerCustomResolverSettings Custom {
+                       get { return custom; }
+               }
+               
+               [MonoTODO]
+               public PeerResolverMode Mode {
+                       get { return mode; }
+                       set { mode = value; }
+               }
+               
+               [MonoTODO]
+               public PeerReferralPolicy ReferralPolicy {
+                       get { return referral_policy; }
+                       set { referral_policy = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RefreshInfo.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RefreshInfo.cs
new file mode 100644 (file)
index 0000000..71d6049
--- /dev/null
@@ -0,0 +1,69 @@
+// 
+// RefreshInfo.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       [MessageContract (IsWrapped = false)]
+       public class RefreshInfo
+       {
+               [MessageBodyMember (Name = "Refresh", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
+               RefreshInfoDC body;
+               
+               public RefreshInfo ()
+               {
+                       body = new RefreshInfoDC ();
+               }
+               
+               public RefreshInfo (string meshId, Guid regId)
+                       : this ()
+               {
+                       body.MeshId = meshId;
+                       body.RegistrationId = regId;
+               }
+               
+               public string MeshId {
+                       get { return body.MeshId; }
+               }
+               
+               public Guid RegistrationId {
+                       get { return body.RegistrationId; }
+               }
+               
+               [MonoTODO]
+               public bool HasBody ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       [DataContract]
+       internal class RefreshInfoDC
+       {
+               string mesh_id;
+               Guid registration_id;
+
+               public RefreshInfoDC ()
+               {
+               }
+               
+               [DataMember]
+               public string MeshId {
+                       get { return mesh_id; }
+                       set { mesh_id = value; }
+               }
+               
+               [DataMember]
+               public Guid RegistrationId {
+                       get { return registration_id; }
+                       set { registration_id = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RefreshResponseInfo.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RefreshResponseInfo.cs
new file mode 100644 (file)
index 0000000..8c79130
--- /dev/null
@@ -0,0 +1,72 @@
+// 
+// RefreshResponseInfo.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       [MessageContract (IsWrapped = false)]
+       public class RefreshResponseInfo
+       {
+               // FIXME: I'm not 100% sure its Name is "Update", I need to take some more long period traces.
+               [MessageBodyMember (Name = "Update", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
+               RefreshResponseInfoDC body;
+               
+               public RefreshResponseInfo ()
+               {
+                       body = new RefreshResponseInfoDC ();
+               }
+               
+               public RefreshResponseInfo (TimeSpan registrationLifetime, RefreshResult result)
+                       : this ()
+               {
+                       body.RegistrationLifetime = registrationLifetime;
+                       body.Result = result;
+               }
+               
+               public TimeSpan RegistrationLifetime {
+                       get { return body.RegistrationLifetime; }
+                       set { body.RegistrationLifetime = value; }
+               }
+               
+               public RefreshResult Result {
+                       get { return body.Result; }
+                       set { body.Result = value; }
+               }
+               
+               [MonoTODO]
+               public bool HasBody ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       [DataContract]
+       internal class RefreshResponseInfoDC
+       {
+               TimeSpan registration_lifetime;
+               RefreshResult result;
+
+               public RefreshResponseInfoDC ()
+               {
+               }
+               
+               [DataMember]
+               public TimeSpan RegistrationLifetime {
+                       get { return registration_lifetime; }
+                       set { registration_lifetime = value; }
+               }
+               
+               [DataMember]
+               public RefreshResult Result {
+                       get { return result; }
+                       set { result = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RefreshResult.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RefreshResult.cs
new file mode 100644 (file)
index 0000000..bfdfe5a
--- /dev/null
@@ -0,0 +1,16 @@
+// 
+// RefreshResult.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+namespace System.ServiceModel.PeerResolvers
+{
+       public enum RefreshResult {
+               Success, 
+               RegistrationNotFound
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RegisterInfo.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RegisterInfo.cs
new file mode 100644 (file)
index 0000000..29ddd0d
--- /dev/null
@@ -0,0 +1,102 @@
+// 
+// RegisterInfo.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+//     Atsushi Enomoto  <atsushi@ximian.com>
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// Copyright (C) 2007 Novell, Inc. http://novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       [MessageContract (IsWrapped = false)]
+       public class RegisterInfo
+       {
+               [MessageBodyMember (Name = "Register", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
+               RegisterInfoDC body;
+               
+               public RegisterInfo ()
+               {
+                       body = new RegisterInfoDC ();
+               }
+               
+               public RegisterInfo (Guid client, string meshId, PeerNodeAddress address)
+                       : this ()
+               {
+                       body.ClientId = client;
+                       body.MeshId = meshId;
+                       body.NodeAddress = address;
+               }
+               
+               public Guid ClientId {
+                       get { return body.ClientId; }
+               }
+               
+               public string MeshId {
+                       get { return body.MeshId; }
+               }
+               
+               public PeerNodeAddress NodeAddress {
+                       get { return body.NodeAddress; }
+               }
+               
+               [MonoTODO]
+               public bool HasBody ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       [DataContract (Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
+       internal class RegisterInfoDC
+       {
+               Guid client_id;
+               string mesh_id;
+               PeerNodeAddress node_address;
+
+               public RegisterInfoDC ()
+               {
+               }
+               
+               [DataMember]
+               public Guid ClientId {
+                       get { return client_id; }
+                       set { client_id = value; }
+               }
+               
+               [DataMember]
+               public string MeshId {
+                       get { return mesh_id; }
+                       set { mesh_id = value; }
+               }
+               
+               [DataMember]
+               public PeerNodeAddress NodeAddress {
+                       get { return node_address; }
+                       set { node_address = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RegisterResponseInfo.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/RegisterResponseInfo.cs
new file mode 100644 (file)
index 0000000..88b1999
--- /dev/null
@@ -0,0 +1,70 @@
+// 
+// RegisterResponseInfo.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       [MessageContract (IsWrapped = false)]
+       public class RegisterResponseInfo
+       {
+               [MessageBodyMember (Name = "Update", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
+               RegisterResponseInfoDC body;
+               
+               public RegisterResponseInfo ()
+               {
+                       body = new RegisterResponseInfoDC ();
+               }
+               
+               public RegisterResponseInfo (Guid registrationId, TimeSpan registrationLifetime)
+               {
+                       body.RegistrationId = registrationId;
+                       body.RegistrationLifetime = registrationLifetime;
+               }
+               
+               public Guid RegistrationId {
+                       get { return body.RegistrationId; }
+                       set { body.RegistrationId = value; }
+               }
+               
+               public TimeSpan RegistrationLifetime {
+                       get { return body.RegistrationLifetime; }
+                       set { body.RegistrationLifetime = value; }
+               }
+               
+               [MonoTODO]
+               public bool HasBody ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       [DataContract]
+       internal class RegisterResponseInfoDC
+       {
+               Guid registration_id;
+               TimeSpan registration_lifetime;
+
+               public RegisterResponseInfoDC ()
+               {
+               }
+               
+               [DataMember]
+               public Guid RegistrationId {
+                       get { return registration_id; }
+                       set { registration_id = value; }
+               }
+               
+               [DataMember]
+               public TimeSpan RegistrationLifetime {
+                       get { return registration_lifetime; }
+                       set { registration_lifetime = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ResolveInfo.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ResolveInfo.cs
new file mode 100644 (file)
index 0000000..3610175
--- /dev/null
@@ -0,0 +1,79 @@
+// 
+// ResolveInfo.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       [MessageContract (IsWrapped = false)]
+       public class ResolveInfo
+       {
+               [MessageBodyMember (Name = "Resolve", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
+               ResolveInfoDC body;
+               
+               public ResolveInfo ()
+               {
+                       body = new ResolveInfoDC ();
+               }
+               
+               public ResolveInfo (Guid clientId, string meshId, int maxAddresses)
+                       : this ()
+               {
+                       body.ClientId = clientId;
+                       body.MeshId = meshId;
+                       body.MaxAddresses = maxAddresses;
+               }
+               
+               public Guid ClientId {
+                       get { return body.ClientId; }
+               }
+               public int MaxAddresses {
+                       get { return body.MaxAddresses; }
+               }
+               public string MeshId {
+                       get { return body.MeshId; }
+               }
+               
+               [MonoTODO]
+               public bool HasBody()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       [DataContract]
+       internal class ResolveInfoDC
+       {
+               Guid client_id;
+               int max_addresses;
+               string mesh_id;
+
+               public ResolveInfoDC ()
+               {
+               }
+               
+               [DataMember]
+               public Guid ClientId {
+                       get { return client_id; }
+                       set { client_id = value; }
+               }
+               
+               [DataMember]
+               public int MaxAddresses {
+                       get { return max_addresses; }
+                       set { max_addresses = value; }
+               }
+               
+               [DataMember]
+               public string MeshId {
+                       get { return mesh_id; }
+                       set { mesh_id = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ResolveResponseInfo.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ResolveResponseInfo.cs
new file mode 100644 (file)
index 0000000..4a77e54
--- /dev/null
@@ -0,0 +1,58 @@
+// 
+// ResolveResponseInfo.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       [MessageContract (IsWrapped = false)]
+       public class ResolveResponseInfo
+       {
+               [MessageBodyMember (Name = "ResolveResponse", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
+               ResolveResponseInfoDC body;
+               
+               public ResolveResponseInfo ()
+               {
+                       body = new ResolveResponseInfoDC ();
+               }
+               
+               public ResolveResponseInfo (PeerNodeAddress[] addresses)
+               {
+                       body.Addresses = new List<PeerNodeAddress> (addresses);
+               }
+               
+               public IList<PeerNodeAddress> Addresses {
+                       get { return body.Addresses; }
+                       set { body.Addresses = value; }
+               }
+               
+               [MonoTODO]
+               public bool HasBody ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       [DataContract]
+       internal class ResolveResponseInfoDC
+       {
+               IList<PeerNodeAddress> addresses;
+
+               public ResolveResponseInfoDC ()
+               {
+               }
+               
+               [DataMember]
+               public IList<PeerNodeAddress> Addresses {
+                       get { return addresses; }
+                       set { addresses = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ServiceSettingsResponseInfo.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/ServiceSettingsResponseInfo.cs
new file mode 100644 (file)
index 0000000..fd440f8
--- /dev/null
@@ -0,0 +1,58 @@
+// 
+// ServiceSettingsResponseInfo.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       [MessageContract (IsWrapped = false)]
+       public class ServiceSettingsResponseInfo
+       {
+               [MessageBodyMember (Name = "ServiceSettings", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
+               ServiceSettingsResponseInfoDC body;
+               
+               public ServiceSettingsResponseInfo ()
+               {
+                       body = new ServiceSettingsResponseInfoDC ();
+               }
+               
+               public ServiceSettingsResponseInfo (bool control)
+                       : this ()
+               {
+                       body.ControlMeshShape = control;
+               }
+               
+               public bool ControlMeshShape {
+                       get { return body.ControlMeshShape; }
+                       set { body.ControlMeshShape = value; }
+               }
+               
+               [MonoTODO]
+               public bool HasBody ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       [DataContract]
+       internal class ServiceSettingsResponseInfoDC
+       {
+               bool control_mesh_shape;
+
+               public ServiceSettingsResponseInfoDC ()
+               {
+               }
+               
+               [DataMember]
+               public bool ControlMeshShape {
+                       get { return control_mesh_shape; }
+                       set { control_mesh_shape = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/UnregisterInfo.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/UnregisterInfo.cs
new file mode 100644 (file)
index 0000000..aadb494
--- /dev/null
@@ -0,0 +1,69 @@
+// 
+// UnregisterInfo.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       [MessageContract (IsWrapped = false)]
+       public class UnregisterInfo
+       {
+               [MessageBodyMember (Name = "Unregister", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
+               UnregisterInfoDC body;
+               
+               public UnregisterInfo ()
+               {
+                       body = new UnregisterInfoDC ();
+               }
+               
+               public UnregisterInfo (string meshId, Guid registration_id)
+                       : this ()
+               {
+                       body.MeshId = meshId;
+                       body.RegistrationId = registration_id;
+               }
+               
+               public string MeshId {
+                       get { return body.MeshId; }
+               }
+               
+               public Guid RegistrationId  {
+                       get { return body.RegistrationId; }
+               }
+               
+               [MonoTODO]
+               public bool HasBody ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       [DataContract]
+       internal class UnregisterInfoDC
+       {
+               string mesh_id;
+               Guid registration_id;
+
+               public UnregisterInfoDC ()
+               {
+               }
+               
+               [DataMember]
+               public string MeshId {
+                       get { return mesh_id; }
+                       set { mesh_id = value; }
+               }
+               
+               [DataMember]
+               public Guid RegistrationId  {
+                       get { return registration_id; }
+                       set { registration_id = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/UpdateInfo.cs b/mcs/class/System.ServiceModel/System.ServiceModel.PeerResolvers/UpdateInfo.cs
new file mode 100644 (file)
index 0000000..53caa65
--- /dev/null
@@ -0,0 +1,93 @@
+// 
+// UpdateInfo.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel.PeerResolvers
+{
+       [MessageContract (IsWrapped = false)]
+       public class UpdateInfo
+       {
+               [MessageBodyMember (Name = "Update", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
+               UpdateInfoDC body;
+               
+               public UpdateInfo ()
+               {
+                       body = new UpdateInfoDC ();
+               }
+               
+               public UpdateInfo (Guid registrationId, Guid client, string meshId, PeerNodeAddress address)
+                       : this ()
+               {
+                       body.RegistrationId = registrationId;
+                       body.ClientId = client;
+                       body.MeshId = meshId;
+                       body.NodeAddress = address;
+               }
+               
+               public Guid ClientId {
+                       get { return body.ClientId; }
+               }
+               
+               public string MeshId {
+                       get { return body.MeshId; }
+               }
+               
+               public PeerNodeAddress NodeAddress {
+                       get { return body.NodeAddress; }
+               }
+               
+               public Guid RegistrationId {
+                       get { return body.RegistrationId; }
+               }
+               
+               [MonoTODO]
+               public bool HasBody ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       [DataContract]
+       internal class UpdateInfoDC
+       {
+               Guid client_id;
+               string mesh_id;
+               PeerNodeAddress node_address;
+               Guid registration_id;
+
+               public UpdateInfoDC ()
+               {
+               }
+               
+               [DataMember]
+               public Guid ClientId {
+                       get { return client_id; }
+                       set { client_id = value; }
+               }
+               
+               [DataMember]
+               public string MeshId {
+                       get { return mesh_id; }
+                       set { mesh_id = value; }
+               }
+               
+               [DataMember]
+               public PeerNodeAddress NodeAddress {
+                       get { return node_address; }
+                       set { node_address = value; }
+               }
+               
+               [DataMember]
+               public Guid RegistrationId {
+                       get { return registration_id; }
+                       set { registration_id = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/AuthenticatorCommunicationObject.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/AuthenticatorCommunicationObject.cs
new file mode 100644 (file)
index 0000000..327e4ae
--- /dev/null
@@ -0,0 +1,113 @@
+//
+// AuthenticatorCommunicationObject.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       abstract class AuthenticatorCommunicationObject : CommunicationObject
+       {
+               public abstract Message ProcessNegotiation (Message request);
+
+               Binding issuer_binding;
+               EndpointAddress issuer_address;
+               Uri listen_uri;
+               KeyedByTypeCollection<IEndpointBehavior> behaviors =
+                       new KeyedByTypeCollection<IEndpointBehavior> ();
+               SecurityTokenSerializer serializer;
+               SecurityAlgorithmSuite algorithm;
+               SecurityBindingElement element;
+
+               public EndpointAddress IssuerAddress {
+                       get { return issuer_address; }
+                       set { issuer_address = value; }
+               }
+
+               public Uri ListenUri {
+                       get { return listen_uri; }
+                       set { listen_uri = value; }
+               }
+
+               public Binding IssuerBinding {
+                       get { return issuer_binding; }
+                       set { issuer_binding = value; }
+               }
+
+               public KeyedByTypeCollection<IEndpointBehavior> IssuerChannelBehaviors {
+                       get { return behaviors; }
+               }
+
+               public SecurityAlgorithmSuite SecurityAlgorithmSuite {
+                       get { return algorithm; }
+                       set { algorithm= value; }
+               }
+
+               public SecurityBindingElement SecurityBindingElement {
+                       get { return element; }
+                       set { element = value; }
+               }
+
+               public SecurityTokenSerializer SecurityTokenSerializer {
+                       get { return serializer; }
+                       set { serializer = value; }
+               }
+
+               protected void EnsureProperties ()
+               {
+                       if (State == CommunicationState.Opened)
+                               throw new InvalidOperationException ("Already opened.");
+
+                       if (SecurityTokenSerializer == null)
+                               throw new InvalidOperationException ("Security token serializer must be set before opening the token provider.");
+
+                       if (IssuerAddress == null)
+                               throw new InvalidOperationException ("Issuer address must be set before opening the token provider.");
+
+                       if (IssuerBinding == null)
+                               throw new InvalidOperationException ("IssuerBinding must be set before opening the token provider.");
+
+                       if (SecurityAlgorithmSuite == null)
+                               throw new InvalidOperationException ("Security algorithm suite must be set before opening the token provider.");
+
+                       if (ListenUri == null)
+                               throw new InvalidOperationException ("Listening uri must be set before opening the token provider.");
+                       if (SecurityBindingElement == null)
+                               throw new InvalidOperationException ("SecurityBindingElement must be set before opening the token provider.");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/BinarySecretSecurityToken.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/BinarySecretSecurityToken.cs
new file mode 100644 (file)
index 0000000..5c7fdf1
--- /dev/null
@@ -0,0 +1,115 @@
+//
+// BinarySecretSecurityToken.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Xml;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class BinarySecretSecurityToken : SecurityToken
+       {
+               ReadOnlyCollection<SecurityKey> keys;
+
+               string id;
+               byte [] key;
+               bool allow_crypto;
+               DateTime valid_from = DateTime.Now.ToUniversalTime ();
+
+               BinarySecretSecurityToken (string id, bool allowCrypto)
+               {
+                       this.id = id;
+                       allow_crypto = allowCrypto;
+               }
+
+               public BinarySecretSecurityToken (byte [] key)
+                       : this ("uuid:" + Guid.NewGuid ().ToString (), key)
+               {
+               }
+
+               public BinarySecretSecurityToken (string id, byte [] key)
+                       : this (id, key, false)
+               {
+               }
+
+               protected BinarySecretSecurityToken (string id, byte [] key, bool allowCrypto)
+                       : this (id, allowCrypto)
+               {
+                       if (key == null)
+                               throw new ArgumentNullException ("key");
+                       this.key = key;
+
+                       SecurityKey [] arr = new SecurityKey [] {new InMemorySymmetricSecurityKey (key)};
+                       keys = new ReadOnlyCollection<SecurityKey> (arr);
+               }
+
+               public BinarySecretSecurityToken (int keySizeInBits)
+                       : this ("uuid:" + Guid.NewGuid ().ToString (), keySizeInBits)
+               {
+               }
+
+               public BinarySecretSecurityToken (string id, int keySizeInBits)
+                       : this (id, keySizeInBits, false)
+               {
+               }
+
+               protected BinarySecretSecurityToken (string id, int keySizeInBits, bool allowCrypto)
+                       : this (id, allowCrypto)
+               {
+                       if (keySizeInBits < 0)
+                               throw new ArgumentOutOfRangeException ("keySizeInBits");
+
+                       this.key = new byte [keySizeInBits >> 3 + (keySizeInBits % 8 == 0 ? 0 : 1)];
+
+                       SecurityKey [] arr = new SecurityKey [] {new InMemorySymmetricSecurityKey (key)};
+                       keys = new ReadOnlyCollection<SecurityKey> (arr);
+               }
+
+               public override DateTime ValidFrom {
+                       get { return valid_from; }
+               }
+
+               public override DateTime ValidTo {
+                       get { return DateTime.MaxValue.AddDays (-1); }
+               }
+
+               public override string Id {
+                       get { return id; }
+               }
+
+               public override ReadOnlyCollection<SecurityKey> SecurityKeys {
+                       get { return keys; }
+               }
+
+               public byte [] GetKeyBytes ()
+               {
+                       return (byte []) key.Clone ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ChangeLog
new file mode 100755 (executable)
index 0000000..42c30d1
--- /dev/null
@@ -0,0 +1,490 @@
+2008-02-27 Eyal Alaluf <eyala@mainsoft.com>
+
+       * InternalEncryptedKeyIdentifierClause.cs IssuedTokenCommunicationObject.cs:
+         Fix compilation warnings.
+
+2007-04-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenParameters.cs :
+         implemented CreateRequestParameters().
+
+2007-04-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TlsClientSession.cs, TlsServerSession.cs,
+         SslSecurityTokenProvider.cs : support mutual sslnego.
+       * SslnegoCookieResolver.cs : .net seems to include X509Certificate
+         information in the cookie.
+
+2007-04-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityContextSecurityToken.cs : Cookie needs a setter.
+       * SslnegoCookieResolver.cs : set Cookie so that it can be serialized.
+       * SslSecurityTokenProvider.cs, SslSecurityTokenAuthenticator.cs :
+         (At provider) check contextId returned by the server.
+         Reverted ProofToken value (see comments).
+       * CommunicationSecurityTokenAuthenticator.cs : it now implements
+         IIssuanceSecurityTokenAuthenticator.
+
+2007-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AuthenticatorCommunicationObject.cs : added SecurityBindingElement.
+       * SslSecurityTokenProvider.cs : a few updates, key is now from
+         proof token.
+       * SslSecurityTokenAuthenticator.cs :
+         use LocalServiceSecuritySettings.IssuedCookieLifetime.
+       * SpnegoSecurityTokenProvider.cs, SpnegoSecurityTokenAuthenticator.cs,
+         SspiSession.cs : some ongoing updates
+         as well as spnego (kerberos) negotiation handling.
+       * TlsClientSession.cs : by specification it is P_SHA, not PRF
+         (though not sure, as CombinedHash is for PRF).
+
+2007-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslnegoCookieResolver.cs : ResolveCookie() should simply return
+         entire SecurityContextToken parsed by dnse:Cookie binary.
+
+2007-03-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenAuthenticator.cs, SslSecurityTokenProvider.cs :
+         Ongoing implementation. Applied some changes for SSPI support. 
+         WSSecurityTokenSerializer is implemented to return binary-secret-
+         aware token, so just return it. Fixed some CK-HASH usage.
+       * IssuedTokenCommunicationObject.cs :
+         Applied some changes for SSPI support.
+       * SpnegoSecurityTokenAuthenticator.cs, SpnegoSecurityTokenProvider.cs,
+         SspiSession.cs : new ongoing implementation for SSPI negotiation.
+       * SspiClientSecurityTokenAuthenticator.cs : spnego authenticator
+         will go here (it is just a stub. Created when opening a channel).
+
+2007-03-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TlsClientSession.cs, SslSecurityTokenProvider.cs,
+         SslSecurityTokenAuthenticator.cs : added hash calculation support,
+         not working yet though (probably at service side).
+
+2007-03-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenAuthenticator.cs : don't reuse ContextId for SCT.
+         Process ServerFinished before ApplicationData exchange.
+       * TlsServerSession.cs : Fixed ClientKeyExchange stream processing.
+
+2007-03-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TlsClientSession.cs, TlsServerSession.cs :
+         added ProcessApplicationData()
+       * SslSecurityTokenAuthenticator.cs, SslSecurityTokenProvider.cs :
+         process RequestedProofToken as raw TLS negotiation data.
+       * SslnegoCookieResolver.cs : add comments on data format.
+
+2007-03-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TlsClientSession.cs : added CreateAuthHash(), used by authenticator.
+       * SecurityContextSecurityToken.cs : support "probably correct" rawdata
+         creation for cookie. It is not the secret key but some binary xml
+         data.
+       * SslnegoCookieResolver.cs : added CreateData() for creating
+         binary-xmlized token cookie info.
+       * SslSecurityTokenAuthenticator.cs : create session key (dummy for
+         now) and use it instead of MasterSecret. Support t:Authenticator.
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenAuthenticator.cs, SslSecurityTokenProvider.cs :
+         (The build should be fixed at this state.)
+         Implemented RSTR consumption and RSTR collection creation (as the
+         final stage at sslnego phase).
+
+        Note that it is still not working, as our binary XmlDictionaryReader
+        is not working fine (and still not sure if it will work when they
+        are working fine, as currently there is no way to check if the
+        byte array binary-serialized and encrypted in the dnse:Cookie is
+        the actual symmetric key).
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenParameters.cs : support SecurityContextSecurityToken
+         in CreateKeyIdentifierClause(). Comment out generic xml token
+         support until we need it for sure.
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityContextSecurityToken.cs : implemented almost all members.
+       * X509SecurityTokenParameters.cs : added comment on wrong documentation.
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslnegoCookieResolver.cs : new file. It contains the resolver for
+         MS's non-standard encrypted sslnego shared key (dnse:Cookie), and
+         more importantly, the description on its data format (which was
+         almost unabled to be guessed, until I use non-protecting 
+         SecurityStateEncoder and dug in depth to Binary XmlDictionaryReader).
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TlsServerSession.cs, TlsClientSession.cs : complete every operations
+         that depends on ReceiveRecord(). Added accessor to MasterSecret.
+
+2007-03-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TlsServerSession.cs : now ssl negotiation is functional enough to
+         implement SecurityContextToken(Collection) transmit.
+       * TlsClientSession.cs : cosmetic code consistency fix.
+
+2007-03-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TlsClientSession.cs, TlsServerSession.cs :
+         okay, there is RecordProtocol, which makes things much easier and
+         correct. Now client seems to be interoperable with .net.
+
+2007-03-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TlsClientSession.cs, TlsServerSession.cs :
+         several fixes; Fixed content type processing (Handshake and
+         ChangeCipherSpec). Fixed chunk output of handshake messages.
+         Set server side key verifier.
+       * SslSecurityTokenProvider.cs : use IssueReply for RSTR (fixed SOAP
+         action mismatch).
+       * SslSecurityTokenAuthenticator.cs : implemented most of TLS
+         negotiation support, except for the final stage (still not clear
+         what to do here).
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AuthenticatorCommunicationObject.cs,
+         CommunicationSecurityTokenAuthenticator.cs,
+         SecureConversationSecurityTokenAuthenticator.cs :
+         new classes for negotiation-based token authenticators.
+       * SslSecurityTokenAuthenticator.cs : now it is based on
+         CommunicationSecurityTokenAuthenticator (like corresponding
+         provider class).
+
+2007-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureConversationSecurityTokenParameters.cs :
+         implemented protected properties.
+       * X509SecurityTokenParameters.cs : added missing ToString().
+
+2007-03-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenProvider.cs : implemented some client negotiation
+         based on Mono.Security.Protocols.Tls.* and WSTrust contracts.
+       * TlsServerSession.cs, TlsClientSession.cs : session state transition
+         manager (controls Tls Context).
+
+2007-03-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UserNameSecurityTokenParameters.cs,
+         RsaSecurityTokenParameters.cs,
+         IssuedSecurityTokenParameters.cs,
+         SslSecurityTokenParameters.cs
+         SspiSecurityTokenParameters.cs,
+         KerberosSecurityTokenParameters.cs,
+         SecureConversationSecurityTokenParameters.cs : updated 
+         InitializeSecurityTokenRequirement() based on updated MSDN docs.
+         Implemented Ssl CreateKeyIdentifierClause().
+         Implemented IssuedToken copy .ctor().
+
+2007-03-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelSecurityTokenRequirement.cs,
+         RecipientServiceModelSecurityTokenRequirement.cs,
+         InitiatorServiceModelSecurityTokenRequirement.cs :
+         implemented ToString().
+
+2007-03-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenParameters.cs : more initialization of requirement.
+       * SslSecurityTokenAuthenticator.cs : new file.
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityToken.cs : okkk, HMAC is extra. Just use SHA1,
+         and not for raw key but for wrapped key.
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityToken.cs :
+         create HMACSHA1 always with the key to compute hash (I'm not sure
+         it is correct; it is rather to adjust all hash consistent.)
+
+2007-02-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DerivedKeySecurityToken.cs : added ReferenceList for corresponding
+         references to this key.
+
+2007-02-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DerivedKeySecurityToken.cs : new internal class to represent
+         wssc:DerivedKeyToken.
+
+2007-02-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityToken.cs : reverted previous change. Key hash
+         could not be identical for the same key, but EncryptedKeySHA1 is
+         based on the wrapped key. So, there is an issue that .NET returns
+         different key than the one in the request message.
+
+2007-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityToken.cs : SecurityKey should hold raw key, not
+         wrapped one.
+
+2007-02-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityToken.cs : it cannot resolve clauses from its
+         .ctor() argument identifier clauses. Match EncrypedKeySHA1 clause
+         if the hash values match.
+       * InternalEncryptedKeyIdentifierClause.cs :
+         derive from Binary clause.
+
+2007-02-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InternalEncryptedKeyIdentifierClause.cs : new file. It might not be
+         required, but for now it is used to write embedded EncryptedKey in
+         o:SecurityTokenReference.
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityToken.cs : added internal ReferenceList, to
+         output e:ReferenceList (kind of compromised solution; see comments).
+
+2007-01-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityToken.cs : GetWrappedKey() return value should
+         be the encrypted value of argument keyToWrap. Added several argument
+         check.
+
+2006-12-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityToken.cs : implemented missing members, except for
+         incomplete MatchKeyIdentifierClause().
+       * SecureConversationSecurityTokenParameters.cs : default
+         ChannelProtectionRequirements should cover all body parts i.e.
+         IsBodyIncluded should be true.
+
+2006-12-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SupportingTokenParameters.cs : implemented SetKeyDerivation().
+
+2006-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * X509SecurityTokenParameters.cs : additional constructors.
+
+2006-10-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BinarySecretSecurityToken.cs : it does not seem that it uses
+         urn:uuid:blah ("urn:" is extraneous).
+
+2006-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityTokenParameters.cs : added internal properties to access
+         protected properties.
+       * UserNameSecurityTokenParameters.cs : it's done now.
+
+2006-09-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityTokenParameters.cs : removed MonoTODOs.
+       * X509SecurityTokenParameters.cs :
+         InitializeSecurityTokenRequirement() is done.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ProviderCommunicationObject.cs, IssuedTokenCommunicationObject.cs,
+         SslSecurityTokenProvider.cs : both of issued token and ssl requires
+         connection requirement, so commonize the check.
+
+2006-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * X509SecurityTokenParameters.cs,
+         SspiSecurityTokenParameters.cs,
+         UserNameSecurityTokenParameters.cs,
+         RsaSecurityTokenParameters.cs,
+         IssuedSecurityTokenParameters.cs,
+         SslSecurityTokenParameters.cs : implemented security feature
+         declaration properties (HasAsymmetricKey etc.) and implemented
+         some members.
+
+2006-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * RsaSecurityTokenParameters.cs : TokenType fix.
+       * ProviderCommunicationObject.cs,
+         CommunicationSecurityTokenProvider.cs : an abstract token provider
+         that implements ICommunicationObject, and the abstract communication
+         object that is used in the provider.
+       * SslSecurityTokenProvider.cs : a practical example of the above,
+         not done yet though.
+       * IssuedTokenCommunicationObject.cs, IssuedSecurityTokenProvider.cs :
+         it is also significantly refactored like the above.
+         The ICommunicationObject part of this provider class now just wraps
+         the intermediate object.
+
+2006-09-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * X509SecurityTokenParameters.cs : when token reference style is 
+         Internal, use LocalIdKeyIdentifierClause. The default for this type
+         should be "Any".
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelSecurityTokenRequirement.cs : implemented IsInitiator.
+       * InitiatorServiceModelSecurityTokenRequirement.cs :
+         initialize IsInitiator as true.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityContextSecurityTokenAuthenticator.cs,
+         SspiSecurityToken.cs : new files.
+       * SupportingTokenParameters.cs : copy ctor became private.
+
+2006-08-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * X509SecurityTokenParameters.cs,
+         UserNameSecurityTokenParameters.cs : implemented properties.
+       * RsaSecurityTokenParameters.cs : new file.
+
+2006-08-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProvider.cs : (GetToken) partly implemented
+         response message consumption.
+
+2006-08-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * X509SecurityTokenParameters.cs :
+         implemented CreateKeyIdentifierClause().
+
+2006-08-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SupportingTokenParameters.cs : added some missing members.
+
+2006-08-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BinarySecretSecurityToken.cs : some .ctor() are protected.
+
+2006-08-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * KerberosSecurityTokenParameters.cs : new test.
+
+2006-08-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InitiatorServiceModelSecurityTokenRequirement.cs,
+         RecipientServiceModelSecurityTokenRequirement.cs :
+         just use Properties to set and get each property.
+       * SslSecurityTokenParameters.cs : fix ctor chain.
+         hacky InitializeSecurityTokenRequirement implementation.
+
+2006-08-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureConversationSecurityTokenParameters.cs :
+         fill SecurityAlgorithmSuite to the requirement.
+       * SecurityTokenParameters.cs :
+         added internal IssuerBindingContext property for
+         SecurityBindingElement.SetIssuerBindingContextIfRequired().
+         Use this context in CallInitializeSecurityTokenParameters().
+
+2006-08-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenParameters.cs : oops, oops. fix build.
+
+2006-08-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenParameters.cs : added missing members.
+       * IssuedSecurityTokenProvider.cs : replacing broken data contract
+         based contracts with message based contract.
+         Support IssuerChannelBehaviors.
+       * SecureConversationSecurityTokenParameters.cs :
+         more InitializeSerurityTokenRequirement().
+
+2006-08-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityContextSecurityTokenResolver.cs
+         ISecurityContextSecurityTokenCache.cs
+         SecurityContextSecurityToken.cs : new files.
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureConversationSecurityTokenParameters.cs :
+         partially implemented InitializeSecurityTokenRequirement().
+       * X509SecurityTokenParameters.cs : added X509ReferenceStyle.
+       * SspiSecurityTokenParameters.cs : new file.
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenParameters.cs,
+         SecureConversationSecurityTokenParameters.cs : new files.
+       * SecurityTokenParameters.cs : added internal invoker for
+         InitializeSecurityTokenRequirement().
+       * IssuedSecurityTokenParameters.cs, X509SecurityTokenParameters.cs :
+         implement InitializeSecurityTokenRequirement() (incomplete).
+       * ServiceModelSecurityTokenRequirement.cs :
+         MessageSecurityVersion is of type SecurityTokenVersion.
+
+2006-08-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelSecurityTokenTypes.cs : new file.
+
+2006-08-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProvider.cs :
+         WST request and response types are renamed.
+
+2006-08-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProvider.cs : use new WSTrust proxy (ClientBase)
+         instead of ChannelFactory.
+       * SecurityTokenParameters.cs : added internal helper method for
+         CreateKeyIdentifierClause().
+       * ServiceModelSecurityTokenRequirement.cs : in several properties,
+         use TryGetProperty<T>() instead of having direct fields (so that
+         only setting items to "Properties" also affects on those props).
+
+2006-08-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InitiatorServiceModelSecurityTokenRequirement.cs,
+         RecipientServiceModelSecurityTokenRequirement.cs,
+         ServiceModelSecurityTokenRequirement.cs : new files.
+
+2006-08-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProvider.cs : moved some premise checks from
+         GetTokenCore() to Open().
+
+2006-08-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityToken.cs : new file.
+
+2006-08-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BinarySecretSecurityToken.cs : new file.
+
+2006-08-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UserNameSecurityTokenParameters.cs,
+         X509SecurityTokenParameters.cs : new files.
+
+2006-08-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProvider.cs : (GetTokenCore) some premise check.
+
+2006-08-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProvider.cs : implemented some properties.
+       * RenewedSecurityTokenHandler.cs, IssuedSecurityTokenHandler.cs,
+         IIssuanceSecurityTokenAuthenticator.cs : new files.
+
+2006-08-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProvider.cs, ClaimTypeRequirement.cs : new files.
+       * IssuedSecurityTokenParameters.cs : added some missing members.
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityTokenReferenceStyle.cs : moved from S.SM.Security namespace.
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenParameters.cs, SecurityTokenParameters.cs :
+         new files.
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SupportingTokenParameters.cs : new file.
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ClaimTypeRequirement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ClaimTypeRequirement.cs
new file mode 100644 (file)
index 0000000..7017b67
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// ClaimTypeRequirement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class ClaimTypeRequirement
+       {
+               public ClaimTypeRequirement (string claimType)
+                       : this (claimType, false)
+               {
+               }
+
+               public ClaimTypeRequirement (string claimType, bool isOptional)
+               {
+                       claim_type = claimType;
+                       is_optional = isOptional;
+               }
+
+               public string ClaimType {
+                       get { return claim_type; }
+               }
+
+               public bool IsOptional {
+                       get { return is_optional; }
+               }
+
+               string claim_type;
+               bool is_optional;
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/CommunicationSecurityTokenAuthenticator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/CommunicationSecurityTokenAuthenticator.cs
new file mode 100644 (file)
index 0000000..94cb1ec
--- /dev/null
@@ -0,0 +1,155 @@
+//
+// CommunicationSecurityTokenAuthenticator.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections.ObjectModel;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       abstract class CommunicationSecurityTokenAuthenticator
+               : SecurityTokenAuthenticator, ICommunicationObject,
+                 IIssuanceSecurityTokenAuthenticator
+       {
+               protected CommunicationSecurityTokenAuthenticator ()
+               {
+               }
+
+               IssuedSecurityTokenHandler issuance_handler;
+               RenewedSecurityTokenHandler renew_handler;
+
+               public IssuedSecurityTokenHandler IssuedSecurityTokenHandler { 
+                       get { return issuance_handler; }
+                       set { issuance_handler = value; }
+               }
+
+               public RenewedSecurityTokenHandler RenewedSecurityTokenHandler { 
+                       get { return renew_handler; }
+                       set { renew_handler = value; }
+               }
+
+               public abstract AuthenticatorCommunicationObject Communication { get; }
+
+               [MonoTODO]
+               protected override bool CanValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override ReadOnlyCollection<IAuthorizationPolicy> ValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public CommunicationState State {
+                       get { return Communication.State; }
+               }
+
+               public void Abort ()
+               {
+                       Communication.Abort ();
+               }
+
+               public void Open ()
+               {
+                       Communication.Open ();
+               }
+
+               public void Open (TimeSpan timeout)
+               {
+                       Communication.Open (timeout);
+               }
+
+               public IAsyncResult BeginOpen (AsyncCallback callback, object state)
+               {
+                       return Communication.BeginOpen (callback, state);
+               }
+
+               public IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return Communication.BeginOpen (timeout, callback, state);
+               }
+
+               public void EndOpen (IAsyncResult result)
+               {
+                       Communication.EndOpen (result);
+               }
+
+               public void Close ()
+               {
+                       Communication.Close ();
+               }
+
+               public void Close (TimeSpan timeout)
+               {
+                       Communication.Close (timeout);
+               }
+
+               public IAsyncResult BeginClose (AsyncCallback callback, object state)
+               {
+                       return Communication.BeginClose (callback, state);
+               }
+
+               public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return Communication.BeginClose (timeout, callback, state);
+               }
+
+               public void EndClose (IAsyncResult result)
+               {
+                       Communication.EndClose (result);
+               }
+
+               public event EventHandler Opening {
+                       add { Communication.Opening += value; }
+                       remove { Communication.Opening -= value; }
+               }
+
+               public event EventHandler Opened {
+                       add { Communication.Opened += value; }
+                       remove { Communication.Opened -= value; }
+               }
+
+               public event EventHandler Closing {
+                       add { Communication.Closing += value; }
+                       remove { Communication.Closing -= value; }
+               }
+
+               public event EventHandler Closed {
+                       add { Communication.Closed += value; }
+                       remove { Communication.Closed -= value; }
+               }
+
+               public event EventHandler Faulted {
+                       add { Communication.Faulted += value; }
+                       remove { Communication.Faulted -= value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/CommunicationSecurityTokenProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/CommunicationSecurityTokenProvider.cs
new file mode 100644 (file)
index 0000000..6204b4d
--- /dev/null
@@ -0,0 +1,140 @@
+//
+// CommunicationSecurityTokenProvider.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       abstract class CommunicationSecurityTokenProvider : SecurityTokenProvider, ICommunicationObject
+       {
+               public abstract ProviderCommunicationObject Communication { get; }
+
+               protected override SecurityToken GetTokenCore (TimeSpan timeout)
+               {
+                       if (State != CommunicationState.Opened)
+                               throw new InvalidOperationException ("Open the provider before issuing actual request to get token.");
+                       return GetOnlineToken (timeout);
+               }
+
+               public abstract SecurityToken GetOnlineToken (TimeSpan timeout);
+
+               public CommunicationState State {
+                       get { return Communication.State; }
+               }
+
+               public void Abort ()
+               {
+                       Communication.Abort ();
+               }
+
+               public void Open ()
+               {
+                       Communication.Open ();
+               }
+
+               public void Open (TimeSpan timeout)
+               {
+                       Communication.Open (timeout);
+               }
+
+               public IAsyncResult BeginOpen (AsyncCallback callback, object state)
+               {
+                       return Communication.BeginOpen (callback, state);
+               }
+
+               public IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return Communication.BeginOpen (timeout, callback, state);
+               }
+
+               public void EndOpen (IAsyncResult result)
+               {
+                       Communication.EndOpen (result);
+               }
+
+               public void Close ()
+               {
+                       Communication.Close ();
+               }
+
+               public void Close (TimeSpan timeout)
+               {
+                       Communication.Close (timeout);
+               }
+
+               public IAsyncResult BeginClose (AsyncCallback callback, object state)
+               {
+                       return Communication.BeginClose (callback, state);
+               }
+
+               public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return Communication.BeginClose (timeout, callback, state);
+               }
+
+               public void EndClose (IAsyncResult result)
+               {
+                       Communication.EndClose (result);
+               }
+
+               public event EventHandler Opening {
+                       add { Communication.Opening += value; }
+                       remove { Communication.Opening -= value; }
+               }
+
+               public event EventHandler Opened {
+                       add { Communication.Opened += value; }
+                       remove { Communication.Opened -= value; }
+               }
+
+               public event EventHandler Closing {
+                       add { Communication.Closing += value; }
+                       remove { Communication.Closing -= value; }
+               }
+
+               public event EventHandler Closed {
+                       add { Communication.Closed += value; }
+                       remove { Communication.Closed -= value; }
+               }
+
+               public event EventHandler Faulted {
+                       add { Communication.Faulted += value; }
+                       remove { Communication.Faulted -= value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/DerivedKeySecurityToken.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/DerivedKeySecurityToken.cs
new file mode 100644 (file)
index 0000000..c3a77d7
--- /dev/null
@@ -0,0 +1,121 @@
+using System;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Security;
+using System.Text;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       internal class DerivedKeySecurityToken : SecurityToken
+       {
+               string algorithm;
+               SecurityKeyIdentifierClause reference;
+               SecurityToken resolved_token; // store resolved one.
+               int? generation, offset, length;
+               // properties
+               string id, name, label;
+               byte [] nonce;
+               ReadOnlyCollection<SecurityKey> keys;
+               ReferenceList reflist;
+
+               public DerivedKeySecurityToken (string id, string algorithm,
+                       SecurityKeyIdentifierClause reference,
+                       SymmetricSecurityKey referencedKey,
+                       string name,
+                       int? generation,
+                       int? offset,
+                       int? length,
+                       string label,
+                       byte [] nonce)
+               {
+                       algorithm = algorithm ?? SecurityAlgorithms.Psha1KeyDerivation;
+
+                       this.id = id;
+                       this.algorithm = algorithm;
+                       this.reference = reference;
+                       this.generation = generation;
+                       this.offset = offset;
+                       this.length = length;
+                       this.nonce = nonce;
+                       this.name = name;
+                       this.label = label;
+
+                       SecurityKey key = new InMemorySymmetricSecurityKey (
+                               referencedKey.GenerateDerivedKey (
+                                       algorithm,
+                                       Encoding.UTF8.GetBytes (label ?? Constants.WsscDefaultLabel),
+                                       nonce,
+                                       (length ?? 32) * 8,
+                                       offset ?? 0));
+                       keys = new ReadOnlyCollection<SecurityKey> (
+                               new SecurityKey [] {key});
+               }
+
+               public override string Id {
+                       get { return id; }
+               }
+
+               public override ReadOnlyCollection<SecurityKey> SecurityKeys {
+                       get { return keys; }
+               }
+
+               public override DateTime ValidFrom {
+                       get { return resolved_token.ValidFrom; }
+               }
+
+               public override DateTime ValidTo {
+                       get { return resolved_token.ValidTo; }
+               }
+
+               internal ReferenceList ReferenceList {
+                       get { return reflist; }
+                       set { reflist = value; }
+               }
+
+               public SecurityKeyIdentifierClause TokenReference {
+                       get { return reference; }
+               }
+
+               public int? Generation {
+                       get { return generation; }
+               }
+
+               public int? Length {
+                       get { return length; }
+               }
+
+               public int? Offset {
+                       get { return offset; }
+               }
+
+               public string Label {
+                       get { return label; }
+               }
+
+               public byte [] Nonce {
+                       get { return nonce; }
+               }
+
+               public string Name {
+                       get { return name; }
+               }
+
+               public override bool MatchesKeyIdentifierClause (
+                       SecurityKeyIdentifierClause keyIdentifierClause)
+               {
+                       LocalIdKeyIdentifierClause l = keyIdentifierClause
+                               as LocalIdKeyIdentifierClause;
+                       return l != null && l.LocalId == Id;
+               }
+
+               public override SecurityKey ResolveKeyIdentifierClause (
+                       SecurityKeyIdentifierClause keyIdentifierClause)
+               {
+                       return MatchesKeyIdentifierClause (keyIdentifierClause) ?
+                               keys [0] : null;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IIssuanceSecurityTokenAuthenticator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IIssuanceSecurityTokenAuthenticator.cs
new file mode 100644 (file)
index 0000000..1089e13
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// IIssuanceSecurityTokenAuthenticator.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public interface IIssuanceSecurityTokenAuthenticator
+       {
+               IssuedSecurityTokenHandler IssuedSecurityTokenHandler { get; set; }
+               RenewedSecurityTokenHandler RenewedSecurityTokenHandler { get; set; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ISecurityContextSecurityTokenCache.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ISecurityContextSecurityTokenCache.cs
new file mode 100644 (file)
index 0000000..4ea6b48
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// ISecurityContextSecurityTokenCache.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.Xml;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public interface ISecurityContextSecurityTokenCache
+       {
+               void AddContext (SecurityContextSecurityToken token);
+
+               void ClearContexts ();
+
+               Collection<SecurityContextSecurityToken> GetAllContexts (UniqueId contextId);
+
+               SecurityContextSecurityToken GetContext (UniqueId contextId, UniqueId generation);
+
+               void RemoveAllContexts (UniqueId contextId);
+
+               void RemoveContext (UniqueId contextId, UniqueId generation);
+
+               bool TryAddContext (SecurityContextSecurityToken token);
+
+               void UpdateContextCachingTime (SecurityContextSecurityToken context, DateTime expirationTime);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/InitiatorServiceModelSecurityTokenRequirement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/InitiatorServiceModelSecurityTokenRequirement.cs
new file mode 100644 (file)
index 0000000..12e8c47
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// InitiatorServiceModelSecurityTokenRequirement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public sealed class InitiatorServiceModelSecurityTokenRequirement
+               : ServiceModelSecurityTokenRequirement
+       {
+               public InitiatorServiceModelSecurityTokenRequirement ()
+               {
+                       Properties [ServiceModelSecurityTokenRequirement.IsInitiatorProperty] = true;
+               }
+
+               public EndpointAddress TargetAddress {
+                       get {
+                               EndpointAddress ret;
+                               TryGetProperty<EndpointAddress> (TargetAddressProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [TargetAddressProperty] = value; }
+               }
+
+               public Uri Via {
+                       get {
+                               Uri ret;
+                               TryGetProperty<Uri> (ViaProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [ViaProperty] = value; }
+               }
+
+               public override string ToString ()
+               {
+                       return Dump ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/InternalEncryptedKeyIdentifierClause.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/InternalEncryptedKeyIdentifierClause.cs
new file mode 100644 (file)
index 0000000..95e4334
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// InternalEncryptedKeyIdentifierClause.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+using System.IdentityModel.Tokens;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       internal class InternalEncryptedKeyIdentifierClause : BinaryKeyIdentifierClause
+       {
+               public InternalEncryptedKeyIdentifierClause (byte [] hash)
+                       : base (null, hash, false)
+               {
+               }
+
+               public override bool Matches (SecurityKeyIdentifierClause keyIdentifierClause)
+               {
+                       InternalEncryptedKeyIdentifierClause kic = keyIdentifierClause as InternalEncryptedKeyIdentifierClause;
+                       if (kic == null)
+                               return false;
+                       return Matches (kic.GetRawBuffer ());
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedSecurityTokenHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedSecurityTokenHandler.cs
new file mode 100644 (file)
index 0000000..5204900
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// IssuedSecurityTokenHandler .cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public delegate void IssuedSecurityTokenHandler (
+               SecurityToken issuedToken, EndpointAddress tokenRequestor);
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedSecurityTokenParameters.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedSecurityTokenParameters.cs
new file mode 100644 (file)
index 0000000..ce91e21
--- /dev/null
@@ -0,0 +1,203 @@
+//
+// IssuedSecurityTokenParameters.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.Xml;
+using System.Xml.XPath;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class IssuedSecurityTokenParameters : SecurityTokenParameters
+       {
+               public IssuedSecurityTokenParameters ()
+               {
+               }
+
+               public IssuedSecurityTokenParameters (string tokenType)
+                       : this (tokenType, null)
+               {
+               }
+
+               public IssuedSecurityTokenParameters (string tokenType, EndpointAddress issuerAddress)
+                       : this (tokenType, issuerAddress, null)
+               {
+               }
+
+               public IssuedSecurityTokenParameters (string tokenType,
+                       EndpointAddress issuerAddress, Binding issuerBinding)
+               {
+                       token_type = tokenType;
+                       issuer_address = issuerAddress;
+                       binding = issuerBinding;
+               }
+
+               protected IssuedSecurityTokenParameters (IssuedSecurityTokenParameters source)
+                       : base (source)
+               {
+                       binding = source.binding;
+                       issuer_address = source.issuer_address;
+                       issuer_meta_address = source.issuer_meta_address;
+                       key_size = source.key_size;
+                       key_type = source.key_type;
+                       token_type = source.token_type;
+                       reqs = new Collection<ClaimTypeRequirement> (source.reqs);
+                       additional_reqs = new Collection<XmlElement> (source.additional_reqs);
+               }
+
+               Binding binding;
+               EndpointAddress issuer_address, issuer_meta_address;
+               int key_size;
+               SecurityKeyType key_type;
+               string token_type;
+               Collection<ClaimTypeRequirement> reqs =
+                       new Collection<ClaimTypeRequirement> ();
+               Collection<XmlElement> additional_reqs =
+                       new Collection<XmlElement> ();
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+
+               public Collection<XmlElement> AdditionalRequestParameters {
+                       get { return additional_reqs; }
+               }
+
+               public Collection<ClaimTypeRequirement> ClaimTypeRequirements { 
+                       get { return reqs; }
+               }
+
+               protected override bool HasAsymmetricKey {
+                       get { return false; }
+               }
+
+               public EndpointAddress IssuerAddress {
+                       get { return issuer_address; }
+                       set { issuer_address = value; }
+               }
+
+               public Binding IssuerBinding {
+                       get { return binding; }
+                       set { binding = value; }
+               }
+
+               public EndpointAddress IssuerMetadataAddress {
+                       get { return issuer_meta_address; }
+                       set { issuer_meta_address = value; }
+               }
+
+               public int KeySize {
+                       get { return key_size; }
+                       set { key_size = value; }
+               }
+
+               public SecurityKeyType KeyType {
+                       get { return key_type; }
+                       set { key_type = value; }
+               }
+
+               public string TokenType {
+                       get { return token_type; }
+                       set { token_type = value; }
+               }
+
+               protected override bool SupportsClientAuthentication {
+                       get { return true; }
+               }
+
+               protected override bool SupportsClientWindowsIdentity {
+                       get { return false; }
+               }
+
+               protected override bool SupportsServerAuthentication {
+                       get { return true; }
+               }
+
+               protected override SecurityTokenParameters CloneCore ()
+               {
+                       return new IssuedSecurityTokenParameters (this);
+               }
+
+               [MonoTODO]
+               protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public Collection<XmlElement> CreateRequestParameters (
+                       MessageSecurityVersion messageSecurityVersion,
+                       SecurityTokenSerializer securityTokenSerializer)
+               {
+                       XmlDocument doc = new XmlDocument ();
+                       Collection<XmlElement> ret = new Collection<XmlElement> ();
+                       // KeyType
+                       string keyTypeUri =
+                               KeyType == SecurityKeyType.SymmetricKey ?
+                               Constants.WstSymmetricKeyTypeUri :
+                               Constants.WstAsymmetricKeyTypeUri;
+                       XmlElement kt = doc.CreateElement ("t", "KeyType", Constants.WstNamespace);
+                       kt.AppendChild (doc.CreateTextNode (keyTypeUri));
+                       ret.Add (kt);
+
+                       // ClaimTypes
+                       XmlElement cts = doc.CreateElement ("t", "Claims", Constants.WstNamespace);
+                       foreach (ClaimTypeRequirement req in ClaimTypeRequirements) {
+                               XmlElement el = doc.CreateElement ("wsid", "ClaimType", Constants.WsidNamespace);
+                               el.SetAttribute ("Uri", req.ClaimType);
+                               if (req.IsOptional)
+                                       el.SetAttribute ("Optional", "true");
+                               cts.AppendChild (el);
+                       }
+                       ret.Add (cts);
+
+                       // Additional parameters
+                       foreach (XmlElement el in AdditionalRequestParameters)
+                               ret.Add (el);
+                       return ret;
+               }
+
+               protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+               {
+                       if (requirement == null)
+                               throw new ArgumentNullException ("requirement");
+                       requirement.TokenType = TokenType;
+                       requirement.Properties [ReqType.IssuedSecurityTokenParametersProperty] = this.Clone ();
+                       requirement.Properties [ReqType.IssuerAddressProperty] = IssuerAddress;
+                       requirement.Properties [ReqType.IssuerBindingProperty] = IssuerBinding;
+                       requirement.RequireCryptographicToken = true;
+                       requirement.KeyType = KeyType;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedSecurityTokenProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedSecurityTokenProvider.cs
new file mode 100644 (file)
index 0000000..9e4e466
--- /dev/null
@@ -0,0 +1,259 @@
+//
+// IssuedSecurityTokenProvider.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Xml;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class IssuedSecurityTokenProvider : SecurityTokenProvider, ICommunicationObject
+       {
+               public IssuedSecurityTokenProvider ()
+               {
+               }
+
+               IssuedTokenCommunicationObject comm =
+                       new IssuedTokenCommunicationObject ();
+
+               SecurityKeyEntropyMode entropy_mode =
+                       SecurityKeyEntropyMode.CombinedEntropy;
+               TimeSpan max_cache_time = TimeSpan.MaxValue;
+               MessageSecurityVersion version = MessageSecurityVersion.Default;
+               int threshold = 60;
+               IdentityVerifier verifier = IdentityVerifier.CreateDefault ();
+               bool cache_issued_tokens = true;
+               Collection<XmlElement> request_params =
+                       new Collection<XmlElement> ();
+
+               CommunicationState state = CommunicationState.Created;
+
+               internal IssuedTokenCommunicationObject Communication {
+                       get { return comm; }
+               }
+
+               public bool CacheIssuedTokens {
+                       get { return cache_issued_tokens; }
+                       set { cache_issued_tokens = value; }
+               }
+
+               public virtual TimeSpan DefaultCloseTimeout {
+                       get { return comm.DefaultCloseTimeout; }
+               }
+
+               public virtual TimeSpan DefaultOpenTimeout {
+                       get { return comm.DefaultOpenTimeout; }
+               }
+
+               public IdentityVerifier IdentityVerifier {
+                       get { return verifier; }
+                       set { verifier = value; }
+               }
+
+               public int IssuedTokenRenewalThresholdPercentage {
+                       get { return threshold; }
+                       set { threshold = value; }
+               }
+
+               public EndpointAddress IssuerAddress {
+                       get { return comm.IssuerAddress; }
+                       set { comm.IssuerAddress = value; }
+               }
+
+               public Binding IssuerBinding {
+                       get { return comm.IssuerBinding; }
+                       set { comm.IssuerBinding = value; }
+               }
+
+               public KeyedByTypeCollection<IEndpointBehavior> IssuerChannelBehaviors {
+                       get { return comm.IssuerChannelBehaviors; }
+               }
+
+               public SecurityKeyEntropyMode KeyEntropyMode {
+                       get { return entropy_mode; }
+                       set { entropy_mode = value; }
+               }
+
+               public TimeSpan MaxIssuedTokenCachingTime {
+                       get { return max_cache_time; }
+                       set { max_cache_time = value; }
+               }
+
+               public MessageSecurityVersion MessageSecurityVersion {
+                       get { return version; }
+                       set { version = value; }
+               }
+
+               public SecurityAlgorithmSuite SecurityAlgorithmSuite {
+                       get { return comm.SecurityAlgorithmSuite; }
+                       set { comm.SecurityAlgorithmSuite = value; }
+               }
+
+               public SecurityTokenSerializer SecurityTokenSerializer {
+                       get { return comm.SecurityTokenSerializer; }
+                       set { comm.SecurityTokenSerializer = value; }
+               }
+
+               public EndpointAddress TargetAddress {
+                       get { return comm.TargetAddress; }
+                       set { comm.TargetAddress = value; }
+               }
+
+               public Collection<XmlElement> TokenRequestParameters {
+                       get { return request_params; }
+               }
+
+               // SecurityTokenProvider
+
+               [MonoTODO ("support it then")]
+               public override bool SupportsTokenCancellation {
+                       get { return true; }
+               }
+
+               [MonoTODO]
+               protected override SecurityToken GetTokenCore (TimeSpan timeout)
+               {
+                       if (State != CommunicationState.Opened)
+                               throw new InvalidOperationException ("Open the provider before issuing actual request to get token.");
+                       return comm.GetToken (timeout);
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult BeginGetTokenCore (
+                       TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override SecurityToken EndGetTokenCore (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               // ICommunicationObject
+
+               public CommunicationState State {
+                       get { return comm.State; }
+               }
+
+               [MonoTODO]
+               public void Abort ()
+               {
+                       comm.Abort ();
+               }
+
+               public void Open ()
+               {
+                       comm.Open ();
+               }
+
+               [MonoTODO]
+               public void Open (TimeSpan timeout)
+               {
+                       comm.Open (timeout);
+               }
+
+               public IAsyncResult BeginOpen (AsyncCallback callback, object state)
+               {
+                       return comm.BeginOpen (callback, state);
+               }
+
+               [MonoTODO]
+               public IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return comm.BeginOpen (timeout, callback, state);
+               }
+
+               [MonoTODO]
+               public void EndOpen (IAsyncResult result)
+               {
+                       comm.EndOpen (result);
+               }
+
+               public void Close ()
+               {
+                       comm.Close ();
+               }
+
+               [MonoTODO]
+               public void Close (TimeSpan timeout)
+               {
+                       comm.Close (timeout);
+               }
+
+               public IAsyncResult BeginClose (AsyncCallback callback, object state)
+               {
+                       return comm.BeginClose (callback, state);
+               }
+
+               [MonoTODO]
+               public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return comm.BeginClose (timeout, callback, state);
+               }
+
+               [MonoTODO]
+               public void EndClose (IAsyncResult result)
+               {
+                       comm.EndClose (result);
+               }
+
+               public void Dispose ()
+               {
+                       Close ();
+               }
+
+               public event EventHandler Opened {
+                       add { comm.Opened += value; }
+                       remove { comm.Opened -= value; }
+               }
+               public event EventHandler Opening {
+                       add { comm.Opening += value; }
+                       remove { comm.Opening -= value; }
+               }
+               public event EventHandler Closed {
+                       add { comm.Closed += value; }
+                       remove { comm.Closed -= value; }
+               }
+               public event EventHandler Closing {
+                       add { comm.Closing += value; }
+                       remove { comm.Closing -= value; }
+               }
+               public event EventHandler Faulted {
+                       add { comm.Faulted += value; }
+                       remove { comm.Faulted -= value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedTokenCommunicationObject.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/IssuedTokenCommunicationObject.cs
new file mode 100644 (file)
index 0000000..f090d70
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// IssuedTokenCommunicationObject.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Xml;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       class IssuedTokenCommunicationObject : ProviderCommunicationObject
+       {
+               WSTrustSecurityTokenServiceProxy comm;
+
+               public SecurityToken GetToken (TimeSpan timeout)
+               {
+                       WstRequestSecurityToken req = new WstRequestSecurityToken ();
+                       BodyWriter body = new WstRequestSecurityTokenWriter (req, SecurityTokenSerializer);
+                       Message msg = Message.CreateMessage (IssuerBinding.MessageVersion, Constants.WstIssueAction, body);
+                       Message res = comm.Issue (msg);
+
+                       // FIXME: provide SecurityTokenResolver (but from where?)
+                       using (WSTrustRequestSecurityTokenResponseReader resreader = new WSTrustRequestSecurityTokenResponseReader (null, res.GetReaderAtBodyContents (), SecurityTokenSerializer, null)) {
+                               WstRequestSecurityTokenResponse rstr = resreader.Read ();
+                               if (rstr.RequestedSecurityToken != null)
+                                       return rstr.RequestedSecurityToken;
+                               throw new NotImplementedException ("IssuedSecurityTokenProvider did not see RequestedSecurityToken in the response.");
+                       }
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return comm == null ? DefaultCommunicationTimeouts.Instance.CloseTimeout : comm.ChannelFactory.DefaultCloseTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return comm == null ? DefaultCommunicationTimeouts.Instance.OpenTimeout : comm.ChannelFactory.DefaultOpenTimeout; }
+               }
+
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       if (comm != null)
+                               throw new InvalidOperationException ("Already opened.");
+
+                       EnsureProperties ();
+
+                       comm = new WSTrustSecurityTokenServiceProxy (
+                               IssuerBinding, IssuerAddress);
+                       KeyedByTypeCollection<IEndpointBehavior> bl =
+                               comm.Endpoint.Behaviors;
+                       foreach (IEndpointBehavior b in IssuerChannelBehaviors) {
+                               bl.Remove (b.GetType ());
+                               bl.Add (b);
+                       }
+                       comm.Open ();
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       comm.Close ();
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/KerberosSecurityTokenParameters.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/KerberosSecurityTokenParameters.cs
new file mode 100644 (file)
index 0000000..5e2aa7d
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// KerberosSecurityTokenParameters.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class KerberosSecurityTokenParameters : SecurityTokenParameters
+       {
+               public KerberosSecurityTokenParameters ()
+               {
+               }
+
+               [MonoTODO]
+               protected KerberosSecurityTokenParameters (KerberosSecurityTokenParameters source)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override bool HasAsymmetricKey {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               protected override bool SupportsClientAuthentication {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               protected override bool SupportsClientWindowsIdentity {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               protected override bool SupportsServerAuthentication {
+                       get { throw new NotImplementedException (); }
+               }
+
+               protected override SecurityTokenParameters CloneCore ()
+               {
+                       return new KerberosSecurityTokenParameters (this);
+               }
+
+               [MonoTODO]
+               protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+               {
+                       if (requirement == null)
+                               throw new ArgumentNullException ("requirement");
+                       requirement.TokenType = SecurityTokenTypes.Kerberos;
+                       requirement.RequireCryptographicToken = true;
+                       requirement.KeyType = SecurityKeyType.SymmetricKey;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ProviderCommunicationObject.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ProviderCommunicationObject.cs
new file mode 100644 (file)
index 0000000..1569409
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// ProviderCommunicationObject.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       abstract class ProviderCommunicationObject : CommunicationObject
+       {
+               Binding issuer_binding;
+               EndpointAddress issuer_address, target_address;
+               KeyedByTypeCollection<IEndpointBehavior> behaviors =
+                       new KeyedByTypeCollection<IEndpointBehavior> ();
+               SecurityTokenSerializer serializer;
+               SecurityAlgorithmSuite algorithm;
+
+               public EndpointAddress IssuerAddress {
+                       get { return issuer_address; }
+                       set { issuer_address = value; }
+               }
+
+               public EndpointAddress TargetAddress {
+                       get { return target_address; }
+                       set { target_address = value; }
+               }
+
+               public Binding IssuerBinding {
+                       get { return issuer_binding; }
+                       set { issuer_binding = value; }
+               }
+
+               public KeyedByTypeCollection<IEndpointBehavior> IssuerChannelBehaviors {
+                       get { return behaviors; }
+               }
+
+               public SecurityAlgorithmSuite SecurityAlgorithmSuite {
+                       get { return algorithm; }
+                       set { algorithm= value; }
+               }
+
+               public SecurityTokenSerializer SecurityTokenSerializer {
+                       get { return serializer; }
+                       set { serializer = value; }
+               }
+
+               protected void EnsureProperties ()
+               {
+                       if (State == CommunicationState.Opened)
+                               throw new InvalidOperationException ("Already opened.");
+
+                       if (SecurityTokenSerializer == null)
+                               throw new InvalidOperationException ("Security token serializer must be set before opening the token provider.");
+
+                       if (IssuerAddress == null)
+                               throw new InvalidOperationException ("Issuer address must be set before opening the token provider.");
+
+                       if (IssuerBinding == null)
+                               throw new InvalidOperationException ("IssuerBinding must be set before opening the token provider.");
+
+                       if (SecurityAlgorithmSuite == null)
+                               throw new InvalidOperationException ("Security algorithm suite must be set before opening the token provider.");
+
+                       if (TargetAddress == null)
+                               throw new InvalidOperationException ("Target address must be set before opening the token provider.");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/RecipientServiceModelSecurityTokenRequirement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/RecipientServiceModelSecurityTokenRequirement.cs
new file mode 100644 (file)
index 0000000..3490455
--- /dev/null
@@ -0,0 +1,83 @@
+//
+// RecipientServiceModelSecurityTokenRequirement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public sealed class RecipientServiceModelSecurityTokenRequirement
+               : ServiceModelSecurityTokenRequirement
+       {
+               public RecipientServiceModelSecurityTokenRequirement ()
+               {
+               }
+
+               public AuditLogLocation AuditLogLocation {
+                       get {
+                               AuditLogLocation ret;
+                               TryGetProperty<AuditLogLocation> (AuditLogLocationProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [AuditLogLocationProperty] = value; }
+               }
+
+               public Uri ListenUri {
+                       get {
+                               Uri ret;
+                               TryGetProperty<Uri> (ListenUriProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [ListenUriProperty] = value; }
+               }
+
+               public AuditLevel MessageAuthenticationAuditLevel {
+                       get {
+                               AuditLevel ret;
+                               TryGetProperty<AuditLevel> (MessageAuthenticationAuditLevelProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [MessageAuthenticationAuditLevelProperty] = value; }
+               }
+
+               public bool SuppressAuditFailure {
+                       get {
+                               bool ret;
+                               TryGetProperty<bool> (SuppressAuditFailureProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [SuppressAuditFailureProperty] = value; }
+               }
+
+               public override string ToString ()
+               {
+                       return Dump ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/RenewedSecurityTokenHandler.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/RenewedSecurityTokenHandler.cs
new file mode 100644 (file)
index 0000000..78181c7
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// RenewedSecurityTokenHandler.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Tokens;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public delegate void RenewedSecurityTokenHandler (
+               SecurityToken newSecurityToken,
+               SecurityToken oldSecurityToken);
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/RsaSecurityTokenParameters.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/RsaSecurityTokenParameters.cs
new file mode 100644 (file)
index 0000000..50d9811
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// RsaSecurityTokenParameters.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class RsaSecurityTokenParameters : SecurityTokenParameters
+       {
+               public RsaSecurityTokenParameters ()
+               {
+                       InclusionMode = SecurityTokenInclusionMode.Never;
+                       RequireDerivedKeys = true;
+               }
+
+               protected RsaSecurityTokenParameters (RsaSecurityTokenParameters source)
+                       : base (source)
+               {
+               }
+
+               protected override bool HasAsymmetricKey {
+                       get { return true; }
+               }
+
+               protected override bool SupportsClientAuthentication {
+                       get { return true; }
+               }
+
+               protected override bool SupportsClientWindowsIdentity {
+                       get { return false; }
+               }
+
+               protected override bool SupportsServerAuthentication {
+                       get { return true; }
+               }
+
+               protected override SecurityTokenParameters CloneCore ()
+               {
+                       return new RsaSecurityTokenParameters (this);
+               }
+
+               protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       if (token == null)
+                               throw new ArgumentNullException ("token");
+                       RsaSecurityToken rt = token as RsaSecurityToken;
+                       if (rt == null)
+                               throw new NotSupportedException (String.Format ("Cannot create a key identifier clause from this security token '{0}'", token));
+                       return new RsaKeyIdentifierClause (rt.Rsa);
+               }
+
+               protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+               {
+                       if (requirement == null)
+                               throw new ArgumentNullException ("requirement");
+                       requirement.TokenType = SecurityTokenTypes.Rsa;
+                       requirement.RequireCryptographicToken = true;
+                       requirement.KeyType = SecurityKeyType.AsymmetricKey;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenAuthenticator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenAuthenticator.cs
new file mode 100644 (file)
index 0000000..74fa2e6
--- /dev/null
@@ -0,0 +1,132 @@
+//
+// SecureConversationSecurityTokenAuthenticator.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections.ObjectModel;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       class SecureConversationSecurityTokenAuthenticator : CommunicationSecurityTokenAuthenticator
+       {
+               SecurityTokenRequirement req;
+               SecurityContextSecurityTokenAuthenticator sc_auth;
+               SecurityContextSecurityTokenResolver sc_res;
+               WsscAuthenticatorCommunicationObject comm;
+
+               public SecureConversationSecurityTokenAuthenticator (
+                       SecurityTokenRequirement r,
+                       SecurityContextSecurityTokenAuthenticator scAuth,
+                       SecurityContextSecurityTokenResolver scResolver)
+               {
+                       this.req = r;
+                       this.sc_auth = scAuth;
+                       this.sc_res = scResolver;
+                       comm = new WsscAuthenticatorCommunicationObject ();
+               }
+
+               public override AuthenticatorCommunicationObject Communication {
+                       get { return comm; }
+               }
+
+               [MonoTODO]
+               protected override bool CanValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override ReadOnlyCollection<IAuthorizationPolicy> ValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
+       class WsscAuthenticatorCommunicationObject : AuthenticatorCommunicationObject
+       {
+               WSTrustSecurityTokenServiceProxy proxy;
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { throw new NotImplementedException (); }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public override Message ProcessNegotiation (Message request)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       if (State == CommunicationState.Opened)
+                               throw new InvalidOperationException ("Already opened.");
+
+                       EnsureProperties ();
+
+                       proxy = new WSTrustSecurityTokenServiceProxy (
+                               IssuerBinding, IssuerAddress);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       if (proxy != null)
+                               proxy.Close ();
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenParameters.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenParameters.cs
new file mode 100644 (file)
index 0000000..ef61a10
--- /dev/null
@@ -0,0 +1,164 @@
+//
+// SecureConversationSecurityTokenParameters.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class SecureConversationSecurityTokenParameters : SecurityTokenParameters
+       {
+               static readonly ChannelProtectionRequirements default_channel_protection_requirements;
+               static readonly BindingContext dummy_context;
+
+               static SecureConversationSecurityTokenParameters ()
+               {
+                       ChannelProtectionRequirements r =
+                               new ChannelProtectionRequirements ();
+                       r.IncomingSignatureParts.ChannelParts.IsBodyIncluded = true;
+                       r.OutgoingSignatureParts.ChannelParts.IsBodyIncluded = true;
+                       r.IncomingEncryptionParts.ChannelParts.IsBodyIncluded = true;
+                       r.OutgoingEncryptionParts.ChannelParts.IsBodyIncluded = true;
+                       r.MakeReadOnly ();
+                       default_channel_protection_requirements = r;
+
+                       dummy_context = new BindingContext (
+                               new CustomBinding (),
+                               new BindingParameterCollection ());
+               }
+
+               SecurityBindingElement element;
+               ChannelProtectionRequirements requirements;
+               bool cancellable;
+
+               public SecureConversationSecurityTokenParameters ()
+                       : this ((SecurityBindingElement) null)
+               {
+               }
+
+               public SecureConversationSecurityTokenParameters (
+                       SecurityBindingElement element)
+                       : this (element, true)
+               {
+               }
+
+               public SecureConversationSecurityTokenParameters (
+                       SecurityBindingElement element,
+                       bool requireCancellation)
+                       : this (element, requireCancellation, null)
+               {
+               }
+
+               public SecureConversationSecurityTokenParameters (
+                       SecurityBindingElement element,
+                       bool requireCancellation,
+                       ChannelProtectionRequirements requirements)
+               {
+                       this.element = element;
+                       this.cancellable = requireCancellation;
+                       if (requirements == null)
+                               this.requirements = new ChannelProtectionRequirements (default_channel_protection_requirements);
+                       else
+                               this.requirements = new ChannelProtectionRequirements (requirements);
+               }
+
+               protected SecureConversationSecurityTokenParameters (SecureConversationSecurityTokenParameters source)
+                       : base (source)
+               {
+                       this.element = (SecurityBindingElement) source.element.Clone ();
+                       this.cancellable = source.cancellable;
+                       this.requirements = new ChannelProtectionRequirements (default_channel_protection_requirements);
+               }
+
+               public bool RequireCancellation {
+                       get { return cancellable; }
+                       set { cancellable = value; }
+               }
+
+               public SecurityBindingElement BootstrapSecurityBindingElement {
+                       get { return element; }
+                       set { element = value; }
+               }
+
+               public ChannelProtectionRequirements BootstrapProtectionRequirements {
+                       get { return requirements; }
+               }
+
+               // SecurityTokenParameters
+
+               protected override bool HasAsymmetricKey {
+                       get { return false; }
+               }
+
+               protected override bool SupportsClientAuthentication {
+                       get { return element.GetProperty<ISecurityCapabilities> (dummy_context).SupportsClientAuthentication; }
+               }
+
+               protected override bool SupportsClientWindowsIdentity {
+                       get { return element.GetProperty<ISecurityCapabilities> (dummy_context).SupportsClientWindowsIdentity; }
+               }
+
+               protected override bool SupportsServerAuthentication {
+                       get { return element.GetProperty<ISecurityCapabilities> (dummy_context).SupportsServerAuthentication; }
+               }
+
+               protected override SecurityTokenParameters CloneCore ()
+               {
+                       return new SecureConversationSecurityTokenParameters (this);
+               }
+
+               [MonoTODO]
+               protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+               {
+                       // .NET somehow causes NRE. dunno why.
+                       requirement.TokenType = ServiceModelSecurityTokenTypes.SecureConversation;
+                       requirement.RequireCryptographicToken = true;
+                       requirement.Properties [ReqType.SupportSecurityContextCancellationProperty] = RequireCancellation;
+                       requirement.Properties [ReqType.SecureConversationSecurityBindingElementProperty] =
+                               BootstrapSecurityBindingElement;
+                       requirement.Properties [ReqType.IssuedSecurityTokenParametersProperty] = this.Clone ();
+                       requirement.KeyType = SecurityKeyType.SymmetricKey;
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityToken.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityToken.cs
new file mode 100644 (file)
index 0000000..846d835
--- /dev/null
@@ -0,0 +1,217 @@
+//
+// SecurityContextSecretSecurityToken.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Xml;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class SecurityContextSecurityToken : SecurityToken
+       {
+               #region Static members 
+
+               public static SecurityContextSecurityToken CreateCookieSecurityContextToken (
+                       UniqueId contextId,
+                       string id,
+                       byte [] key,
+                       DateTime validFrom,
+                       DateTime validTo,
+                       ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies,
+                       SecurityStateEncoder securityStateEncoder)
+               {
+                       return CreateCookieSecurityContextToken (
+                               contextId, id, key, validFrom, validTo, new UniqueId (Guid.NewGuid ()), validFrom, validTo, authorizationPolicies, securityStateEncoder);
+               }
+
+               public static SecurityContextSecurityToken CreateCookieSecurityContextToken (
+                       UniqueId contextId,
+                       string id,
+                       byte [] key,
+                       DateTime validFrom,
+                       DateTime validTo,
+                       UniqueId keyGeneration,
+                       DateTime keyEffectiveTime,
+                       DateTime keyExpirationTime,
+                       ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies,
+                       SecurityStateEncoder securityStateEncoder)
+               {
+                       if (securityStateEncoder == null)
+                               throw new ArgumentNullException ("securityStateEncoder");
+
+                       SecurityContextSecurityToken sct = new SecurityContextSecurityToken (
+                               contextId, id, key, validFrom, validTo,
+                               keyGeneration, keyEffectiveTime, 
+                               keyExpirationTime,  authorizationPolicies);
+                       byte [] rawdata = SslnegoCookieResolver.CreateData (
+                               contextId, keyGeneration, key,
+                               validFrom, validTo,
+                               keyEffectiveTime, keyExpirationTime);
+                       sct.cookie = securityStateEncoder.EncodeSecurityState (rawdata);
+                       return sct;
+               }
+
+               #endregion
+
+               string id;
+               InMemorySymmetricSecurityKey key;
+               ReadOnlyCollection<SecurityKey> keys;
+               DateTime token_since, token_until, key_since, key_until;
+               UniqueId context_id, key_generation;
+               ReadOnlyCollection<IAuthorizationPolicy> policies;
+               byte [] cookie;
+
+               public SecurityContextSecurityToken (
+                       UniqueId contextId,
+                       byte[] key,
+                       DateTime validFrom,
+                       DateTime validTo)
+                       : this (contextId, new UniqueId ().ToString (), key, validFrom, validTo)
+               {
+               }
+
+               public SecurityContextSecurityToken (
+                       UniqueId contextId,
+                       string id,
+                       byte[] key,
+                       DateTime validFrom,
+                       DateTime validTo)
+                       : this (contextId, id, key, validFrom, validTo, null)
+               {
+               }
+
+               public SecurityContextSecurityToken (
+                       UniqueId contextId,
+                       string id,
+                       byte[] key,
+                       DateTime validFrom,
+                       DateTime validTo,
+                       ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies)
+               {
+                       context_id = contextId;
+                       this.id = id;
+                       this.key = new InMemorySymmetricSecurityKey (key);
+                       token_since = validFrom;
+                       token_until = validTo;
+                       if (authorizationPolicies == null)
+                               authorizationPolicies = new ReadOnlyCollection<IAuthorizationPolicy> (new Collection<IAuthorizationPolicy> ());
+                       policies = authorizationPolicies;
+               }
+
+               public SecurityContextSecurityToken (
+                       UniqueId contextId,
+                       string id,
+                       byte[] key,
+                       DateTime validFrom,
+                       DateTime validTo,
+                       UniqueId keyGeneration,
+                       DateTime keyEffectiveTime,
+                       DateTime keyExpirationTime,
+                       ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies)
+                       : this (contextId, id, key, validFrom, validTo, authorizationPolicies)
+               {
+                       key_generation = keyGeneration;
+                       key_since = keyEffectiveTime;
+                       key_until = keyExpirationTime;
+               }
+
+               public ReadOnlyCollection<IAuthorizationPolicy> AuthorizationPolicies {
+                       get { return policies; }
+               }
+
+               public UniqueId ContextId {
+                       get { return context_id; }
+               }
+
+               public UniqueId KeyGeneration {
+                       get { return key_generation; }
+               }
+
+               public DateTime KeyEffectiveTime {
+                       get { return key_since; }
+               }
+
+               public DateTime KeyExpirationTime {
+                       get { return key_until; }
+               }
+
+               public override DateTime ValidFrom {
+                       get { return token_since; }
+               }
+
+               public override DateTime ValidTo {
+                       get { return token_until; }
+               }
+
+               public override string Id {
+                       get { return id; }
+               }
+
+               public override ReadOnlyCollection<SecurityKey> SecurityKeys {
+                       get {
+                               if (keys == null)
+                                       keys = new ReadOnlyCollection<SecurityKey> (new SecurityKey [] {key});
+                               return keys;
+                       }
+               }
+
+               internal byte [] Cookie {
+                       get { return cookie; }
+                       set { cookie = value; }
+               }
+
+               public override bool CanCreateKeyIdentifierClause<T> ()
+               {
+                       return typeof (T) == typeof (SecurityContextKeyIdentifierClause);
+               }
+
+               public override T CreateKeyIdentifierClause<T> ()
+               {
+                       Type t = typeof (T);
+                       if (t == typeof (SecurityContextKeyIdentifierClause))
+                               return (T) (object) new SecurityContextKeyIdentifierClause (ContextId, KeyGeneration);
+
+                       throw new NotSupportedException (String.Format ("X509SecurityToken does not support creation of {0}.", t));
+               }
+
+               public override bool MatchesKeyIdentifierClause (SecurityKeyIdentifierClause clause)
+               {
+                       SecurityContextKeyIdentifierClause sctic =
+                               clause as SecurityContextKeyIdentifierClause;
+                       return sctic != null && sctic.ContextId == ContextId &&
+                              sctic.Generation == KeyGeneration;
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenAuthenticator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenAuthenticator.cs
new file mode 100644 (file)
index 0000000..cbbc56a
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// SecurityContextSecurityTokenAuthenticator.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Collections.ObjectModel;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class SecurityContextSecurityTokenAuthenticator : SecurityTokenAuthenticator
+       {
+               public SecurityContextSecurityTokenAuthenticator ()
+               {
+               }
+
+               [MonoTODO]
+               protected override bool CanValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override ReadOnlyCollection<IAuthorizationPolicy> ValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenResolver.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenResolver.cs
new file mode 100644 (file)
index 0000000..0509bc4
--- /dev/null
@@ -0,0 +1,153 @@
+//
+// SecurityContextSecurityTokenResolver.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Xml;
+
+using Table = System.Collections.Generic.Dictionary<System.Xml.UniqueId,System.ServiceModel.Security.Tokens.SecurityContextSecurityToken>;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class SecurityContextSecurityTokenResolver : SecurityTokenResolver, ISecurityContextSecurityTokenCache
+       {
+               int capacity;
+               bool allow_removal;
+
+               Dictionary<UniqueId,Table> cache =
+                       new Dictionary<UniqueId,Table> ();
+
+               public SecurityContextSecurityTokenResolver (
+                       int securityContextCacheCapacity,
+                       bool removeOldestTokensOnCacheFull)
+               {
+                       capacity = securityContextCacheCapacity;
+                       allow_removal = removeOldestTokensOnCacheFull;
+               }
+
+               public bool RemoveOldestTokensOnCacheFull {
+                       get { return allow_removal; }
+               }
+
+               public int SecurityContextTokenCacheCapacity {
+                       get { return capacity; }
+               }
+
+               public void AddContext (SecurityContextSecurityToken token)
+               {
+                       if (!TryAddContext (token))
+                               throw new InvalidOperationException ("Argument token is already in the cache.");
+               }
+
+               public void ClearContexts ()
+               {
+                       cache.Clear ();
+               }
+
+               public Collection<SecurityContextSecurityToken> GetAllContexts (UniqueId contextId)
+               {
+                       Table table;
+                       if (!cache.TryGetValue (contextId, out table))
+                               return new Collection<SecurityContextSecurityToken> ();
+                       SecurityContextSecurityToken [] arr =
+                               new SecurityContextSecurityToken [table.Count];
+                       table.Values.CopyTo (arr, 0);
+                       return new Collection<SecurityContextSecurityToken> (arr);
+               }
+
+               public SecurityContextSecurityToken GetContext (UniqueId contextId, UniqueId generation)
+               {
+                       Table table;
+                       if (!cache.TryGetValue (contextId, out table))
+                               return null;
+                       SecurityContextSecurityToken ret;
+                       return table.TryGetValue (generation, out ret) ? ret : null;
+               }
+
+               public void RemoveAllContexts (UniqueId contextId)
+               {
+                       cache.Remove (contextId);
+               }
+
+               public void RemoveContext (UniqueId contextId, UniqueId generation)
+               {
+                       Table table;
+                       if (!cache.TryGetValue (contextId, out table))
+                               return;
+                       table.Remove (generation);
+               }
+
+               public bool TryAddContext (SecurityContextSecurityToken token)
+               {
+                       Table table;
+                       if (!cache.TryGetValue (token.ContextId, out table)) {
+                               table = new Table ();
+                               table [token.KeyGeneration] = token;
+                       } else {
+                               if (table.ContainsKey (token.KeyGeneration))
+                                       return false;
+                               table [token.KeyGeneration] = token;
+                       }
+                       return true;
+               }
+
+               [MonoTODO]
+               public void UpdateContextCachingTime (SecurityContextSecurityToken context, DateTime expirationTime)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               // SecurityTokenResolver
+
+               [MonoTODO]
+               protected override bool TryResolveSecurityKeyCore (
+                       SecurityKeyIdentifierClause keyIdentifierClause,
+                       out SecurityKey key)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override bool TryResolveTokenCore (
+                       SecurityKeyIdentifier keyIdentifier,
+                       out SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override bool TryResolveTokenCore (
+                       SecurityKeyIdentifierClause keyIdentifierClause,
+                       out SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityTokenParameters.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityTokenParameters.cs
new file mode 100644 (file)
index 0000000..39b0fdc
--- /dev/null
@@ -0,0 +1,134 @@
+//
+// SecurityTokenParameters.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public abstract class SecurityTokenParameters
+       {
+               protected SecurityTokenParameters ()
+               {
+               }
+
+               protected SecurityTokenParameters (SecurityTokenParameters source)
+               {
+               }
+
+               SecurityTokenInclusionMode inclusion_mode;
+               SecurityTokenReferenceStyle reference_style;
+               bool require_derived_keys = true;
+               BindingContext issuer_binding_context;
+
+               public SecurityTokenInclusionMode InclusionMode {
+                       get { return inclusion_mode; }
+                       set { inclusion_mode = value; }
+               }
+
+               public SecurityTokenReferenceStyle ReferenceStyle {
+                       get { return reference_style; }
+                       set { reference_style = value; }
+               }
+
+               public bool RequireDerivedKeys {
+                       get { return require_derived_keys; }
+                       set { require_derived_keys = value; }
+               }
+
+               public SecurityTokenParameters Clone ()
+               {
+                       return CloneCore ();
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+
+               protected abstract bool HasAsymmetricKey { get; }
+
+               protected abstract bool SupportsClientAuthentication { get; }
+
+               protected abstract bool SupportsClientWindowsIdentity { get; }
+
+               protected abstract bool SupportsServerAuthentication { get; }
+
+               internal bool InternalHasAsymmetricKey {
+                       get { return HasAsymmetricKey; }
+               }
+
+               internal bool InternalSupportsClientAuthentication {
+                       get { return SupportsClientAuthentication; }
+               }
+
+               internal bool InternalSupportsClientWindowsIdentity {
+                       get { return SupportsClientWindowsIdentity; }
+               }
+
+               internal bool InternalSupportsServerAuthentication {
+                       get { return SupportsServerAuthentication; }
+               }
+
+               protected abstract SecurityTokenParameters CloneCore ();
+
+               protected abstract SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle);
+
+               // internalized call to CreateKeyIdentifierClause()
+               internal SecurityKeyIdentifierClause CallCreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       return CreateKeyIdentifierClause (token, referenceStyle);
+               }
+
+               protected abstract void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement);
+
+               internal BindingContext IssuerBindingContext {
+                       set { issuer_binding_context = value; }
+               }
+
+               internal void CallInitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+               {
+                       if (issuer_binding_context != null)
+                               requirement.Properties [ServiceModelSecurityTokenRequirement.IssuerBindingContextProperty] = issuer_binding_context;
+                       InitializeSecurityTokenRequirement (requirement);
+               }
+
+               [MonoTODO]
+               protected virtual bool MatchesKeyIdentifierClause (
+                       SecurityToken token,
+                       SecurityKeyIdentifierClause keyIdentifierClause,
+                       SecurityTokenReferenceStyle referenceStyle)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityTokenReferenceStyle.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SecurityTokenReferenceStyle.cs
new file mode 100644 (file)
index 0000000..bafac07
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// SecurityTokenReferenceStyle.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public enum SecurityTokenReferenceStyle
+       {
+               Internal,
+               External
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenRequirement.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenRequirement.cs
new file mode 100644 (file)
index 0000000..f02fbee
--- /dev/null
@@ -0,0 +1,235 @@
+//
+// ServiceModelSecurityTokenRequirement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.Text;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public abstract class ServiceModelSecurityTokenRequirement :
+               SecurityTokenRequirement
+       {
+               protected ServiceModelSecurityTokenRequirement ()
+               {
+               }
+
+               protected const string Namespace = "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement";
+
+               public static string AuditLogLocationProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/AuditLogLocation"; }
+               }
+
+               public static string ChannelParametersCollectionProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/ChannelParametersCollection"; }
+               }
+
+               public static string DuplexClientLocalAddressProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/DuplexClientLocalAddress"; }
+               }
+
+               public static string EndpointFilterTableProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/EndpointFilterTable"; }
+               }
+
+               public static string HttpAuthenticationSchemeProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/HttpAuthenticationScheme"; }
+               }
+
+               public static string IsInitiatorProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IsInitiator"; }
+               }
+
+               public static string IsOutOfBandTokenProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IsOutOfBandToken"; }
+               }
+
+               public static string IssuedSecurityTokenParametersProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuedSecurityTokenParameters"; }
+               }
+
+               public static string IssuerAddressProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuerAddress"; }
+               }
+
+               public static string IssuerBindingContextProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuerBindingContext"; }
+               }
+
+               public static string IssuerBindingProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuerBinding"; }
+               }
+
+               public static string ListenUriProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/ListenUri"; }
+               }
+
+               public static string MessageAuthenticationAuditLevelProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/MessageAuthenticationAuditLevel"; }
+               }
+
+               public static string MessageDirectionProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/MessageDirection"; }
+               }
+
+               public static string MessageSecurityVersionProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/MessageSecurityVersion"; }
+               }
+
+               public static string PrivacyNoticeUriProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/PrivacyNoticeUri"; }
+               }
+
+               public static string PrivacyNoticeVersionProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/PrivacyNoticeVersion"; }
+               }
+
+               public static string SecureConversationSecurityBindingElementProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SecureConversationSecurityBindingElement"; }
+               }
+
+               public static string SecurityAlgorithmSuiteProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SecurityAlgorithmSuite"; }
+               }
+
+               public static string SecurityBindingElementProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SecurityBindingElement"; }
+               }
+
+               public static string SupportingTokenAttachmentModeProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SupportingTokenAttachmentMode"; }
+               }
+
+               public static string SupportSecurityContextCancellationProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SupportSecurityContextCancellation"; }
+               }
+
+               public static string SuppressAuditFailureProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SuppressAuditFailure"; }
+               }
+
+               public static string TargetAddressProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/TargetAddress"; }
+               }
+
+               public static string TransportSchemeProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/TransportScheme"; }
+               }
+
+               public static string ViaProperty {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/Via"; }
+               }
+
+               public bool IsInitiator {
+                       get {
+                               bool ret;
+                               if (TryGetProperty<bool> (IsInitiatorProperty, out ret))
+                                       return ret;
+                               return false;
+                       }
+               }
+
+               public EndpointAddress IssuerAddress {
+                       get {
+                               EndpointAddress ret;
+                               TryGetProperty<EndpointAddress> (IssuerAddressProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [IssuerAddressProperty] = value; }
+               }
+
+               public Binding IssuerBinding {
+                       get {
+                               Binding ret;
+                               TryGetProperty<Binding> (IssuerBindingProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [IssuerBindingProperty] = value; }
+               }
+
+               public SecurityTokenVersion MessageSecurityVersion {
+                       get {
+                               SecurityTokenVersion ret;
+                               TryGetProperty<SecurityTokenVersion> (MessageSecurityVersionProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [MessageSecurityVersionProperty] = value; }
+               }
+
+               public SecurityBindingElement SecureConversationSecurityBindingElement {
+                       get {
+                               SecurityBindingElement ret;
+                               TryGetProperty<SecurityBindingElement> (SecureConversationSecurityBindingElementProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [SecureConversationSecurityBindingElementProperty] = value; }
+               }
+
+               public SecurityAlgorithmSuite SecurityAlgorithmSuite {
+                       get {
+                               SecurityAlgorithmSuite ret;
+                               TryGetProperty<SecurityAlgorithmSuite> (SecurityAlgorithmSuiteProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [SecurityAlgorithmSuiteProperty] = value; }
+               }
+
+               public SecurityBindingElement SecurityBindingElement {
+                       get {
+                               SecurityBindingElement ret;
+                               TryGetProperty<SecurityBindingElement> (SecurityBindingElementProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [SecurityBindingElementProperty] = value; }
+               }
+
+               public string TransportScheme {
+                       get {
+                               string ret;
+                               TryGetProperty<string> (TransportSchemeProperty, out ret);
+                               return ret;
+                       }
+                       set { Properties [TransportSchemeProperty] = value; }
+               }
+
+               internal string Dump ()
+               {
+                       StringBuilder sb = new StringBuilder ();
+                       sb.Append (GetType ()).Append (":");
+                       foreach (KeyValuePair<string, object> p in Properties)
+                               sb.Append ("\n------------\n")
+                                 .Append ("URI: ")
+                                 .Append (p.Key)
+                                 .Append ("\nValue: ")
+                                 .Append (p.Value);
+                       return sb.ToString ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenTypes.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenTypes.cs
new file mode 100644 (file)
index 0000000..f682134
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// ServiceModelSecurityTokenTypes.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public static class ServiceModelSecurityTokenTypes
+       {
+               public static string AnonymousSslnego {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/AnonymousSslnego"; }
+               }
+
+               public static string MutualSslnego {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/MutualSslnego"; }
+               }
+
+               public static string SecureConversation {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/SecureConversation"; }
+               }
+
+               public static string SecurityContext {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/SecurityContextToken"; }
+               }
+
+               public static string Spnego {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/Spnego"; }
+               }
+
+               public static string SspiCredential {
+                       get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/SspiCredential"; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SpnegoSecurityTokenAuthenticator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SpnegoSecurityTokenAuthenticator.cs
new file mode 100755 (executable)
index 0000000..a98ba30
--- /dev/null
@@ -0,0 +1,320 @@
+//
+// SpnegoSecurityTokenAuthenticator.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net.Security;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Text;
+using System.Xml;
+using Mono.Security;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       // FIXME: implement all
+       class SpnegoSecurityTokenAuthenticator : CommunicationSecurityTokenAuthenticator
+       {
+               ServiceCredentialsSecurityTokenManager manager;
+               SpnegoAuthenticatorCommunicationObject comm;
+
+               public SpnegoSecurityTokenAuthenticator (
+                       ServiceCredentialsSecurityTokenManager manager, 
+                       SecurityTokenRequirement r)
+               {
+                       this.manager = manager;
+                       comm = new SpnegoAuthenticatorCommunicationObject (this);
+               }
+
+               public ServiceCredentialsSecurityTokenManager Manager {
+                       get { return manager; }
+               }
+
+               public override AuthenticatorCommunicationObject Communication {
+                       get { return comm; }
+               }
+
+               protected override bool CanValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override ReadOnlyCollection<IAuthorizationPolicy>
+                       ValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
+       class SpnegoAuthenticatorCommunicationObject : AuthenticatorCommunicationObject
+       {
+               SpnegoSecurityTokenAuthenticator owner;
+
+               public SpnegoAuthenticatorCommunicationObject (SpnegoSecurityTokenAuthenticator owner)
+               {
+                       this.owner = owner;
+               }
+
+               WSTrustSecurityTokenServiceProxy proxy;
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { throw new NotImplementedException (); }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public override Message ProcessNegotiation (Message request)
+               {
+                       if (request.Headers.Action == Constants.WstIssueAction)
+                               return ProcessMessageType1 (request);
+                       else
+                               return ProcessMessageType3 (request);
+               }
+
+               class TlsServerSessionInfo
+               {
+                       public TlsServerSessionInfo (string context, TlsServerSession tls)
+                       {
+                               ContextId = context;
+                               Tls = tls;
+                       }
+
+                       public string ContextId;
+                       public TlsServerSession Tls;
+                       public MemoryStream Messages = new MemoryStream ();
+               }
+
+               Dictionary<string,SspiServerSession> sessions =
+                       new Dictionary<string,SspiServerSession> ();
+
+               void AppendNegotiationMessageXml (XmlReader reader, TlsServerSessionInfo tlsInfo)
+               {
+                       XmlDsigExcC14NTransform t = new XmlDsigExcC14NTransform ();
+                       XmlDocument doc = new XmlDocument ();
+                       doc.PreserveWhitespace = true;
+                       reader.MoveToContent ();
+                       doc.AppendChild (doc.ReadNode (reader));
+                       t.LoadInput (doc);
+                       MemoryStream stream = (MemoryStream) t.GetOutput ();
+                       byte [] bytes = stream.ToArray ();
+                       tlsInfo.Messages.Write (bytes, 0, bytes.Length);
+               }
+
+               Message ProcessMessageType1 (Message request)
+               {
+                       // FIXME: use correct buffer size
+                       MessageBuffer buffer = request.CreateBufferedCopy (0x10000);
+                       WSTrustRequestSecurityTokenReader reader =
+                               new WSTrustRequestSecurityTokenReader (buffer.CreateMessage ().GetReaderAtBodyContents (), SecurityTokenSerializer);
+                       reader.Read ();
+
+                       if (sessions.ContainsKey (reader.Value.Context))
+                               throw new SecurityNegotiationException (String.Format ("The context '{0}' already exists in this SSL negotiation manager", reader.Value.Context));
+
+Console.WriteLine (buffer.CreateMessage ());
+
+                       SspiServerSession sspi = new SspiServerSession ();
+//                     AppendNegotiationMessageXml (buffer.CreateMessage ().GetReaderAtBodyContents (), tlsInfo);
+
+                       // FIXME: when an explicit endpoint identity is
+                       // specified in the target EndpointAddress at client,
+                       // it sends some other kind of binary octets that
+                       // include NTLM octet, instead of raw NTLM octet itself.
+
+                       byte [] raw = reader.Value.BinaryExchange.Value;
+
+                       bool gss = "NTLMSSP" != Encoding.ASCII.GetString (raw, 0, 7);
+
+                       if (gss)
+                               sspi.ProcessSpnegoInitialContextTokenRequest (raw);
+                       else
+                               sspi.ProcessMessageType1 (raw);
+
+                       WstRequestSecurityTokenResponse rstr =
+                               new WstRequestSecurityTokenResponse (SecurityTokenSerializer);
+                       rstr.Context = reader.Value.Context;
+                       rstr.BinaryExchange = new WstBinaryExchange (Constants.WstBinaryExchangeValueGss);
+
+                       if (gss)
+                               rstr.BinaryExchange.Value = sspi.ProcessSpnegoInitialContextTokenResponse ();
+                       else
+                               rstr.BinaryExchange.Value = sspi.ProcessMessageType2 ();
+
+                       Message reply = Message.CreateMessage (request.Version, Constants.WstIssueReplyAction, rstr);
+                       reply.Headers.RelatesTo = request.Headers.MessageId;
+
+                       // FIXME: use correct buffer size
+                       buffer = reply.CreateBufferedCopy (0x10000);
+//                     AppendNegotiationMessageXml (buffer.CreateMessage ().GetReaderAtBodyContents (), tlsInfo);
+
+                       sessions [reader.Value.Context] = sspi;
+
+                       return buffer.CreateMessage ();
+               }
+
+               Message ProcessMessageType3 (Message request)
+               {
+                       // FIXME: use correct buffer size
+                       MessageBuffer buffer = request.CreateBufferedCopy (0x10000);
+Console.WriteLine (buffer.CreateMessage ());
+                       WSTrustRequestSecurityTokenResponseReader reader =
+                               new WSTrustRequestSecurityTokenResponseReader (Constants.WstSpnegoProofTokenType, buffer.CreateMessage ().GetReaderAtBodyContents (), SecurityTokenSerializer, null);
+                       reader.Read ();
+
+                       byte [] raw = reader.Value.BinaryExchange.Value;
+
+                       bool gss = "NTLMSSP" != Encoding.ASCII.GetString (raw, 0, 7);
+
+foreach (byte b in raw) Console.Write ("{0:X02} ", b); Console.WriteLine ();
+
+                       SspiServerSession sspi;
+                       if (!sessions.TryGetValue (reader.Value.Context, out sspi))
+                               throw new SecurityNegotiationException (String.Format ("The context '{0}' does not exist in this SSL negotiation manager", reader.Value.Context));
+
+                       if (gss)
+                               sspi.ProcessSpnegoProcessContextToken (raw);
+                       else
+                               sspi.ProcessMessageType3 (raw);
+
+                       throw new NotImplementedException ();
+/*
+                       AppendNegotiationMessageXml (buffer.CreateMessage ().GetReaderAtBodyContents (), tlsInfo);
+//Console.WriteLine (System.Text.Encoding.UTF8.GetString (tlsInfo.Messages.ToArray ()));
+
+                       tls.ProcessClientKeyExchange (reader.Value.BinaryExchange.Value);
+
+                       byte [] serverFinished = tls.ProcessServerFinished ();
+
+                       // The shared key is computed as recommended in WS-Trust:
+                       // P_SHA1(encrypted_key,SHA1(exc14n(RST..RSTRs))+"CK-HASH")
+                       byte [] hash = SHA1.Create ().ComputeHash (tlsInfo.Messages.ToArray ());
+                       byte [] key = tls.CreateHash (tls.MasterSecret, hash, "CK-HASH");
+foreach (byte b in hash) Console.Write ("{0:X02} ", b); Console.WriteLine ();
+foreach (byte b in key) Console.Write ("{0:X02} ", b); Console.WriteLine ();
+
+                       WstRequestSecurityTokenResponseCollection col =
+                               new WstRequestSecurityTokenResponseCollection ();
+                       WstRequestSecurityTokenResponse rstr =
+                               new WstRequestSecurityTokenResponse (SecurityTokenSerializer);
+                       rstr.Context = reader.Value.Context;
+                       rstr.TokenType = Constants.WsscContextToken;
+                       DateTime from = DateTime.Now;
+                       // FIXME: not sure if arbitrary key is used here.
+                       SecurityContextSecurityToken sct = SecurityContextSecurityToken.CreateCookieSecurityContextToken (
+                               // Create a new context.
+                               // (do not use sslnego context here.)
+                               new UniqueId (),
+                               "uuid-" + Guid.NewGuid (),
+                               key,
+                               from,
+                               // FIXME: use LocalServiceSecuritySettings.NegotiationTimeout
+                               from.AddHours (8),
+                               null,
+                               owner.Manager.ServiceCredentials.SecureConversationAuthentication.SecurityStateEncoder);
+                       rstr.RequestedSecurityToken = sct;
+                       rstr.RequestedProofToken = tls.ProcessApplicationData (key);
+                       rstr.RequestedAttachedReference = new LocalIdKeyIdentifierClause (sct.Id);
+                       rstr.RequestedUnattachedReference = new SecurityContextKeyIdentifierClause (sct.ContextId, null);
+                       WstLifetime lt = new WstLifetime ();
+                       lt.Created = from;
+                       // FIXME: use LocalServiceSecuritySettings.NegotiationTimeout
+                       lt.Expires = from.AddHours (8);
+                       rstr.Lifetime = lt;
+                       rstr.BinaryExchange = new WstBinaryExchange (Constants.WstBinaryExchangeValueGss);
+                       rstr.BinaryExchange.Value = serverFinished;
+
+                       col.Responses.Add (rstr);
+
+                       // Authenticator is mandatory for MS sslnego.
+                       rstr = new WstRequestSecurityTokenResponse (SecurityTokenSerializer);
+                       rstr.Context = reader.Value.Context;
+                       rstr.Authenticator = tls.CreateHash (key, hash, "AUTH-HASH");
+                       col.Responses.Add (rstr);
+
+                       sessions.Remove (reader.Value.Context);
+
+                       return Message.CreateMessage (request.Version, Constants.WstIssueReplyAction, col);
+*/
+               }
+
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       if (State == CommunicationState.Opened)
+                               throw new InvalidOperationException ("Already opened.");
+
+                       EnsureProperties ();
+
+                       proxy = new WSTrustSecurityTokenServiceProxy (
+                               IssuerBinding, IssuerAddress);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       if (proxy != null)
+                               proxy.Close ();
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SpnegoSecurityTokenProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SpnegoSecurityTokenProvider.cs
new file mode 100755 (executable)
index 0000000..3fcdf9f
--- /dev/null
@@ -0,0 +1,203 @@
+//
+// SpnegoSecurityTokenProvider.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Net;
+using System.Security.Principal;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using Mono.Security;
+
+// mhm, why is this class not in S.SM.S.Tokens??
+namespace System.ServiceModel.Security
+{
+       // Anyways we won't support SSPI until it becomes open.
+       internal class SpnegoSecurityTokenProvider : CommunicationSecurityTokenProvider
+       {
+               ClientCredentialsSecurityTokenManager manager;
+               SecurityTokenRequirement requirement;
+               SpnegoCommunicationObject comm;
+
+               public SpnegoSecurityTokenProvider (ClientCredentialsSecurityTokenManager manager, SecurityTokenRequirement requirement)
+               {
+                       this.manager = manager;
+                       comm = new SpnegoCommunicationObject (this);
+               }
+
+               public ClientCredentialsSecurityTokenManager Manager {
+                       get { return manager; }
+               }
+
+               public override ProviderCommunicationObject Communication {
+                       get { return comm; }
+               }
+
+               public override SecurityToken GetOnlineToken (TimeSpan timeout)
+               {
+                       return comm.GetToken (timeout);
+               }
+       }
+
+       class SpnegoCommunicationObject : ProviderCommunicationObject
+       {
+               SpnegoSecurityTokenProvider owner;
+
+               public SpnegoCommunicationObject (SpnegoSecurityTokenProvider owner)
+               {
+                       this.owner = owner;
+               }
+
+               WSTrustSecurityTokenServiceProxy proxy;
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { throw new NotImplementedException (); }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { throw new NotImplementedException (); }
+               }
+
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       if (State == CommunicationState.Opened)
+                               throw new InvalidOperationException ("Already opened.");
+
+                       EnsureProperties ();
+
+                       proxy = new WSTrustSecurityTokenServiceProxy (
+                               IssuerBinding, IssuerAddress);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       if (proxy != null)
+                               proxy.Close ();
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public SecurityToken GetToken (TimeSpan timeout)
+               {
+                       bool gss = (TargetAddress.Identity == null);
+                       SspiClientSession sspi = new SspiClientSession ();
+
+                       WstRequestSecurityToken rst =
+                               new WstRequestSecurityToken ();
+
+                       // send MessageType1
+                       rst.BinaryExchange = new WstBinaryExchange (Constants.WstBinaryExchangeValueGss);
+                       // When the TargetAddress does not contain the endpoint
+                       // identity, then .net seems to use Kerberos instead of
+                       // raw NTLM.
+                       if (gss)
+                               rst.BinaryExchange.Value = sspi.ProcessSpnegoInitialContextTokenRequest ();
+                       else
+                               rst.BinaryExchange.Value = sspi.ProcessMessageType1 ();
+
+                       Message request = Message.CreateMessage (IssuerBinding.MessageVersion, Constants.WstIssueAction, rst);
+                       request.Headers.MessageId = new UniqueId ();
+                       request.Headers.ReplyTo = new EndpointAddress (Constants.WsaAnonymousUri);
+                       request.Headers.To = TargetAddress.Uri;
+                       MessageBuffer buffer = request.CreateBufferedCopy (0x10000);
+//                     tlsctx.StoreMessage (buffer.CreateMessage ().GetReaderAtBodyContents ());
+
+                       // receive MessageType2
+                       Message response = proxy.Issue (buffer.CreateMessage ());
+                       buffer = response.CreateBufferedCopy (0x10000);
+//                     tlsctx.StoreMessage (buffer.CreateMessage ().GetReaderAtBodyContents ());
+
+                       WSTrustRequestSecurityTokenResponseReader reader =
+                               new WSTrustRequestSecurityTokenResponseReader (Constants.WstSpnegoProofTokenType, buffer.CreateMessage ().GetReaderAtBodyContents (), SecurityTokenSerializer, null);
+                       reader.Read ();
+
+                       byte [] raw = reader.Value.BinaryExchange.Value;
+                       if (gss)
+                               sspi.ProcessSpnegoInitialContextTokenResponse (raw);
+                       else
+                               sspi.ProcessMessageType2 (raw);
+
+                       // send MessageType3
+                       WstRequestSecurityTokenResponse rstr =
+                               new WstRequestSecurityTokenResponse (SecurityTokenSerializer);
+                       rstr.Context = reader.Value.Context;
+                       rstr.BinaryExchange = new WstBinaryExchange (Constants.WstBinaryExchangeValueGss);
+
+                       NetworkCredential cred = owner.Manager.ClientCredentials.Windows.ClientCredential;
+                       string user = string.IsNullOrEmpty (cred.UserName) ? Environment.UserName : cred.UserName;
+                       string pass = cred.Password ?? String.Empty;
+                       if (gss)
+                               rstr.BinaryExchange.Value = sspi.ProcessSpnegoProcessContextToken (user, pass);
+                       else
+                               rstr.BinaryExchange.Value = sspi.ProcessMessageType3 (user, pass);
+
+                       request = Message.CreateMessage (IssuerBinding.MessageVersion, Constants.WstIssueReplyAction, rstr);
+                       request.Headers.MessageId = new UniqueId ();
+                       request.Headers.ReplyTo = new EndpointAddress (Constants.WsaAnonymousUri);
+                       request.Headers.To = TargetAddress.Uri;
+
+                       buffer = request.CreateBufferedCopy (0x10000);
+//                     tlsctx.StoreMessage (buffer.CreateMessage ().GetReaderAtBodyContents ());
+
+                       proxy = new WSTrustSecurityTokenServiceProxy (
+                               IssuerBinding, IssuerAddress);
+                       response = proxy.IssueReply (buffer.CreateMessage ());
+                       // FIXME: use correct limitation
+                       buffer = response.CreateBufferedCopy (0x10000);
+                       // don't store this message for ckhash (it's not part
+                       // of exchange)
+Console.WriteLine (buffer.CreateMessage ());
+
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenAuthenticator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenAuthenticator.cs
new file mode 100644 (file)
index 0000000..ae6cb82
--- /dev/null
@@ -0,0 +1,300 @@
+//
+// SslSecurityTokenAuthenticator.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net.Security;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       // FIXME: implement all
+       class SslSecurityTokenAuthenticator : CommunicationSecurityTokenAuthenticator
+       {
+               ServiceCredentialsSecurityTokenManager manager;
+               SslAuthenticatorCommunicationObject comm;
+               bool mutual;
+
+               public SslSecurityTokenAuthenticator (
+                       ServiceCredentialsSecurityTokenManager manager, 
+                       SecurityTokenRequirement r)
+               {
+                       this.manager = manager;
+                       mutual = (r.TokenType == ServiceModelSecurityTokenTypes.MutualSslnego);
+                       comm = new SslAuthenticatorCommunicationObject (this);
+               }
+
+               public bool IsMutual {
+                       get { return mutual; }
+               }
+
+               public ServiceCredentialsSecurityTokenManager Manager {
+                       get { return manager; }
+               }
+
+               public override AuthenticatorCommunicationObject Communication {
+                       get { return comm; }
+               }
+
+               protected override bool CanValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override ReadOnlyCollection<IAuthorizationPolicy>
+                       ValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
+       class SslAuthenticatorCommunicationObject : AuthenticatorCommunicationObject
+       {
+               SslSecurityTokenAuthenticator owner;
+
+               public SslAuthenticatorCommunicationObject (SslSecurityTokenAuthenticator owner)
+               {
+                       this.owner = owner;
+               }
+
+               WSTrustSecurityTokenServiceProxy proxy;
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { throw new NotImplementedException (); }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public override Message ProcessNegotiation (Message request)
+               {
+                       if (request.Headers.Action == Constants.WstIssueAction)
+                               return ProcessClientHello (request);
+                       else
+                               return ProcessClientKeyExchange (request);
+               }
+
+               class TlsServerSessionInfo
+               {
+                       public TlsServerSessionInfo (string context, TlsServerSession tls)
+                       {
+                               ContextId = context;
+                               Tls = tls;
+                       }
+
+                       public string ContextId;
+                       public TlsServerSession Tls;
+                       public MemoryStream Messages = new MemoryStream ();
+               }
+
+               Dictionary<string,TlsServerSessionInfo> sessions =
+                       new Dictionary<string,TlsServerSessionInfo> ();
+
+               void AppendNegotiationMessageXml (XmlReader reader, TlsServerSessionInfo tlsInfo)
+               {
+                       XmlDsigExcC14NTransform t = new XmlDsigExcC14NTransform ();
+                       XmlDocument doc = new XmlDocument ();
+                       doc.PreserveWhitespace = true;
+                       reader.MoveToContent ();
+                       doc.AppendChild (doc.ReadNode (reader));
+                       t.LoadInput (doc);
+                       MemoryStream stream = (MemoryStream) t.GetOutput ();
+                       byte [] bytes = stream.ToArray ();
+                       tlsInfo.Messages.Write (bytes, 0, bytes.Length);
+               }
+
+               Message ProcessClientHello (Message request)
+               {
+                       // FIXME: use correct buffer size
+                       MessageBuffer buffer = request.CreateBufferedCopy (0x10000);
+                       WSTrustRequestSecurityTokenReader reader =
+                               new WSTrustRequestSecurityTokenReader (buffer.CreateMessage ().GetReaderAtBodyContents (), SecurityTokenSerializer);
+                       reader.Read ();
+
+                       if (sessions.ContainsKey (reader.Value.Context))
+                               throw new SecurityNegotiationException (String.Format ("The context '{0}' already exists in this SSL negotiation manager", reader.Value.Context));
+
+                       TlsServerSession tls = new TlsServerSession (owner.Manager.ServiceCredentials.ServiceCertificate.Certificate, owner.IsMutual);
+                       TlsServerSessionInfo tlsInfo = new TlsServerSessionInfo (
+                               reader.Value.Context, tls);
+
+                       AppendNegotiationMessageXml (buffer.CreateMessage ().GetReaderAtBodyContents (), tlsInfo);
+
+                       tls.ProcessClientHello (reader.Value.BinaryExchange.Value);
+                       WstRequestSecurityTokenResponse rstr =
+                               new WstRequestSecurityTokenResponse (SecurityTokenSerializer);
+                       rstr.Context = reader.Value.Context;
+                       rstr.BinaryExchange = new WstBinaryExchange (Constants.WstBinaryExchangeValueTls);
+                       rstr.BinaryExchange.Value = tls.ProcessServerHello ();
+
+                       Message reply = Message.CreateMessage (request.Version, Constants.WstIssueReplyAction, rstr);
+                       reply.Headers.RelatesTo = request.Headers.MessageId;
+
+                       // FIXME: use correct buffer size
+                       buffer = reply.CreateBufferedCopy (0x10000);
+                       AppendNegotiationMessageXml (buffer.CreateMessage ().GetReaderAtBodyContents (), tlsInfo);
+
+                       sessions [reader.Value.Context] = tlsInfo;
+
+                       return buffer.CreateMessage ();
+               }
+
+               Message ProcessClientKeyExchange (Message request)
+               {
+                       // FIXME: use correct buffer size
+                       MessageBuffer buffer = request.CreateBufferedCopy (0x10000);
+                       WSTrustRequestSecurityTokenResponseReader reader =
+                               new WSTrustRequestSecurityTokenResponseReader (Constants.WstTlsnegoProofTokenType, buffer.CreateMessage ().GetReaderAtBodyContents (), SecurityTokenSerializer, null);
+                       reader.Read ();
+
+                       TlsServerSessionInfo tlsInfo;
+                       if (!sessions.TryGetValue (reader.Value.Context, out tlsInfo))
+                               throw new SecurityNegotiationException (String.Format ("The context '{0}' does not exist in this SSL negotiation manager", reader.Value.Context));
+                       TlsServerSession tls = tlsInfo.Tls;
+
+                       AppendNegotiationMessageXml (buffer.CreateMessage ().GetReaderAtBodyContents (), tlsInfo);
+//Console.WriteLine (System.Text.Encoding.UTF8.GetString (tlsInfo.Messages.ToArray ()));
+
+                       tls.ProcessClientKeyExchange (reader.Value.BinaryExchange.Value);
+
+                       byte [] serverFinished = tls.ProcessServerFinished ();
+
+                       // The shared key is computed as recommended in WS-Trust:
+                       // P_SHA1(encrypted_key,SHA1(exc14n(RST..RSTRs))+"CK-HASH")
+                       byte [] hash = SHA1.Create ().ComputeHash (tlsInfo.Messages.ToArray ());
+                       byte [] key = tls.CreateHash (tls.MasterSecret, hash, "CK-HASH");
+                       byte [] keyTlsApplied = tls.ProcessApplicationData (key);
+foreach (byte b in hash) Console.Write ("{0:X02} ", b); Console.WriteLine ();
+foreach (byte b in key) Console.Write ("{0:X02} ", b); Console.WriteLine ();
+
+                       WstRequestSecurityTokenResponseCollection col =
+                               new WstRequestSecurityTokenResponseCollection ();
+                       WstRequestSecurityTokenResponse rstr =
+                               new WstRequestSecurityTokenResponse (SecurityTokenSerializer);
+                       rstr.Context = reader.Value.Context;
+                       rstr.TokenType = Constants.WsscContextToken;
+                       DateTime from = DateTime.Now;
+                       // FIXME: not sure if arbitrary key is used here.
+                       SecurityContextSecurityToken sct = SecurityContextSecurityToken.CreateCookieSecurityContextToken (
+                               // Create a new context.
+                               // (do not use sslnego context here.)
+                               new UniqueId (),
+                               "uuid-" + Guid.NewGuid (),
+                               key,
+                               from,
+                               // FIXME: use LocalServiceSecuritySettings.NegotiationTimeout
+                               from.AddHours (8),
+                               null,
+                               owner.Manager.ServiceCredentials.SecureConversationAuthentication.SecurityStateEncoder);
+                       rstr.RequestedSecurityToken = sct;
+                       // without this ProcessApplicationData(), .NET seems
+                       // to fail recovering the key.
+                       rstr.RequestedProofToken = keyTlsApplied;
+                       rstr.RequestedAttachedReference = new LocalIdKeyIdentifierClause (sct.Id);
+                       rstr.RequestedUnattachedReference = new SecurityContextKeyIdentifierClause (sct.ContextId, null);
+                       WstLifetime lt = new WstLifetime ();
+                       lt.Created = from;
+                       lt.Expires = from.Add (SecurityBindingElement.LocalServiceSettings.IssuedCookieLifetime);
+                       rstr.Lifetime = lt;
+                       rstr.BinaryExchange = new WstBinaryExchange (Constants.WstBinaryExchangeValueTls);
+                       rstr.BinaryExchange.Value = serverFinished;
+
+                       col.Responses.Add (rstr);
+
+                       // Authenticator is mandatory for MS sslnego.
+                       rstr = new WstRequestSecurityTokenResponse (SecurityTokenSerializer);
+                       rstr.Context = reader.Value.Context;
+                       rstr.Authenticator = tls.CreateHash (key, hash, "AUTH-HASH");
+                       col.Responses.Add (rstr);
+
+                       sessions.Remove (reader.Value.Context);
+
+                       // FIXME: get correct tokenRequestor address (probably identity authorized?)
+                       if (owner.IssuedSecurityTokenHandler != null)
+                               owner.IssuedSecurityTokenHandler (sct, request.Headers.ReplyTo);
+
+                       return Message.CreateMessage (request.Version, Constants.WstIssueReplyAction, col);
+               }
+
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       if (State == CommunicationState.Opened)
+                               throw new InvalidOperationException ("Already opened.");
+
+                       EnsureProperties ();
+
+                       proxy = new WSTrustSecurityTokenServiceProxy (
+                               IssuerBinding, IssuerAddress);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       if (proxy != null)
+                               proxy.Close ();
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenParameters.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenParameters.cs
new file mode 100644 (file)
index 0000000..0e70f06
--- /dev/null
@@ -0,0 +1,134 @@
+//
+// SslSecurityTokenParameters.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Security;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class SslSecurityTokenParameters : SecurityTokenParameters
+       {
+               public SslSecurityTokenParameters ()
+                       : this (false, false)
+               {
+               }
+
+               public SslSecurityTokenParameters (bool requireClientCertificate)
+                       : this (requireClientCertificate, false)
+               {
+               }
+
+               public SslSecurityTokenParameters (bool requireClientCertificate,
+                       bool requireCancellation)
+               {
+                       this.cert = requireClientCertificate;
+                       this.cancel = requireCancellation;
+               }
+
+               protected SslSecurityTokenParameters (SslSecurityTokenParameters source)
+                       : base (source)
+               {
+                       cert = source.cert;
+                       cancel = source.cancel;
+               }
+
+               bool cert, cancel;
+
+               public bool RequireClientCertificate {
+                       get { return cert; }
+                       set { cert = value; }
+               }
+
+               public bool RequireCancellation {
+                       get { return cancel; }
+                       set { cancel = value; }
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+
+               protected override bool HasAsymmetricKey {
+                       get { return false; }
+               }
+
+               protected override bool SupportsClientAuthentication {
+                       get { return false; } 
+               }
+
+               protected override bool SupportsClientWindowsIdentity {
+                       get { return false; } 
+               }
+
+               protected override bool SupportsServerAuthentication {
+                       get { return true; } 
+               }
+
+               protected override SecurityTokenParameters CloneCore ()
+               {
+                       return new SslSecurityTokenParameters (this);
+               }
+
+               protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       if (token == null)
+                               throw new ArgumentNullException ("token");
+
+                       SecurityContextSecurityToken sct = token as SecurityContextSecurityToken;
+                       if (sct == null)
+                               throw new ArgumentException (String.Format ("Not supported SecurityToken: '{0}'", token));
+                       return referenceStyle == SecurityTokenReferenceStyle.Internal ?
+                               (SecurityKeyIdentifierClause)
+                               new LocalIdKeyIdentifierClause (sct.Id) :
+                               new SecurityContextKeyIdentifierClause (sct.ContextId, sct.KeyGeneration);
+                       /*
+                       GenericXmlSecurityToken x = token as GenericXmlSecurityToken;
+                       if (x == null)
+                               throw new ArgumentException (String.Format ("Not supported SecurityToken: '{0}'", token));
+                       return referenceStyle == SecurityTokenReferenceStyle.Internal ? x.InternalTokenReference : x.ExternalTokenReference;
+                       */
+               }
+
+               protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+               {
+                       requirement.TokenType =
+                               RequireClientCertificate ?
+                               ServiceModelSecurityTokenTypes.MutualSslnego :
+                               ServiceModelSecurityTokenTypes.AnonymousSslnego;
+                       requirement.RequireCryptographicToken = true;
+                       requirement.Properties [ReqType.SupportSecurityContextCancellationProperty] = RequireCancellation;
+                       requirement.Properties [ReqType.IssuedSecurityTokenParametersProperty] = this.Clone ();
+                       requirement.KeyType = SecurityKeyType.SymmetricKey;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslSecurityTokenProvider.cs
new file mode 100644 (file)
index 0000000..6664b46
--- /dev/null
@@ -0,0 +1,284 @@
+//
+// SslSecurityTokenProvider.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       class SslSecurityTokenProvider : CommunicationSecurityTokenProvider
+       {
+               SslCommunicationObject comm;
+               ClientCredentialsSecurityTokenManager manager;
+
+               public SslSecurityTokenProvider (ClientCredentialsSecurityTokenManager manager, bool mutual)
+               {
+                       this.manager = manager;
+                       comm = new SslCommunicationObject (this, mutual);
+               }
+
+               public override ProviderCommunicationObject Communication {
+                       get { return comm; }
+               }
+
+               public ClientCredentialsSecurityTokenManager Manager {
+                       get { return manager; }
+               }
+
+               public override SecurityToken GetOnlineToken (TimeSpan timeout)
+               {
+                       return comm.GetToken (timeout);
+               }
+       }
+
+       class SslCommunicationObject : ProviderCommunicationObject
+       {
+               SslSecurityTokenProvider owner;
+               WSTrustSecurityTokenServiceProxy proxy;
+               X509Certificate2 client_certificate;
+               
+
+               public SslCommunicationObject (SslSecurityTokenProvider owner, bool mutual)
+               {
+                       if (mutual) {
+                               client_certificate = owner.Manager.ClientCredentials.ClientCertificate.Certificate;
+                               if (client_certificate == null)
+                                       throw new InvalidOperationException ("ClientCertificate is required for mutual SSL negotiation.");
+                       }
+                       this.owner = owner;
+               }
+
+               class TlsnegoClientSessionContext
+               {
+                       XmlDocument doc = new XmlDocument ();
+                       XmlDsigExcC14NTransform t = new XmlDsigExcC14NTransform ();
+                       MemoryStream stream = new MemoryStream ();
+
+                       public void StoreMessage (XmlReader reader)
+                       {
+                               doc.RemoveAll ();
+                               doc.AppendChild (doc.ReadNode (reader));
+                               t.LoadInput (doc);
+                               MemoryStream s = (MemoryStream) t.GetOutput ();
+                               byte [] bytes = s.ToArray ();
+                               stream.Write (bytes, 0, bytes.Length);
+                       }
+
+                       public byte [] GetC14NResults ()
+                       {
+                               return stream.ToArray ();
+                       }
+               }
+
+               public SecurityToken GetToken (TimeSpan timeout)
+               {
+                       TlsnegoClientSessionContext tlsctx =
+                               new TlsnegoClientSessionContext ();
+                       TlsClientSession tls = new TlsClientSession (IssuerAddress.Uri.ToString (), client_certificate);
+                       WstRequestSecurityToken rst =
+                               new WstRequestSecurityToken ();
+                       string contextId = rst.Context;
+
+                       // send ClientHello
+                       rst.BinaryExchange = new WstBinaryExchange (Constants.WstBinaryExchangeValueTls);
+                       rst.BinaryExchange.Value = tls.ProcessClientHello ();
+
+                       Message request = Message.CreateMessage (IssuerBinding.MessageVersion, Constants.WstIssueAction, rst);
+                       request.Headers.MessageId = new UniqueId ();
+                       request.Headers.ReplyTo = new EndpointAddress (Constants.WsaAnonymousUri);
+                       request.Headers.To = TargetAddress.Uri;
+                       MessageBuffer buffer = request.CreateBufferedCopy (0x10000);
+                       tlsctx.StoreMessage (buffer.CreateMessage ().GetReaderAtBodyContents ());
+                       Message response = proxy.Issue (buffer.CreateMessage ());
+
+                       // FIXME: use correct limitation
+                       buffer = response.CreateBufferedCopy (0x10000);
+                       tlsctx.StoreMessage (buffer.CreateMessage ().GetReaderAtBodyContents ());
+
+                       // receive ServerHello
+                       WSTrustRequestSecurityTokenResponseReader reader =
+                               new WSTrustRequestSecurityTokenResponseReader (Constants.WstTlsnegoProofTokenType, buffer.CreateMessage ().GetReaderAtBodyContents (), SecurityTokenSerializer, null);
+                       reader.Read ();
+                       if (reader.Value.RequestedSecurityToken != null)
+                               return reader.Value.RequestedSecurityToken;
+
+                       tls.ProcessServerHello (reader.Value.BinaryExchange.Value);
+
+                       // send ClientKeyExchange
+                       WstRequestSecurityTokenResponse rstr =
+                               new WstRequestSecurityTokenResponse (SecurityTokenSerializer);
+                       rstr.Context = reader.Value.Context;
+                       rstr.BinaryExchange = new WstBinaryExchange (Constants.WstBinaryExchangeValueTls);
+                       rstr.BinaryExchange.Value = tls.ProcessClientKeyExchange ();
+
+                       request = Message.CreateMessage (IssuerBinding.MessageVersion, Constants.WstIssueReplyAction, rstr);
+                       request.Headers.ReplyTo = new EndpointAddress (Constants.WsaAnonymousUri);
+                       request.Headers.To = TargetAddress.Uri;
+
+                       buffer = request.CreateBufferedCopy (0x10000);
+                       tlsctx.StoreMessage (buffer.CreateMessage ().GetReaderAtBodyContents ());
+//Console.WriteLine (System.Text.Encoding.UTF8.GetString (tlsctx.GetC14NResults ()));
+
+                       // FIXME: regeneration of this instance is somehow required, but should not be.
+                       proxy = new WSTrustSecurityTokenServiceProxy (
+                               IssuerBinding, IssuerAddress);
+                       response = proxy.IssueReply (buffer.CreateMessage ());
+                       // FIXME: use correct limitation
+                       buffer = response.CreateBufferedCopy (0x10000);
+
+                       WstRequestSecurityTokenResponseCollection coll =
+                               new WstRequestSecurityTokenResponseCollection ();
+                       coll.Read (Constants.WstTlsnegoProofTokenType, buffer.CreateMessage ().GetReaderAtBodyContents (), SecurityTokenSerializer, null);
+                       if (coll.Responses.Count != 2)
+                               throw new SecurityNegotiationException (String.Format ("Expected response is RequestSecurityTokenResponseCollection which contains two RequestSecurityTokenResponse items, but it actually contains {0} items", coll.Responses.Count));
+
+                       WstRequestSecurityTokenResponse r = coll.Responses [0];
+                       tls.ProcessServerFinished (r.BinaryExchange.Value);
+                       SecurityContextSecurityToken sctSrc =
+                               r.RequestedSecurityToken;
+
+#if false // FIXME: should this final RSTR included in RSTRC considered too?
+                       XmlDocument doc = new XmlDocument ();
+                       doc.PreserveWhitespace = true;
+                       using (XmlDictionaryWriter dw = XmlDictionaryWriter.CreateDictionaryWriter (doc.CreateNavigator ().AppendChild ())) {
+                               if (r == null) throw new Exception ("r");
+                               if (dw == null) throw new Exception ("dw");
+                               r.WriteBodyContents (dw);
+                       }
+                       tlsctx.StoreMessage (XmlDictionaryReader.CreateDictionaryReader (new XmlNodeReader (doc)));
+#endif
+
+                       // the RequestedProofToken is represented as 32 bytes
+                       // of TLS ApplicationData.
+                       // - According to WSE2 doc, it is *the* key, but not
+                       //   sure it also applies to WCF.
+                       // - WSS4J also seems to store the encryped shared key.
+                       // - (Important) It seems that without tls decryption,
+                       //   .NET fails to recover the key.
+                       byte [] proof = tls.ProcessApplicationData (
+                               (byte []) r.RequestedProofToken);
+                       byte [] key = proof;
+
+                       // Authenticate token.
+
+                       byte [] actual = coll.Responses [1].Authenticator;
+                       if (actual == null)
+                               throw new SecurityNegotiationException ("Token authenticator is expected in the RequestSecurityTokenResponse but not found.");
+
+                       if (coll.Responses [0].Context != contextId)
+                               throw new SecurityNegotiationException ("The context Id does not match with that of the corresponding token authenticator.");
+
+                       // H = sha1(exc14n(RST..RSTRs))
+                       byte [] hash = SHA1.Create ().ComputeHash (tlsctx.GetC14NResults ());
+                       byte [] referent = tls.CreateHash (key, hash, "AUTH-HASH");
+Console.WriteLine (System.Text.Encoding.ASCII.GetString (tlsctx.GetC14NResults ()));
+Console.Write ("Hash: ");
+foreach (byte b in hash) Console.Write ("{0:X02} ", b); Console.WriteLine ();
+Console.Write ("Referent: ");
+foreach (byte b in referent) Console.Write ("{0:X02} ", b); Console.WriteLine ();
+Console.Write ("Actual: ");
+foreach (byte b in actual) Console.Write ("{0:X02} ", b); Console.WriteLine ();
+Console.Write ("Proof: ");
+foreach (byte b in proof) Console.Write ("{0:X02} ", b); Console.WriteLine ();
+                       bool mismatch = referent.Length != actual.Length;
+                       if (!mismatch)
+                               for (int i = 0; i < referent.Length; i++)
+                                       if (referent [i] != actual [i])
+                                               mismatch = true;
+                       // FIXME: enable verification
+//                     if (mismatch)
+//                             throw new SecurityNegotiationException ("The CombinedHash does not match the expected value.");
+
+                       return sctSrc;
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { throw new NotImplementedException (); }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { throw new NotImplementedException (); }
+               }
+
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       if (State == CommunicationState.Opened)
+                               throw new InvalidOperationException ("Already opened.");
+
+                       EnsureProperties ();
+
+                       proxy = new WSTrustSecurityTokenServiceProxy (
+                               IssuerBinding, IssuerAddress);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       if (proxy != null)
+                               proxy.Close ();
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslnegoCookieResolver.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SslnegoCookieResolver.cs
new file mode 100644 (file)
index 0000000..9f3ede9
--- /dev/null
@@ -0,0 +1,214 @@
+//
+// SslnegoCookieResolver.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Security.Cryptography.X509Certificates;
+using System.Xml;
+
+/*
+
+LAMESPEC: The cookie value is encoded by
+ServiceCredential.SecureConversationAuthentication.SecurityStateEncoder.
+
+When a custom SecurityStateEncoder is used,
+- at service side it is actually invoked,
+- at client side it is impossible to specify such custom state decoder, so
+  it is treated as if the key is passed as is, and thus if it could raise
+  verification error (it is LAMESPEC, since if the custom state encoder is
+  pass-through it just works fine).
+
+Raw Cookie data format (via pass-through SecurityStateEncoder)
+
+<42 00 42 02 83 42 06 99> L[uuid-_________] bbbb-bb 
+<42 04 AD> (16bytes)  <42 08 9E 1E> (43 bytes)
+<C9 08 42 10 8F> (6 bytes)
+<C9 08 42 14 8F> (6 bytes)
+<C9 08 42 16 8F> (6 bytes)
+<C9 08 01>
+
+The uuid seems kept identical while one service is running (i.e. unique per ServiceHost).
+
+Actually the raw octets corresponds to 
+XmlBinaryWriter output format, so it is likely.
+So, it will be parsed as below:
+42 00 
+42 02 
+83 
+42 06 99 2B 75 75 69 64 2D 31 65 38 33 62 63 37 39 2D 35 30 33 37 2D 34 61 32 30 2D 38 32 66 37 2D 64 32 39 37 31 34 61 30 32 62 37 66 2D 31 // UniqueId wsu:Id
+42 04 AD 45 34 07 4E 38 D2 18 4D 8B 22 FD 6C E6 CE B2 17 // UniqueIdFromGuid ContextId
+42 08 9E 1E CA AC F2 71 6E 61 99 DA FB 71 B2 A8 DC 51 36 5B CD F3 F9 60 D2 B6 67 BF 5D B0 CE ED 37 35 9F 02 DC 7D // Base64 Key
+42 0E 8F F4 4C 9C 48 61 33 C9 08 // Int64 KeyCreation
+42 10 8F F4 5C 48 1A B5 33 C9 08 // Int64 KeyExpiration
+42 14 8F F4 4C 9C 48 61 33 C9 08 // Int64 CookieCreatation
+42 16 8F F4 5C 48 1A B5 33 C9 08 // Int64 CookieExpiration
+01
+
+
+The actual XML looks like:
+<n1><n2>1</n2><n4>uuid-950f764e-f6dc-4f5d-8df36699e28618cf-1</n4><n3>urn:uuid:a13aa8b0-f0b5-4a78-967e-fbd05459d882</n3><n5>W0I2qFT/H5ElE14l3wy8rqZHVvjbesvtshaLOdQdXyk=</n5><n8>633092852947500000</n8><n9>633093212947500000</n9><n11>633092852947500000</n11><n12>633093212947500000</n12></n1>
+
+where n[x] are presumed names. They would be meaningful in MS implementation,
+but as a binary XML array with preconfigured IXmlDictionary (sigh), it doesn't
+matter.
+
+n2 matches the context Identifier for SecurityContextToken.
+n3 matches the u:Id for SecurityContextToken.
+
+*/
+
+
+namespace System.ServiceModel.Security.Tokens
+{
+       internal class SslnegoCookieResolver
+       {
+               public static SecurityContextSecurityToken ResolveCookie (byte [] bytes, byte [] cookie)
+               {
+                       string id = null;
+                       UniqueId context = null;
+                       DateTime validFrom = DateTime.MinValue,
+                                validTo = DateTime.MaxValue,
+                                keyEffective = DateTime.MinValue,
+                                keyExpired = DateTime.MaxValue;
+                       byte [] key = null;
+                       X509Certificate2 cert = null;
+                       X500DistinguishedName issuer = null;
+
+                       XmlDictionary dic = new XmlDictionary ();
+                       for (int i = 0; i < 30; i++)
+                               dic.Add ("n" + i);
+                       // FIXME: create proper quotas
+                       XmlDictionaryReaderQuotas quotas =
+                               new XmlDictionaryReaderQuotas ();
+                       XmlDictionaryReader cr = XmlDictionaryReader.CreateBinaryReader (bytes, 0, bytes.Length, dic, quotas);
+
+                       cr.MoveToContent (); // -> n1
+                       cr.ReadStartElement ("n0", String.Empty);
+                       do {
+                               cr.MoveToContent ();
+                               if (cr.NodeType == XmlNodeType.EndElement)
+                                       break;
+                               if (cr.NodeType != XmlNodeType.Element)
+                                       throw new Exception ("Unxpected non-element content:" + cr.NodeType);
+
+                               switch (cr.Name) {
+                               case "n1":
+                                       // FIXME: some integer here
+                                       int n1 = cr.ReadElementContentAsInt ();
+                                       if (n1 != 1)
+                                               throw new Exception ("INTERNAL ERROR: there was unexpected n2 content: " + n1);
+                                       break;
+                               case "n2":
+                                       context = cr.ReadElementContentAsUniqueId ();
+                                       break;
+                               case "n3":
+                                       id = cr.ReadElementContentAsString ();
+                                       break;
+                               case "n4":
+                                       key = cr.ReadElementContentAsBase64 ();
+                                       break;
+                               case "n7":
+                                       validFrom = new DateTime (cr.ReadElementContentAsLong ());
+                                       break;
+                               case "n8":
+                                       validTo = new DateTime (cr.ReadElementContentAsLong ());
+                                       break;
+                               case "n10":
+                                       keyEffective = new DateTime (cr.ReadElementContentAsLong ());
+                                       break;
+                               case "n11":
+                                       keyExpired = new DateTime (cr.ReadElementContentAsLong ());
+                                       break;
+                               case "n13":
+                                       // <n18>X509Certificate</n18>
+                                       cr.Read ();
+                                       cr.MoveToContent ();
+                                       cert = new X509Certificate2 (cr.ReadElementContentAsBase64 ());
+                                       cr.ReadEndElement ();
+                                       break;
+                               case "n15":
+                                       // <n16><n24 n25="IssuerName" /></n16>
+                                       cr.Read ();
+                                       cr.ReadStartElement ("n16", String.Empty);
+                                       issuer = new X500DistinguishedName (cr.GetAttribute ("n25"));
+                                       bool empty = cr.IsEmptyElement;
+                                       cr.ReadStartElement ("n24", String.Empty);
+                                       if (!empty)
+                                               cr.ReadEndElement (); // n24
+                                       cr.ReadEndElement (); // n16
+                                       cr.ReadEndElement (); // n15
+                                       break;
+                               default:
+                                       throw new Exception ("INTERNAL ERROR: there was an unhandled element: " + cr.Name);
+                               }
+                       } while (true);
+
+                       SecurityContextSecurityToken sct = new SecurityContextSecurityToken (
+                               context, id, key, validFrom, validTo,
+                               null, keyEffective, keyExpired, null);
+                       sct.Cookie = cookie;
+                       return sct;
+               }
+
+               public static byte [] CreateData (UniqueId contextId, UniqueId session, byte [] key, DateTime tokenSince, DateTime tokenUntil, DateTime keySince, DateTime keyUntil)
+               {
+                       XmlDictionary dic = new XmlDictionary ();
+                       for (int i = 0; i < 12; i++)
+                               dic.Add ("n" + i);
+                       MemoryStream ms = new MemoryStream ();
+                       XmlDictionaryWriter w = XmlDictionaryWriter.CreateBinaryWriter (ms, dic);
+                       XmlDictionaryString e = XmlDictionaryString.Empty;
+                       w.WriteStartElement (dic.Add ("n0"), e);
+                       w.WriteStartElement (dic.Add ("n1"), e);
+                       w.WriteValue (1);
+                       w.WriteEndElement ();
+                       w.WriteStartElement (dic.Add ("n3"), e);
+                       w.WriteValue (contextId);
+                       w.WriteEndElement ();
+                       w.WriteStartElement (dic.Add ("n2"), e);
+                       w.WriteValue (contextId);
+                       w.WriteEndElement ();
+                       w.WriteStartElement (dic.Add ("n4"), e);
+                       w.WriteBase64 (key, 0, key.Length);
+                       w.WriteEndElement ();
+                       w.WriteStartElement (dic.Add ("n7"), e);
+                       w.WriteValue (tokenSince.Ticks);
+                       w.WriteEndElement ();
+                       w.WriteStartElement (dic.Add ("n8"), e);
+                       w.WriteValue (tokenUntil.Ticks);
+                       w.WriteEndElement ();
+                       w.WriteStartElement (dic.Add ("n10"), e);
+                       w.WriteValue (keySince.Ticks);
+                       w.WriteEndElement ();
+                       w.WriteStartElement (dic.Add ("n11"), e);
+                       w.WriteValue (keyUntil.Ticks);
+                       w.WriteEndElement ();
+                       w.Close ();
+                       return ms.ToArray ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiClientSecurityTokenAuthenticator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiClientSecurityTokenAuthenticator.cs
new file mode 100755 (executable)
index 0000000..9848a7d
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// SspiClientSecurityTokenAuthenticator.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net.Security;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       // FIXME: implement all
+       class SspiClientSecurityTokenAuthenticator : SecurityTokenAuthenticator
+       {
+               ClientCredentialsSecurityTokenManager manager;
+
+               public SspiClientSecurityTokenAuthenticator (
+                       ClientCredentialsSecurityTokenManager manager, 
+                       SecurityTokenRequirement r)
+               {
+                       this.manager = manager;
+               }
+
+               public ClientCredentialsSecurityTokenManager Manager {
+                       get { return manager; }
+               }
+
+               protected override bool CanValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override ReadOnlyCollection<IAuthorizationPolicy>
+                       ValidateTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiSecurityToken.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiSecurityToken.cs
new file mode 100644 (file)
index 0000000..be273ce
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// SspiSecurityToken.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Xml;
+using System.Security.Principal;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class SspiSecurityToken : SecurityToken
+       {
+               string id;
+               DateTime valid_from = DateTime.Now.ToUniversalTime ();
+               DateTime valid_to;
+               ReadOnlyCollection<SecurityKey> keys;
+               bool extract_groups, allow_unauth;
+
+               [MonoTODO]
+               public SspiSecurityToken (NetworkCredential cred,
+                       bool extractGroupsForWindowsAccounts,
+                       bool allowUnauthenticatedCallers)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public SspiSecurityToken (
+                       TokenImpersonationLevel impersonationLevel,
+                       bool allowNtlm, NetworkCredential cred)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override DateTime ValidFrom {
+                       get { return valid_from; }
+               }
+
+               [MonoTODO]
+               public override DateTime ValidTo {
+                       get { return valid_to; }
+               }
+
+               [MonoTODO]
+               public override string Id {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public override ReadOnlyCollection<SecurityKey> SecurityKeys {
+                       get { throw new NotImplementedException (); }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiSecurityTokenParameters.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiSecurityTokenParameters.cs
new file mode 100644 (file)
index 0000000..c5aab7c
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// SspiSecurityTokenParameters.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Security;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class SspiSecurityTokenParameters : SecurityTokenParameters
+       {
+               bool cancel;
+
+               public SspiSecurityTokenParameters ()
+                       : this (false)
+               {
+               }
+
+               public SspiSecurityTokenParameters (bool requireCancellation)
+               {
+                       this.cancel = requireCancellation;
+               }
+
+               protected SspiSecurityTokenParameters (SspiSecurityTokenParameters source)
+                       : base (source)
+               {
+                       this.cancel = source.cancel;
+               }
+
+               public bool RequireCancellation {
+                       get { return cancel; }
+                       set { cancel = value; }
+               }
+
+               protected override bool HasAsymmetricKey {
+                       get { return false; }
+               }
+
+               protected override bool SupportsClientAuthentication {
+                       get { return true; }
+               }
+
+               protected override bool SupportsClientWindowsIdentity {
+                       get { return true; }
+               }
+
+               protected override bool SupportsServerAuthentication {
+                       get { return true; }
+               }
+
+               protected override SecurityTokenParameters CloneCore ()
+               {
+                       return new SspiSecurityTokenParameters (this);
+               }
+
+               [MonoTODO]
+               protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+               {
+                       if (requirement == null)
+                               throw new ArgumentNullException ();
+                       requirement.TokenType = ServiceModelSecurityTokenTypes.Spnego;
+                       requirement.RequireCryptographicToken = true;
+                       requirement.Properties [ReqType.SupportSecurityContextCancellationProperty] = RequireCancellation;
+                       requirement.Properties [ReqType.IssuedSecurityTokenParametersProperty] = this.Clone ();
+                       requirement.KeyType = SecurityKeyType.SymmetricKey;
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiSession.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SspiSession.cs
new file mode 100755 (executable)
index 0000000..3f31f67
--- /dev/null
@@ -0,0 +1,273 @@
+using System;
+using System.IO;
+using System.Net;
+using System.Net.NetworkInformation;
+using System.Security.Cryptography;
+using System.Text;
+using Mono.Security;
+using Mono.Security.Protocol.Ntlm;
+
+namespace System.ServiceModel.Security
+{
+       internal abstract class SspiSession
+       {
+               internal static readonly byte [] NtlmSSP = new byte [] {
+                       0x4E, 0x54, 0x4C, 0x4D, 0x53, 0x53, 0x50, 0x00};
+
+               public long Challenge, Context, ClientOSVersion, ServerOSVersion;
+               public string ServerName, DomainName, DnsHostName, DnsDomainName;
+
+               public bool Verify (byte [] expected, byte [] actual, int offset, int length)
+               {
+                       if (expected.Length != length)
+                               return false;
+                       for (int i = 0; i < length; i++)
+                               if (expected [i] != actual [i + offset])
+                                       return false;
+                       return true;
+               }
+
+               public SspiSecurityBufferStruct ReadSecurityBuffer (BinaryReader reader)
+               {
+                       return new SspiSecurityBufferStruct (
+                               reader.ReadInt16 (),
+                               reader.ReadInt16 (),
+                               reader.ReadInt32 ());
+               }
+       }
+
+       internal struct SspiSecurityBufferStruct
+       {
+               public SspiSecurityBufferStruct (short length, short allocatedSpace, int offset)
+               {
+                       Length = length;
+                       AllocatedSpace = allocatedSpace;
+                       Offset = offset;
+               }
+
+               public readonly short Length;
+               public readonly short AllocatedSpace;
+               public readonly int Offset;
+       }
+
+       internal class SspiClientSession : SspiSession
+       {
+               Type2Message type2;
+               Type3Message type3;
+
+               // Class(60) {
+               //   OID(spnego),
+               //   Class(A0) {
+               //     Class(30) {
+               //       Class(A0) {
+               //         Class(30) { OID,OID,OID} },
+               //       Class(A2) { OctetStream } } } }
+               public byte [] ProcessSpnegoInitialContextTokenRequest ()
+               {
+                       Type1Message type1 = new Type1Message (NtlmVersion.Version3);
+                       type1.Flags = unchecked ((NtlmFlags) 0xE21882B7);
+                       type1.Domain = "WORKGROUP"; // FIXME: remove it
+
+                       ASN1 asn = new ASN1 (0x60);
+                       ASN1 asn2 = new ASN1 (0xA0);
+                       ASN1 asn21 = new ASN1 (0x30);
+                       ASN1 asn211 = new ASN1 (0xA0);
+                       ASN1 asn2111 = new ASN1 (0x30);
+                       asn211.Add (asn2111);
+                       asn2111.Add (ASN1Convert.FromOid (Constants.OidNtlmSsp));
+                       asn2111.Add (ASN1Convert.FromOid (Constants.OidKerberos5));
+                       asn2111.Add (ASN1Convert.FromOid (Constants.OidMIT));
+                       ASN1 asn212 = new ASN1 (0xA2);
+                       ASN1 asn2121 = new ASN1 (0x4);
+                       asn2121.Value = type1.GetBytes ();
+                       asn212.Add (asn2121);
+                       asn21.Add (asn211);
+                       asn21.Add (asn212);
+                       asn2.Add (asn21);
+                       asn.Add (ASN1Convert.FromOid (Constants.OidSpnego));
+                       asn.Add (asn2);
+                       return asn.GetBytes ();
+               }
+
+               // Example buffer:
+               // A18181 307F A003
+               //   0A0101
+               //   A10C 060A2B06010401823702020A
+               //   A26A 0468 NTLM
+               //   NTLM = 4E544C4D53535000 0200000004000400 3800000035829AE2
+               //    0D1A7FF0F171F339 0000000000000000 2C002C003C000000
+               //    0501280A0000000F 5000430002000400 5000430001000400
+               //    5000430004000400 5000430003000400 5000430006000400
+               //    0100000000000000
+               public void ProcessSpnegoInitialContextTokenResponse (byte [] raw)
+               {
+                       ASN1 asn1 = new ASN1 (raw);
+                       // FIXME: check OIDs and structure
+                       ProcessMessageType2 (asn1 [0] [2] [0].Value);
+               }
+
+               // Class { Class { Class { OctetStream } } }
+               public byte [] ProcessSpnegoProcessContextToken (string user, string pass)
+               {
+                       ASN1 asn = new ASN1 (0xA1);
+                       ASN1 asn2 = new ASN1 (0x30);
+                       ASN1 asn3 = new ASN1 (0xA2);
+                       asn3.Add (new ASN1 (0x04, ProcessMessageType3 (user, pass)));
+                       asn2.Add (asn3);
+                       asn.Add (asn2);
+                       return asn.GetBytes ();
+               }
+
+               public byte [] ProcessMessageType1 ()
+               {
+                       Type1Message type1 = new Type1Message (NtlmVersion.Version3);
+                       type1.Flags = unchecked ((NtlmFlags) 0xE21882B7);
+                       return type1.GetBytes ();
+               }
+
+               string TargetName;
+
+               public void ProcessMessageType2 (byte [] raw)
+               {
+                       type2 = new Type2Message (raw);
+               }
+
+               public byte [] ProcessMessageType3 (string user, string password)
+               {
+                       TargetName = Environment.MachineName;
+                       ServerName = Environment.MachineName;
+                       // FIXME
+                       DomainName = ServerName;// IPGlobalProperties.GetIPGlobalProperties ().DomainName;
+                       DnsHostName = Dns.GetHostName ();
+                       DnsDomainName = DnsHostName; // FIXME
+
+                       type3 = new Type3Message (NtlmVersion.Version3);
+                       type3.Flags = (NtlmFlags) (unchecked ((int) 0xE2188235));
+                       type3.Domain = DomainName;
+                       type3.Host = DnsHostName;
+                       type3.Challenge = type2.Nonce;
+                       type3.Username = user;
+                       type3.Password = password;
+
+                       return type3.GetBytes ();
+               }
+       }
+
+       internal class SspiServerSession : SspiSession
+       {
+               public string TargetName;
+               public long SuppliedDomain, SuppliedWorkstation;
+               Type1Message type1;
+               Type2Message type2;
+               Type3Message type3;
+
+               // Example buffer:
+               // 6069 0606 2B0601050502 A05F 305D A024 3022
+               //        060A 2B06010401823702020A
+               //        0609 2A864882F712010202
+               //        0609 2A864886F712010202
+               // A235 0433 NTLM
+               // NTLM = 4E544C4D53535000 01000000 B7B218E2 090009002A000000
+               //  0200020028000000 0501280A0000000F 5043 574F524B47524F5550
+               public void ProcessSpnegoInitialContextTokenRequest (byte [] raw)
+               {
+                       ASN1 asn1 = new ASN1 (raw);
+                       // FIXME: check OIDs
+                       ProcessMessageType1 (asn1 [1] [0] [1] [0].Value);
+               }
+
+               // Class {
+               //   Class {
+               //     Class { Enum },
+               //     Class { OID(NTLMSSP) },
+               //     Class { OctetStream } } }
+               public byte [] ProcessSpnegoInitialContextTokenResponse ()
+               {
+                       ASN1 top = new ASN1 (0xA1);
+                       ASN1 asn = new ASN1 (0x30);
+                       ASN1 asn1 = new ASN1 (0xA0);
+                       // FIXME: what is this enum?
+                       asn1.Add (new ASN1 (0x0A, new byte [] {1})); // Enum whatever
+                       ASN1 asn2 = new ASN1 (0xA1);
+                       asn2.Add (ASN1Convert.FromOid (Constants.OidNtlmSsp));
+                       ASN1 asn3 = new ASN1 (0xA2);
+                       asn3.Add (new ASN1 (0x04, ProcessMessageType2 ()));
+                       asn.Add (asn1);
+                       asn.Add (asn2);
+                       asn.Add (asn3);
+                       top.Add (asn);
+                       return top.GetBytes ();
+               }
+
+               // Example buffer:
+               // A181A7
+               //   3081A4
+               //     A281A1
+               //       04819E
+               // 4E544C4D53535000 03000000 
+               // 180018005E000000 1800180076000000 0400040048000000
+               // 0E000E004C000000 040004005A000000 100010008E000000
+               // 358218E2 0501280A0000000F
+               // 50004300 6100740073007500730068006900 50004300
+               // [8 bytes LM] [16 bytes of 0s]
+               // [24 bytes of NTLM]
+               // C94EE2ADE7E32244 BD60D3B33609C167
+               public void ProcessSpnegoProcessContextToken (byte [] raw)
+               {
+                       ASN1 asn1 = new ASN1 (raw);
+                       // FIXME: check structure
+                       ProcessMessageType3 (asn1 [0] [0] [0].Value);
+               }
+
+               public void ProcessMessageType1 (byte [] raw)
+               {
+                       type1 = new Type1Message (raw, NtlmVersion.Version3);
+               }
+
+               public byte [] ProcessMessageType2 ()
+               {
+                       byte [] bytes = new byte [8];
+                       RandomNumberGenerator.Create ().GetNonZeroBytes (bytes);
+                       Challenge = bytes [0] << 24 + bytes [1] << 16 + bytes [2] << 8 + bytes [3];
+                       Context = 0; // FIXME
+                       ServerOSVersion = 0x0F00000A28010500; // FIXME
+                       TargetName = Environment.MachineName;
+                       ServerName = Environment.MachineName;
+                       // FIXME
+                       DomainName = ServerName;// IPGlobalProperties.GetIPGlobalProperties ().DomainName;
+                       DnsHostName = Dns.GetHostName ();
+                       DnsDomainName = DnsHostName; // FIXME
+
+                       type2 = new Type2Message (NtlmVersion.Version3);
+                       type2.Flags = (NtlmFlags) (unchecked ((int) 0xE21882B7));
+                       type2.TargetName = TargetName;
+                       type2.Target.ServerName = ServerName;
+                       type2.Target.DomainName = DomainName;
+                       type2.Target.DnsHostName = DnsHostName;
+                       type2.Target.DnsDomainName = DnsDomainName;
+                       return type2.GetBytes ();
+               }
+
+               public void ProcessMessageType3 (byte [] raw)
+               {
+                       /*
+                       MemoryStream ms = new MemoryStream (raw);
+                       if (!Verify (NtlmSSP, raw, 0, 8))
+                               throw new SecurityNegotiationException ("Expected NTLM SSPI header not found");
+                       BinaryReader reader = new BinaryReader (ms);
+                       reader.ReadInt64 (); // skip 8 bytes
+                       if (reader.ReadInt32 () != 3)
+                               throw new SecurityNegotiationException ("SSPI type 3 message is expected");
+                       SspiSecurityBufferStruct lmResInfo = ReadSecurityBuffer (reader);
+                       SspiSecurityBufferStruct ntlmResInfo = ReadSecurityBuffer (reader);
+                       SspiSecurityBufferStruct targetNameInfo = ReadSecurityBuffer (reader);
+                       SspiSecurityBufferStruct userNameInfo = ReadSecurityBuffer (reader);
+                       SspiSecurityBufferStruct wsNameInfo = ReadSecurityBuffer (reader);
+                       SspiSecurityBufferStruct sessionKeyInfo = ReadSecurityBuffer (reader);
+                       int flags = reader.ReadInt32 ();
+                       ServerOSVersion = reader.ReadInt64 ();
+                       */
+                       type3 = new Type3Message (raw, NtlmVersion.Version3);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SupportingTokenParameters.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/SupportingTokenParameters.cs
new file mode 100644 (file)
index 0000000..b8bb7f4
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// SupportingTokenParameters.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+
+using ParamList = System.Collections.ObjectModel.Collection<System.ServiceModel.Security.Tokens.SecurityTokenParameters>;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class SupportingTokenParameters
+       {
+               ParamList endorsing = new ParamList (),
+                         signed = new ParamList (),
+                         signed_encrypted = new ParamList (),
+                         signed_endorsing = new ParamList ();
+
+               public SupportingTokenParameters ()
+               {
+               }
+
+               private SupportingTokenParameters (SupportingTokenParameters source)
+               {
+                       endorsing = new ParamList (source.endorsing);
+                       signed = new ParamList (source.signed);
+                       signed_encrypted= new ParamList (source.signed_encrypted);
+                       signed_endorsing = new ParamList (source.signed_endorsing);
+               }
+
+               public Collection<SecurityTokenParameters> Endorsing {
+                       get { return endorsing; }
+               }
+
+               public Collection<SecurityTokenParameters> Signed {
+                       get { return signed; }
+               }
+
+               public Collection<SecurityTokenParameters> SignedEncrypted {
+                       get { return signed_encrypted; }
+               }
+
+               public Collection<SecurityTokenParameters> SignedEndorsing {
+                       get { return signed_endorsing; }
+               }
+
+               public SupportingTokenParameters Clone ()
+               {
+                       return new SupportingTokenParameters (this);
+               }
+
+               public void SetKeyDerivation (bool requireDerivedKeys)
+               {
+                       foreach (SecurityTokenParameters p in endorsing)
+                               p.RequireDerivedKeys = requireDerivedKeys;
+                       foreach (SecurityTokenParameters p in signed)
+                               p.RequireDerivedKeys = requireDerivedKeys;
+                       foreach (SecurityTokenParameters p in signed_encrypted)
+                               p.RequireDerivedKeys = requireDerivedKeys;
+                       foreach (SecurityTokenParameters p in signed_endorsing)
+                               p.RequireDerivedKeys = requireDerivedKeys;
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/TlsClientSession.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/TlsClientSession.cs
new file mode 100644 (file)
index 0000000..91ae86d
--- /dev/null
@@ -0,0 +1,237 @@
+//
+// TlsClientSession.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Text;
+using Mono.Security.Protocol.Tls;
+using Mono.Security.Protocol.Tls.Handshake;
+using Mono.Security.Protocol.Tls.Handshake.Client;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       internal abstract class TlsSession
+       {
+               protected abstract Context Context { get; }
+
+               protected abstract RecordProtocol Protocol { get; }
+
+               public byte [] MasterSecret {
+                       get { return Context.MasterSecret; }
+               }
+
+               public byte [] CreateHash (byte [] key, byte [] seedSrc, string label)
+               {
+                       byte [] labelBytes = Encoding.UTF8.GetBytes (label);
+                       byte [] seed = new byte [seedSrc.Length + labelBytes.Length];
+                       Array.Copy (seedSrc, seed, seedSrc.Length);
+                       Array.Copy (labelBytes, 0, seed, seedSrc.Length, labelBytes.Length);
+                       return Context.Current.Cipher.Expand ("SHA1", key, seed, 256 / 8);
+               }
+
+               public byte [] CreateHashAlt (byte [] key, byte [] seed, string label)
+               {
+                       return Context.Current.Cipher.PRF (key, label, seed, 256 / 8);
+               }
+
+               protected void WriteHandshake (MemoryStream ms)
+               {
+                       Context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers (SecurityProtocolType.Tls);
+                       ms.WriteByte (0x16); // Handshake
+                       ms.WriteByte (3); // version-major
+                       ms.WriteByte (1); // version-minor
+               }
+
+               protected void WriteChangeCipherSpec (MemoryStream ms)
+               {
+                       ms.WriteByte (0x14); // Handshake
+                       ms.WriteByte (3); // version-major
+                       ms.WriteByte (1); // version-minor
+                       ms.WriteByte (0); // size-upper
+                       ms.WriteByte (1); // size-lower
+                       ms.WriteByte (1); // ChangeCipherSpec content (1 byte)
+               }
+
+               protected void ReadHandshake (MemoryStream ms)
+               {
+                       if (ms.ReadByte () != 0x16)
+                               throw new Exception ("INTERNAL ERROR: handshake is expected");
+                       Context.ChangeProtocol ((short) (ms.ReadByte () * 0x100 + ms.ReadByte ()));
+               }
+
+               protected void ReadChangeCipherSpec (MemoryStream ms)
+               {
+                       if (ms.ReadByte () != 0x14)
+                               throw new Exception ("INTERNAL ERROR: ChangeCipherSpec is expected");
+                       Context.ChangeProtocol ((short) (ms.ReadByte () * 0x100 + ms.ReadByte ()));
+                       if (ms.ReadByte () * 0x100 + ms.ReadByte () != 1)
+                               throw new Exception ("INTERNAL ERROR: unexpected ChangeCipherSpec length");
+                       ms.ReadByte (); // ChangeCipherSpec content (1 byte) ... anything is OK?
+               }
+
+               protected byte [] ReadNextOperation (MemoryStream ms, HandshakeType expected)
+               {
+                       if (ms.ReadByte () != (int) expected)
+                               throw new Exception ("INTERNAL ERROR: unexpected server response");
+                       int size = ms.ReadByte () * 0x10000 + ms.ReadByte () * 0x100 + ms.ReadByte ();
+                       // FIXME: use correct valid input range
+                       if (size > 0x100000)
+                               throw new Exception ("rejected massive input size.");
+                       byte [] bytes = new byte [size];
+                       ms.Read (bytes, 0, size);
+                       return bytes;
+               }
+
+               protected void WriteOperations (MemoryStream ms, params HandshakeMessage [] msgs)
+               {
+                       List<byte []> rawbufs = new List<byte []> ();
+                       int total = 0;
+                       for (int i = 0; i < msgs.Length; i++) {
+                               HandshakeMessage msg = msgs [i];
+                               msg.Process ();
+                               rawbufs.Add (msg.EncodeMessage ());
+                               total += rawbufs [i].Length;
+                               msg.Update ();
+                       }
+                       // FIXME: split packets when the size exceeded 0x10000 (or so)
+                       ms.WriteByte ((byte) (total / 0x100));
+                       ms.WriteByte ((byte) (total % 0x100));
+                       foreach (byte [] bytes in rawbufs)
+                               ms.Write (bytes, 0, bytes.Length);
+               }
+
+               protected void VerifyEndOfTransmit (MemoryStream ms)
+               {
+                       if (ms.Position == ms.Length)
+                               return;
+
+                       /*
+                       byte [] bytes = new byte [ms.Length - ms.Position];
+                       ms.Read (bytes, 0, bytes.Length);
+                       foreach (byte b in bytes)
+                               Console.Write ("{0:X02} ", b);
+                       Console.WriteLine (" - total {0} bytes remained.", bytes.Length);
+                       */
+
+                       throw new Exception ("INTERNAL ERROR: unexpected server response");
+               }
+       }
+
+       internal class TlsClientSession : TlsSession
+       {
+               SslClientStream ssl;
+               MemoryStream stream;
+               bool mutual;
+
+               public TlsClientSession (string host, X509Certificate2 clientCert)
+               {
+                       stream = new MemoryStream ();
+                       if (clientCert == null)
+                               ssl = new SslClientStream (stream, host, true, SecurityProtocolType.Tls);
+                       else {
+                               ssl = new SslClientStream (stream, host, true, SecurityProtocolType.Tls, new X509CertificateCollection (new X509Certificate [] {clientCert}));
+                               mutual = true;
+                               ssl.ClientCertSelection += delegate (
+                                       X509CertificateCollection clientCertificates,
+                               X509Certificate serverCertificate,
+                               string targetHost,
+                               X509CertificateCollection serverRequestedCertificates) {
+                                       return clientCertificates [0];
+                               };
+                       }
+               }
+
+               protected override Context Context {
+                       get { return ssl.context; }
+               }
+
+               protected override RecordProtocol Protocol {
+                       get { return ssl.protocol; }
+               }
+
+               public byte [] ProcessClientHello ()
+               {
+                       Context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers (Context.SecurityProtocol);
+                       Context.HandshakeState = HandshakeState.Started;
+                       Protocol.SendRecord (HandshakeType.ClientHello);
+                       stream.Flush ();
+                       return stream.ToArray ();
+               }
+
+               // ServerHello, ServerCertificate and ServerHelloDone
+               public void ProcessServerHello (byte [] raw)
+               {
+                       stream.SetLength (0);
+                       stream.Write (raw, 0, raw.Length);
+                       stream.Seek (0, SeekOrigin.Begin);
+
+                       Protocol.ReceiveRecord (stream); // ServerHello
+                       Protocol.ReceiveRecord (stream); // ServerCertificate
+                       if (mutual)
+                               Protocol.ReceiveRecord (stream); // CertificateRequest
+                       Protocol.ReceiveRecord (stream); // ServerHelloDone
+                       if (stream.Position != stream.Length)
+                               throw new SecurityNegotiationException (String.Format ("Unexpected SSL negotiation binary: {0} bytes of excess in {1} bytes of the octets", stream.Length - stream.Position, stream.Length));
+               }
+
+               public byte [] ProcessClientKeyExchange ()
+               {
+                       stream.SetLength (0);
+                       if (mutual)
+                               Protocol.SendRecord (HandshakeType.Certificate);
+                       Protocol.SendRecord (HandshakeType.ClientKeyExchange);
+                       Context.Negotiating.Cipher.ComputeKeys ();
+                       Context.Negotiating.Cipher.InitializeCipher ();
+                       Protocol.SendChangeCipherSpec ();
+                       Context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers (SecurityProtocolType.Tls);
+                       Protocol.SendRecord (HandshakeType.Finished);
+                       stream.Flush ();
+                       return stream.ToArray ();
+               }
+
+               public void ProcessServerFinished (byte [] raw)
+               {
+                       stream.SetLength (0);
+                       stream.Write (raw, 0, raw.Length);
+                       stream.Seek (0, SeekOrigin.Begin);
+
+                       Protocol.ReceiveRecord (stream); // ChangeCipherSpec
+                       Protocol.ReceiveRecord (stream); // ServerFinished
+               }
+
+               public byte [] ProcessApplicationData (byte [] raw)
+               {
+                       stream.SetLength (0);
+                       stream.Write (raw, 0, raw.Length);
+                       stream.Seek (0, SeekOrigin.Begin);
+                       return Protocol.ReceiveRecord (stream); // ApplicationData
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/TlsServerSession.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/TlsServerSession.cs
new file mode 100644 (file)
index 0000000..0355e9f
--- /dev/null
@@ -0,0 +1,147 @@
+//
+// TlsServerSession.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Security.Cryptography.X509Certificates;
+using Mono.Security.Protocol.Tls;
+using Mono.Security.Protocol.Tls.Handshake;
+using Mono.Security.Protocol.Tls.Handshake.Server;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       internal class TlsServerSession : TlsSession
+       {
+               SslServerStream ssl;
+               MemoryStream stream;
+               bool mutual;
+
+               public TlsServerSession (X509Certificate2 cert, bool mutual)
+               {
+                       this.mutual = mutual;
+                       stream = new MemoryStream ();
+                       ssl = new SslServerStream (stream, cert, mutual, true, SecurityProtocolType.Tls);
+                       ssl.PrivateKeyCertSelectionDelegate = delegate (X509Certificate c, string host) {
+                               if (c.GetCertHashString () == cert.GetCertHashString ())
+                                       return cert.PrivateKey;
+                               return null;
+                       };
+                       ssl.ClientCertValidationDelegate = delegate (X509Certificate certificate, int[] certificateErrors) {
+                               // FIXME: use X509CertificateValidator
+                               return true;
+                       };
+               }
+
+               protected override Context Context {
+                       get { return ssl.context; }
+               }
+
+               protected override RecordProtocol Protocol {
+                       get { return ssl.protocol; }
+               }
+
+               public void ProcessClientHello (byte [] raw)
+               {
+                       Context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers (Context.SecurityProtocol);
+                       Context.HandshakeState = HandshakeState.Started;
+
+                       stream.Write (raw, 0, raw.Length);
+                       stream.Seek (0, SeekOrigin.Begin);
+
+                       Protocol.ReceiveRecord (stream);
+               }
+
+               // ServerHello, ServerCertificate and ServerHelloDone
+               public byte [] ProcessServerHello ()
+               {
+                       Context.SessionId = Context.GetSecureRandomBytes (32);
+
+#if false
+                       // so, can I send handshake batch with RecordProtocol?
+                       stream.SetLength (0);
+                       Protocol.SendRecord (HandshakeType.ServerHello);
+                       Protocol.SendRecord (HandshakeType.Certificate);
+                       Protocol.SendRecord (HandshakeType.ServerHelloDone);
+                       stream.Flush ();
+                       return stream.ToArray ();
+
+#else
+
+                       MemoryStream ms = new MemoryStream ();
+
+                       WriteHandshake (ms);
+
+                       if (mutual)
+                               WriteOperations (ms,
+                                       new TlsServerHello (ssl.context),
+                                       new TlsServerCertificate (ssl.context),
+                                       new TlsServerCertificateRequest (ssl.context),
+                                       new TlsServerHelloDone (ssl.context));
+                       else
+                               WriteOperations (ms,
+                                       new TlsServerHello (ssl.context),
+                                       new TlsServerCertificate (ssl.context),
+                                       new TlsServerHelloDone (ssl.context));
+
+                       return ms.ToArray ();
+#endif
+               }
+
+               public void ProcessClientKeyExchange (byte [] raw)
+               {
+                       stream.SetLength (0);
+                       stream.Write (raw, 0, raw.Length);
+                       stream.Seek (0, SeekOrigin.Begin);
+
+                       if (mutual)
+                               Protocol.ReceiveRecord (stream); // Certificate
+                       Protocol.ReceiveRecord (stream); // ClientKeyExchange
+                       Protocol.ReceiveRecord (stream); // ChangeCipherSpec
+                       Protocol.ReceiveRecord (stream); // ClientFinished
+
+                       if (stream.Position != stream.Length)
+                               throw new SecurityNegotiationException (String.Format ("Unexpected SSL negotiation binary: {0} bytes of excess in {1} bytes of the octets", stream.Length - stream.Position, stream.Length));
+               }
+
+               public byte [] ProcessServerFinished ()
+               {
+                       stream.SetLength (0);
+                       Protocol.SendChangeCipherSpec ();
+                       Protocol.SendRecord (HandshakeType.Finished);
+                       stream.Flush ();
+                       return stream.ToArray ();
+               }
+
+               public byte [] ProcessApplicationData (byte [] raw)
+               {
+                       stream.SetLength (0);
+                       Protocol.SendRecord (ContentType.ApplicationData, raw);
+                       stream.Flush ();
+                       return stream.ToArray ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/UserNameSecurityTokenParameters.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/UserNameSecurityTokenParameters.cs
new file mode 100644 (file)
index 0000000..a5b6daa
--- /dev/null
@@ -0,0 +1,85 @@
+//
+// UserNameSecurityTokenParameters.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class UserNameSecurityTokenParameters : SecurityTokenParameters
+       {
+               public UserNameSecurityTokenParameters ()
+               {
+                       RequireDerivedKeys = false;
+               }
+
+               protected UserNameSecurityTokenParameters (UserNameSecurityTokenParameters source)
+                       : base (source)
+               {
+               }
+
+               protected override bool HasAsymmetricKey {
+                       get { return false; }
+               }
+
+               protected override bool SupportsClientAuthentication {
+                       get { return true; }
+               }
+
+               protected override bool SupportsClientWindowsIdentity {
+                       get { return true; }
+               }
+
+               protected override bool SupportsServerAuthentication {
+                       get { return false; }
+               }
+
+               protected override SecurityTokenParameters CloneCore ()
+               {
+                       return new UserNameSecurityTokenParameters (this);
+               }
+
+               protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       if (token == null)
+                               throw new ArgumentNullException ("token");
+                       if (token is UserNameSecurityToken &&
+                           referenceStyle == SecurityTokenReferenceStyle.Internal)
+                               return new LocalIdKeyIdentifierClause (token.Id);
+                       // External reference is not supported.
+                       throw new NotSupportedException (String.Format ("This security token '{0}' with {1} reference mode is not supported.", token, referenceStyle));
+               }
+
+               protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+               {
+                       requirement.TokenType = SecurityTokenTypes.UserName;
+                       requirement.RequireCryptographicToken = true;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/WrappedKeySecurityToken.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/WrappedKeySecurityToken.cs
new file mode 100644 (file)
index 0000000..d3c47f2
--- /dev/null
@@ -0,0 +1,176 @@
+//
+// WrappedKeySecurityToken.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Security.Cryptography;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class WrappedKeySecurityToken : SecurityToken
+       {
+               string id;
+               byte [] raw_key;
+               byte [] wrapped_key;
+               string wrap_alg;
+               SecurityToken wrap_token;
+               SecurityKeyIdentifier wrap_token_ref;
+               DateTime valid_from = DateTime.Now.ToUniversalTime ();
+               ReadOnlyCollection<SecurityKey> keys;
+               ReferenceList reference_list;
+               byte [] keyhash;
+
+               public WrappedKeySecurityToken (
+                       string id,
+                       byte [] keyToWrap,
+                       string wrappingAlgorithm,
+                       SecurityToken wrappingToken,
+                       SecurityKeyIdentifier wrappingTokenReference)
+               {
+                       if (id == null)
+                               throw new ArgumentNullException ("id");
+                       if (keyToWrap == null)
+                               throw new ArgumentNullException ("keyToWrap");
+                       if (wrappingAlgorithm == null)
+                               throw new ArgumentNullException ("wrappingAlgorithm");
+                       if (wrappingToken == null)
+                               throw new ArgumentNullException ("wrappingToken");
+
+                       raw_key = keyToWrap;
+                       this.id = id;
+                       wrap_alg = wrappingAlgorithm;
+                       wrap_token = wrappingToken;
+                       wrap_token_ref = wrappingTokenReference;
+                       Collection<SecurityKey> l = new Collection<SecurityKey> ();
+                       foreach (SecurityKey sk in wrappingToken.SecurityKeys) {
+                               if (sk.IsSupportedAlgorithm (wrappingAlgorithm)) {
+                                       wrapped_key = sk.EncryptKey (wrappingAlgorithm, keyToWrap);
+                                       l.Add (new InMemorySymmetricSecurityKey (keyToWrap));
+                                       break;
+                               }
+                       }
+                       keys = new ReadOnlyCollection<SecurityKey> (l);
+                       if (wrapped_key == null)
+                               throw new ArgumentException (String.Format ("None of the security keys in the argument token supports specified wrapping algorithm '{0}'", wrappingAlgorithm));
+               }
+
+               internal byte [] RawKey {
+                       get { return raw_key; }
+               }
+
+               // It is kind of compromised solution to output
+               // ReferenceList inside e:EncryptedKey and might disappear
+               // when non-wrapped key is represented by another token type.
+               internal ReferenceList ReferenceList {
+                       get { return reference_list; }
+                       set { reference_list = value; }
+               }
+
+               public override DateTime ValidFrom {
+                       get { return valid_from; }
+               }
+
+               public override DateTime ValidTo {
+                       get { return DateTime.MaxValue.AddDays (-1); }
+               }
+
+               public override string Id {
+                       get { return id; }
+               }
+
+               public override ReadOnlyCollection<SecurityKey> SecurityKeys {
+                       get { return keys; }
+               }
+
+               public string WrappingAlgorithm {
+                       get { return wrap_alg; }
+               }
+
+               public SecurityToken WrappingToken {
+                       get { return wrap_token; }
+               }
+
+               public SecurityKeyIdentifier WrappingTokenReference {
+                       get { return wrap_token_ref; }
+               }
+
+               public byte [] GetWrappedKey ()
+               {
+                       return (byte []) wrapped_key.Clone ();
+               }
+
+               internal void SetWrappedKey (byte [] value)
+               {
+                       wrapped_key = (byte []) value.Clone ();
+               }
+
+               [MonoTODO]
+               public override bool CanCreateKeyIdentifierClause<T> ()
+               {
+                       /*
+                       foreach (SecurityKeyIdentifierClause k in WrappingTokenReference) {
+                               Type t = k.GetType ();
+                               if (t == typeof (T) || t.IsSubclassOf (typeof (T)))
+                                       return true;
+                       }
+                       */
+                       return false;
+               }
+
+               [MonoTODO]
+               public override T CreateKeyIdentifierClause<T> ()
+               {
+                       /*
+                       foreach (SecurityKeyIdentifierClause k in WrappingTokenReference) {
+                               Type t = k.GetType ();
+                               if (t == typeof (T) || t.IsSubclassOf (typeof (T)))
+                                       return (T) k;
+                       }
+                       */
+                       throw new NotSupportedException (String.Format ("WrappedKeySecurityToken cannot create '{0}'", typeof (T)));
+               }
+
+               public override bool MatchesKeyIdentifierClause (SecurityKeyIdentifierClause keyIdentifierClause)
+               {
+                       LocalIdKeyIdentifierClause lkic = keyIdentifierClause as LocalIdKeyIdentifierClause;
+                       if (lkic != null && lkic.LocalId == Id)
+                               return true;
+
+                       InternalEncryptedKeyIdentifierClause khic = keyIdentifierClause as InternalEncryptedKeyIdentifierClause;
+                       if (keyhash == null)
+                               keyhash = SHA1.Create ().ComputeHash (wrapped_key);
+                       if (khic != null && khic.Matches (keyhash))
+                               return true;
+
+                       return false;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/X509SecurityTokenParameters.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security.Tokens/X509SecurityTokenParameters.cs
new file mode 100644 (file)
index 0000000..7fda2ea
--- /dev/null
@@ -0,0 +1,124 @@
+//
+// X509SecurityTokenParameters.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public class X509SecurityTokenParameters : SecurityTokenParameters
+       {
+               X509KeyIdentifierClauseType reference_style;
+
+               public X509SecurityTokenParameters ()
+                       : this (X509KeyIdentifierClauseType.Any)
+               {
+               }
+
+               public X509SecurityTokenParameters (X509KeyIdentifierClauseType x509ReferenceStyle)
+                       : this (x509ReferenceStyle, SecurityTokenInclusionMode.AlwaysToRecipient)
+               {
+               }
+
+               public X509SecurityTokenParameters (X509KeyIdentifierClauseType x509ReferenceStyle, SecurityTokenInclusionMode inclusionMode)
+               {
+                       reference_style = x509ReferenceStyle;
+                       InclusionMode = inclusionMode;
+               }
+
+               protected X509SecurityTokenParameters (X509SecurityTokenParameters source)
+                       : base (source)
+               {
+                       reference_style = source.reference_style;
+               }
+
+               public X509KeyIdentifierClauseType X509ReferenceStyle {
+                       get { return reference_style; }
+                       set { reference_style = value; }
+               }
+
+               // It is documented as to return false, but that is wrong.
+               protected override bool HasAsymmetricKey {
+                       get { return true; }
+               }
+
+               protected override bool SupportsClientAuthentication {
+                       get { return true; }
+               }
+
+               protected override bool SupportsClientWindowsIdentity {
+                       get { return true; }
+               }
+
+               protected override bool SupportsServerAuthentication {
+                       get { return true; }
+               }
+
+               protected override SecurityTokenParameters CloneCore ()
+               {
+                       return new X509SecurityTokenParameters (this);
+               }
+
+               protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       if (token == null)
+                               throw new ArgumentNullException ("token");
+
+                       if (referenceStyle == SecurityTokenReferenceStyle.Internal)
+                               return new LocalIdKeyIdentifierClause (token.Id, token.GetType ());
+
+                       switch (reference_style) {
+                       default:
+                               return token.CreateKeyIdentifierClause<X509IssuerSerialKeyIdentifierClause> ();
+                       case X509KeyIdentifierClauseType.Thumbprint:
+                               return token.CreateKeyIdentifierClause<X509ThumbprintKeyIdentifierClause> ();
+                       case X509KeyIdentifierClauseType.SubjectKeyIdentifier:
+                               return token.CreateKeyIdentifierClause<X509SubjectKeyIdentifierClause> ();
+                       case X509KeyIdentifierClauseType.RawDataKeyIdentifier:
+                               return token.CreateKeyIdentifierClause<X509RawDataKeyIdentifierClause> ();
+                       case X509KeyIdentifierClauseType.Any:
+                               if (token.CanCreateKeyIdentifierClause<X509SubjectKeyIdentifierClause> ())
+                                       goto case X509KeyIdentifierClauseType.SubjectKeyIdentifier;
+                               goto default;
+                       }
+               }
+
+               protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+               {
+                       requirement.TokenType = SecurityTokenTypes.X509Certificate;
+                       requirement.KeyType = SecurityKeyType.AsymmetricKey;
+                       requirement.RequireCryptographicToken = true;
+               }
+
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/BasicSecurityProfileVersion.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/BasicSecurityProfileVersion.cs
new file mode 100644 (file)
index 0000000..bd4714e
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// BasicSecurityProfileVersion.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Security
+{
+       public abstract class BasicSecurityProfileVersion
+       {
+               static BasicSecurityProfileVersion impl = new BasicSecurityProfileVersionImpl ();
+
+               public static BasicSecurityProfileVersion BasicSecurityProfile10 {
+                       get { return impl; }
+               }
+
+               private BasicSecurityProfileVersion ()
+               {
+               }
+
+               class BasicSecurityProfileVersionImpl : BasicSecurityProfileVersion
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/BinarySecretKeyIdentifierClause.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/BinarySecretKeyIdentifierClause.cs
new file mode 100644 (file)
index 0000000..497d5c7
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// BinarySecretKeyIdentifierClause.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Xml;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       public class BinarySecretKeyIdentifierClause : BinaryKeyIdentifierClause
+       {
+               public BinarySecretKeyIdentifierClause (byte [] key)
+                       : this (key, true)
+               {
+               }
+
+               [MonoTODO ("ClauseType")]
+               public BinarySecretKeyIdentifierClause (byte [] key, bool cloneBuffer)
+                       : base ("", key, cloneBuffer)
+               {
+               }
+
+               [MonoTODO ("ClauseType")]
+               public BinarySecretKeyIdentifierClause (byte [] key, bool cloneBuffer, byte [] derivationNonce, int derivationLength)
+                       : base ("", key, cloneBuffer, derivationNonce, derivationLength)
+               {
+               }
+
+               public override bool CanCreateKey {
+                       get { return true; }
+               }
+
+               public byte [] GetKeyBytes ()
+               {
+                       return GetBuffer ();
+               }
+
+               public override SecurityKey CreateKey ()
+               {
+                       return new InMemorySymmetricSecurityKey (GetRawBuffer (), true);
+               }
+
+               public override bool Matches (SecurityKeyIdentifierClause clause)
+               {
+                       if (clause == null)
+                               throw new ArgumentNullException ("clause");
+                       BinarySecretKeyIdentifierClause other =
+                               clause as BinarySecretKeyIdentifierClause;
+                       if (other == null)
+                               return false;
+                       byte [] b1 = GetRawBuffer ();
+                       byte [] b2 = other.GetRawBuffer ();
+                       if (b1.Length != b2.Length)
+                               return false;
+                       for (int i = 0; i < b1.Length; i++)
+                               if (b1 [i] != b2 [i])
+                                       return false;
+                       return true;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog
new file mode 100755 (executable)
index 0000000..274be2e
--- /dev/null
@@ -0,0 +1,604 @@
+2007-04-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : write GenericXmlSecurityToken (btw
+         it is not readable due to missing token information by nature ...).
+         read and write SamlAssertionKeyIdentifierClause.
+
+2007-04-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs : support mutual sslnego.
+
+2007-04-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : set cookie property for such tokens
+         that was created from cookie binary.
+
+2007-04-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DataProtectionSecurityStateEncoder.cs : oops, Encode->Protect,
+         Decode->Unprotect.
+
+2007-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs : SecurityBindingElement
+         is also needed to retrieve local service settings.
+
+2007-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : when reading SCT from
+         SecurityContextSecurityToken, return it from cookie binary.
+         knownTypes argument can be null.
+
+2007-03-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SspiSecurityTokenProvider.cs : removed SspiCommunicationObject from
+         this class, as it is not for spnego.
+       * ServiceCredentialsSecurityTokenManager.cs :
+         handle spnego authenticator.
+       * WSSecurityTokenSerializer.cs : some comments.
+
+2007-03-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : fixed SecurityContextToken Id
+         and prefix output.
+
+2007-03-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs :
+         use Type.EmptyTypes instead of null to avoid ANE.
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs :
+         updated Ssl token authenticator .ctor().
+         Pass SecurityStateEncoder to WSSecurityTokenSerializer (it is used
+         for cookie sct).
+       * WSSecurityTokenSerializer.cs : added couple of support for
+         SecurityContextToken. Implemented CanWriteKeyIdentifierClause().
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DataProtectionSecurityStateEncoder.cs, SecurityStateEncoder.cs :
+         nominally implemented (it won't work under Linux as it depends on
+         DPAPI). We should just ignore those lazy users who depend on them
+         by using default settings.
+
+2007-03-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs :
+         add SslSecurityTokenAuthenticator .ctor() arg.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs :
+         started secure conversation authenticator code (not sure when it
+         should work though. Any attempt to initialize requirement with
+         SecureConv parameter causes NRE on .NET).
+
+2007-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelProtectionRequirements.cs : null arg check.
+
+2007-03-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs :
+         IsIssuedSecurityTokenRequirement() fix, the same way as client.
+
+2007-03-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs :
+         internalize IsIssuedSecurityTokenRequirement().
+         Use SecurityTokenRequirement.ToString().
+
+2007-03-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs :
+         Return ssl token authenticator (just almost stub now).
+         Ssl does not support token provider, so explicitly throw an error.
+
+2007-02-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : there could be more types than
+         EncryptedKey type that could be indicated by ValueType attribute.
+
+2007-02-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : read/write DerivedKeyToken.
+         Supply OwnerType for LocalId key when there is ValueType attribute.
+
+2007-02-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : handle X509 issue serial key
+         identifier clauses.
+
+2007-02-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : set cipher value as wrapped key
+         (workaround for EncryptedKeySHA1).
+
+2007-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UnionSecurityTokenResolver.cs : internal helper resolver.
+
+2007-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs :
+         WrappedKeySecurityToken could be read.
+
+2007-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs :
+         implement CanReadKeyIdentifierClauseCore() (partially).
+
+2007-02-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs : minor message fix.
+         MutualCertificateDuplex is different from usual certificate-based
+         conection.
+
+2007-02-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : read UsernameToken.
+
+2007-02-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs :
+         changes due to the latest EncryptedKeySHA1 clause changes.
+
+2007-02-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityMessageProperty.cs :
+         Added internal EncryptionKey. Cosmetic GetOrCreate() refactoring.
+       * WSSecurityTokenSerializer.cs : Support BinarySecret clause writer.
+         Support embedded encryptedkey clause (o:SecurityTokenReference with
+         o:KeyIdentifier) writer.
+
+2007-01-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : handle EncryptedKeySHA1 for
+         SecurityTokenReference reader too.
+
+2007-01-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : now ReadKeyIdentifierClause() supports
+         wsse:KeyIdentifier (only with X509Thumbprint for now).
+
+2007-01-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityMessageProperty.cs : added internal ConfirmedSignatures.
+
+2007-01-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityAlgorithmSuite.cs : give more meaningful field names.
+         Implemented some Is[blah]Supported() methods.
+       * WSSecurityTokenSerializer.cs : corcompare fix.
+       * SecurityVersion : removed MonoTODO.
+
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs :
+         CreateSecurityTokenSerializer() should consider securityVersion
+         and emitBspRequiredAttributes based on SecurityTokenVersion.
+       * WSSecurityTokenSerializer.cs : EmitBspRequiredAttributes is the
+         magic key to determine to output some attributes or not.
+         Added CreateKeyIdentifierClauseFromTokenXml() stub.
+
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : handle WrappedKeySecurityToken in
+         GetTokenTypeUri().
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : add e:ReferenceList output.
+
+2007-01-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : X509Thumbprint is not supported
+         when SecurityVersion is WSS 1.0.
+
+2007-01-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : write correct wrapped key. Don't
+         output WrappingToken.
+
+2006-12-09  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ChannelProtectionRequirements.cs : moved code for population from
+         ContractDescription, from ClientRuntimeChannel.cs. Parts should be
+         created from headers, not body parts. Fill IsBodyIncluded flag
+         from ContractDescription.[Has]ProtectionLevel.
+       * WSSecurityTokenSerializer.cs : implemented writer for
+         WrappedKeySecurityToken.
+
+2006-12-08  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityMessageProperty.cs : initialize SenderIdPrefix as "_".
+
+2006-12-08  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityContextKeyIdentifierClause.cs,
+         SecurityAccessDeniedException.cs,
+         ExpiredSecurityTokenException.cs : added missing types.
+       * SecurityNegotiationException.cs, MessageSecurityException.cs :
+         minor API fixes.
+
+2006-12-08  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityMessageProperty.cs : implemented, though not in actual use.
+       * ServiceSecurityContext.cs : implemented some members.
+
+2006-12-07  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * MessagePartSpecification : implemented Union().
+       * ScopedMessagePartSpecification.cs : AddParts() is now implemented
+         correctly (it merges into existing parts).
+       * ChannelProtectionRequirements.cs : cosmetic comment.
+
+2006-12-06  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : several improvements to read and
+         write EncryptedKeyIdentifierClause.
+
+2006-12-05  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs :
+         Added EncryptedKeyIdentifier clause writer.
+         Fixed thumbprint writer. WS-Security X509 Certificate Token Profile
+         does allows direct cetificate info only with IssuerSerial.
+
+2006-10-12  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityAlgorithmSuite.cs : added some overrides in impl. class
+         so that I don't forget them (they are not implemented yet).
+
+2006-09-27  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : URI attribute in o:Reference element
+         is not mandatory.
+
+2006-09-26  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : (ReadKeyIdentifierClauseCore) remove
+         extra consumption of Reference element.
+
+2006-09-22  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityAlgorithmSuite.cs : fixed AsymmetricSignatureAlgorithm.
+         Use SecurityAlgorithms constants.
+
+2006-09-22  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * MessagePartSpecification.cs : default IsBodyIncluded is false.
+
+2006-09-21  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : ReadKeyIdentifierClauseCore() now handles
+         <SecurityTokenReference> element (as LocalIdKeyIdentifierClause).
+
+2006-09-20  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * BinarySecretKeyIdentifierClause.cs : a few more API cleanup.
+
+2006-09-19  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * BinarySecretKeyIdentifierClause.cs : added missing members.
+
+2006-09-15  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SspiSecurityTokenProvider.cs : ProviderCommunicationObject-based
+         implementation (but do we implement it?)
+       * ServiceCredentialsSecurityTokenManager.cs : more rejection in
+         CreateSecurityTokenProvider().
+       * WindowsClientCredential.cs : implemented as long as they are
+         required in the tests.
+
+2006-09-14  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * UserNamePasswordServiceCredential.cs,
+         X509PeerCertificateAuthentication.cs,
+         SecureConversationServiceCredential.cs,
+         ServiceCredentialsSecurityTokenManager.cs,
+         DataProtectionSecurityStateEncoder.cs,
+         IssuedTokenServiceCredential.cs,
+         X509ClientCertificateAuthentication.cs :
+         several fixes for the default values.
+       * KeyNameIdentifierClause.cs : implemented Matches().
+
+2006-09-12  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs : service certificate
+         must contain a private key.
+       * WSSecurityTokenSerializer.cs : RsaSecurityToken is not supported.
+         Support LocalId and X509Thumbprint in WriteKeyIdentifierClause().
+
+2006-09-07  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityVersion.cs, SecurityMessageProperty.cs,
+         ServiceCredentialsSecurityTokenManager.cs,
+         HttpDigestClientCredential.cs : assorted RC1 API fixes.
+       * WindowsClientCredential.cs, WindowsServiceCredential.cs,
+         SspiSecurityTokenProvider.cs, PeerCredential.cs :
+         new files, cleaning Dummy.cs up in this namespace.
+
+2006-09-06  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * X509CertificateRecipientServiceCredential.cs :
+         added missing SetCertificate().
+       * UserNamePasswordServiceCredential.cs,
+         X509PeerCertificateAuthentication.cs : API fix to RC1.
+       * WSSecurityTokenSerializer.cs : ReadTokenCore() now works for X509.
+
+2006-09-06  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * UserNamePasswordServiceCredential.cs : some API fixes.
+
+2006-09-05  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * X509CertificateRecipientClientCredential.cs :
+         added ScopedCertificates.
+
+2006-09-05  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityStateEncoder.cs, DataProtectionSecurityStateEncoder.cs :
+         new files.
+
+2006-09-01  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : fixed namespace URI for BinarySecret.
+
+2006-08-30  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManager.cs : implemented some members,
+         actually as copy of ClientCredentialsSecurityTokenManager.
+
+2006-08-29  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ScopedMessagePartSpecification.cs : partly implemented.
+
+2006-08-29  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs :
+         some ReadToken()/CanReadToken() implementation.
+
+2006-08-28  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : support BinarySecret WriteToken().
+
+2006-08-25  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SupportingTokenSpecification.cs, IEndpointIdentityProvider.cs,
+         ISecuritySession.cs, X509PeerCertificateAuthentication.cs,
+         ISecureConversationSession.cs, SecurityTokenSpecification.cs :
+         new files.
+       * X509CertificateInitiatorServiceCredential.cs,
+         X509ServiceCertificateAuthentication.cs : removed extra properties.
+       * ServiceCredentialsSecurityTokenManager.cs :
+         It implements IEndpointIdentityProvider.
+
+2006-08-23  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : some constant renamings.
+
+2006-08-22  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecureConversationServiceCredential.cs,
+         MessagePartSpecification.cs : new files.
+       * ChannelProtectionRequirements.cs,
+         ScopedMessagePartSpecification.cs : largely implemented.
+       * SecurityCredentialsManager.cs : CreateSecurityTokenManager() is
+         public indeed. Thus removed internal caller as well.
+
+2006-08-17  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : removed SamlSerializer and
+         SecurityStateEncoder. Added GetTokenTypeUri(). 
+
+2006-08-14  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityCredentialsManager.cs : add internal helper method to call
+         CreateSecurityTokenManager().
+
+2006-08-11  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityCredentialsManager.cs : no need to be internal.
+       * ServiceCredentialsSecurityTokenManager.cs : new file.
+
+2006-08-10  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * X509CertificateRecipientClientCredential.cs :
+         implemented get_Authentication().
+
+2006-08-04  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * KeyNameIdentifierClause.cs, BinarySecretKeyIdentifierClause.cs :
+         new files.
+
+2006-08-03  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * BinarySecretSecurityTokenAuthenticator.cs,
+         FederationServiceIssuedSecurityTokenProvider.cs : removed old code.
+
+2006-08-02  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * KeyType.cs : removed obsolete type.
+
+2006-08-01  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : implemented 
+         WriteKeyIdentifierClauseCore() for X509IssuerSerial (though
+         notworking due to X509IssuerSerialKeyIdentifierClause).
+
+2006-08-01  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : implemented WriteTokenCore() for
+         UserNameSecurityToken and X509SecurityToken.
+
+2006-07-31  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs :
+         DefaultInstance is a property, not a field.
+
+2006-07-31  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializer.cs : new file.
+
+2006-07-28  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * X509CertificateInitiatorServiceCredential.cs :
+         added missing Authentication property.
+       * X509ServiceCertificateAuthentication.cs,
+         X509ClientCertificateAuthentication.cs,
+         MessageSecurityException.cs :
+         new files.
+
+2006-07-28  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * IssuedTokenClientCredential.cs : some field initialization.
+       * IdentityVerifier.cs : added DefaultIdentityVerifier, though it
+         does not work.
+
+2006-07-28  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * IdentityVerifier.cs : new file.
+
+2006-07-27  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * InfocardInteractiveChannelInitializer.cs,
+         IssuedTokenServiceCredential.cs : new files.
+       * IssuedTokenClientCredential.cs,
+         X509CertificateInitiatorClientCredential.cs,
+         X509CertificateRecipientServiceCredential.cs,
+         X509CertificateInitiatorServiceCredential.cs :
+         some June CTP updates.
+
+2006-07-21  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * X509CertificateRecipientClientCredential.cs : July CTP API update.
+
+2006-07-21  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityTokenReferenceStyle.cs : it will be moved to S.SM.S.Tokens.
+
+2006-07-10  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * RequestSecurityToken.cs, RequestSecurityTokenResponse.cs :
+         removed old code.
+
+2006-07-10  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * BasicSecurityProfileVersion.cs : new file.
+       * SecurityAlgorithmSuite.cs : implemented properties.
+       * SecurityVersion.cs : In June CTP it became a class. Implemented
+         as long as it covers the public API.
+
+2006-07-05  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * IKeySizeValidator.cs : removed unused code.
+
+2006-05-29  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityStandardsManager.cs : vanished in beta2.
+       * FederationServiceIssuedSecurityTokenProvider.cs,
+         RequestSecurityToken.cs, RequestSecurityTokenResponse.cs :
+         SecurityStandardsManager -> SecurityTokenSerializer.
+
+2006-03-29  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * BinarySecretSecurityTokenAuthenticator.cs : added overrides, fix
+         the build.
+
+2006-03-23  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * FederationServiceIssuedSecurityTokenProvider.cs : make it compile
+         with the latest S.IM.dll.
+
+2006-02-23  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * BinarySecretSecurityTokenAuthenticator.cs
+         FederationServiceIssuedSecurityTokenProvider.cs
+         RequestSecurityToken.cs RequestSecurityTokenResponse.cs
+         SecurityCredentialsManager.cs SecurityMessageProperty.cs
+         SecurityStandardsManager.cs :
+
+         Dependent fixes for System.IdentityModel reorgainzation.
+
+2006-02-23  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * FederationServiceIssuedSecurityTokenProvider.cs :
+         System.IdentityModel dependent fix.
+
+2006-02-23  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : due to the big move between sys.servicemodel.dll and
+         sys.identitymodel.dll, moved some dummy classes as well.
+
+2006-02-23  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * ChangeLog-System.ServiceModel.Security.Protocols :
+         moved old ChangeLog in that dir to here.
+
+2006-02-23  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * BinarySecretSecurityTokenAuthenticator.cs RequestSecurityToken.cs
+         FederationServiceIssuedSecurityTokenProvider.cs
+         ChannelProtectionRequirements.cs SecurityNegotiationException.cs
+         RequestSecurityTokenResponse.cs IKeySizeValidator.cs
+         ScopedMessagePartSpecification.cs :
+         Moved from obsoleted System.ServiceModel.Security.Protocols.
+
+2006-02-23  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * KeyEntropyMode.cs KeyType.cs MessageProtectionOrder.cs
+         SecurityAlgorithmSuite.cs SecurityAlgorithms.cs
+         SecurityCredentialsManager.cs SecurityMessageProperty.cs
+         SecurityStandardsManager.cs SecurityTokenAttachmentMode.cs
+         SecurityTokenReferenceStyle.cs SecurityVersion.cs :
+         Feb. CTP API changes - chapter 1.
+
+2005-11-20  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityTokenProvider.cs, SecurityTokenAttachmentMode.cs,
+         MessageProtectionOrder.cs, SecurityStandardsManager.cs :
+         Dummy.cs : updated to beta2.
+       * IssuedTokenProvider.cs : removed in beta2.
+
+2005-11-02  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityTokenAttachmentMode.cs, MessageProtectionOrder.cs,
+         KeyType.cs, SecurityTokenReferenceStyle.cs : added missing enums.
+       * Dummy.cs : removed above.
+       * SecurityVersion.cs, KeyEntropyMode.cs : value fixes.
+
+2005-11-01  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * KeyEntropyMode.cs : new file.
+       * Dummy.cs : removed.
+
+2005-10-31  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityTokenProvider.cs : added missing bits and MonoTODO.
+
+2005-10-31  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityVersion.cs, SecurityAlgorithms.cs,
+         SecurityStandardsManager.cs, SecurityAlgorithmSuite.cs,
+         SecurityTokenResolver.cs : new files.
+       * Dummy.cs : removed above.
+       * IssuedTokenProvider.cs : tiny method signature fix.
+
+2005-10-18  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityMessageProperty.cs : new file.
+       * Dummy.cs : removed above.
+
+2005-10-12  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityCredentialsManager.cs : new file.
+       * Dummy.cs : removed above.
+
+2005-09-28  Atsushi Emomoto  <atsushi@ximian.com>
+
+       * SecurityTokenProvider.cs, IssuedTokenProvider.cs : new files.
+       * Dummy.cs : removed those new classes.
+
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog-System.ServiceModel.Security.Protocols b/mcs/class/System.ServiceModel/System.ServiceModel.Security/ChangeLog-System.ServiceModel.Security.Protocols
new file mode 100755 (executable)
index 0000000..01fb79d
--- /dev/null
@@ -0,0 +1,31 @@
+2005-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BinarySecretSecurityTokenAuthenticator.cs
+         ChannelProtectionRequirements.cs
+         FederationServiceIssuedSecurityTokenProvider.cs
+         IKeySizeValidator.cs RequestSecurityToken.cs
+         RequestSecurityTokenResponse.cs ScopedMessagePartSpecification.cs
+         SecurityNegotiationException.cs :
+         Feb. CTP API changes - chapter 1.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * RequestSecurityTokenResponse.cs,
+         FederationServiceIssuedSecurityTokenProvider.cs,
+         SecurityNegotiationException.cs : updated to beta2.
+
+2005-10-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BinarySecretSecurityTokenAuthenticator.cs,
+         RequestSecurityTokenResponse.cs,
+         FederationServiceIssuedSecurityTokenProvider.cs,
+         IKeySizeValidator.cs,
+         SecurityNegotiationException.cs,
+         ScopedMessagePartSpecification.cs : added all remaining stuff.
+       * Dummy.cs : thus removed itself.
+
+2005-10-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelProtectionRequirements.cs,
+         RequestSecurityTokens.cs : new files.
+       * Dummy.cs : removed above.
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/ChannelProtectionRequirements.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/ChannelProtectionRequirements.cs
new file mode 100644 (file)
index 0000000..f2802a0
--- /dev/null
@@ -0,0 +1,212 @@
+//
+// ChannelProtectionRequirements.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net.Security;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.Xml;
+
+namespace System.ServiceModel.Security
+{
+       // Represents sp:SignedParts and sp:EncryptedParts in
+       // sp:SupportingTokens/ws:Policy/.
+       public class ChannelProtectionRequirements
+       {
+               bool is_readonly;
+               ScopedMessagePartSpecification in_enc, in_sign, out_enc, out_sign;
+
+               public ChannelProtectionRequirements ()
+               {
+                       in_enc = new ScopedMessagePartSpecification ();
+                       out_enc = new ScopedMessagePartSpecification ();
+                       in_sign = new ScopedMessagePartSpecification ();
+                       out_sign = new ScopedMessagePartSpecification ();
+               }
+
+               public ChannelProtectionRequirements (
+                       ChannelProtectionRequirements other)
+               {
+                       if (other == null)
+                               throw new ArgumentNullException ("other");
+                       in_enc = new ScopedMessagePartSpecification (other.in_enc);
+                       out_enc = new ScopedMessagePartSpecification (other.out_enc);
+                       in_sign = new ScopedMessagePartSpecification (other.in_sign);
+                       out_sign = new ScopedMessagePartSpecification (other.out_sign);
+               }
+
+               public bool IsReadOnly {
+                       get { return is_readonly; }
+               }
+
+               public ScopedMessagePartSpecification IncomingEncryptionParts {
+                       get { return in_enc; }
+               }
+
+               public ScopedMessagePartSpecification IncomingSignatureParts {
+                       get { return in_sign; }
+               }
+
+               public ScopedMessagePartSpecification OutgoingEncryptionParts {
+                       get { return out_enc; }
+               }
+
+               public ScopedMessagePartSpecification OutgoingSignatureParts {
+                       get { return out_sign; }
+               }
+
+               public void Add (
+                       ChannelProtectionRequirements protectionRequirements)
+               {
+                       Add (protectionRequirements, false);
+               }
+
+               public void Add (
+                       ChannelProtectionRequirements protectionRequirements,
+                       bool channelScopeOnly)
+               {
+                       if (is_readonly)
+                               throw new InvalidOperationException ("This ChannelProtectionRequirements is read-only.");
+
+                       AddScopedParts (
+                               protectionRequirements.IncomingEncryptionParts, 
+                               IncomingEncryptionParts,
+                               channelScopeOnly);
+                       AddScopedParts (
+                               protectionRequirements.IncomingSignatureParts, 
+                               IncomingSignatureParts,
+                               channelScopeOnly);
+                       AddScopedParts (
+                               protectionRequirements.OutgoingEncryptionParts, 
+                               OutgoingEncryptionParts,
+                               channelScopeOnly);
+                       AddScopedParts (
+                               protectionRequirements.OutgoingSignatureParts, 
+                               OutgoingSignatureParts,
+                               channelScopeOnly);
+               }
+
+               void AddScopedParts (ScopedMessagePartSpecification src, ScopedMessagePartSpecification dst, bool channelOnly)
+               {
+                       dst.AddParts (src.ChannelParts);
+                       if (channelOnly)
+                               return;
+
+                       foreach (string a in src.Actions) {
+                               MessagePartSpecification m;
+                               src.TryGetParts (a, out m);
+                               src.AddParts (m);
+                       }
+               }
+
+               public ChannelProtectionRequirements CreateInverse ()
+               {
+                       ChannelProtectionRequirements r =
+                               new ChannelProtectionRequirements ();
+                       AddScopedParts (in_enc, r.out_enc, false);
+                       AddScopedParts (in_sign, r.out_sign, false);
+                       AddScopedParts (out_enc, r.in_enc, false);
+                       AddScopedParts (out_sign, r.in_sign, false);
+                       return r;
+               }
+
+               public void MakeReadOnly ()
+               {
+                       is_readonly = true;
+                       in_enc.MakeReadOnly ();
+                       in_sign.MakeReadOnly ();
+                       out_enc.MakeReadOnly ();
+                       out_sign.MakeReadOnly ();
+               }
+
+               internal static ChannelProtectionRequirements CreateFromContract (ContractDescription cd)
+               {
+                       ChannelProtectionRequirements cp =
+                               new ChannelProtectionRequirements ();
+                       List<XmlQualifiedName> enc = new List<XmlQualifiedName> ();
+                       List<XmlQualifiedName> sig = new List<XmlQualifiedName> ();
+                       if (cd.HasProtectionLevel) {
+                               switch (cd.ProtectionLevel) {
+                               case ProtectionLevel.EncryptAndSign:
+                                       cp.IncomingEncryptionParts.ChannelParts.IsBodyIncluded = true;
+                                       cp.OutgoingEncryptionParts.ChannelParts.IsBodyIncluded = true;
+                                       goto case ProtectionLevel.Sign;
+                               case ProtectionLevel.Sign:
+                                       cp.IncomingSignatureParts.ChannelParts.IsBodyIncluded = true;
+                                       cp.OutgoingSignatureParts.ChannelParts.IsBodyIncluded = true;
+                                       break;
+                               }
+                       }
+                       foreach (OperationDescription od in cd.Operations) {
+                               foreach (MessageDescription md in od.Messages) {
+                                       enc.Clear ();
+                                       sig.Clear ();
+                                       ProtectionLevel mplv =
+                                               md.HasProtectionLevel ? md.ProtectionLevel :
+                                               od.HasProtectionLevel ? od.ProtectionLevel :
+                                               ProtectionLevel.EncryptAndSign; // default
+                                       foreach (MessageHeaderDescription hd in md.Headers)
+                                               AddPartProtectionRequirements (enc, sig, hd, cp);
+
+                                       ScopedMessagePartSpecification spec;
+                                       bool includeBodyEnc = mplv == ProtectionLevel.EncryptAndSign;
+                                       bool includeBodySig = mplv != ProtectionLevel.None;
+
+                                       // enc
+                                       spec = md.Direction == MessageDirection.Input ?
+                                               cp.IncomingEncryptionParts :
+                                               cp.OutgoingEncryptionParts;
+                                       spec.AddParts (new MessagePartSpecification (includeBodyEnc, enc.ToArray ()), md.Action);
+                                       // sig
+                                       spec = md.Direction == MessageDirection.Input ?
+                                               cp.IncomingSignatureParts :
+                                               cp.OutgoingSignatureParts;
+                                       spec.AddParts (new MessagePartSpecification (includeBodySig, sig.ToArray ()), md.Action);
+                               }
+                       }
+                       return cp;
+               }
+
+               static void AddPartProtectionRequirements (List<XmlQualifiedName> enc,
+                       List<XmlQualifiedName> sig,
+                       MessageHeaderDescription pd,
+                       ChannelProtectionRequirements cp)
+               {
+                       if (!pd.HasProtectionLevel)
+                               return; // no specific part indication
+                       switch (pd.ProtectionLevel) {
+                       case ProtectionLevel.EncryptAndSign:
+                               enc.Add (new XmlQualifiedName (pd.Name, pd.Namespace));
+                               goto case ProtectionLevel.Sign;
+                       case ProtectionLevel.Sign:
+                               sig.Add (new XmlQualifiedName (pd.Name, pd.Namespace));
+                               break;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/DataProtectionSecurityStateEncoder.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/DataProtectionSecurityStateEncoder.cs
new file mode 100644 (file)
index 0000000..998359d
--- /dev/null
@@ -0,0 +1,78 @@
+//
+// DataProtectionSecurityStateEncoder.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Security.Cryptography;
+
+namespace System.ServiceModel.Security
+{
+       public class DataProtectionSecurityStateEncoder : SecurityStateEncoder
+       {
+               public DataProtectionSecurityStateEncoder ()
+                       : this (true)
+               {
+               }
+
+               public DataProtectionSecurityStateEncoder (bool useCurrentUserProtectionScope)
+               {
+                       user = useCurrentUserProtectionScope;
+               }
+
+               public DataProtectionSecurityStateEncoder (bool useCurrentUserProtectionScope, byte [] entropy)
+               {
+                       user = useCurrentUserProtectionScope;
+                       this.entropy = entropy;
+               }
+
+               bool user;
+               byte [] entropy;
+
+               public bool UseCurrentUserProtectionScope {
+                       get { return user; }
+               }
+
+               public byte [] GetEntropy ()
+               {
+                       return entropy == null ? null : (byte []) entropy.Clone ();
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+
+               protected internal override byte [] DecodeSecurityState (byte [] data)
+               {
+                       return ProtectedData.Unprotect (data, entropy, DataProtectionScope.CurrentUser);
+               }
+
+               protected internal override byte [] EncodeSecurityState (byte [] data)
+               {
+                       return ProtectedData.Protect (data, entropy, DataProtectionScope.CurrentUser);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/ExpiredSecurityTokenException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/ExpiredSecurityTokenException.cs
new file mode 100644 (file)
index 0000000..26864ee
--- /dev/null
@@ -0,0 +1,65 @@
+//
+// ExpiredSecurityTokenException.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IdentityModel.Tokens;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Security
+{
+       [Serializable]
+       public class ExpiredSecurityTokenException : MessageSecurityException
+       {
+               public ExpiredSecurityTokenException ()
+                       : this ("The security token is expired.")
+               {
+               }
+
+               public ExpiredSecurityTokenException (string message)
+                       : base (message)
+               {
+               }
+
+               public ExpiredSecurityTokenException (string message,
+                       Exception innerException)
+                       : base (message, innerException)
+               {
+               }
+
+               protected ExpiredSecurityTokenException (SerializationInfo info,
+                       StreamingContext context)
+                       : base (info, context)
+               {
+               }
+
+               public override void GetObjectData (SerializationInfo info,  StreamingContext ctx)
+               {
+                       base.GetObjectData (info, ctx);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/HttpDigestClientCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/HttpDigestClientCredential.cs
new file mode 100644 (file)
index 0000000..572f35e
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// HttpDigestClientCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Net;
+using System.Security.Principal;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel.Security
+{
+       public sealed class HttpDigestClientCredential
+       {
+               internal HttpDigestClientCredential ()
+               {
+               }
+
+               NetworkCredential credential = new NetworkCredential ();
+               TokenImpersonationLevel level;
+
+               public NetworkCredential ClientCredential {
+                       get { return credential; }
+                       set { credential = value; }
+               }
+               public TokenImpersonationLevel AllowedImpersonationLevel {
+                       get { return level; }
+                       set { level = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/IEndpointIdentityProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/IEndpointIdentityProvider.cs
new file mode 100644 (file)
index 0000000..fca9d91
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// IEndpointIdentityProvider.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Selectors;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Security
+{
+       public interface IEndpointIdentityProvider
+       {
+               EndpointIdentity GetIdentityOfSelf (SecurityTokenRequirement tokenRequirement);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/ISecureConversationSession.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/ISecureConversationSession.cs
new file mode 100644 (file)
index 0000000..a242a86
--- /dev/null
@@ -0,0 +1,39 @@
+//
+// ISecureConversationSession.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.ServiceModel;
+using System.Xml;
+
+namespace System.ServiceModel.Security
+{
+       public interface ISecureConversationSession : ISecuritySession
+       {
+               bool TryReadSessionTokenIdentifier (XmlReader reader);
+
+               void WriteSessionTokenIdentifier (XmlDictionaryWriter writer);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/ISecuritySession.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/ISecuritySession.cs
new file mode 100644 (file)
index 0000000..4886723
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// ISecuritySession.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Security
+{
+       public interface ISecuritySession : ISession
+       {
+               EndpointIdentity RemoteIdentity { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/IdentityVerifier.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/IdentityVerifier.cs
new file mode 100644 (file)
index 0000000..7d2ecb4
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// IdentityVerifier.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.IdentityModel.Claims;
+using System.IdentityModel.Policy;
+using System.ServiceModel;
+
+namespace System.ServiceModel.Security
+{
+       [MonoTODO]
+       public abstract class IdentityVerifier
+       {
+               [MonoTODO]
+               public static IdentityVerifier CreateDefault ()
+               {
+                       return new DefaultIdentityVerifier ();
+               }
+
+               protected IdentityVerifier ()
+               {
+               }
+
+               public abstract bool CheckAccess (EndpointIdentity identity,
+                       AuthorizationContext authContext);
+
+               public abstract bool TryGetIdentity (EndpointAddress reference,
+                       out EndpointIdentity identity);
+
+               class DefaultIdentityVerifier : IdentityVerifier
+               {
+                       public override bool CheckAccess (
+                               EndpointIdentity identity,
+                               AuthorizationContext authContext)
+                       {
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       }
+
+                       public override bool TryGetIdentity (
+                               EndpointAddress reference,
+                               out EndpointIdentity identity)
+                       {
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       }
+               }
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/InfocardInteractiveChannelInitializer.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/InfocardInteractiveChannelInitializer.cs
new file mode 100644 (file)
index 0000000..a55f95a
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// InfocardInteractiveChannelInitializer.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel.Security
+{
+
+       [MonoTODO]
+       public class InfocardInteractiveChannelInitializer
+               : IInteractiveChannelInitializer
+       {
+               [MonoTODO]
+               public InfocardInteractiveChannelInitializer (
+                       ClientCredentials credentials,
+                       Binding binding)
+               {
+                       this.binding = binding;
+                       this.credentials = credentials;
+               }
+
+               Binding binding;
+               ClientCredentials credentials;
+
+               public Binding Binding {
+                       get { return binding; }
+               }
+
+               [MonoTODO]
+               public IAsyncResult BeginDisplayInitializationUI (
+                       IClientChannel channel,
+                       AsyncCallback callback,
+                       object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void EndDisplayInitializationUI (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/IssuedTokenClientCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/IssuedTokenClientCredential.cs
new file mode 100644 (file)
index 0000000..cb45d68
--- /dev/null
@@ -0,0 +1,95 @@
+//
+// IssuedTokenClientCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       [MonoTODO]
+       public sealed class IssuedTokenClientCredential
+       {
+               internal IssuedTokenClientCredential ()
+               {
+               }
+
+               bool cache = true;
+               Dictionary<Uri,KeyedByTypeCollection<IEndpointBehavior>> behaviors =
+                       new Dictionary<Uri,KeyedByTypeCollection<IEndpointBehavior>> ();
+               SecurityKeyEntropyMode entropy = SecurityKeyEntropyMode.CombinedEntropy;
+               KeyedByTypeCollection<IEndpointBehavior> local_behaviors =
+                       new KeyedByTypeCollection<IEndpointBehavior> ();
+               EndpointAddress local_issuer_address;
+               Binding local_issuer_binding;
+               TimeSpan max_cache_time = TimeSpan.MaxValue;
+               // FIXME: could be related to LocalClientSecuritysettings.CookieRenewalThresholdPercentage ?
+               int renewal_threshold = 60;
+
+               public bool CacheIssuedTokens {
+                       get { return cache; }
+                       set { cache = value; }
+               }
+
+               public int IssuedTokenRenewalThresholdPercentage {
+                       get { return renewal_threshold; }
+                       set { renewal_threshold = value; }
+               }
+
+               public Dictionary<Uri,KeyedByTypeCollection<IEndpointBehavior>> IssuerChannelBehaviors {
+                       get { return behaviors; }
+               }
+
+               public SecurityKeyEntropyMode DefaultKeyEntropyMode {
+                       get { return entropy; }
+                       set { entropy = value; }
+               }
+
+               public KeyedByTypeCollection<IEndpointBehavior> LocalIssuerChannelBehaviors { 
+                       get { return local_behaviors; }
+               }
+
+               public EndpointAddress LocalIssuerAddress {
+                       get { return local_issuer_address; }
+                       set { local_issuer_address = value; }
+               }
+
+               public Binding LocalIssuerBinding {
+                       get { return local_issuer_binding; }
+                       set { local_issuer_binding = value; }
+               }
+
+               public TimeSpan MaxIssuedTokenCachingTime {
+                       get { return max_cache_time; }
+                       set { max_cache_time = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/IssuedTokenServiceCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/IssuedTokenServiceCredential.cs
new file mode 100644 (file)
index 0000000..70d713d
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// IssuedTokenServiceCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Security.Cryptography.X509Certificates;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       [MonoTODO]
+       public class IssuedTokenServiceCredential
+       {
+               bool allow_untrusted_rsa_issuers;
+               X509CertificateValidationMode cert_verify_mode =
+                       X509CertificateValidationMode.ChainTrust;
+               X509CertificateValidator custom_cert_validator;
+               List<X509Certificate2> known_certs = new List<X509Certificate2> ();
+               X509RevocationMode revocation_mode = X509RevocationMode.Online;
+               SamlSerializer saml_serializer;
+               StoreLocation store_location = StoreLocation.LocalMachine;
+
+               internal IssuedTokenServiceCredential ()
+               {
+               }
+
+               [MonoTODO]
+               public bool AllowUntrustedRsaIssuers {
+                       get { return allow_untrusted_rsa_issuers; }
+                       set { allow_untrusted_rsa_issuers = value; }
+               }
+
+               [MonoTODO]
+               public X509CertificateValidationMode CertificateValidationMode {
+                       get { return cert_verify_mode; }
+                       set { cert_verify_mode = value; }
+               }
+
+               [MonoTODO]
+               public X509CertificateValidator CustomCertificateValidator {
+                       get { return custom_cert_validator; }
+                       set { custom_cert_validator = value; }
+               }
+
+               [MonoTODO]
+               public IList<X509Certificate2> KnownCertificates {
+                       get { return known_certs; }
+               }
+
+               [MonoTODO]
+               public X509RevocationMode RevocationMode {
+                       get { return revocation_mode; }
+                       set { revocation_mode = value; }
+               }
+
+               [MonoTODO]
+               public SamlSerializer SamlSerializer {
+                       get { return saml_serializer; }
+                       set { saml_serializer = value; }
+               }
+
+               [MonoTODO]
+               public StoreLocation TrustedStoreLocation {
+                       get { return store_location; }
+                       set { store_location = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/KeyEntropyMode.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/KeyEntropyMode.cs
new file mode 100644 (file)
index 0000000..c4acbd2
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// SecurityKeyEntropyMode.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Security
+{
+       public enum SecurityKeyEntropyMode
+       {
+               ClientEntropy,
+               ServerEntropy,
+               CombinedEntropy,
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/KeyNameIdentifierClause.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/KeyNameIdentifierClause.cs
new file mode 100644 (file)
index 0000000..079f209
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// KeyNameIdentifierClause.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Xml;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       public class KeyNameIdentifierClause : SecurityKeyIdentifierClause
+       {
+               public KeyNameIdentifierClause (string keyName)
+                       : base (keyName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               string key_name;
+
+               public string KeyName {
+                       get { return key_name; }
+               }
+
+               public override bool Matches (SecurityKeyIdentifierClause clause)
+               {
+                       if (clause == null)
+                               throw new ArgumentNullException ("clause");
+                       KeyNameIdentifierClause knic =
+                               clause as KeyNameIdentifierClause;
+                       return knic != null && Matches (knic.KeyName);
+               }
+
+               public bool Matches (string keyName)
+               {
+                       return key_name == keyName;
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/MessagePartSpecification.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/MessagePartSpecification.cs
new file mode 100644 (file)
index 0000000..17695f1
--- /dev/null
@@ -0,0 +1,111 @@
+//
+// MessagePartSpecification.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Xml;
+
+namespace System.ServiceModel.Security
+{
+       // Represents WS-SecurityPolicy SignedParts or EncryptedParts.
+       public class MessagePartSpecification
+       {
+               static XmlQualifiedName [] empty = new XmlQualifiedName [0];
+               static MessagePartSpecification no_parts =
+                       new MessagePartSpecification ();
+
+               public static MessagePartSpecification NoParts {
+                       get { return no_parts; }
+               }
+
+               public MessagePartSpecification ()
+                       : this (empty)
+               {
+               }
+
+               public MessagePartSpecification (
+                       bool isBodyIncluded)
+                       : this (isBodyIncluded, empty)
+               {
+               }
+
+               public MessagePartSpecification (params XmlQualifiedName[] headerTypes)
+                       : this (false, headerTypes)
+               {
+               }
+
+               public MessagePartSpecification (
+                       bool isBodyIncluded,
+                       params XmlQualifiedName[] headerTypes)
+               {
+                       body = isBodyIncluded;
+                       header_types = new List<XmlQualifiedName> (headerTypes);
+               }
+
+               bool body;
+               IList<XmlQualifiedName> header_types;
+
+               public ICollection<XmlQualifiedName> HeaderTypes {
+                       get { return header_types; }
+               }
+
+               public bool IsBodyIncluded {
+                       get { return body; }
+                       set { body = value; }
+               }
+
+               public bool IsReadOnly {
+                       get { return header_types.IsReadOnly; }
+               }
+
+               public void Clear ()
+               {
+                       header_types.Clear ();
+               }
+
+               public void MakeReadOnly ()
+               {
+                       if (!header_types.IsReadOnly)
+                               header_types = new ReadOnlyCollection<XmlQualifiedName> (header_types);
+               }
+
+               public void Union (MessagePartSpecification other)
+               {
+                       if (other == null)
+                               throw new ArgumentNullException ("other");
+                       if (header_types.IsReadOnly)
+                               throw new InvalidOperationException ("This MessagePartSpecification is read-only.");
+                       body |= other.body;
+                       foreach (XmlQualifiedName q in other.header_types)
+                               // Sigh. It could be much better here.
+                               //if (!header_types.Contains (q))
+                                       header_types.Add (q);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/MessageProtectionOrder.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/MessageProtectionOrder.cs
new file mode 100644 (file)
index 0000000..9ce51a8
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// MessageProtectionOrder.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Security
+{
+       public enum MessageProtectionOrder
+       {
+               SignBeforeEncrypt,
+               SignBeforeEncryptAndEncryptSignature,
+               EncryptBeforeSign,
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/MessageSecurityException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/MessageSecurityException.cs
new file mode 100644 (file)
index 0000000..f209a43
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// MessageSecurityException.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Security
+{
+       [Serializable]
+       public class MessageSecurityException : CommunicationException
+       {
+               public MessageSecurityException ()
+                       : this ("Message security exception has happened.")
+               {
+               }
+
+               public MessageSecurityException (string message)
+                       : base (message)
+               {
+               }
+
+               public MessageSecurityException (string message,
+                       Exception innerException)
+                       : base (message, innerException)
+               {
+               }
+
+               protected MessageSecurityException (SerializationInfo info,
+                       StreamingContext context)
+                       : base (info, context)
+               {
+               }
+
+               public override void GetObjectData (SerializationInfo info,  StreamingContext ctx)
+               {
+                       base.GetObjectData (info, ctx);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/PeerCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/PeerCredential.cs
new file mode 100644 (file)
index 0000000..e62be5b
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// PeerCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.Security.Cryptography.X509Certificates;
+
+namespace System.ServiceModel.Security
+{
+       public class PeerCredential
+       {
+               internal PeerCredential ()
+               {
+               }
+
+               X509Certificate2 cert;
+               string mesh_pwd;
+               X509PeerCertificateAuthentication cert_auth =
+                       new X509PeerCertificateAuthentication ();
+               X509PeerCertificateAuthentication peer_auth =
+                       new X509PeerCertificateAuthentication ();
+
+               public X509Certificate2 Certificate {
+                       get { return cert; }
+                       set { cert = value; }
+               }
+
+               public string MeshPassword {
+                       get { return mesh_pwd; }
+                       set { mesh_pwd = value; }
+               }
+
+               public X509PeerCertificateAuthentication MessageSenderAuthentication {
+                       get { return cert_auth; }
+                       // huh, should there be a setter?
+                       set { cert_auth = value; }
+               }
+
+               public X509PeerCertificateAuthentication PeerAuthentication {
+                       get { return peer_auth; }
+                       set { peer_auth = value; }
+               }
+
+               [MonoTODO]
+               public void SetCertificate (string subjectName, StoreLocation storeLocation, StoreName storeName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void SetCertificate (StoreLocation storeLocation, StoreName storeName, X509FindType findType, object findValue)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/ScopedMessagePartSpecification.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/ScopedMessagePartSpecification.cs
new file mode 100644 (file)
index 0000000..a517fc7
--- /dev/null
@@ -0,0 +1,114 @@
+//
+// ScopedMessagePartSpecification.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.Xml;
+
+namespace System.ServiceModel.Security
+{
+       public class ScopedMessagePartSpecification
+       {
+               public ScopedMessagePartSpecification ()
+               {
+                       table = new Dictionary<string,MessagePartSpecification> ();
+                       parts = new MessagePartSpecification ();
+               }
+
+               public ScopedMessagePartSpecification (
+                       ScopedMessagePartSpecification other)
+               {
+                       XmlQualifiedName [] array = new XmlQualifiedName [other.parts.HeaderTypes.Count];
+                       other.parts.HeaderTypes.CopyTo (array, 0);
+                       parts = new MessagePartSpecification (
+                               other.parts.IsBodyIncluded, array);
+                       table = new Dictionary<string,MessagePartSpecification> (other.table);
+               }
+
+               Dictionary<string,MessagePartSpecification> table;
+               MessagePartSpecification parts;
+               bool is_readonly;
+
+               public ICollection<string> Actions {
+                       get { return table.Keys; }
+               }
+
+               public MessagePartSpecification ChannelParts {
+                       get { return parts; }
+               }
+
+               public bool IsReadOnly {
+                       get { return is_readonly; }
+               }
+
+               public void AddParts (MessagePartSpecification parts)
+               {
+                       if (parts == null)
+                               throw new ArgumentNullException ("parts");
+                       if (IsReadOnly)
+                               throw new InvalidOperationException ("This ScopedMessagePartSpecification is read-only.");
+                       ChannelParts.Union (parts);
+               }
+
+               public void AddParts (MessagePartSpecification parts,
+                       string action)
+               {
+                       if (parts == null)
+                               throw new ArgumentNullException ("parts");
+                       if (action == null)
+                               throw new ArgumentNullException ("action");
+                       if (IsReadOnly)
+                               throw new InvalidOperationException ("This ScopedMessagePartSpecification is read-only.");
+
+                       MessagePartSpecification existing;
+                       if (table.TryGetValue (action, out existing))
+                               existing.Union (parts);
+                       else
+                               table.Add (action, parts);
+               }
+
+               public void MakeReadOnly ()
+               {
+                       is_readonly = true;
+               }
+
+               public bool TryGetParts (
+                       string action, out MessagePartSpecification parts)
+               {
+                       return TryGetParts (action, false, out parts);
+               }
+
+               public bool TryGetParts (
+                       string action, bool excludeChannelScope,
+                       out MessagePartSpecification parts)
+               {
+                       return table.TryGetValue (action, out parts);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecureConversationServiceCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecureConversationServiceCredential.cs
new file mode 100644 (file)
index 0000000..87d432c
--- /dev/null
@@ -0,0 +1,63 @@
+//
+// SecureConversationServiceCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Tokens;
+using System.Web.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       public sealed class SecureConversationServiceCredential
+       {
+               Collection<Type> ctx_claim_types = new Collection<Type> (new Type [] {
+                       typeof (SamlAuthorizationDecisionClaimResource),
+                       typeof (SamlAuthenticationClaimResource),
+                       typeof (SamlAccessDecision),
+                       typeof (SamlAuthorityBinding),
+                       typeof (SamlNameIdentifierClaimResource)});
+               SecurityStateEncoder encoder =
+                       new DataProtectionSecurityStateEncoder ();
+
+               internal SecureConversationServiceCredential ()
+               {
+               }
+
+               public Collection<Type> SecurityContextClaimTypes {
+                       get { return ctx_claim_types; }
+               }
+
+               public SecurityStateEncoder SecurityStateEncoder {
+                       get { return encoder; }
+                       set { encoder = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityAccessDeniedException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityAccessDeniedException.cs
new file mode 100644 (file)
index 0000000..edd5d9c
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// SecurityAccessDeniedException.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Security
+{
+       [Serializable]
+       public class SecurityAccessDeniedException : CommunicationException
+       {
+               public SecurityAccessDeniedException ()
+                       : this ("Access is denied for some security reason.")
+               {
+               }
+
+               public SecurityAccessDeniedException (string message)
+                       : base (message)
+               {
+               }
+
+               public SecurityAccessDeniedException (string message,
+                       Exception innerException)
+                       : base (message, innerException)
+               {
+               }
+
+               protected SecurityAccessDeniedException (SerializationInfo info,
+                       StreamingContext context)
+                       : base (info, context)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityAlgorithmSuite.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityAlgorithmSuite.cs
new file mode 100644 (file)
index 0000000..bf7ce83
--- /dev/null
@@ -0,0 +1,445 @@
+//
+// SecurityAlgorithmSuite.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       public abstract class SecurityAlgorithmSuite
+       {
+               #region Internal Class
+
+               class BasicSecurityAlgorithmSuite : SecurityAlgorithmSuiteImplBase
+               {
+                       public BasicSecurityAlgorithmSuite (int size, bool sha, bool rsa)
+                               : base (size, sha, rsa, false)
+                       {
+                       }
+
+                       public override int DefaultSignatureKeyDerivationLength {
+                               get { return Size > 192 ? 192 : Size; }
+                       }
+
+                       public override bool IsAsymmetricKeyLengthSupported (int length)
+                       {
+                               switch (length) {
+                               case 128:
+                               case 192:
+                                       return Size >= length;
+                               }
+                               return false;
+                       }
+
+                       public override bool IsSymmetricKeyLengthSupported (int length)
+                       {
+                               switch (length) {
+                               case 128:
+                               case 192:
+                               case 256:
+                                       return Size >= length;
+                               }
+                               return false;
+                       }
+
+                       public override bool IsSymmetricKeyWrapAlgorithmSupported (string algorithm)
+                       {
+                               switch (Size) {
+                               case 256:
+                                       if (algorithm == EncryptedXml.XmlEncAES256KeyWrapUrl)
+                                               return true;
+                                       goto case 192;
+                               case 192:
+                                       if (algorithm == EncryptedXml.XmlEncAES192KeyWrapUrl)
+                                               return true;
+                                       goto case 128;
+                               case 128:
+                                       return algorithm == EncryptedXml.XmlEncAES128KeyWrapUrl;
+                               }
+                               return false;
+                       }
+               }
+
+               class TripleDESSecurityAlgorithmSuite : SecurityAlgorithmSuiteImplBase
+               {
+                       public TripleDESSecurityAlgorithmSuite (bool sha, bool rsa)
+                               : base (192, sha, rsa, true)
+                       {
+                       }
+
+                       public override int DefaultSignatureKeyDerivationLength {
+                               get { return 192; }
+                       }
+
+                       public override bool IsAsymmetricKeyLengthSupported (int length)
+                       {
+                               return length == 192;
+                       }
+
+                       public override bool IsSymmetricKeyLengthSupported (int length)
+                       {
+                               return length == 192;
+                       }
+
+                       public override bool IsSymmetricKeyWrapAlgorithmSupported (
+                               string algorithm)
+                       {
+                               return algorithm == EncryptedXml.XmlEncTripleDESKeyWrapUrl;
+                       }
+               }
+
+               abstract class SecurityAlgorithmSuiteImplBase : SecurityAlgorithmSuite
+               {
+                       int size;
+                       bool rsa15, sha256, tdes;
+
+                       public SecurityAlgorithmSuiteImplBase (
+                               int size, bool sha256, bool rsa15, bool tripleDes)
+                       {
+                               this.size = size;
+                               this.sha256 = sha256;
+                               this.rsa15 = rsa15;
+                               this.tdes = tripleDes;
+                       }
+
+                       public int Size {
+                               get { return size; }
+                       }
+
+                       public bool Rsa15 {
+                               get { return rsa15; }
+                       }
+
+                       public bool Sha256 {
+                               get { return sha256; }
+                       }
+
+                       public override string DefaultAsymmetricKeyWrapAlgorithm {
+                               get { return rsa15 ? EncryptedXml.XmlEncRSA15Url : EncryptedXml.XmlEncRSAOAEPUrl; }
+                       }
+
+                       public override string DefaultAsymmetricSignatureAlgorithm {
+                               get { return sha256 ? SecurityAlgorithms.RsaSha256Signature : SignedXml.XmlDsigRSASHA1Url; }
+                       }
+
+                       public override string DefaultCanonicalizationAlgorithm {
+                               get { return SignedXml.XmlDsigExcC14NTransformUrl; }
+                       }
+
+
+                       public override string DefaultDigestAlgorithm {
+                               get { return sha256 ? EncryptedXml.XmlEncSHA256Url : SignedXml.XmlDsigSHA1Url; }
+                       }
+
+                       public override string DefaultEncryptionAlgorithm {
+                               get {
+                                       if (tdes)
+                                               return EncryptedXml.XmlEncTripleDESUrl;
+                                       switch (size) {
+                                       case 128:
+                                               return EncryptedXml.XmlEncAES128Url;
+                                       case 192:
+                                               return EncryptedXml.XmlEncAES192Url;
+                                       case 256:
+                                               return EncryptedXml.XmlEncAES256Url;
+                                       }
+                                       throw new Exception ("Should not happen.");
+                               }
+                       }
+
+                       public override int DefaultEncryptionKeyDerivationLength {
+                               get { return size; }
+                       }
+
+                       public override int DefaultSymmetricKeyLength {
+                               get { return size; }
+                       }
+
+                       public override string DefaultSymmetricKeyWrapAlgorithm {
+                               get {
+                                       if (tdes)
+                                               return EncryptedXml.XmlEncTripleDESKeyWrapUrl;
+                                       switch (size) {
+                                       case 128:
+                                               return EncryptedXml.XmlEncAES128KeyWrapUrl;
+                                       case 192:
+                                               return EncryptedXml.XmlEncAES192KeyWrapUrl;
+                                       case 256:
+                                               return EncryptedXml.XmlEncAES256KeyWrapUrl;
+                                       }
+                                       throw new Exception ("Should not happen.");
+                               }
+                       }
+
+                       public override string DefaultSymmetricSignatureAlgorithm {
+                               get { return sha256 ? SecurityAlgorithms.HmacSha256Signature : SignedXml.XmlDsigHMACSHA1Url; }
+                       }
+
+                       [MonoTODO]
+                       public override bool IsAsymmetricSignatureAlgorithmSupported (
+                               string algorithm)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       [MonoTODO]
+                       public override bool IsCanonicalizationAlgorithmSupported (
+                               string algorithm)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       [MonoTODO]
+                       public override bool IsDigestAlgorithmSupported (string algorithm)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       [MonoTODO]
+                       public override bool IsEncryptionAlgorithmSupported (
+                               string algorithm)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       [MonoTODO]
+                       public override bool IsEncryptionKeyDerivationAlgorithmSupported (
+                               string algorithm)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       [MonoTODO]
+                       public override bool IsSignatureKeyDerivationAlgorithmSupported (
+                               string algorithm)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       [MonoTODO]
+                       public override bool IsSymmetricSignatureAlgorithmSupported (
+                               string algorithm)
+                       {
+                               throw new NotImplementedException ();
+                       }
+               }
+
+               #endregion
+
+               #region Static members
+
+               static SecurityAlgorithmSuite b128, b128r, b128s, b128sr;
+               static SecurityAlgorithmSuite b192, b192r, b192s, b192sr;
+               static SecurityAlgorithmSuite b256, b256r, b256s, b256sr;
+               static SecurityAlgorithmSuite tdes, tdes_r, tdes_s, tdes_sr;
+
+               static SecurityAlgorithmSuite ()
+               {
+                       b128 = new BasicSecurityAlgorithmSuite (128, false, false);
+                       b128r = new BasicSecurityAlgorithmSuite (128, false, true);
+                       b128s = new BasicSecurityAlgorithmSuite (128, true, false);
+                       b128sr = new BasicSecurityAlgorithmSuite (128, true, true);
+                       b192 = new BasicSecurityAlgorithmSuite (192, false, false);
+                       b192r = new BasicSecurityAlgorithmSuite (192, false, true);
+                       b192s = new BasicSecurityAlgorithmSuite (192, true, false);
+                       b192sr = new BasicSecurityAlgorithmSuite (192, true, true);
+                       b256 = new BasicSecurityAlgorithmSuite (256, false, false);
+                       b256r = new BasicSecurityAlgorithmSuite (256, false, true);
+                       b256s = new BasicSecurityAlgorithmSuite (256, true, false);
+                       b256sr = new BasicSecurityAlgorithmSuite (256, true, true);
+                       tdes = new TripleDESSecurityAlgorithmSuite (false, false);
+                       tdes_r = new TripleDESSecurityAlgorithmSuite (false, true);
+                       tdes_s = new TripleDESSecurityAlgorithmSuite (true, false);
+                       tdes_sr = new TripleDESSecurityAlgorithmSuite (true, true);
+               }
+
+               public static SecurityAlgorithmSuite Default {
+                       get { return Basic256; }
+               }
+
+               public static SecurityAlgorithmSuite Basic128 {
+                       get { return b128; }
+               }
+
+               public static SecurityAlgorithmSuite Basic128Rsa15 {
+                       get { return b128r; }
+               }
+
+               public static SecurityAlgorithmSuite Basic128Sha256 {
+                       get { return b128s; }
+               }
+
+               public static SecurityAlgorithmSuite Basic128Sha256Rsa15 {
+                       get { return b128sr; }
+               }
+
+               public static SecurityAlgorithmSuite Basic192 {
+                       get { return b192; }
+               }
+
+               public static SecurityAlgorithmSuite Basic192Rsa15 {
+                       get { return b192r; }
+               }
+
+               public static SecurityAlgorithmSuite Basic192Sha256 {
+                       get { return b192s; }
+               }
+
+               public static SecurityAlgorithmSuite Basic192Sha256Rsa15 {
+                       get { return b192sr; }
+               }
+
+               public static SecurityAlgorithmSuite Basic256 {
+                       get { return b256; }
+               }
+
+               public static SecurityAlgorithmSuite Basic256Rsa15 {
+                       get { return b256r; }
+               }
+
+               public static SecurityAlgorithmSuite Basic256Sha256 {
+                       get { return b256s; }
+               }
+
+               public static SecurityAlgorithmSuite Basic256Sha256Rsa15 {
+                       get { return b256sr; }
+               }
+
+               public static SecurityAlgorithmSuite TripleDes {
+                       get { return tdes; }
+               }
+
+               public static SecurityAlgorithmSuite TripleDesRsa15 {
+                       get { return tdes_r; }
+               }
+
+               public static SecurityAlgorithmSuite TripleDesSha256 {
+                       get { return tdes_s; }
+               }
+
+               public static SecurityAlgorithmSuite TripleDesSha256Rsa15 {
+                       get { return tdes_sr; }
+               }
+
+               #endregion
+
+               #region Instance members
+
+               protected SecurityAlgorithmSuite ()
+               {
+               }
+
+               public abstract string DefaultAsymmetricKeyWrapAlgorithm { get; }
+
+               public abstract string DefaultAsymmetricSignatureAlgorithm { get; }
+
+               public abstract string DefaultCanonicalizationAlgorithm { get; }
+
+               public abstract string DefaultDigestAlgorithm { get; }
+
+               public abstract string DefaultEncryptionAlgorithm { get; }
+
+               public abstract int DefaultEncryptionKeyDerivationLength { get; }
+
+               public abstract int DefaultSignatureKeyDerivationLength { get; }
+
+               public abstract int DefaultSymmetricKeyLength { get; }
+
+               public abstract string DefaultSymmetricKeyWrapAlgorithm { get; }
+
+               public abstract string DefaultSymmetricSignatureAlgorithm { get; }
+
+                       public virtual bool IsAsymmetricKeyWrapAlgorithmSupported (
+                               string algorithm)
+                       {
+                               return algorithm == DefaultAsymmetricKeyWrapAlgorithm;
+                       }
+
+               public abstract bool IsAsymmetricKeyLengthSupported (int length);
+
+               public virtual bool IsAsymmetricSignatureAlgorithmSupported (
+                       string algorithm)
+               {
+                               return algorithm == DefaultAsymmetricSignatureAlgorithm;
+               }
+
+               [MonoTODO]
+               public virtual bool IsCanonicalizationAlgorithmSupported (
+                       string algorithm)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public virtual bool IsDigestAlgorithmSupported (string algorithm)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public virtual bool IsEncryptionAlgorithmSupported (
+                       string algorithm)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public virtual bool IsEncryptionKeyDerivationAlgorithmSupported (
+                       string algorithm)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public virtual bool IsSignatureKeyDerivationAlgorithmSupported (
+                       string algorithm)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public abstract bool IsSymmetricKeyLengthSupported (int length);
+
+               [MonoTODO]
+               public virtual bool IsSymmetricKeyWrapAlgorithmSupported (
+                       string algorithm)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public virtual bool IsSymmetricSignatureAlgorithmSupported (
+                       string algorithm)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityContextKeyIdentifierClause.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityContextKeyIdentifierClause.cs
new file mode 100644 (file)
index 0000000..2ac33ba
--- /dev/null
@@ -0,0 +1,84 @@
+//
+// SecurityContextKeyIdentifierClause.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Xml;
+
+namespace System.ServiceModel.Security
+{
+       public class SecurityContextKeyIdentifierClause : SecurityKeyIdentifierClause
+       {
+               public SecurityContextKeyIdentifierClause (UniqueId contextId)
+                       : this (contextId, new UniqueId ())
+               {
+               }
+
+               public SecurityContextKeyIdentifierClause (UniqueId contextId, UniqueId generation)
+                       : this (contextId, generation, null, 0)
+               {
+               }
+
+               public SecurityContextKeyIdentifierClause (UniqueId contextId, UniqueId generation, byte [] derivationNonce, int derivationLength)
+                       : base (null, derivationNonce, derivationLength)
+               {
+                       this.context = contextId;
+                       this.generation = generation;
+               }
+
+               UniqueId context, generation;
+
+               public UniqueId ContextId {
+                       get { return context; }
+               }
+
+               public UniqueId Generation {
+                       get { return generation; }
+               }
+
+               public override bool Matches (
+                       SecurityKeyIdentifierClause keyIdentifierClause)
+               {
+                       SecurityContextKeyIdentifierClause other =
+                               keyIdentifierClause as SecurityContextKeyIdentifierClause;
+                       return  other != null && Matches (other.context, other.generation);
+               }
+
+               public bool Matches (UniqueId contextId, UniqueId generation)
+               {
+                       return context == contextId &&
+                               this.generation == generation;
+               }
+
+               [MonoTODO]
+               public override string ToString ()
+               {
+                       return base.ToString ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityCredentialsManager.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityCredentialsManager.cs
new file mode 100644 (file)
index 0000000..2b6a914
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// SecurityCredentialsManager.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IdentityModel.Selectors;
+using System.ServiceModel;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       public abstract class SecurityCredentialsManager
+       {
+               protected SecurityCredentialsManager ()
+               {
+               }
+
+               public abstract SecurityTokenManager CreateSecurityTokenManager ();
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityMessageProperty.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityMessageProperty.cs
new file mode 100644 (file)
index 0000000..428fb03
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// SecurityMessageProperty.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       public class SecurityMessageProperty : IMessageProperty, IDisposable
+       {
+               SecurityTokenSpecification initiator_token, protection_token,
+                       recipient_token, transport_token;
+               Collection<SupportingTokenSpecification> incoming_supp_tokens =
+                       new Collection<SupportingTokenSpecification> ();
+               ReadOnlyCollection<IAuthorizationPolicy> policies;
+               string sender_id_prefix = "_";
+               ServiceSecurityContext context = ServiceSecurityContext.Anonymous;
+
+               // internal
+               internal Collection<string> ConfirmedSignatures = new Collection<string> ();
+               internal byte [] EncryptionKey;
+
+               public SecurityMessageProperty ()
+               {
+               }
+
+               public bool HasIncomingSupportingTokens {
+                       get { return incoming_supp_tokens != null && incoming_supp_tokens.Count > 0; }
+               }
+
+               public ReadOnlyCollection<IAuthorizationPolicy>
+                       ExternalAuthorizationPolicies {
+                       get { return policies; }
+                       set { policies = value; }
+               }
+
+               public Collection<SupportingTokenSpecification>
+                       IncomingSupportingTokens {
+                       get { return incoming_supp_tokens; }
+               }
+
+               public SecurityTokenSpecification InitiatorToken {
+                       get { return initiator_token; }
+                       set { initiator_token = value; }
+               }
+
+               public SecurityTokenSpecification ProtectionToken {
+                       get { return protection_token; }
+                       set { protection_token = value; }
+               }
+
+               public SecurityTokenSpecification RecipientToken {
+                       get { return recipient_token; }
+                       set { recipient_token = value; }
+               }
+
+               public SecurityTokenSpecification TransportToken {
+                       get { return transport_token; }
+                       set { transport_token = value; }
+               }
+
+               public string SenderIdPrefix {
+                       get { return sender_id_prefix; }
+                       set { sender_id_prefix = value; }
+               }
+
+               public ServiceSecurityContext ServiceSecurityContext {
+                       get { return context; }
+                       set { context = value; }
+               }
+
+               public IMessageProperty CreateCopy ()
+               {
+                       return (SecurityMessageProperty) MemberwiseClone ();
+               }
+
+               public void Dispose ()
+               {
+                       context = null;
+                       policies = null;
+               }
+
+               public static SecurityMessageProperty GetOrCreate (Message message)
+               {
+                       SecurityMessageProperty s = message.Properties.Security;
+                       if (s == null) {
+                               s = new SecurityMessageProperty ();
+                               message.Properties.Security = s;
+                       }
+                       return s;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityNegotiationException.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityNegotiationException.cs
new file mode 100644 (file)
index 0000000..14bc122
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// SecurityNegotiationException.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel.Security
+{
+       [Serializable]
+       public class SecurityNegotiationException : CommunicationException
+       {
+               public SecurityNegotiationException ()
+                       : this ("Failed to process security negotiation.")
+               {
+               }
+
+               public SecurityNegotiationException (string message)
+                       : base (message)
+               {
+               }
+
+               public SecurityNegotiationException (string message,
+                       Exception innerException)
+                       : base (message, innerException)
+               {
+               }
+
+               protected SecurityNegotiationException (SerializationInfo info,
+                       StreamingContext context)
+                       : base (info, context)
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityStateEncoder.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityStateEncoder.cs
new file mode 100644 (file)
index 0000000..10af7b5
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// SecurityStateEncoder.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Security
+{
+       public abstract class SecurityStateEncoder
+       {
+               protected SecurityStateEncoder ()
+               {
+               }
+
+               protected internal abstract byte [] DecodeSecurityState (byte [] data);
+
+               protected internal abstract byte [] EncodeSecurityState (byte [] data);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityTokenAttachmentMode.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityTokenAttachmentMode.cs
new file mode 100644 (file)
index 0000000..fa49130
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// SecurityTokenAttachmentMode.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Security
+{
+       public enum SecurityTokenAttachmentMode
+       {
+               Signed,
+               Endorsing,
+               SignedEndorsing,
+               SignedEncrypted,
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityTokenSpecification.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityTokenSpecification.cs
new file mode 100644 (file)
index 0000000..0bac54d
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// SecurityTokenSpecification.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Security
+{
+       public class SecurityTokenSpecification
+       {
+               SecurityToken token;
+               ReadOnlyCollection<IAuthorizationPolicy> policies;
+
+               public SecurityTokenSpecification (SecurityToken token,
+                       ReadOnlyCollection<IAuthorizationPolicy> tokenPolicies)
+               {
+                       this.token = token;
+                       this.policies = tokenPolicies;
+               }
+
+               public SecurityToken SecurityToken {
+                       get { return token; }
+               }
+
+               public ReadOnlyCollection<IAuthorizationPolicy> SecurityTokenPolicies {
+                       get { return policies; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityVersion.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SecurityVersion.cs
new file mode 100644 (file)
index 0000000..69ff26b
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// SecurityVersion.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel.Security
+{
+       public abstract class SecurityVersion
+       {
+               static SecurityVersion wss10, wss11;
+
+               static SecurityVersion ()
+               {
+                       wss10 = new SecurityVersion10 ();
+                       wss11 = new SecurityVersion11 ();
+               }
+
+               public static SecurityVersion WSSecurity10 {
+                       get { return wss10; }
+               }
+
+               public static SecurityVersion WSSecurity11 {
+                       get { return wss11; }
+               }
+       }
+
+       class SecurityVersion10 : SecurityVersion
+       {
+       }
+
+       class SecurityVersion11 : SecurityVersion
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManager.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManager.cs
new file mode 100644 (file)
index 0000000..c48944b
--- /dev/null
@@ -0,0 +1,362 @@
+//
+// ServiceCredentialsSecurityTokenManager.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security.Tokens;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel.Security
+{
+       public class ServiceCredentialsSecurityTokenManager : SecurityTokenManager, IEndpointIdentityProvider
+       {
+               ServiceCredentials credentials;
+
+               public ServiceCredentialsSecurityTokenManager (
+                       ServiceCredentials credentials)
+               {
+                       this.credentials = credentials;
+               }
+
+               public ServiceCredentials ServiceCredentials {
+                       get { return credentials; }
+               }
+
+               [MonoTODO]
+               public virtual EndpointIdentity GetIdentityOfSelf (
+                       SecurityTokenRequirement requirement)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public override SecurityTokenAuthenticator CreateSecurityTokenAuthenticator (
+                       SecurityTokenRequirement requirement,
+                       out SecurityTokenResolver outOfBandTokenResolver)
+               {
+                       outOfBandTokenResolver = null;
+                       if (requirement.TokenType == SecurityTokenTypes.UserName)
+                               return CreateUserNameAuthenticator (requirement);
+                       if (requirement.TokenType == SecurityTokenTypes.X509Certificate)
+                               return CreateX509Authenticator (requirement);
+                       if (requirement.TokenType == SecurityTokenTypes.Rsa)
+                               return new RsaSecurityTokenAuthenticator ();
+                       if (requirement.TokenType == ServiceModelSecurityTokenTypes.SecureConversation) {
+                               // FIXME: get parameters from somewhere
+                               SecurityContextSecurityTokenResolver resolver =
+                                       new SecurityContextSecurityTokenResolver (0x1000, true);
+                               outOfBandTokenResolver = resolver;
+                               SecurityContextSecurityTokenAuthenticator sc =
+                                       new SecurityContextSecurityTokenAuthenticator ();
+                               return new SecureConversationSecurityTokenAuthenticator (requirement, sc, resolver);
+                       }
+                       if (requirement.TokenType == ServiceModelSecurityTokenTypes.AnonymousSslnego)
+                               return CreateSslTokenAuthenticator (requirement);
+                       if (requirement.TokenType == ServiceModelSecurityTokenTypes.MutualSslnego)
+                               return CreateSslTokenAuthenticator (requirement);
+                       if (requirement.TokenType == ServiceModelSecurityTokenTypes.Spnego)
+                               return CreateSpnegoTokenAuthenticator (requirement);
+                       else
+                               throw new NotImplementedException ("Not implemented token type: " + requirement.TokenType);
+               }
+
+               SpnegoSecurityTokenAuthenticator CreateSpnegoTokenAuthenticator (SecurityTokenRequirement requirement)
+               {
+                       SpnegoSecurityTokenAuthenticator a =
+                               new SpnegoSecurityTokenAuthenticator (this, requirement);
+                       InitializeAuthenticatorCommunicationObject (a.Communication, requirement);
+                       return a;
+               }
+
+               SslSecurityTokenAuthenticator CreateSslTokenAuthenticator (SecurityTokenRequirement requirement)
+               {
+                       SslSecurityTokenAuthenticator a =
+                               new SslSecurityTokenAuthenticator (this, requirement);
+                       InitializeAuthenticatorCommunicationObject (a.Communication, requirement);
+                       return a;
+               }
+
+               UserNameSecurityTokenAuthenticator CreateUserNameAuthenticator (SecurityTokenRequirement requirement)
+               {
+                       UserNamePasswordServiceCredential c = ServiceCredentials.UserNameAuthentication;
+                       switch (c.UserNamePasswordValidationMode) {
+                       case UserNamePasswordValidationMode.MembershipProvider:
+                               if (c.MembershipProvider == null)
+                                       throw new InvalidOperationException ("For MembershipProvider validation mode, MembershipProvider is required to create a user name token authenticator.");
+                               return new CustomUserNameSecurityTokenAuthenticator (UserNamePasswordValidator.CreateMembershipProviderValidator (c.MembershipProvider));
+                       case UserNamePasswordValidationMode.Windows:
+                               return new WindowsUserNameSecurityTokenAuthenticator (c.IncludeWindowsGroups);
+                       default:
+                               if (c.CustomUserNamePasswordValidator == null)
+                                       throw new InvalidOperationException ("For Custom validation mode, CustomUserNamePasswordValidator is required to create a user name token authenticator.");
+                               return new CustomUserNameSecurityTokenAuthenticator (c.CustomUserNamePasswordValidator);
+                       }
+               }
+
+               X509SecurityTokenAuthenticator CreateX509Authenticator (SecurityTokenRequirement requirement)
+               {
+                       X509CertificateInitiatorServiceCredential c = ServiceCredentials.ClientCertificate;
+                       switch (c.Authentication.CertificateValidationMode) {
+                       case X509CertificateValidationMode.Custom:
+                               if (c.Authentication.CustomCertificateValidator == null)
+                                       throw new InvalidOperationException ("For Custom certificate validation mode, CustomCertificateValidator is required to create a token authenticator for X509 certificate.");
+                               return new X509SecurityTokenAuthenticator (c.Authentication.CustomCertificateValidator);
+                       case X509CertificateValidationMode.None:
+                               return new X509SecurityTokenAuthenticator (X509CertificateValidator.None);
+                       case X509CertificateValidationMode.PeerOrChainTrust:
+                               return new X509SecurityTokenAuthenticator (X509CertificateValidator.PeerOrChainTrust);
+                       case X509CertificateValidationMode.ChainTrust:
+                               return new X509SecurityTokenAuthenticator (X509CertificateValidator.ChainTrust);
+                       default:
+                               return new X509SecurityTokenAuthenticator (X509CertificateValidator.PeerTrust);
+                       }
+               }
+
+               void InitializeAuthenticatorCommunicationObject (AuthenticatorCommunicationObject p, SecurityTokenRequirement r)
+               {
+                       p.ListenUri = r.GetProperty<Uri> (ReqType.ListenUriProperty);
+
+                       // FIXME: use it somewhere, probably to build 
+                       // IssuerBinding. However, there is also IssuerBinding 
+                       // property. SecureConversationSecurityBindingElement
+                       // as well.
+                       SecurityBindingElement sbe =
+                               r.GetProperty<SecurityBindingElement> (ReqType.SecurityBindingElementProperty);
+                       p.SecurityBindingElement = sbe;
+
+/*
+                       // I doubt the binding is acquired this way ...
+                       Binding binding;
+                       if (!r.TryGetProperty<Binding> (ReqType.IssuerBindingProperty, out binding))
+                               binding = new CustomBinding (
+                                       new TextMessageEncodingBindingElement (),
+                                       new HttpTransportBindingElement ());
+                       p.IssuerBinding = binding;
+
+                       // not sure if it is used only for this purpose though ...
+                       BindingContext ctx = r.GetProperty<BindingContext> (ReqType.IssuerBindingContextProperty);
+                       foreach (IEndpointBehavior b in ctx.BindingParameters.FindAll<IEndpointBehavior> ())
+                               p.IssuerChannelBehaviors.Add (b);
+*/
+
+                       SecurityTokenVersion ver =
+                               r.GetProperty<SecurityTokenVersion> (ReqType.MessageSecurityVersionProperty);
+                       p.SecurityTokenSerializer =
+                               CreateSecurityTokenSerializer (ver);
+
+/*
+                       // seems like they are optional here ... (but possibly
+                       // used later)
+                       EndpointAddress address;
+                       if (!r.TryGetProperty<EndpointAddress> (ReqType.IssuerAddressProperty, out address))
+                               address = p.TargetAddress;
+                       p.IssuerAddress = address;
+*/
+
+                       // It is somehow not checked as mandatory ...
+                       SecurityAlgorithmSuite suite = null;
+                       r.TryGetProperty<SecurityAlgorithmSuite> (ReqType.SecurityAlgorithmSuiteProperty, out suite);
+                       p.SecurityAlgorithmSuite = suite;
+               }
+
+               #region CreateSecurityTokenProvider()
+
+               [MonoTODO]
+               public override SecurityTokenProvider CreateSecurityTokenProvider (SecurityTokenRequirement requirement)
+               {
+                       if (IsIssuedSecurityTokenRequirement (requirement))
+                               return CreateIssuedTokenProvider (requirement);
+
+                       // not supported: UserName, Rsa, AnonymousSslnego, SecureConv
+
+                       // huh, they are not constants but properties.
+                       if (requirement.TokenType == SecurityTokenTypes.X509Certificate)
+                               return CreateX509SecurityTokenProvider (requirement);
+                       else if (requirement.TokenType == ServiceModelSecurityTokenTypes.MutualSslnego) {
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       } else if (requirement.TokenType == ServiceModelSecurityTokenTypes.SecurityContext) {
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       } else if (requirement.TokenType == ServiceModelSecurityTokenTypes.AnonymousSslnego) {
+                               throw new NotSupportedException (String.Format ("Token type '{0}' is not supported", requirement.TokenType));
+                       } else if (requirement.TokenType == ServiceModelSecurityTokenTypes.Spnego) {
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       } else if (requirement.TokenType == ServiceModelSecurityTokenTypes.SspiCredential) {
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       } else if (requirement.TokenType == SecurityTokenTypes.Saml) {
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       } else if (requirement.TokenType == SecurityTokenTypes.Kerberos) {
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       }
+                       throw new NotSupportedException (String.Format ("Securirty token requirement '{0}' is not supported", requirement));
+               }
+
+               X509SecurityTokenProvider CreateX509SecurityTokenProvider (SecurityTokenRequirement requirement)
+               {
+                       bool isInitiator;
+                       requirement.TryGetProperty<bool> (ReqType.IsInitiatorProperty, out isInitiator);
+                       // when it is initiator, then it is for MutualCertificateDuplex.
+                       X509Certificate2 cert;
+                       if (isInitiator) {
+                               cert = credentials.ClientCertificate.Certificate;
+                               if (cert == null)
+                                       throw new InvalidOperationException ("Client certificate is not provided in ServiceCredentials.");
+                               if (cert.PrivateKey == null)
+                                       throw new ArgumentException ("Client certificate for MutualCertificateDuplex does not have a private key which is required for key exchange.");
+                       } else {
+                               cert = credentials.ServiceCertificate.Certificate;
+                               if (cert == null)
+                                       throw new InvalidOperationException ("Service certificate is not provided in ServiceCredentials.");
+                               if (cert.PrivateKey == null)
+                                       throw new ArgumentException ("Service certificate does not have a private key which is required for key exchange.");
+                       }
+                       X509SecurityTokenProvider p =
+                               new X509SecurityTokenProvider (cert);
+                       return p;
+               }
+
+               IssuedSecurityTokenProvider CreateIssuedProviderBase (SecurityTokenRequirement r)
+               {
+                       IssuedSecurityTokenProvider p =
+                               new IssuedSecurityTokenProvider ();
+
+                       p.TargetAddress = r.GetProperty<EndpointAddress> (ReqType.TargetAddressProperty);
+
+                       // FIXME: use it somewhere, probably to build 
+                       // IssuerBinding. However, there is also IssuerBinding 
+                       // property. SecureConversationSecurityBindingElement
+                       // as well.
+                       SecurityBindingElement sbe =
+                               r.GetProperty<SecurityBindingElement> (ReqType.SecurityBindingElementProperty);
+
+                       // I doubt the binding is acquired this way ...
+                       Binding binding;
+                       if (!r.TryGetProperty<Binding> (ReqType.IssuerBindingProperty, out binding))
+                               binding = new CustomBinding (sbe,
+                                       new TextMessageEncodingBindingElement (),
+                                       new HttpTransportBindingElement ());
+                       p.IssuerBinding = binding;
+
+                       // not sure if it is used only for this purpose though ...
+                       BindingContext ctx = r.GetProperty<BindingContext> (ReqType.IssuerBindingContextProperty);
+                       foreach (IEndpointBehavior b in ctx.BindingParameters.FindAll<IEndpointBehavior> ())
+                               p.IssuerChannelBehaviors.Add (b);
+
+                       SecurityTokenVersion ver =
+                               r.GetProperty<SecurityTokenVersion> (ReqType.MessageSecurityVersionProperty);
+                       p.SecurityTokenSerializer =
+                               CreateSecurityTokenSerializer (ver);
+
+                       // seems like they are optional here ... (but possibly
+                       // used later)
+                       EndpointAddress address;
+                       if (!r.TryGetProperty<EndpointAddress> (ReqType.IssuerAddressProperty, out address))
+                               address = p.TargetAddress;
+                       p.IssuerAddress = address;
+
+                       // It is somehow not checked as mandatory ...
+                       SecurityAlgorithmSuite suite = null;
+                       r.TryGetProperty<SecurityAlgorithmSuite> (ReqType.SecurityAlgorithmSuiteProperty, out suite);
+                       p.SecurityAlgorithmSuite = suite;
+
+                       return p;
+               }
+
+               // FIXME: it is far from done.
+               SecurityTokenProvider CreateSecureConversationProvider (SecurityTokenRequirement r)
+               {
+                       IssuedSecurityTokenProvider p =
+                               CreateIssuedProviderBase (r);
+
+                       // FIXME: use it somewhere.
+                       int keySize = r.KeySize;
+
+                       return p;
+               }
+
+               IssuedSecurityTokenProvider CreateIssuedTokenProvider (SecurityTokenRequirement requirement)
+               {
+                       IssuedSecurityTokenProvider p =
+                               new IssuedSecurityTokenProvider ();
+                       // FIXME: fill properties
+                       EndpointAddress address;
+                       if (requirement.TryGetProperty<EndpointAddress> (ReqType.IssuerAddressProperty, out address))
+                               p.IssuerAddress = address;
+                       if (requirement.TryGetProperty<EndpointAddress> (ReqType.TargetAddressProperty, out address))
+                               p.TargetAddress = address;
+                       Binding binding;
+                       if (requirement.TryGetProperty<Binding> (ReqType.IssuerBindingProperty, out binding))
+                               p.IssuerBinding = binding;
+                       MessageSecurityVersion ver;
+                       if (requirement.TryGetProperty<MessageSecurityVersion> (ReqType.MessageSecurityVersionProperty, out ver))
+                               p.SecurityTokenSerializer = CreateSecurityTokenSerializer (ver.SecurityTokenVersion);
+                       SecurityAlgorithmSuite suite;
+                       if (requirement.TryGetProperty<SecurityAlgorithmSuite> (ReqType.SecurityAlgorithmSuiteProperty, out suite))
+                               p.SecurityAlgorithmSuite = suite;
+                       return p;
+               }
+
+               #endregion
+
+               [MonoTODO ("pass correct arguments to WSSecurityTokenSerializer..ctor()")]
+               public override SecurityTokenSerializer CreateSecurityTokenSerializer (SecurityTokenVersion version)
+               {
+                       bool bsp = version.GetSecuritySpecifications ().Contains (Constants.WSBasicSecurityProfileCore1);
+                       SecurityVersion ver =
+                               version.GetSecuritySpecifications ().Contains (Constants.Wss11Namespace) ?
+                               SecurityVersion.WSSecurity11 :
+                               SecurityVersion.WSSecurity10;
+
+                       // FIXME: pass correct arguments.
+                       return new WSSecurityTokenSerializer (ver, bsp, null,
+                               ServiceCredentials.SecureConversationAuthentication.SecurityStateEncoder,
+                               Type.EmptyTypes,
+                               int.MaxValue, int.MaxValue, int.MaxValue);
+               }
+
+               protected internal bool IsIssuedSecurityTokenRequirement (
+                       SecurityTokenRequirement requirement)
+               {
+                       SecurityTokenParameters ret;
+                       if (!requirement.TryGetProperty<SecurityTokenParameters> (ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty, out ret))
+                               return false;
+                       return ret is IssuedSecurityTokenParameters;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SspiSecurityTokenProvider.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SspiSecurityTokenProvider.cs
new file mode 100644 (file)
index 0000000..5eba9f8
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// SspiSecurityTokenProvider.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Net;
+using System.Security.Principal;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+
+using System.ServiceModel.Security.Tokens;
+
+// mhm, why is this class not in S.SM.S.Tokens??
+namespace System.ServiceModel.Security
+{
+       // Anyways we won't support SSPI until it becomes open.
+       public class SspiSecurityTokenProvider : SecurityTokenProvider
+       {
+               [MonoTODO]
+               public SspiSecurityTokenProvider (NetworkCredential credential,
+                       bool extractGroupsForWindowsAccounts,
+                       bool allowUnauthenticatedCallers)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public SspiSecurityTokenProvider (NetworkCredential credential, 
+                       bool allowNtlm, TokenImpersonationLevel impersonationLevel)
+               {
+                       if (credential == null)
+                               throw new ArgumentNullException ("credential");
+                       this.credential = credential;
+                       allow_ntlm = allowNtlm;
+                       impersonation_level = impersonationLevel;
+               }
+
+               NetworkCredential credential;
+               bool allow_ntlm;
+               TokenImpersonationLevel impersonation_level;
+
+               // SecurityTokenProvider
+
+               [MonoTODO]
+               protected override SecurityToken GetTokenCore (TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/SupportingTokenSpecification.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/SupportingTokenSpecification.cs
new file mode 100644 (file)
index 0000000..6badbc9
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// SupportingTokenSpecification.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel.Security
+{
+       public class SupportingTokenSpecification : SecurityTokenSpecification
+       {
+               SecurityTokenAttachmentMode mode;
+
+               public SupportingTokenSpecification (
+                       SecurityToken token,
+                       ReadOnlyCollection<IAuthorizationPolicy> tokenPolicies,
+                       SecurityTokenAttachmentMode attachmentMode)
+                       : base (token, tokenPolicies)
+               {
+                       mode = attachmentMode;
+               }
+
+               public SecurityTokenAttachmentMode SecurityTokenAttachmentMode {
+                       get { return mode; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/UnionSecurityTokenResolver.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/UnionSecurityTokenResolver.cs
new file mode 100644 (file)
index 0000000..f6dd3cc
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// UnionSecurityTokenResolver.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Channels
+{
+       class UnionSecurityTokenResolver : SecurityTokenResolver
+       {
+               SecurityTokenResolver [] resolvers;
+
+               public UnionSecurityTokenResolver (params SecurityTokenResolver [] resolvers)
+               {
+                       this.resolvers = resolvers;
+               }
+
+               protected override bool TryResolveSecurityKeyCore (
+                       SecurityKeyIdentifierClause keyIdentifierClause,
+                       out SecurityKey key)
+               {
+                       key = null;
+                       foreach (SecurityTokenResolver r in resolvers)
+                               if (r != null && r.TryResolveSecurityKey (keyIdentifierClause, out key))
+                                       return true;
+                       return false;
+               }
+
+               protected override bool TryResolveTokenCore (
+                       SecurityKeyIdentifier keyIdentifier,
+                       out SecurityToken token)
+               {
+                       token = null;
+                       foreach (SecurityTokenResolver r in resolvers)
+                               if (r != null && r.TryResolveToken (keyIdentifier, out token))
+                                       return true;
+                       return false;
+               }
+
+               protected override bool TryResolveTokenCore (
+                       SecurityKeyIdentifierClause keyIdentifierClause,
+                       out SecurityToken token)
+               {
+                       token = null;
+                       foreach (SecurityTokenResolver r in resolvers)
+                               if (r != null && r.TryResolveToken (keyIdentifierClause, out token))
+                                       return true;
+                       return false;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/UserNamePasswordClientCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/UserNamePasswordClientCredential.cs
new file mode 100644 (file)
index 0000000..c832ffc
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// UserNamePasswordClientCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       public sealed class UserNamePasswordClientCredential
+       {
+               internal UserNamePasswordClientCredential ()
+               {
+               }
+
+               string username, password;
+
+               public string Password {
+                       get { return password; }
+                       set { password = value; }
+               }
+
+               public string UserName {
+                       get { return username; }
+                       set { username = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/UserNamePasswordServiceCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/UserNamePasswordServiceCredential.cs
new file mode 100644 (file)
index 0000000..8d38daa
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// UserNamePasswordServiceCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Security.Cryptography.X509Certificates;
+using System.Web.Security;
+using System.IdentityModel.Selectors;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       public sealed class UserNamePasswordServiceCredential
+       {
+               internal UserNamePasswordServiceCredential ()
+               {
+               }
+
+               MembershipProvider provider;
+               TimeSpan lifetime = TimeSpan.FromMinutes (15);
+               bool cache_tokens, include_win_groups = true;
+               int max_cache_tokens = 0x80;
+               UserNamePasswordValidator validator;
+               UserNamePasswordValidationMode mode;
+
+               [MonoTODO]
+               public UserNamePasswordValidationMode UserNamePasswordValidationMode {
+                       get { return mode; }
+                       set { mode = value; }
+               }
+
+               [MonoTODO]
+               public bool CacheLogonTokens {
+                       get { return cache_tokens; }
+                       set { cache_tokens = value; }
+               }
+
+               [MonoTODO]
+               public TimeSpan CachedLogonTokenLifetime {
+                       get { return lifetime; }
+                       set { lifetime = value; }
+               }
+
+               [MonoTODO]
+               public bool IncludeWindowsGroups {
+                       get { return include_win_groups; }
+                       set { include_win_groups = value; }
+               }
+
+               [MonoTODO]
+               public int MaxCachedLogonTokens {
+                       get { return max_cache_tokens; }
+                       set { max_cache_tokens = value; }
+               }
+
+               public UserNamePasswordValidator CustomUserNamePasswordValidator {
+                       get { return validator; }
+                       set { validator = value; }
+               }
+
+               public MembershipProvider MembershipProvider {
+                       get { return provider; }
+                       set { provider = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/WSSecurityTokenSerializer.cs
new file mode 100644 (file)
index 0000000..026daa9
--- /dev/null
@@ -0,0 +1,947 @@
+//
+// WSSecurityTokenSerializer.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel.Security.Tokens;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel.Security
+{
+       public class WSSecurityTokenSerializer : SecurityTokenSerializer
+       {
+               static WSSecurityTokenSerializer default_instance =
+                       new WSSecurityTokenSerializer ();
+
+               public static WSSecurityTokenSerializer DefaultInstance {
+                       get { return default_instance; }
+               }
+
+               const int defaultOffset = 64,
+                       defaultLabelLength = 128,
+                       defaultNonceLength = 128;
+
+               public WSSecurityTokenSerializer ()
+                       : this (false)
+               {
+               }
+
+               public WSSecurityTokenSerializer (bool emitBspRequiredAttributes)
+                       : this (SecurityVersion.WSSecurity11, emitBspRequiredAttributes)
+               {
+               }
+
+               public WSSecurityTokenSerializer (SecurityVersion securityVersion)
+                       : this (securityVersion, false)
+               {
+               }
+
+               public WSSecurityTokenSerializer (SecurityVersion securityVersion, bool emitBspRequiredAttributes)
+                       : this (securityVersion, emitBspRequiredAttributes, new SamlSerializer ())
+               {
+               }
+
+               public WSSecurityTokenSerializer (
+                       SecurityVersion securityVersion,
+                       bool emitBspRequiredAttributes,
+                       SamlSerializer samlSerializer)
+                       : this (securityVersion, emitBspRequiredAttributes, 
+                               samlSerializer, null, null)
+               {
+               }
+
+               public WSSecurityTokenSerializer (
+                       SecurityVersion securityVersion,
+                       bool emitBspRequiredAttributes,
+                       SamlSerializer samlSerializer,
+                       SecurityStateEncoder securityStateEncoder,
+                       IEnumerable<Type> knownTypes)
+                       : this (securityVersion, emitBspRequiredAttributes, 
+                               samlSerializer, securityStateEncoder,
+                               knownTypes, defaultOffset, defaultLabelLength,
+                               defaultNonceLength)
+               {
+               }
+               
+               public WSSecurityTokenSerializer (
+                       SecurityVersion securityVersion,
+                       bool emitBspRequiredAttributes,
+                       SamlSerializer samlSerializer,
+                       SecurityStateEncoder securityStateEncoder,
+                       IEnumerable<Type> knownTypes,
+                       int maximumKeyDerivationOffset,
+                       int maximumKeyDerivationLabelLength,
+                       int maximumKeyDerivationNonceLength)
+               {
+                       security_version = securityVersion;
+                       emit_bsp = emitBspRequiredAttributes;
+                       saml_serializer = samlSerializer;
+                       encoder = securityStateEncoder;
+                       known_types = new List<Type> (knownTypes ?? Type.EmptyTypes);
+                       max_offset = maximumKeyDerivationOffset;
+                       max_label_length = maximumKeyDerivationLabelLength;
+                       max_nonce_length = maximumKeyDerivationNonceLength;
+
+                       if (encoder == null)
+                               encoder = new DataProtectionSecurityStateEncoder ();
+               }
+
+               SecurityVersion security_version;
+               bool emit_bsp;
+               SamlSerializer saml_serializer;
+               SecurityStateEncoder encoder;
+               List<Type> known_types;
+               int max_offset, max_label_length, max_nonce_length;
+
+               bool WSS1_0 {
+                       get { return SecurityVersion == SecurityVersion.WSSecurity10; }
+               }
+
+               public bool EmitBspRequiredAttributes {
+                       get { return emit_bsp; }
+               }
+
+               public SecurityVersion SecurityVersion {
+                       get { return security_version; }
+               }
+
+               [MonoTODO]
+               public int MaximumKeyDerivationOffset {
+                       get { return max_offset; }
+               }
+
+               [MonoTODO]
+               public int MaximumKeyDerivationLabelLength {
+                       get { return max_label_length; }
+               }
+
+               [MonoTODO]
+               public int MaximumKeyDerivationNonceLength {
+                       get { return max_nonce_length; }
+               }
+
+               protected virtual string GetTokenTypeUri (Type tokenType)
+               {
+                       if (tokenType == typeof (WrappedKeySecurityToken))
+                               return Constants.WSSEncryptedKeyToken;
+                       if (tokenType == typeof (X509SecurityToken))
+                               return Constants.WSSX509Token;
+//                     if (tokenType == typeof (RsaSecurityToken))
+//                             return null;
+                       if (tokenType == typeof (SamlSecurityToken))
+                               return Constants.WSSSamlToken;
+                       if (tokenType == typeof (SecurityContextSecurityToken))
+                               return Constants.WsscContextToken;
+//                     if (tokenType == typeof (huh))
+//                             return ServiceModelSecurityTokenTypes.SecureConversation;
+//                     if (tokenType == typeof (hah))
+//                             return ServiceModelSecurityTokenTypes.MutualSslnego;
+//                     if (tokenType == typeof (whoa))
+//                             return ServiceModelSecurityTokenTypes.AnonymousSslnego;
+                       if (tokenType == typeof (UserNameSecurityToken))
+                               return Constants.WSSUserNameToken;
+//                     if (tokenType == typeof (uhoh))
+//                             return ServiceModelSecurityTokenTypes.Spnego;
+//                     if (tokenType == typeof (SspiSecurityToken))
+//                             return ServiceModelSecurityTokenTypes.SspiCredential;
+                       if (tokenType == typeof (KerberosRequestorSecurityToken))
+                               return Constants.WSSKerberosToken;
+                       return null;
+               }
+
+               [MonoTODO]
+               protected override bool CanReadKeyIdentifierClauseCore (XmlReader reader)
+               {
+                       reader.MoveToContent ();
+                       switch (reader.NamespaceURI) {
+                       case EncryptedXml.XmlEncNamespaceUrl:
+                               switch (reader.LocalName) {
+                               case "EncryptedKey":
+                                       return true;
+                               }
+                               break;
+                       case Constants.WssNamespace:
+                               switch (reader.LocalName) {
+                               case "SecurityTokenReference":
+                                       return true;
+                               }
+                               break;
+                       }
+
+                       return false;
+               }
+
+               [MonoTODO]
+               protected override bool CanReadKeyIdentifierCore (XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override bool CanReadTokenCore (XmlReader reader)
+               {
+                       reader.MoveToContent ();
+
+                       switch (reader.NamespaceURI) {
+                       case Constants.WssNamespace:
+                               switch (reader.LocalName) {
+                               case "BinarySecurityToken":
+                               case "BinarySecret":
+                               case "UsernameToken":
+                                       return true;
+                               }
+                               break;
+                       case Constants.WsscNamespace:
+                               switch (reader.LocalName) {
+                               case "DerivedKeyToken":
+                               case "SecurityContextToken":
+                                       return true;
+                               }
+                               break;
+                       case EncryptedXml.XmlEncNamespaceUrl:
+                               switch (reader.LocalName) {
+                               case "EncryptedKey":
+                                       return true;
+                               }
+                               break;
+                       }
+                       return false;
+               }
+
+               [MonoTODO]
+               public virtual SecurityKeyIdentifierClause CreateKeyIdentifierClauseFromTokenXml (
+                       XmlElement tokenXml, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override SecurityKeyIdentifier ReadKeyIdentifierCore (
+                       XmlReader reader)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override SecurityKeyIdentifierClause ReadKeyIdentifierClauseCore (XmlReader reader)
+               {
+                       reader.MoveToContent ();
+                       switch (reader.NamespaceURI) {
+                       case EncryptedXml.XmlEncNamespaceUrl:
+                               switch (reader.LocalName) {
+                               case "EncryptedKey":
+                                       return ReadEncryptedKeyIdentifierClause (reader);
+                               }
+                               break;
+                       case Constants.WssNamespace:
+                               switch (reader.LocalName) {
+                               case "SecurityTokenReference":
+                                       return ReadSecurityTokenReference (reader);
+                               }
+                               break;
+                       }
+
+                       throw new NotImplementedException (String.Format ("Security key identifier clause element '{0}' in namespace '{1}' is either not implemented or not supported.", reader.LocalName, reader.NamespaceURI));
+               }
+
+               SecurityKeyIdentifierClause ReadSecurityTokenReference (XmlReader reader)
+               {
+                       reader.ReadStartElement ();
+                       reader.MoveToContent ();
+                       if (reader.NamespaceURI == SignedXml.XmlDsigNamespaceUrl) {
+                               KeyInfoX509Data x509 = new KeyInfoX509Data ();
+                               x509.LoadXml (new XmlDocument ().ReadNode (reader) as XmlElement);
+                               if (x509.IssuerSerials.Count == 0)
+                                       throw new XmlException ("'X509IssuerSerial' element is expected inside 'X509Data' element");
+                               X509IssuerSerial s = (X509IssuerSerial) x509.IssuerSerials [0];
+                               reader.MoveToContent ();
+                               reader.ReadEndElement ();
+                               return new X509IssuerSerialKeyIdentifierClause (s.IssuerName, s.SerialNumber);
+                       }
+                       if (reader.NamespaceURI != Constants.WssNamespace)
+                               throw new XmlException (String.Format ("Unexpected SecurityTokenReference content: expected local name 'Reference' and namespace URI '{0}' but found local name '{1}' and namespace '{2}'.", Constants.WssNamespace, reader.LocalName, reader.NamespaceURI));
+
+                       switch (reader.LocalName) {
+                       case "Reference":
+                               Type ownerType = null;
+                               // FIXME: there could be more token types.
+                               if (reader.MoveToAttribute ("ValueType")) {
+                                       switch (reader.Value) {
+                                       case Constants.WSSEncryptedKeyToken:
+                                               ownerType = typeof (WrappedKeySecurityToken);
+                                               break;
+                                       case Constants.WSSX509Token:
+                                               ownerType = typeof (X509SecurityToken);
+                                               break;
+                                       case Constants.WsscContextToken:
+                                               ownerType = typeof (SecurityContextSecurityToken);
+                                               break;
+                                       default:
+                                               throw new XmlException (String.Format ("Unexpected ValueType in 'Reference' element: '{0}'", reader.Value));
+                                       }
+                               }
+                               reader.MoveToElement ();
+                               string uri = reader.GetAttribute ("URI");
+                               if (String.IsNullOrEmpty (uri))
+                                       uri = "#";
+                               SecurityKeyIdentifierClause ic = null;
+                               if (ownerType == typeof (SecurityContextSecurityToken) && uri [0] != '#')
+                                       // FIXME: Generation?
+                                       ic = new SecurityContextKeyIdentifierClause (new UniqueId (uri));
+                               else
+                                ic = new LocalIdKeyIdentifierClause (uri.Substring (1), ownerType);
+                               reader.Skip ();
+                               reader.MoveToContent ();
+                               reader.ReadEndElement ();
+                               return ic;
+                       case "KeyIdentifier":
+                               string valueType = reader.GetAttribute ("ValueType");
+                               string value = reader.ReadElementContentAsString ();
+                               reader.MoveToContent ();
+                               reader.ReadEndElement (); // consume </Reference>
+                               switch (valueType) {
+                               case Constants.WssKeyIdentifierX509Thumbptint:
+                                       return new X509ThumbprintKeyIdentifierClause (Convert.FromBase64String (value));
+                               case Constants.WssKeyIdentifierEncryptedKey:
+                                       return new InternalEncryptedKeyIdentifierClause (Convert.FromBase64String (value));
+                               case Constants.WssKeyIdentifierSamlAssertion:
+                                       return new SamlAssertionKeyIdentifierClause (value);
+                               default:
+                                       // It is kinda weird but it throws XmlException here ...
+                                       throw new XmlException (String.Format ("KeyIdentifier type '{0}' is not supported in WSSecurityTokenSerializer.", valueType));
+                               }
+                       default:
+                               throw new XmlException (String.Format ("Unexpected SecurityTokenReference content: expected local name 'Reference' and namespace URI '{0}' but found local name '{1}' and namespace '{2}'.", Constants.WssNamespace, reader.LocalName, reader.NamespaceURI));
+                       }
+               }
+
+               EncryptedKeyIdentifierClause ReadEncryptedKeyIdentifierClause (
+                       XmlReader reader)
+               {
+                       string encNS = EncryptedXml.XmlEncNamespaceUrl;
+
+                       string id = reader.GetAttribute ("Id", Constants.WsuNamespace);
+                       reader.Read ();
+                       reader.MoveToContent ();
+                       string encMethod = reader.GetAttribute ("Algorithm");
+                       bool isEmpty = reader.IsEmptyElement;
+                       reader.ReadStartElement ("EncryptionMethod", encNS);
+                       string digMethod = null;
+                       if (!isEmpty) {
+                               reader.MoveToContent ();
+                               if (reader.LocalName == "DigestMethod" && reader.NamespaceURI == SignedXml.XmlDsigNamespaceUrl)
+                                       digMethod = reader.GetAttribute ("Algorithm");
+                               while (reader.NodeType != XmlNodeType.EndElement) {
+                                       reader.Skip ();
+                                       reader.MoveToContent ();
+                               }
+                               reader.ReadEndElement ();
+                       }
+                       reader.MoveToContent ();
+                       SecurityKeyIdentifier ki = null;
+                       if (!reader.IsEmptyElement) {
+                               reader.ReadStartElement ("KeyInfo", SignedXml.XmlDsigNamespaceUrl);
+                               reader.MoveToContent ();
+                               SecurityKeyIdentifierClause kic = ReadKeyIdentifierClauseCore (reader);
+                               ki = new SecurityKeyIdentifier ();
+                               ki.Add (kic);
+                               reader.MoveToContent ();
+                               reader.ReadEndElement (); // </ds:KeyInfo>
+                               reader.MoveToContent ();
+                       }
+                       byte [] keyValue = null;
+                       if (!reader.IsEmptyElement) {
+                               reader.ReadStartElement ("CipherData", encNS);
+                               reader.MoveToContent ();
+                               keyValue = Convert.FromBase64String (reader.ReadElementContentAsString ("CipherValue", encNS));
+                               reader.MoveToContent ();
+                               reader.ReadEndElement (); // CipherData
+                       }
+                       string carriedKeyName = null;
+                       if (!reader.IsEmptyElement && reader.LocalName == "CarriedKeyName" && reader.NamespaceURI == encNS) {
+                               carriedKeyName = reader.ReadElementContentAsString ();
+                               reader.MoveToContent ();
+                       }
+                       // FIXME: handle derived keys??
+                       return new EncryptedKeyIdentifierClause (keyValue, encMethod, ki, carriedKeyName);
+               }
+
+               [MonoTODO]
+               protected override SecurityToken ReadTokenCore (
+                       XmlReader reader,
+                       SecurityTokenResolver tokenResolver)
+               {
+                       if (!CanReadToken (reader))
+                               throw new XmlException (String.Format ("Cannot read security token from {0} node of name '{1}' and namespace URI '{2}'", reader.NodeType, reader.LocalName, reader.NamespaceURI));
+
+                       switch (reader.NamespaceURI) {
+                       case Constants.WssNamespace:
+                               switch (reader.LocalName) {
+                               case "BinarySecurityToken":
+                                       return ReadX509TokenCore (reader, tokenResolver);
+                               case "BinarySecret":
+                                       return ReadBinarySecretTokenCore (reader, tokenResolver);
+                               case "UsernameToken":
+                                       return ReadUserNameTokenCore (reader, tokenResolver);
+                               }
+                               break;
+                       case Constants.WsscNamespace:
+                               if (reader.LocalName == "DerivedKeyToken")
+                                       return ReadDerivedKeyToken (reader, tokenResolver);
+                               if (reader.LocalName == "SecurityContextToken")
+                                       return ReadSecurityContextToken (reader, tokenResolver);
+                               break;
+                       case EncryptedXml.XmlEncNamespaceUrl:
+                               switch (reader.LocalName) {
+                               case "EncryptedKey":
+                                       return ReadWrappedKeySecurityTokenCore (reader, tokenResolver);
+                               }
+                               break;
+                       }
+
+                       throw new NotImplementedException ();
+               }
+
+               DerivedKeySecurityToken ReadDerivedKeyToken (
+                       XmlReader reader, SecurityTokenResolver tokenResolver)
+               {
+                       try {
+                               return ReadDerivedKeyTokenCore (reader, tokenResolver);
+                       } catch (XmlException) {
+                               throw;
+                       } catch (Exception ex) {
+                               throw new XmlException ("Cannot read DerivedKeyToken", ex);
+                       }
+               }
+               
+               DerivedKeySecurityToken ReadDerivedKeyTokenCore (
+                       XmlReader reader, SecurityTokenResolver tokenResolver)
+               {
+                       if (tokenResolver == null)
+                               throw new ArgumentNullException ("tokenResolver");
+                       string id = reader.GetAttribute ("Id", Constants.WsuNamespace);
+                       string algorithm = reader.MoveToAttribute ("Algorithm") ? reader.Value : null;
+                       reader.MoveToElement ();
+                       reader.ReadStartElement ();
+                       reader.MoveToContent ();
+                       SecurityKeyIdentifierClause kic = ReadKeyIdentifierClause (reader);
+                       int? generation = null, offset = null, length = null;
+                       byte [] nonce = null;
+                       string name = null, label = null;
+                       for (reader.MoveToContent ();
+                              reader.NodeType != XmlNodeType.EndElement;
+                              reader.MoveToContent ())
+                               switch (reader.LocalName) {
+                               case "Properties":
+                                       reader.ReadStartElement ("Properties", Constants.WsscNamespace);
+                                       for (reader.MoveToContent ();
+                                              reader.NodeType != XmlNodeType.EndElement;
+                                              reader.MoveToContent ())
+                                               switch (reader.LocalName) {
+                                               case "Name":
+                                                       name = reader.ReadElementContentAsString ("Name", Constants.WsscNamespace);
+                                                       break;
+                                               case "Label":
+                                                       label = reader.ReadElementContentAsString ("Label", Constants.WsscNamespace);
+                                                       break;
+                                               case "Nonce":
+                                                       nonce = Convert.FromBase64String (reader.ReadElementContentAsString ("Nonce", Constants.WsscNamespace));
+                                                       break;
+                                               }
+                                       reader.ReadEndElement ();
+                                       break;
+                               case "Offset":
+                                       offset = reader.ReadElementContentAsInt ("Offset", Constants.WsscNamespace);
+                                       break;
+                               case "Length":
+                                       length = reader.ReadElementContentAsInt ("Length", Constants.WsscNamespace);
+                                       break;
+                               case "Nonce":
+                                       nonce = Convert.FromBase64String (reader.ReadElementContentAsString ("Nonce", Constants.WsscNamespace));
+                                       break;
+                               case "Label":
+                                       label = reader.ReadElementContentAsString ("Label", Constants.WsscNamespace);
+                                       break;
+                               }
+                       reader.ReadEndElement ();
+
+                       // resolve key reference
+                       SymmetricSecurityKey key = tokenResolver.ResolveSecurityKey (kic) as SymmetricSecurityKey;
+                       if (key == null)
+                               throw new XmlException ("Cannot resolve the security key referenced by the DerivedKeyToken as a symmetric key");
+
+                       return new DerivedKeySecurityToken (id, algorithm, kic, key, name, generation, offset, length, label, nonce);
+               }
+
+               // since it cannot consume RequestSecurityTokenResponse,
+               // the token information cannot be complete.
+               SecurityContextSecurityToken ReadSecurityContextToken (
+                       XmlReader reader, SecurityTokenResolver tokenResolver)
+               {
+                       string id = reader.GetAttribute ("Id", Constants.WsuNamespace);
+                       reader.Read ();
+
+                       // The input dnse:Cookie value is encrypted by the
+                       // server's SecurityStateEncoder
+                       // (setting error-raising encoder to ServiceCredentials.
+                       // SecureConversationAuthentication.SecurityStateEncoder
+                       // shows it).
+                       UniqueId cid = null;
+                       byte [] cookie = null;
+                       while (true) {
+                               reader.MoveToContent ();
+                               if (reader.NodeType != XmlNodeType.Element)
+                                       break;
+                               switch (reader.NamespaceURI) {
+                               case Constants.WsscNamespace:
+                                       switch (reader.LocalName) {
+                                       case "Identifier":
+                                               cid = new UniqueId (reader.ReadElementContentAsString ());
+                                               continue;
+                                       }
+                                       break;
+                               case Constants.MSTlsnegoTokenContent:
+                                       switch (reader.LocalName) {
+                                       case "Cookie":
+                                               cookie = Convert.FromBase64String (reader.ReadElementContentAsString ());
+                                               continue;
+                                       }
+                                       break;
+                               }
+                               throw new XmlException (String.Format ("Unexpected element {0} in namespace {1}", reader.LocalName, reader.NamespaceURI));
+                       }
+                       reader.ReadEndElement ();
+
+                       // LAMESPEC: at client side there is no way to specify
+                       // SecurityStateEncoder, so it must be guessed from
+                       // its cookie content itself.
+                       if (encoder == null) throw new Exception ();
+                       byte [] decoded =
+                               cookie != null && cookie.Length > 154 ?
+                               encoder.DecodeSecurityState (cookie) :
+                               cookie;
+                       return SslnegoCookieResolver.ResolveCookie (decoded, cookie);
+               }
+
+               WrappedKeySecurityToken ReadWrappedKeySecurityTokenCore (
+                       XmlReader reader, SecurityTokenResolver tokenResolver)
+               {
+                       if (tokenResolver == null)
+                               throw new ArgumentNullException ("tokenResolver");
+                       EncryptedKey ek = new EncryptedKey ();
+                       ek.LoadXml (new XmlDocument ().ReadNode (reader) as XmlElement);
+                       SecurityKeyIdentifier ki = new SecurityKeyIdentifier ();
+                       foreach (KeyInfoClause kic in ek.KeyInfo)
+                               ki.Add (ReadKeyIdentifierClause (new XmlNodeReader (kic.GetXml ())));
+                       SecurityToken token = tokenResolver.ResolveToken (ki);
+                       string alg = ek.EncryptionMethod.KeyAlgorithm;
+                       foreach (SecurityKey skey in token.SecurityKeys)
+                               if (skey.IsSupportedAlgorithm (alg)) {
+                                       byte [] key = skey.DecryptKey (alg, ek.CipherData.CipherValue);
+                                       WrappedKeySecurityToken wk =
+                                               new WrappedKeySecurityToken (ek.Id, key, alg, token, ki);
+                                       // FIXME: This should not be required.
+                                       wk.SetWrappedKey (ek.CipherData.CipherValue);
+                                       wk.ReferenceList = ek.ReferenceList;
+                                       return wk;
+                               }
+                       throw new InvalidOperationException (String.Format ("Cannot resolve security key with the resolved SecurityToken specified by the key identifier in the EncryptedKey XML. The key identifier is: {0}", ki));
+               }
+
+               X509SecurityToken ReadX509TokenCore (
+                       XmlReader reader, SecurityTokenResolver resolver)
+               {
+                       string id = reader.GetAttribute ("Id", Constants.WsuNamespace);
+                       byte [] raw = Convert.FromBase64String (reader.ReadElementContentAsString ());
+                       return new X509SecurityToken (new X509Certificate2 (raw), id);
+               }
+
+               UserNameSecurityToken ReadUserNameTokenCore (
+                       XmlReader reader, SecurityTokenResolver resolver)
+               {
+                       string id = reader.GetAttribute ("Id", Constants.WsuNamespace);
+                       if (reader.IsEmptyElement)
+                               throw new XmlException ("At least UsernameToken must contain Username");
+                       reader.Read ();
+                       reader.MoveToContent ();
+                       string user = reader.ReadElementContentAsString ("Username", Constants.WssNamespace);
+                       reader.MoveToContent ();
+                       string pass = null;
+                       if (reader.LocalName == "Password" && reader.NamespaceURI == Constants.WssNamespace) {
+                               pass = reader.ReadElementContentAsString ("Password", Constants.WssNamespace);
+                               reader.MoveToContent ();
+                       }
+                       reader.ReadEndElement ();
+                       return id != null ?
+                               new UserNameSecurityToken (user, pass, id) :
+                               new UserNameSecurityToken (user, pass);
+               }
+
+               BinarySecretSecurityToken ReadBinarySecretTokenCore (
+                       XmlReader reader, SecurityTokenResolver resolver)
+               {
+                       string id = reader.GetAttribute ("Id", Constants.WsuNamespace);
+                       byte [] data = Convert.FromBase64String (reader.ReadElementContentAsString ());
+                       return new BinarySecretSecurityToken (id, data);
+               }
+
+               [MonoTODO]
+               protected override bool CanWriteKeyIdentifierCore (
+                       SecurityKeyIdentifier keyIdentifier)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override bool CanWriteKeyIdentifierClauseCore (
+                       SecurityKeyIdentifierClause keyIdentifierClause)
+               {
+                       if (keyIdentifierClause == null)
+                               throw new ArgumentNullException ("keyIdentifierClause");
+                       if (keyIdentifierClause is LocalIdKeyIdentifierClause ||
+                           keyIdentifierClause is SecurityContextKeyIdentifierClause ||
+                           keyIdentifierClause is X509IssuerSerialKeyIdentifierClause ||
+                           (keyIdentifierClause is X509ThumbprintKeyIdentifierClause && !WSS1_0) ||
+                           keyIdentifierClause is EncryptedKeyIdentifierClause ||
+                           keyIdentifierClause is BinarySecretKeyIdentifierClause ||
+                           keyIdentifierClause is InternalEncryptedKeyIdentifierClause ||
+                           keyIdentifierClause is SamlAssertionKeyIdentifierClause)
+                               return true;
+                       else
+                               return false;
+               }
+
+               [MonoTODO]
+               protected override bool CanWriteTokenCore (SecurityToken token)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void WriteKeyIdentifierCore (
+                       XmlWriter writer,
+                       SecurityKeyIdentifier keyIdentifier)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void WriteKeyIdentifierClauseCore (
+                       XmlWriter writer,
+                       SecurityKeyIdentifierClause keyIdentifierClause)
+               {
+                       string errorReason = null;
+
+                       if (keyIdentifierClause == null)
+                               throw new ArgumentNullException ("keyIdentifierClause");
+                       if (keyIdentifierClause is LocalIdKeyIdentifierClause)
+                               WriteLocalIdKeyIdentifierClause (writer, (LocalIdKeyIdentifierClause) keyIdentifierClause);
+                       else if (keyIdentifierClause is SecurityContextKeyIdentifierClause)
+                               WriteSecurityContextKeyIdentifierClause (writer, (SecurityContextKeyIdentifierClause) keyIdentifierClause);
+                       else if (keyIdentifierClause is X509IssuerSerialKeyIdentifierClause)
+                               WriteX509IssuerSerialKeyIdentifierClause (writer, (X509IssuerSerialKeyIdentifierClause) keyIdentifierClause);
+                       else if (keyIdentifierClause is X509ThumbprintKeyIdentifierClause) {
+                               if (WSS1_0)
+                                       errorReason = String.Format ("Security key identifier clause '{0}' is not supported in this serializer.", keyIdentifierClause.GetType ());
+                               else
+                                       WriteX509ThumbprintKeyIdentifierClause (writer, (X509ThumbprintKeyIdentifierClause) keyIdentifierClause);
+                       }
+                       else if (keyIdentifierClause is EncryptedKeyIdentifierClause)
+                               WriteEncryptedKeyIdentifierClause (writer, (EncryptedKeyIdentifierClause) keyIdentifierClause);
+                       else if (keyIdentifierClause is BinarySecretKeyIdentifierClause)
+                               WriteBinarySecretKeyIdentifierClause (writer, (BinarySecretKeyIdentifierClause) keyIdentifierClause);
+                       else if (keyIdentifierClause is InternalEncryptedKeyIdentifierClause)
+                               WriteInternalEncryptedKeyIdentifierClause (writer, (InternalEncryptedKeyIdentifierClause) keyIdentifierClause);
+                       else if (keyIdentifierClause is SamlAssertionKeyIdentifierClause)
+                               WriteSamlAssertionKeyIdentifierClause (writer, (SamlAssertionKeyIdentifierClause) keyIdentifierClause);
+                       else
+                               throw new NotImplementedException (String.Format ("Security key identifier clause '{0}' is not either implemented or supported.", keyIdentifierClause.GetType ()));
+
+                       if (errorReason != null)
+                               throw new InvalidOperationException (errorReason);
+               }
+
+               void WriteX509IssuerSerialKeyIdentifierClause (
+                       XmlWriter w, X509IssuerSerialKeyIdentifierClause ic)
+               {
+                       w.WriteStartElement ("o", "SecurityTokenReference", Constants.WssNamespace);
+                       w.WriteStartElement ("X509Data", Constants.XmlDsig);
+                       w.WriteStartElement ("X509IssuerSerial", Constants.XmlDsig);
+                       w.WriteStartElement ("X509IssuerName", Constants.XmlDsig);
+                       w.WriteString (ic.IssuerName);
+                       w.WriteEndElement ();
+                       w.WriteStartElement ("X509SerialNumber", Constants.XmlDsig);
+                       w.WriteString (ic.IssuerSerialNumber);
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+               }
+
+               void WriteX509ThumbprintKeyIdentifierClause (
+                       XmlWriter w, X509ThumbprintKeyIdentifierClause ic)
+               {
+                       w.WriteStartElement ("o", "SecurityTokenReference", Constants.WssNamespace);
+                       w.WriteStartElement ("o", "KeyIdentifier", Constants.WssNamespace);
+                       w.WriteAttributeString ("ValueType", Constants.WssKeyIdentifierX509Thumbptint);
+                       if (EmitBspRequiredAttributes)
+                               w.WriteAttributeString ("EncodingType", Constants.WssBase64BinaryEncodingType);
+                       w.WriteString (Convert.ToBase64String (ic.GetX509Thumbprint ()));
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+               }
+
+               void WriteLocalIdKeyIdentifierClause (
+                       XmlWriter w, LocalIdKeyIdentifierClause ic)
+               {
+                       w.WriteStartElement ("o", "SecurityTokenReference", Constants.WssNamespace);
+                       w.WriteStartElement ("o", "Reference", Constants.WssNamespace);
+                       if (EmitBspRequiredAttributes && ic.OwnerType != null) {
+                               string vt = GetTokenTypeUri (ic.OwnerType);
+                               if (vt != null)
+                                       w.WriteAttributeString ("ValueType", vt);
+                       }
+                       w.WriteAttributeString ("URI", "#" + ic.LocalId);
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+               }
+
+               void WriteSecurityContextKeyIdentifierClause (
+                       XmlWriter w, SecurityContextKeyIdentifierClause ic)
+               {
+                       w.WriteStartElement ("o", "SecurityTokenReference", Constants.WssNamespace);
+                       w.WriteStartElement ("o", "Reference", Constants.WssNamespace);
+                       w.WriteAttributeString ("URI", ic.ContextId.ToString ());
+                       string vt = GetTokenTypeUri (typeof (SecurityContextSecurityToken));
+                       w.WriteAttributeString ("ValueType", vt);
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+               }
+
+               void WriteEncryptedKeyIdentifierClause (
+                       XmlWriter w, EncryptedKeyIdentifierClause ic)
+               {
+                       w.WriteStartElement ("e", "EncryptedKey", EncryptedXml.XmlEncNamespaceUrl);
+                       w.WriteStartElement ("EncryptionMethod", EncryptedXml.XmlEncNamespaceUrl);
+                       w.WriteAttributeString ("Algorithm", ic.EncryptionMethod);
+                       w.WriteEndElement ();
+                       if (ic.EncryptingKeyIdentifier != null) {
+                               w.WriteStartElement ("KeyInfo", SignedXml.XmlDsigNamespaceUrl);
+                               foreach (SecurityKeyIdentifierClause ckic in ic.EncryptingKeyIdentifier)
+                                       WriteKeyIdentifierClause (w, ckic);
+                               w.WriteEndElement ();
+                       }
+                       w.WriteStartElement ("CipherData", EncryptedXml.XmlEncNamespaceUrl);
+                       w.WriteStartElement ("CipherValue", EncryptedXml.XmlEncNamespaceUrl);
+                       w.WriteString (Convert.ToBase64String (ic.GetEncryptedKey ()));
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+                       if (ic.CarriedKeyName != null)
+                               w.WriteElementString ("CarriedKeyName", EncryptedXml.XmlEncNamespaceUrl, ic.CarriedKeyName);
+                       w.WriteEndElement ();
+               }
+
+               void WriteBinarySecretKeyIdentifierClause (
+                       XmlWriter w, BinarySecretKeyIdentifierClause ic)
+               {
+                       w.WriteStartElement ("t", "BinarySecret", Constants.WstNamespace);
+                       w.WriteString (Convert.ToBase64String (ic.GetBuffer ()));
+                       w.WriteEndElement ();
+               }
+
+               void WriteInternalEncryptedKeyIdentifierClause (
+                       XmlWriter w, InternalEncryptedKeyIdentifierClause ic)
+               {
+                       w.WriteStartElement ("o", "SecurityTokenReference", Constants.WssNamespace);
+                       w.WriteStartElement ("o", "KeyIdentifier", Constants.WssNamespace);
+                       w.WriteAttributeString ("ValueType", Constants.WssKeyIdentifierEncryptedKey);
+                       w.WriteString (Convert.ToBase64String (ic.GetBuffer ()));
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+               }
+
+               void WriteSamlAssertionKeyIdentifierClause (XmlWriter w, SamlAssertionKeyIdentifierClause ic)
+               {
+                       w.WriteStartElement ("o", "SecurityTokenReference", Constants.WssNamespace);
+                       w.WriteStartElement ("o", "KeyIdentifier", Constants.WssNamespace);
+                       w.WriteAttributeString ("ValueType", Constants.WssKeyIdentifierSamlAssertion);
+                       w.WriteString (ic.AssertionId);
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+               }
+
+               [MonoTODO]
+               protected override void WriteTokenCore (
+                       XmlWriter writer, SecurityToken token)
+               {
+                       // WSSecurity supports:
+                       //      - UsernameToken : S.IM.T.UserNameSecurityToken
+                       //      - X509SecurityToken : S.IM.T.X509SecurityToken
+                       //      - SAML Assertion : S.IM.T.SamlSecurityToken
+                       //      - Kerberos : S.IM.T.KerberosRequestorSecurityToken
+                       //      - Rights Expression Language (REL) : N/A
+                       //      - SOAP with Attachments : N/A
+                       // they are part of standards support:
+                       //      - WrappedKey (EncryptedKey)
+                       //      - BinarySecret (WS-Trust)
+                       //      - SecurityContext (WS-SecureConversation)
+                       // additionally there are extra token types in WCF:
+                       //      - GenericXml
+                       //      - Windows
+                       //      - Sspi
+                       // not supported in this class:
+                       //      - Rsa
+
+                       if (token is UserNameSecurityToken)
+                               WriteUserNameSecurityToken (writer, ((UserNameSecurityToken) token));
+                       else if (token is X509SecurityToken)
+                               WriteX509SecurityToken (writer, ((X509SecurityToken) token));
+                       else if (token is BinarySecretSecurityToken)
+                               WriteBinarySecretSecurityToken (writer, ((BinarySecretSecurityToken) token));
+                       else if (token is SamlSecurityToken)
+                               throw new NotImplementedException ("WriteTokenCore() is not implemented for " + token);
+                       else if (token is GenericXmlSecurityToken)
+                               ((GenericXmlSecurityToken) token).TokenXml.WriteTo (writer);
+                       else if (token is WrappedKeySecurityToken)
+                               WriteWrappedKeySecurityToken (writer, (WrappedKeySecurityToken) token);
+                       else if (token is DerivedKeySecurityToken)
+                               WriteDerivedKeySecurityToken (writer, (DerivedKeySecurityToken) token);
+                       else if (token is SecurityContextSecurityToken)
+                               WriteSecurityContextSecurityToken (writer, (SecurityContextSecurityToken) token);
+                       else if (token is SspiSecurityToken)
+                               throw new NotImplementedException ("WriteTokenCore() is not implemented for " + token);
+                       else if (token is KerberosRequestorSecurityToken)
+                               throw new NotImplementedException ("WriteTokenCore() is not implemented for " + token);
+                       else if (token is WindowsSecurityToken)
+                               throw new NotImplementedException ("WriteTokenCore() is not implemented for " + token);
+                       else
+                               throw new InvalidOperationException (String.Format ("This SecurityTokenSerializer does not support security token '{0}'.", token));
+               }
+
+               void WriteUserNameSecurityToken (XmlWriter w, UserNameSecurityToken token)
+               {
+                       w.WriteStartElement ("o", "UsernameToken", Constants.WssNamespace);
+                       w.WriteAttributeString ("u", "Id", Constants.WsuNamespace, token.Id);
+                       w.WriteStartElement ("o", "Username", Constants.WssNamespace);
+                       w.WriteString (token.UserName);
+                       w.WriteEndElement ();
+                       w.WriteStartElement ("o", "Password", Constants.WssNamespace);
+                       w.WriteString (token.Password);
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+               }
+
+               void WriteX509SecurityToken (XmlWriter w, X509SecurityToken token)
+               {
+                       w.WriteStartElement ("o", "BinarySecurityToken", Constants.WssNamespace);
+                       w.WriteAttributeString ("u", "Id", Constants.WsuNamespace, token.Id);
+                       w.WriteAttributeString ("ValueType", Constants.WSSX509Token);
+                       w.WriteString (Convert.ToBase64String (token.Certificate.RawData));
+                       w.WriteEndElement ();
+               }
+
+               void WriteBinarySecretSecurityToken (XmlWriter w, BinarySecretSecurityToken token)
+               {
+                       w.WriteStartElement ("t", "BinarySecret", Constants.WstNamespace);
+                       w.WriteAttributeString ("u", "Id", Constants.WsuNamespace, token.Id);
+                       w.WriteString (Convert.ToBase64String (token.GetKeyBytes ()));
+                       w.WriteEndElement ();
+               }
+
+               void WriteDerivedKeySecurityToken (XmlWriter w, DerivedKeySecurityToken token)
+               {
+                       string ns = Constants.WsscNamespace;
+                       w.WriteStartElement ("c", "DerivedKeyToken", ns);
+                       w.WriteAttributeString ("u", "Id", Constants.WsuNamespace, token.Id);
+                       WriteKeyIdentifierClause (w, token.TokenReference);
+                       if (token.Name != null) {
+                               w.WriteStartElement ("Properties", ns);
+                               w.WriteElementString ("Name", ns, token.Name);
+                               w.WriteEndElement ();
+                       }
+                       if (token.Offset != null)
+                               w.WriteElementString ("Offset", ns, Convert.ToString (token.Offset));
+                       if (token.Length != null)
+                               w.WriteElementString ("Length", ns, Convert.ToString (token.Length));
+                       if (token.Label != null)
+                               w.WriteElementString ("Label", ns, token.Label);
+                       w.WriteElementString ("Nonce", ns, Convert.ToBase64String (token.Nonce));
+                       w.WriteEndElement ();
+               }
+
+               void WriteWrappedKeySecurityToken (XmlWriter w, WrappedKeySecurityToken token)
+               {
+                       string encNS = EncryptedXml.XmlEncNamespaceUrl;
+                       w.WriteStartElement ("e", "EncryptedKey", encNS);
+                       w.WriteAttributeString ("Id", token.Id);
+                       w.WriteStartElement ("EncryptionMethod", encNS);
+                       w.WriteAttributeString ("Algorithm", token.WrappingAlgorithm);
+                       w.WriteStartElement ("DigestMethod", SignedXml.XmlDsigNamespaceUrl);
+                       w.WriteAttributeString ("Algorithm", SignedXml.XmlDsigSHA1Url);
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+
+                       w.WriteStartElement ("KeyInfo", SignedXml.XmlDsigNamespaceUrl);
+                       if (token.WrappingTokenReference != null)
+                               foreach (SecurityKeyIdentifierClause kic in token.WrappingTokenReference)
+                                       WriteKeyIdentifierClause (w, kic);
+                       w.WriteEndElement ();
+                       w.WriteStartElement ("CipherData", encNS);
+                       w.WriteStartElement ("CipherValue", encNS);
+                       w.WriteString (Convert.ToBase64String (token.GetWrappedKey ()));
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+                       if (token.ReferenceList != null) {
+                               w.WriteStartElement ("e", "ReferenceList", encNS);
+                               foreach (DataReference er in token.ReferenceList) {
+                                       w.WriteStartElement ("DataReference", encNS);
+                                       w.WriteAttributeString ("URI", er.Uri);
+                                       w.WriteEndElement ();
+                               }
+                               w.WriteEndElement ();
+                       }
+                       w.WriteEndElement ();
+               }
+
+               void WriteSecurityContextSecurityToken (XmlWriter w, SecurityContextSecurityToken token)
+               {
+                       string ns = Constants.WsscNamespace;
+                       w.WriteStartElement ("c", "SecurityContextToken", ns);
+                       w.WriteAttributeString ("u", "Id", Constants.WsuNamespace, token.Id);
+                       w.WriteElementString ("Identifier", ns, token.ContextId.ToString ());
+                       // FIXME: add Cookie output (from CreateCookieSecurityContextToken() method)
+                       if (token.Cookie != null)
+                               w.WriteElementString ("dnse", "Cookie", Constants.MSTlsnegoTokenContent, Convert.ToBase64String (token.Cookie));
+                       w.WriteEndElement ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/WindowsClientCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/WindowsClientCredential.cs
new file mode 100644 (file)
index 0000000..c3841ae
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// WindowsClientCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net;
+using System.Security.Principal;
+
+namespace System.ServiceModel.Security
+{
+       public sealed class WindowsClientCredential
+       {
+               internal WindowsClientCredential ()
+               {
+               }
+
+               bool allow_ntlm = true;
+               TokenImpersonationLevel impersonation_level = TokenImpersonationLevel.Identification;
+               NetworkCredential client_credential = new NetworkCredential ();
+
+               public TokenImpersonationLevel AllowedImpersonationLevel {
+                       get { return impersonation_level; }
+                       set { impersonation_level = value; }
+               }
+
+               public bool AllowNtlm {
+                       get { return allow_ntlm; }
+                       set { allow_ntlm = value; }
+               }
+
+               [MonoTODO]
+               public NetworkCredential ClientCredential {
+                       get { return client_credential; }
+                       set { client_credential = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/WindowsServiceCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/WindowsServiceCredential.cs
new file mode 100644 (file)
index 0000000..aacd899
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// WindowsServiceCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net;
+using System.Security.Principal;
+
+namespace System.ServiceModel.Security
+{
+       public sealed class WindowsServiceCredential
+       {
+               internal WindowsServiceCredential ()
+               {
+               }
+
+               bool allow_anon, inc_win_groups;
+
+               public bool AllowAnonymousLogons {
+                       get { return allow_anon; }
+                       set { allow_anon = value; }
+               }
+
+               public bool IncludeWindowsGroups {
+                       get { return inc_win_groups; }
+                       set { inc_win_groups = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateInitiatorClientCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateInitiatorClientCredential.cs
new file mode 100644 (file)
index 0000000..2012103
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// X509CertificateInitiatorClientCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       public sealed class X509CertificateInitiatorClientCredential
+       {
+               internal X509CertificateInitiatorClientCredential ()
+               {
+               }
+
+               X509Certificate2 certificate;
+
+               public X509Certificate2 Certificate {
+                       get { return certificate; }
+                       set { certificate = value; }
+               }
+
+               [MonoTODO]
+               public void SetCertificate (StoreLocation storeLocation,
+                       StoreName storeName, X509FindType findType,
+                       object findValue)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void SetCertificate (
+                       string subjectName, StoreLocation storeLocation,
+                       StoreName storeName)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateInitiatorServiceCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateInitiatorServiceCredential.cs
new file mode 100644 (file)
index 0000000..615a577
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// X509CertificateInitiatorServiceCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Security.Cryptography.X509Certificates;
+using System.IdentityModel.Selectors;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       [MonoTODO]
+       public sealed class X509CertificateInitiatorServiceCredential
+       {
+               internal X509CertificateInitiatorServiceCredential ()
+               {
+               }
+
+               X509ClientCertificateAuthentication auth =
+                       new X509ClientCertificateAuthentication ();
+               X509Certificate2 certificate;
+
+               [MonoTODO]
+               public X509ClientCertificateAuthentication Authentication {
+                       get { return auth; }
+               }
+
+               public X509Certificate2 Certificate {
+                       get { return certificate; }
+                       set { certificate = value; }
+               }
+
+               [MonoTODO]
+               public void SetCertificate (StoreLocation storeLocation,
+                       StoreName storeName, X509FindType findType,
+                       object findValue)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void SetCertificate (
+                       string subjectName, StoreLocation storeLocation,
+                       StoreName storeName)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateRecipientClientCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateRecipientClientCredential.cs
new file mode 100644 (file)
index 0000000..184aff1
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// X509CertificateRecipientClientCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Selectors;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       public sealed class X509CertificateRecipientClientCredential
+       {
+               internal X509CertificateRecipientClientCredential ()
+               {
+               }
+
+               X509ServiceCertificateAuthentication auth =
+                       new X509ServiceCertificateAuthentication ();
+               X509Certificate2 certificate;
+               Dictionary<Uri,X509Certificate2> scoped =
+                       new Dictionary<Uri,X509Certificate2> ();
+               X509CertificateValidator validator;
+               X509RevocationMode revocation_mode;
+               StoreLocation store_loc;
+
+               public X509ServiceCertificateAuthentication Authentication {
+                       get { return auth; }
+               }
+
+               public X509Certificate2 DefaultCertificate {
+                       get { return certificate; }
+                       set { certificate = value; }
+               }
+
+               public Dictionary<Uri,X509Certificate2> ScopedCertificates {
+                       get { return scoped; }
+               }
+
+               [MonoTODO]
+               public void SetDefaultCertificate (string subjectName,
+                       StoreLocation storeLocation, StoreName storeName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void SetDefaultCertificate (StoreLocation storeLocation,
+                       StoreName storeName, X509FindType findType, Object findValue)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void SetScopedCertificate (string subjectName,
+                       StoreLocation storeLocation, StoreName storeName,
+                       Uri targetService)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void SetScopedCertificate (StoreLocation storeLocation,
+                       StoreName storeName, X509FindType findType,
+                       Object findValue, Uri targetService)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateRecipientServiceCredential.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509CertificateRecipientServiceCredential.cs
new file mode 100644 (file)
index 0000000..8239cbc
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// X509CertificateRecipientServiceCredential.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       public sealed class X509CertificateRecipientServiceCredential
+       {
+               internal X509CertificateRecipientServiceCredential ()
+               {
+               }
+
+               X509Certificate2 certificate;
+
+               public X509Certificate2 Certificate {
+                       get { return certificate; }
+                       set { certificate = value; }
+               }
+
+               [MonoTODO]
+               public void SetCertificate (StoreLocation storeLocation,
+                       StoreName storeName, X509FindType findType,
+                       object findValue)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void SetCertificate (string subjectName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void SetCertificate (
+                       string subjectName, StoreLocation storeLocation,
+                       StoreName storeName)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509ClientCertificateAuthentication.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509ClientCertificateAuthentication.cs
new file mode 100644 (file)
index 0000000..9096a33
--- /dev/null
@@ -0,0 +1,81 @@
+//
+// X509ClientCertificateAuthentication.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.IdentityModel.Selectors;
+
+namespace System.ServiceModel.Security
+{
+       [MonoTODO]
+       public class X509ClientCertificateAuthentication
+       {
+               internal X509ClientCertificateAuthentication ()
+               {
+               }
+
+               X509CertificateValidationMode validation_mode =
+                       X509CertificateValidationMode.ChainTrust;
+               X509CertificateValidator custom_validator;
+               bool include_windows_groups = true, map_cert_account;
+               X509RevocationMode revocation_mode = X509RevocationMode.Online;
+               StoreLocation trusted_store_loc = StoreLocation.LocalMachine;
+
+               public X509CertificateValidationMode CertificateValidationMode {
+                       get { return validation_mode; }
+                       set { validation_mode = value; }
+               }
+
+               public X509CertificateValidator CustomCertificateValidator {
+                       get { return custom_validator; }
+                       set { custom_validator = value; }
+               }
+
+               public bool IncludeWindowsGroups {
+                       get { return include_windows_groups; }
+                       set { include_windows_groups = value; }
+               }
+
+               public bool MapClientCertificateToWindowsAccount {
+                       get { return map_cert_account; }
+                       set { map_cert_account = value; }
+               }
+
+               public X509RevocationMode RevocationMode {
+                       get { return revocation_mode; }
+                       set { revocation_mode = value; }
+               }
+
+               public StoreLocation TrustedStoreLocation { 
+                       get { return trusted_store_loc; }
+                       set { trusted_store_loc = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509PeerCertificateAuthentication.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509PeerCertificateAuthentication.cs
new file mode 100644 (file)
index 0000000..e4807c1
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// X509PeerCertificateAuthentication.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Security.Cryptography.X509Certificates;
+using System.IdentityModel.Selectors;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel.Security
+{
+       [MonoTODO]
+       public class X509PeerCertificateAuthentication
+       {
+               internal X509PeerCertificateAuthentication ()
+               {
+               }
+
+               X509CertificateValidator validator;
+               X509RevocationMode revocation_mode = X509RevocationMode.Online;
+               StoreLocation store_loc = StoreLocation.CurrentUser;
+               X509CertificateValidationMode validation_mode =
+                       X509CertificateValidationMode.PeerOrChainTrust;
+
+               public X509CertificateValidator CustomCertificateValidator {
+                       get { return validator; }
+                       set { validator = value; }
+               }
+
+               public X509RevocationMode RevocationMode {
+                       get { return revocation_mode; }
+                       set { revocation_mode = value; }
+               }
+
+               public StoreLocation TrustedStoreLocation {
+                       get { return store_loc; }
+                       set { store_loc = value; }
+               }
+
+               public X509CertificateValidationMode CertificateValidationMode {
+                       get { return validation_mode; }
+                       set { validation_mode = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509ServiceCertificateAuthentication.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Security/X509ServiceCertificateAuthentication.cs
new file mode 100644 (file)
index 0000000..804dd21
--- /dev/null
@@ -0,0 +1,69 @@
+//
+// X509ServiceCertificateAuthentication.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.IdentityModel.Selectors;
+
+namespace System.ServiceModel.Security
+{
+       [MonoTODO]
+       public class X509ServiceCertificateAuthentication
+       {
+               internal X509ServiceCertificateAuthentication ()
+               {
+               }
+
+               X509CertificateValidationMode validation_mode;
+               X509CertificateValidator custom_validator;
+               X509RevocationMode revocation_mode;
+               StoreLocation trusted_store_loc;
+
+               public X509CertificateValidationMode CertificateValidationMode {
+                       get { return validation_mode; }
+                       set { validation_mode = value; }
+               }
+
+               public X509CertificateValidator CustomCertificateValidator {
+                       get { return custom_validator; }
+                       set { custom_validator = value; }
+               }
+
+               public X509RevocationMode RevocationMode {
+                       get { return revocation_mode; }
+                       set { revocation_mode = value; }
+               }
+
+               public StoreLocation TrustedStoreLocation { 
+                       get { return trusted_store_loc; }
+                       set { trusted_store_loc = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.csproj b/mcs/class/System.ServiceModel/System.ServiceModel.csproj
new file mode 100644 (file)
index 0000000..ebe0d84
--- /dev/null
@@ -0,0 +1,1129 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProductVersion>9.0.21022</ProductVersion>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectGuid>{0CD5DD13-89FF-4710-BAE2-4957418F4251}</ProjectGuid>\r
+    <OutputType>Library</OutputType>\r
+    <AppDesignerFolder>Properties</AppDesignerFolder>\r
+    <RootNamespace>System.ServiceModel</RootNamespace>\r
+    <AssemblyName>System.ServiceModel</AssemblyName>\r
+    <TargetFrameworkVersion>v3.0</TargetFrameworkVersion>\r
+    <FileAlignment>512</FileAlignment>\r
+    <SignAssembly>true</SignAssembly>\r
+    <AssemblyOriginatorKeyFile>\r
+    </AssemblyOriginatorKeyFile>\r
+    <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>bin\Debug\</OutputPath>\r
+    <DefineConstants>TRACE;DEBUG;NET_2_0,TARGET_DOTNET</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE;NET_2_0,TARGET_DOTNET</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="System" />\r
+    <Reference Include="System.configuration" />\r
+    <Reference Include="System.Data" />\r
+    <Reference Include="System.Drawing" />\r
+    <Reference Include="System.IdentityModel">\r
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.IdentityModel.Selectors">\r
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Messaging" />\r
+    <Reference Include="System.Runtime.Serialization">\r
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Security" />\r
+    <Reference Include="System.Transactions" />\r
+    <Reference Include="System.Web" />\r
+    <Reference Include="System.Web.Services" />\r
+    <Reference Include="System.Windows.Forms" />\r
+    <Reference Include="System.Xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\..\build\common\Locale.cs">\r
+      <Link>Locale.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\build\common\MonoTODOAttribute.cs">\r
+      <Link>MonoTODOAttribute.cs</Link>\r
+    </Compile>\r
+    <Compile Include="Assembly\AssemblyInfo.cs" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Math.Prime.Generator\NextPrimeFinder.cs">\r
+      <Link>Mono.Math.Prime.Generator\NextPrimeFinder.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Math.Prime.Generator\PrimeGeneratorBase.cs">\r
+      <Link>Mono.Math.Prime.Generator\PrimeGeneratorBase.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Math.Prime.Generator\SequentialSearchPrimeGeneratorBase.cs">\r
+      <Link>Mono.Math.Prime.Generator\SequentialSearchPrimeGeneratorBase.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Math.Prime\ConfidenceFactor.cs">\r
+      <Link>Mono.Math.Prime\ConfidenceFactor.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Math.Prime\PrimalityTests.cs">\r
+      <Link>Mono.Math.Prime\PrimalityTests.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Math\BigInteger.cs">\r
+      <Link>Mono.Math\BigInteger.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.Cryptography\ARC4Managed.cs">\r
+      <Link>Mono.Security.Cryptography\ARC4Managed.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.Cryptography\CryptoConvert.cs">\r
+      <Link>Mono.Security.Cryptography\CryptoConvert.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.Cryptography\CryptoTools.cs">\r
+      <Link>Mono.Security.Cryptography\CryptoTools.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.Cryptography\MD2.cs">\r
+      <Link>Mono.Security.Cryptography\MD2.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.Cryptography\MD2Managed.cs">\r
+      <Link>Mono.Security.Cryptography\MD2Managed.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.Cryptography\MD4.cs">\r
+      <Link>Mono.Security.Cryptography\MD4.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.Cryptography\MD4Managed.cs">\r
+      <Link>Mono.Security.Cryptography\MD4Managed.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.Cryptography\PKCS1.cs">\r
+      <Link>Mono.Security.Cryptography\PKCS1.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.Cryptography\PKCS8.cs">\r
+      <Link>Mono.Security.Cryptography\PKCS8.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.Cryptography\RC4.cs">\r
+      <Link>Mono.Security.Cryptography\RC4.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.Cryptography\RSAManaged.cs">\r
+      <Link>Mono.Security.Cryptography\RSAManaged.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\AuthorityKeyIdentifierExtension.cs">\r
+      <Link>Mono.Security.X509.Extensions\AuthorityKeyIdentifierExtension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\BasicConstraintsExtension.cs">\r
+      <Link>Mono.Security.X509.Extensions\BasicConstraintsExtension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\CertificatePoliciesExtension.cs">\r
+      <Link>Mono.Security.X509.Extensions\CertificatePoliciesExtension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\CRLDistributionPointsExtension.cs">\r
+      <Link>Mono.Security.X509.Extensions\CRLDistributionPointsExtension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\ExtendedKeyUsageExtension.cs">\r
+      <Link>Mono.Security.X509.Extensions\ExtendedKeyUsageExtension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\GeneralNames.cs">\r
+      <Link>Mono.Security.X509.Extensions\GeneralNames.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\KeyAttributesExtension.cs">\r
+      <Link>Mono.Security.X509.Extensions\KeyAttributesExtension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\KeyUsageExtension.cs">\r
+      <Link>Mono.Security.X509.Extensions\KeyUsageExtension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\NetscapeCertTypeExtension.cs">\r
+      <Link>Mono.Security.X509.Extensions\NetscapeCertTypeExtension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\PrivateKeyUsagePeriodExtension.cs">\r
+      <Link>Mono.Security.X509.Extensions\PrivateKeyUsagePeriodExtension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\SubjectAltNameExtension.cs">\r
+      <Link>Mono.Security.X509.Extensions\SubjectAltNameExtension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509.Extensions\SubjectKeyIdentifierExtension.cs">\r
+      <Link>Mono.Security.X509.Extensions\SubjectKeyIdentifierExtension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\ITrustAnchors.cs">\r
+      <Link>Mono.Security.X509\ITrustAnchors.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\PKCS12.cs">\r
+      <Link>Mono.Security.X509\PKCS12.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\TrustAnchors.cs">\r
+      <Link>Mono.Security.X509\TrustAnchors.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X501Name.cs">\r
+      <Link>Mono.Security.X509\X501Name.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509Builder.cs">\r
+      <Link>Mono.Security.X509\X509Builder.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509Certificate.cs">\r
+      <Link>Mono.Security.X509\X509Certificate.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509CertificateBuilder.cs">\r
+      <Link>Mono.Security.X509\X509CertificateBuilder.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509CertificateCollection.cs">\r
+      <Link>Mono.Security.X509\X509CertificateCollection.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509Chain.cs">\r
+      <Link>Mono.Security.X509\X509Chain.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509ChainStatusFlags.cs">\r
+      <Link>Mono.Security.X509\X509ChainStatusFlags.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509CRL.cs">\r
+      <Link>Mono.Security.X509\X509CRL.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509Extension.cs">\r
+      <Link>Mono.Security.X509\X509Extension.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509Extensions.cs">\r
+      <Link>Mono.Security.X509\X509Extensions.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509Store.cs">\r
+      <Link>Mono.Security.X509\X509Store.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509StoreManager.cs">\r
+      <Link>Mono.Security.X509\X509StoreManager.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X509Stores.cs">\r
+      <Link>Mono.Security.X509\X509Stores.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security.X509\X520Attributes.cs">\r
+      <Link>Mono.Security.X509\X520Attributes.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security\ASN1.cs">\r
+      <Link>Mono.Security\ASN1.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security\ASN1Convert.cs">\r
+      <Link>Mono.Security\ASN1Convert.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security\PKCS7.cs">\r
+      <Link>Mono.Security\PKCS7.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\..\mcs\class\Mono.Security\Mono.Security\StrongName.cs">\r
+      <Link>Mono.Security\StrongName.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\build\common\Consts.cs.in">\r
+      <Link>Consts.cs.in</Link>\r
+    </Compile>\r
+    <Compile Include="Mono.CodeGeneration\CodeAdd.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeAnd.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeArgument.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeArgumentReference.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeArithmeticOperation.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeArrayItem.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeArrayLength.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeAssignment.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeBinaryComparison.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeBinaryOperation.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeBlock.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeBuilder.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeCast.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeClass.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeCustomAttribute.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeDecrement.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeEquals.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeExpression.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeFieldReference.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeFor.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeForeach.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeGenerationHelper.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeIf.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeIncrement.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeIs.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeItem.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeLiteral.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeMethod.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeMethodCall.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeModule.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeNew.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeNewArray.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeNotEquals.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeOr.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeProperty.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodePropertyReference.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeReturn.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeSelect.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeSelfIncrement.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeUnaryOperation.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeValueReference.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeVariableDeclaration.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeVariableReference.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeWhen.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeWhile.cs" />\r
+    <Compile Include="Mono.CodeGeneration\CodeWriter.cs" />\r
+    <Compile Include="Mono.CodeGeneration\Exp.cs" />\r
+    <Compile Include="Mono.Security.Cryptography\MD5SHA1.cs" />\r
+    <Compile Include="Mono.Security.Cryptography\TlsHMAC.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Ntlm\BitConverterLE.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Ntlm\ChallengeResponse.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Ntlm\MessageBase.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Ntlm\NtlmFlags.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Ntlm\NtlmTargetInformation.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Ntlm\NtlmVersion.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Ntlm\Type1Message.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Ntlm\Type2Message.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Ntlm\Type3Message.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Client\TlsClientCertificate.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Client\TlsClientCertificateVerify.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Client\TlsClientFinished.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Client\TlsClientHello.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Client\TlsClientKeyExchange.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Client\TlsServerCertificate.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Client\TlsServerCertificateRequest.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Client\TlsServerFinished.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Client\TlsServerHello.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Client\TlsServerHelloDone.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Client\TlsServerKeyExchange.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Server\TlsClientCertificate.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Server\TlsClientCertificateVerify.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Server\TlsClientFinished.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Server\TlsClientHello.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Server\TlsClientKeyExchange.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Server\TlsServerCertificate.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Server\TlsServerCertificateRequest.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Server\TlsServerFinished.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Server\TlsServerHello.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Server\TlsServerHelloDone.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake.Server\TlsServerKeyExchange.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake\ClientCertificateType.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake\HandshakeMessage.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls.Handshake\HandshakeType.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\Alert.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\CipherAlgorithmType.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\CipherSuite.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\CipherSuiteCollection.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\CipherSuiteFactory.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\ClientContext.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\ClientRecordProtocol.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\ClientSessionCache.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\ContentType.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\Context.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\DebugHelper.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\ExchangeAlgorithmType.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\HandshakeState.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\HashAlgorithmType.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\HttpsClientStream.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\RecordProtocol.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\RSASslSignatureDeformatter.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\RSASslSignatureFormatter.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\SecurityCompressionType.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\SecurityParameters.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\SecurityProtocolType.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\ServerContext.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\ServerRecordProtocol.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\SslCipherSuite.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\SslClientStream.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\SslHandshakeHash.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\SslServerStream.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\SslStreamBase.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\TlsCipherSuite.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\TlsClientSettings.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\TlsException.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\TlsServerSettings.cs" />\r
+    <Compile Include="Mono.Security.Protocol.Tls\TlsStream.cs" />\r
+    <Compile Include="Mono.Xml.XPath\DTMXPathDocument2.cs" />\r
+    <Compile Include="Mono.Xml.XPath\DTMXPathDocumentBuilder2.cs" />\r
+    <Compile Include="Mono.Xml.XPath\DTMXPathDocumentWriter2.cs" />\r
+    <Compile Include="Mono.Xml.XPath\DTMXPathNavigator2.cs" />\r
+    <Compile Include="Mono.Xml.XPath\DTMXPathNode2.cs" />\r
+    <Compile Include="System.Collections.Generic\KeyedByTypeCollection.cs" />\r
+    <Compile Include="System.Collections.Generic\SynchronizedCollection.cs" />\r
+    <Compile Include="System.Collections.Generic\SynchronizedKeyedCollection.cs" />\r
+    <Compile Include="System.Collections.Generic\SynchronizedReadOnlyCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Activation\AspNetIntegrationRequirementsAttribute.cs" />\r
+    <Compile Include="System.ServiceModel.Activation\HttpHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Activation\HttpModule.cs" />\r
+    <Compile Include="System.ServiceModel.Activation\IServiceHostFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Activation\ServiceHostFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Activation\ServiceHostFactoryBase.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\AddressHeader.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\AddressHeaderCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\AddressingVersion.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\AspNetReplyChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\AspNetRequestContext.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\AsymmetricSecurityBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\BinaryMessageEncoder.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\BinaryMessageEncoderFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\BinaryMessageEncodingBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\Binding.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\BindingContext.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\BindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\BindingElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\BindingParameterCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\BodyWriter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\BufferManager.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\CachingCompiler.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ChannelBase.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ChannelFactoryBase.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ChannelListenerBase.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ChannelListenerBase_1.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ChannelManagerBase.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ChannelParameterCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ChannelPoolSettings.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\CommunicationObject.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\CompilationException.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\CompositeDuplexBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\CompositeDuplexBindingElementImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ConnectionOrientedTransportBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\CustomBinding.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\DeliveryFailure.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\DeliveryStatus.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\DirectionalAction.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\DuplexSessionChannelBase.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\FaultConverter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HostedTransportConfiguration.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HtmlizedException.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HttpChannelFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HttpChannelListener.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HttpChannelManager.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HttpReplyChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HttpRequestChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HttpRequestContext.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HttpRequestMessageProperty.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HttpResponseMessageProperty.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HttpsTransportBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\HttpTransportBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IBindingDeliveryCapabilities.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IBindingMulticastCapabilities.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IBindingRuntimePreferences.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IChannelFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IChannelListener.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IDuplexChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IDuplexSession.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IDuplexSessionChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IInputChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IInputSession.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IInputSessionChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IMessageProperty.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\InputChannelBase.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\InvalidChannelBindingException.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IOutputChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IOutputSession.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IOutputSessionChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IReplyChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IReplySessionChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IRequestChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\IRequestSessionChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ISecurityCapabilities.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ISession.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ISessionChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ITransactedBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ITransportTokenAssertionProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\LayeredCommunicationObject.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\LayeredOutputChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\LayeredReplyChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\LayeredRequestChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\LocalClientSecuritySettings.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\Message.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageBuffer.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageBufferImpl.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageEncoder.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageEncoderFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageEncodingBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageEncodingBindingElementImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageFault.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageFaultBodyWriter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageHeader.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageHeaderInfo.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageHeaders.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageImpl.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageProperties.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageSecurityBindingSupport.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MessageVersion.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MsmqBindingElementBase.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MsmqChannelFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MsmqChannelListener.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MsmqInputChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MsmqMessageProperty.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MsmqOutputChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MsmqTransportBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MtomMessageEncoder.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MtomMessageEncoderFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\MtomMessageEncodingBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\NamedPipeConnectionPoolSettings.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\NamedPipetransportBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\OneWayBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\OneWayBindingElementImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\OutputChannelBase.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\PeerResolverBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\PeerTransportBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\PnrpPeerResolverBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ReliableSessionBindingElementImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ReplyChannelBase.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\RequestChannelBase.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\RequestContext.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SecureMessageDecryptor.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SecureMessageGenerator.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SecurityBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SecurityBindingElementImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SecurityChannelFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SecurityChannelListener.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SecurityOutputChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SecurityRequestChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SecurityRequestContext.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\ServiceHostParser.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SslStreamSecurityBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SslStreamSecurityUpgradeAcceptor.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SslStreamSecurityUpgradeProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\StandardBindingImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\StreamSecurityUpgradeAcceptor.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\StreamSecurityUpgradeInitiator.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\StreamSecurityUpgradeProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\StreamUpgradeAcceptor.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\StreamUpgradeBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\StreamUpgradeInitiator.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\StreamUpgradeProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SvcHttpHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SvcHttpHandlerFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\SymmetricSecurityBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TcpChannelFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TcpChannelListener.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TcpConnectionPoolSettings.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TcpDuplexSessionChannel.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TcpTransportBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TextMessageEncoder.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TextMessageEncoderFactory.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TextMessageEncodingBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TransactionFlowBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TransactionFlowBindingElementImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TransactionMessageProperty.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TransportBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TransportBindingElementImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\TransportSecurityBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\UnderstoodHeaders.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\UseManagedPresentationBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\WindowsStreamSecurityBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\WSEncryptedXml.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\WSSecurityMessageHeader.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\WSSignedXml.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\XmlObjectSerializerBodyWriter.cs" />\r
+    <Compile Include="System.ServiceModel.Channels\XmlReaderBodyWriter.cs" />\r
+    <Compile Include="System.ServiceModel.ComIntegration\Dummy.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\AddressHeaderCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\AllowedAudienceUriElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\AllowedAudienceUriElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\AuthenticationMode.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\AuthorizationPolicyTypeElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\AuthorizationPolicyTypeElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BaseAddressElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BaseAddressElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BasicHttpBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BasicHttpBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BasicHttpMessageSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BasicHttpSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BehaviorExtensionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BehaviorsSection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BinaryMessageEncodingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BindingElementExtensionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\BindingsSection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\CallbackDebugElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\CallbackTimeoutsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\CertificateElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\CertificateReferenceElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ChannelEndpointElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ChannelEndpointElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ChannelPoolSettingsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ClaimTypeElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ClaimTypeElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ClientCredentialsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ClientSection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ClientViaElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ComContractElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ComContractElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ComContractsSection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ComMethodElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ComMethodElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\CommonBehaviorsSection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\CommonEndpointBehaviorElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\CommonServiceBehaviorElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ComPersistableTypeElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ComPersistableTypeElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\CompositeDuplexElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ComUdtElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ComUdtElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ConfigUtil.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ConnectionOrientedTransportElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\CustomBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\CustomBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\CustomBindingElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\DataContractSerializerElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\DiagnosticSection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\DnsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\EncodingConverter.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\EndpointAddressElementBase.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\EndpointBehaviorElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\EndpointBehaviorElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ExtensionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ExtensionElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ExtensionsSection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\FederatedMessageSecurityOverHttpElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\HostElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\HostTimeoutsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\HttpDigestClientElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\HttpsTransportElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\HttpTransportElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\HttpTransportSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\IBindingConfigurationElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\IdentityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\IPAddressConverter.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\IssuedTokenClientBehaviorsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\IssuedTokenClientBehaviorsElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\IssuedTokenClientElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\IssuedTokenParametersElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\IssuedTokenParametersEndpointAddressElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\IssuedTokenServiceElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\LocalClientSecuritySettingsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\LocalServiceSecuritySettingsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MessageLoggingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MessageSecurityOverHttpElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MessageSecurityOverMsmqElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MessageSecurityOverTcpElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MessageSecurityVersionConverter.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MessageVersionConverter.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MetadataElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MethodStubs.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MexBindingBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MexBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MexHttpBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MexHttpBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MexHttpsBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MexHttpsBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MexNamedPipeBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MexNamedPipeBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MexTcpBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MexTcpBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MsmqBindingElementBase.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MsmqElementBase.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MsmqIntegrationBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MsmqIntegrationBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MsmqIntegrationElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MsmqIntegrationSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MsmqTransportElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MsmqTransportSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\MtomMessageEncodingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NamedPipeConnectionPoolSettingsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NamedPipeTransportElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NamedPipeTransportSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NamedServiceModelExtensionCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NetMsmqBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NetMsmqBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NetMsmqSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NetNamedPipeBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NetNamedPipeBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NetNamedPipeSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NetPeerTcpBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NetPeerTcpBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NetTcpBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NetTcpBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NetTcpSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\NonDualMessageSecurityOverHttpElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\OneWayElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\PeerCredentialElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\PeerCustomResolverElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\PeerResolverElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\PeerSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\PeerTransportElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\PeerTransportSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\PnrpPeerResolverElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\PolicyImporterElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\PolicyImporterElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\PolicyVersionConverter.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\PrivacyNoticeElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ReliableMessagingVersionConverter.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ReliableSessionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\RsaElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\SecureConversationServiceElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\SecurityAlgorithmSuiteConverter.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\SecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\SecurityElementBase.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceAuthorizationElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceBehaviorElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceBehaviorElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceCredentialsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceDebugElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceEndpointElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceEndpointElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceHostingEnvironmentSection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceMetadataPublishingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceModelConfigurationElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceModelEnhancedConfigurationElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceModelExtensionCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceModelExtensionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceModelSectionGroup.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServicePrincipalNameElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceSecurityAuditElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServicesSection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceThrottlingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\ServiceTimeoutsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\SslStreamSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\StandardBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\StandardBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\StandardBindingElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\StandardBindingOptionalReliableSessionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\StandardBindingReliableSessionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\SynchronousReceiveElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\TcpConnectionPoolSettingsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\TcpTransportElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\TcpTransportSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\TextMessageEncodingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\TransactedBatchingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\TransactionFlowElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\TransactionProtocolConverter.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\TransportConfigurationTypeElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\TransportConfigurationTypeElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\TransportElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\UseManagedPresentationElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\UserNameServiceElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\UserPrincipalNameElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WindowsClientElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WindowsServiceElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WindowsStreamSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WS2007FederationHttpBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WS2007FederationHttpBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WS2007HttpBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WS2007HttpBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WsdlImporterElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WsdlImporterElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WSDualHttpBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WSDualHttpBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WSDualHttpSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WSFederationHttpBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WSFederationHttpBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WSFederationHttpSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WSHttpBindingBaseElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WSHttpBindingCollectionElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WSHttpBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WSHttpSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\WSHttpTransportSecurityElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509CertificateTrustedIssuerElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509CertificateTrustedIssuerElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509ClientCertificateAuthenticationElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509ClientCertificateCredentialsElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509DefaultServiceCertificateElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509InitiatorCertificateClientElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509InitiatorCertificateServiceElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509PeerCertificateAuthenticationElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509PeerCertificateElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509RecipientCertificateClientElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509RecipientCertificateServiceElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509ScopedServiceCertificateElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509ScopedServiceCertificateElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\X509ServiceCertificateAuthenticationElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\XmlDictionaryReaderQuotasElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\XmlElementElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\XmlElementElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\XPathMessageFilterElement.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\XPathMessageFilterElementCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Configuration\XPathMessageFilterElementComparer.cs" />\r
+    <Compile Include="System.ServiceModel.Description\CallbackDebugBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\CallbackTimeoutsBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ClientCredentials.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ClientViaBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ContractDescription.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ContractDescriptionGenerator.cs" />\r
+    <Compile Include="System.ServiceModel.Description\DataContractSerializerMessageContractImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Description\DataContractSerializerOperationBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\FaultDescription.cs" />\r
+    <Compile Include="System.ServiceModel.Description\FaultDescriptionCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Description\HostedBindingBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IContractBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IContractBehaviorAttribute.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IEndpointBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IMetadataExchange.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IOperationBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IOperationContractGenerationExtension.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IpolicyExporter.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IPolicyImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IServiceBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IServiceContractGenerationExtension.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IWsdlExporter.cs" />\r
+    <Compile Include="System.ServiceModel.Description\IWsdlImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Description\LocalServiceSecuritySettings.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MessageBodyDescription.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MessageDescription.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MessageDescriptionCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MessageHeaderDescription.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MessageHeaderDescriptionCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MessagePartDescription.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MessagePartDescriptionCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MessagePropertyDescription.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MessagePropertyDescriptionCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MetadataBundle.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MetadataConversionError.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MetadataExchangeBindings.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MetadataExchangeClient.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MetadataExporter.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MetadataImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MetadataLocation.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MetadataReference.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MetadataResolver.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MetadataSection.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MetadataSectionSerializerBase.cs" />\r
+    <Compile Include="System.ServiceModel.Description\MustUnderstandBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\OperationContractGenerationContext.cs" />\r
+    <Compile Include="System.ServiceModel.Description\OperationDescription.cs" />\r
+    <Compile Include="System.ServiceModel.Description\OperationDescriptionCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Description\PolicyAssertionCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Description\PolicyConversionContext.cs" />\r
+    <Compile Include="System.ServiceModel.Description\PolicyVersion.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceAuthorizationBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceContractGenerationContext.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceContractGenerator.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceCredentials.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceDebugBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceDescription.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceEndpoint.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceEndpointCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceMetadataBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceMetadataExtension.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceSecurityAuditBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceThrottlingBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\ServiceTimeoutsBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\SynchronousReceiveBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\TransactedBatchingBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Description\TypedMessageConverter.cs" />\r
+    <Compile Include="System.ServiceModel.Description\WebServiceHelper.cs" />\r
+    <Compile Include="System.ServiceModel.Description\WsdlContractConversionContext.cs" />\r
+    <Compile Include="System.ServiceModel.Description\WsdlEndpointConversionContext.cs" />\r
+    <Compile Include="System.ServiceModel.Description\WsdlExporter.cs" />\r
+    <Compile Include="System.ServiceModel.Description\WsdlImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Description\WSTrustMessageConverters.cs" />\r
+    <Compile Include="System.ServiceModel.Description\WSTrustSTSContract.cs" />\r
+    <Compile Include="System.ServiceModel.Description\XmlSerializerMessageContractImporter.cs" />\r
+    <Compile Include="System.ServiceModel.Description\XmlSerializerOperationBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Diagnostics\PerformanceCounterScope.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ActionMessageFilter.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ActionMessageFilterTable.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\InputOrReplyRequestProcessor.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\OperationContextScopeHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\PostReceiveRequestHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\BaseMessagesFormatter.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ChannelDispatcher.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ChannelDispatcherBase.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ChannelDispatcherCollection.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ClientOperation.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ClientRuntime.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\DataContractSerializerServiceBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\DefaultInstanceContextProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\DispatchOperation.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\DispatchRuntime.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\EndpointAddressMessageFilter.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\EndpointAddressMessageFilterTable.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\EndpointDispatcher.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ErrorProcessingHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ExceptionHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\FaultContractInfo.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\FilterInvalidBodyAccessException.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\FinalizeProcessingHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ICallContextInitializer.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IChannelInitializer.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IClientMessageFormatter.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IClientMessageInspector.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IClientOperationSelector.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IDispatchMessageFormatter.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IDispatchMessageInspector.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IDispatchOperationSelector.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IErrorHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IInputSessionShutdown.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IInstanceContextInitializer.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IInstanceContextProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IInstanceProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IInteractiveChannelInitializer.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IMessageFilterTable.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\BaseRequestProcessorHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\InstanceBehavior.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\InitializingHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\InstanceContextIdleCallback.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\InvalidBodyAccessException.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IOperationInvoker.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\IParameterInspector.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\MatchAllMessageFilter.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\MatchNoneMessageFilter.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\MessageFilter.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\MessageFilterNodeQuotaExceededException.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\MessageFilterTable.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\MessageProcessingContext.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\BaseRequestProcessor.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\MexInstanceContextProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\MultipleMessageFilterMatchesException.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\NavigatorInvalidBodyAccessException.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\OperationInvokerHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\PrefixEndpointAddressMessageFilter.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ReplyHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\SecurityHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\SeekableXPathNavigator.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\ServiceThrottle.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\SingletonInstanceContextProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\XPathMessageContext.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\XPathMessageFilter.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\XPathMessageFilterTable.cs" />\r
+    <Compile Include="System.ServiceModel.Dispatcher\XPathNavigatorException.cs" />\r
+    <Compile Include="System.ServiceModel.MsmqIntegration\MsmqIntegrationBinding.cs" />\r
+    <Compile Include="System.ServiceModel.MsmqIntegration\MsmqIntegrationBindingElement.cs" />\r
+    <Compile Include="System.ServiceModel.MsmqIntegration\MsmqIntegrationMessageProperty.cs" />\r
+    <Compile Include="System.ServiceModel.MsmqIntegration\MsmqIntegrationSecurity.cs" />\r
+    <Compile Include="System.ServiceModel.MsmqIntegration\MsmqMessage.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\CustomPeerResolverService.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\IPeerResolverContract.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\PeerCustomResolverSettings.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\PeerReferralPolicy.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\PeerResolverMode.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\PeerResolverSettings.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\RefreshInfo.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\RefreshResponseInfo.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\RefreshResult.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\RegisterInfo.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\RegisterResponseInfo.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\ResolveInfo.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\ResolveResponseInfo.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\ServiceSettingsResponseInfo.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\UnregisterInfo.cs" />\r
+    <Compile Include="System.ServiceModel.PeerResolvers\UpdateInfo.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\AuthenticatorCommunicationObject.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\BinarySecretSecurityToken.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\ClaimTypeRequirement.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\CommunicationSecurityTokenAuthenticator.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\CommunicationSecurityTokenProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\DerivedKeySecurityToken.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\IIssuanceSecurityTokenAuthenticator.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\InitiatorServiceModelSecurityTokenRequirement.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\InternalEncryptedKeyIdentifierClause.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\ISecurityContextSecurityTokenCache.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\IssuedSecurityTokenHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\IssuedSecurityTokenParameters.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\IssuedSecurityTokenProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\IssuedTokenCommunicationObject.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\KerberosSecurityTokenParameters.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\ProviderCommunicationObject.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\RecipientServiceModelSecurityTokenRequirement.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\RenewedSecurityTokenHandler.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\RsaSecurityTokenParameters.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SecureConversationSecurityTokenAuthenticator.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SecureConversationSecurityTokenParameters.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SecurityContextSecurityToken.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SecurityContextSecurityTokenAuthenticator.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SecurityContextSecurityTokenResolver.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SecurityTokenParameters.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SecurityTokenReferenceStyle.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\ServiceModelSecurityTokenRequirement.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\ServiceModelSecurityTokenTypes.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SpnegoSecurityTokenAuthenticator.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SpnegoSecurityTokenProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SslnegoCookieResolver.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SslSecurityTokenAuthenticator.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SslSecurityTokenParameters.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SslSecurityTokenProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SspiClientSecurityTokenAuthenticator.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SspiSecurityToken.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SspiSecurityTokenParameters.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SspiSession.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\SupportingTokenParameters.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\TlsClientSession.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\TlsServerSession.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\UserNameSecurityTokenParameters.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\WrappedKeySecurityToken.cs" />\r
+    <Compile Include="System.ServiceModel.Security.Tokens\X509SecurityTokenParameters.cs" />\r
+    <Compile Include="System.ServiceModel.Security\BasicSecurityProfileVersion.cs" />\r
+    <Compile Include="System.ServiceModel.Security\BinarySecretKeyIdentifierClause.cs" />\r
+    <Compile Include="System.ServiceModel.Security\ChannelProtectionRequirements.cs" />\r
+    <Compile Include="System.ServiceModel.Security\DataProtectionSecurityStateEncoder.cs" />\r
+    <Compile Include="System.ServiceModel.Security\ExpiredSecurityTokenException.cs" />\r
+    <Compile Include="System.ServiceModel.Security\HttpDigestClientCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\IdentityVerifier.cs" />\r
+    <Compile Include="System.ServiceModel.Security\IEndpointIdentityProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Security\InfocardInteractiveChannelInitializer.cs" />\r
+    <Compile Include="System.ServiceModel.Security\ISecureConversationSession.cs" />\r
+    <Compile Include="System.ServiceModel.Security\ISecuritySession.cs" />\r
+    <Compile Include="System.ServiceModel.Security\IssuedTokenClientCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\IssuedTokenServiceCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\KeyEntropyMode.cs" />\r
+    <Compile Include="System.ServiceModel.Security\KeyNameIdentifierClause.cs" />\r
+    <Compile Include="System.ServiceModel.Security\MessagePartSpecification.cs" />\r
+    <Compile Include="System.ServiceModel.Security\MessageProtectionOrder.cs" />\r
+    <Compile Include="System.ServiceModel.Security\MessageSecurityException.cs" />\r
+    <Compile Include="System.ServiceModel.Security\PeerCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\ScopedMessagePartSpecification.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SecureConversationServiceCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SecurityAccessDeniedException.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SecurityAlgorithmSuite.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SecurityContextKeyIdentifierClause.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SecurityCredentialsManager.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SecurityMessageProperty.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SecurityNegotiationException.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SecurityStateEncoder.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SecurityTokenAttachmentMode.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SecurityTokenSpecification.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SecurityVersion.cs" />\r
+    <Compile Include="System.ServiceModel.Security\ServiceCredentialsSecurityTokenManager.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SspiSecurityTokenProvider.cs" />\r
+    <Compile Include="System.ServiceModel.Security\SupportingTokenSpecification.cs" />\r
+    <Compile Include="System.ServiceModel.Security\UnionSecurityTokenResolver.cs" />\r
+    <Compile Include="System.ServiceModel.Security\UserNamePasswordClientCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\UserNamePasswordServiceCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\WindowsClientCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\WindowsServiceCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\WSSecurityTokenSerializer.cs" />\r
+    <Compile Include="System.ServiceModel.Security\X509CertificateInitiatorClientCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\X509CertificateInitiatorServiceCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\X509CertificateRecipientClientCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\X509CertificateRecipientServiceCredential.cs" />\r
+    <Compile Include="System.ServiceModel.Security\X509ClientCertificateAuthentication.cs" />\r
+    <Compile Include="System.ServiceModel.Security\X509PeerCertificateAuthentication.cs" />\r
+    <Compile Include="System.ServiceModel.Security\X509ServiceCertificateAuthentication.cs" />\r
+    <Compile Include="System.ServiceModel\ActionNotSupportedException.cs" />\r
+    <Compile Include="System.ServiceModel\AddressAccessDeniedException.cs" />\r
+    <Compile Include="System.ServiceModel\AddressAlreadyInUseException.cs" />\r
+    <Compile Include="System.ServiceModel\AllEnums.cs" />\r
+    <Compile Include="System.ServiceModel\BasicHttpBinding.cs" />\r
+    <Compile Include="System.ServiceModel\BasicHttpMessageSecurity.cs" />\r
+    <Compile Include="System.ServiceModel\BasicHttpSecurity.cs" />\r
+    <Compile Include="System.ServiceModel\CallbackBehaviorAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\ChannelFactory.cs" />\r
+    <Compile Include="System.ServiceModel\ChannelFactory_1.cs" />\r
+    <Compile Include="System.ServiceModel\ClientBase.cs" />\r
+    <Compile Include="System.ServiceModel\ClientCredentialsSecurityTokenManager.cs" />\r
+    <Compile Include="System.ServiceModel\ClientProxyGenerator.cs" />\r
+    <Compile Include="System.ServiceModel\ClientRuntimeChannel.cs" />\r
+    <Compile Include="System.ServiceModel\CommunicationException.cs" />\r
+    <Compile Include="System.ServiceModel\CommunicationObjectFaultedException.cs" />\r
+    <Compile Include="System.ServiceModel\Constants.cs" />\r
+    <Compile Include="System.ServiceModel\DataContractFormatAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\DefaultCommunicationTimeouts.cs" />\r
+    <Compile Include="System.ServiceModel\DeliveryRequirementsAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\DnsEndpointIdentity.cs" />\r
+    <Compile Include="System.ServiceModel\Dummy.cs" />\r
+    <Compile Include="System.ServiceModel\DuplexChannelFactory.cs" />\r
+    <Compile Include="System.ServiceModel\DuplexClientBase.cs" />\r
+    <Compile Include="System.ServiceModel\EndpointAddress.cs" />\r
+    <Compile Include="System.ServiceModel\EndpointAddress10.cs" />\r
+    <Compile Include="System.ServiceModel\EndpointAddressAugust2004.cs" />\r
+    <Compile Include="System.ServiceModel\EndpointAddressBuilder.cs" />\r
+    <Compile Include="System.ServiceModel\EndpointIdentity.cs" />\r
+    <Compile Include="System.ServiceModel\EndpointNotFoundException.cs" />\r
+    <Compile Include="System.ServiceModel\EnvelopeVersion.cs" />\r
+    <Compile Include="System.ServiceModel\ExceptionDetail.cs" />\r
+    <Compile Include="System.ServiceModel\ExtensionCollection.cs" />\r
+    <Compile Include="System.ServiceModel\FaultCode.cs" />\r
+    <Compile Include="System.ServiceModel\FaultContractAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\FaultException.cs" />\r
+    <Compile Include="System.ServiceModel\FaultException_1.cs" />\r
+    <Compile Include="System.ServiceModel\FaultReason.cs" />\r
+    <Compile Include="System.ServiceModel\FaultReasonText.cs" />\r
+    <Compile Include="System.ServiceModel\FederatedMessageSecurityOverHttp.cs" />\r
+    <Compile Include="System.ServiceModel\HttpTransportSecurity.cs" />\r
+    <Compile Include="System.ServiceModel\IClientChannel.cs" />\r
+    <Compile Include="System.ServiceModel\ICommunicationObject.cs" />\r
+    <Compile Include="System.ServiceModel\IContextChannel.cs" />\r
+    <Compile Include="System.ServiceModel\IDefaultCommunicationTimeouts.cs" />\r
+    <Compile Include="System.ServiceModel\IDuplexClientChannel.cs" />\r
+    <Compile Include="System.ServiceModel\IExtensibleObject.cs" />\r
+    <Compile Include="System.ServiceModel\IExtension.cs" />\r
+    <Compile Include="System.ServiceModel\IExtensionCollection.cs" />\r
+    <Compile Include="System.ServiceModel\InstanceContext.cs" />\r
+    <Compile Include="System.ServiceModel\InvalidMessageContractException.cs" />\r
+    <Compile Include="System.ServiceModel\IServiceChannel.cs" />\r
+    <Compile Include="System.ServiceModel\MessageBodyAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\MessageContractAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\MessageContractMemberAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\MessageHeaderArrayAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\MessageHeaderAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\MessageHeaderException.cs" />\r
+    <Compile Include="System.ServiceModel\MessageHeader_1.cs" />\r
+    <Compile Include="System.ServiceModel\MessageParameterAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\MessagePropertyAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\MessageSecurityOverHttp.cs" />\r
+    <Compile Include="System.ServiceModel\MessageSecurityOverMsmq.cs" />\r
+    <Compile Include="System.ServiceModel\MessageSecurityOverTcp.cs" />\r
+    <Compile Include="System.ServiceModel\MessageSecurityVersion.cs" />\r
+    <Compile Include="System.ServiceModel\MsmqBindingBase.cs" />\r
+    <Compile Include="System.ServiceModel\MsmqException.cs" />\r
+    <Compile Include="System.ServiceModel\MsmqPoisonMessageException.cs" />\r
+    <Compile Include="System.ServiceModel\MsmqTransportSecurity.cs" />\r
+    <Compile Include="System.ServiceModel\NetMsmqBinding.cs" />\r
+    <Compile Include="System.ServiceModel\NetMsmqSecurity.cs" />\r
+    <Compile Include="System.ServiceModel\NetPeerTcpBinding.cs" />\r
+    <Compile Include="System.ServiceModel\NetTcpBinding.cs" />\r
+    <Compile Include="System.ServiceModel\NetTcpSecurity.cs" />\r
+    <Compile Include="System.ServiceModel\NonDualMessageSecurityOverHttp.cs" />\r
+    <Compile Include="System.ServiceModel\OperationBehaviorAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\OperationContext.cs" />\r
+    <Compile Include="System.ServiceModel\OperationContextScope.cs" />\r
+    <Compile Include="System.ServiceModel\OperationContractAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\OptionalReliableSession.cs" />\r
+    <Compile Include="System.ServiceModel\PeerMessagePropagationMessageFilter.cs" />\r
+    <Compile Include="System.ServiceModel\PeerNode.cs" />\r
+    <Compile Include="System.ServiceModel\PeerNodeAddress.cs" />\r
+    <Compile Include="System.ServiceModel\PeerResolver.cs" />\r
+    <Compile Include="System.ServiceModel\PeerResolverImpl.cs" />\r
+    <Compile Include="System.ServiceModel\PeerSecuritySettings.cs" />\r
+    <Compile Include="System.ServiceModel\PoisonMessageException.cs" />\r
+    <Compile Include="System.ServiceModel\ProtocolException.cs" />\r
+    <Compile Include="System.ServiceModel\QuotaExceededException.cs" />\r
+    <Compile Include="System.ServiceModel\ReliableMessagingVersion.cs" />\r
+    <Compile Include="System.ServiceModel\ReliableSession.cs" />\r
+    <Compile Include="System.ServiceModel\RsaEndpointIdentity.cs" />\r
+    <Compile Include="System.ServiceModel\ServiceAuthorizationManager.cs" />\r
+    <Compile Include="System.ServiceModel\ServiceBehaviorAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\ServiceContractAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\ServiceHost.cs" />\r
+    <Compile Include="System.ServiceModel\ServiceHostBase.cs" />\r
+    <Compile Include="System.ServiceModel\ServiceHostingEnvironment.cs" />\r
+    <Compile Include="System.ServiceModel\ServiceKnownTypeAttribute.cs" />\r
+    <Compile Include="System.ServiceModel\ServiceRuntimeChannel.cs" />\r
+    <Compile Include="System.ServiceModel\ServiceSecurityContext.cs" />\r
+    <Compile Include="System.ServiceModel\SpnEndpointIdentity.cs" />\r
+    <Compile Include="System.ServiceModel\TcpTransportSecurity.cs" />\r
+    <Compile Include="System.ServiceModel\TransactionProtocol.cs" />\r
+    <Compile Include="System.ServiceModel\TransferMode.cs" />\r
+    <Compile Include="System.ServiceModel\UnknownMessageReceivedEventArgs.cs" />\r
+    <Compile Include="System.ServiceModel\UpnEndpointIdentity.cs" />\r
+    <Compile Include="System.ServiceModel\UriSchemeKeyedCollection.cs" />\r
+    <Compile Include="System.ServiceModel\WS2007FederationHttpBinding.cs" />\r
+    <Compile Include="System.ServiceModel\WS2007HttpBinding.cs" />\r
+    <Compile Include="System.ServiceModel\WSDualHttpBinding.cs" />\r
+    <Compile Include="System.ServiceModel\WSDualHttpSecurity.cs" />\r
+    <Compile Include="System.ServiceModel\WSFederationHttpBinding.cs" />\r
+    <Compile Include="System.ServiceModel\WSFederationHttpSecurity.cs" />\r
+    <Compile Include="System.ServiceModel\WSHttpBinding.cs" />\r
+    <Compile Include="System.ServiceModel\WSHttpBindingBase.cs" />\r
+    <Compile Include="System.ServiceModel\WSHttpSecurity.cs" />\r
+    <Compile Include="System.ServiceModel\X509CertificateEndpointIdentity.cs" />\r
+    <Compile Include="System.ServiceModel\XmlSerializerFormatAttribute.cs" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Folder Include="Properties\" />\r
+    <Folder Include="Test\" />\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+       Other similar extension points exist, see Microsoft.Common.targets.\r
+  <Target Name="BeforeBuild">\r
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
+  -->\r
+  <PropertyGroup>\r
+    <PostBuildEvent>"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe" /i "$(TargetPath)" /f\r
+"C:\Program Files\Mono-1.2.6\bin\gacutil.bat" -i "$(TargetPath)"</PostBuildEvent>\r
+  </PropertyGroup>\r
+</Project>\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.dll.sources b/mcs/class/System.ServiceModel/System.ServiceModel.dll.sources
new file mode 100755 (executable)
index 0000000..1e38134
--- /dev/null
@@ -0,0 +1,889 @@
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+../../build/common/MonoTODOAttribute.cs
+Assembly/AssemblyInfo.cs
+Mono.CodeGeneration/CodeAdd.cs
+Mono.CodeGeneration/CodeAnd.cs
+Mono.CodeGeneration/CodeArgument.cs
+Mono.CodeGeneration/CodeArgumentReference.cs
+Mono.CodeGeneration/CodeArithmeticOperation.cs
+Mono.CodeGeneration/CodeArrayItem.cs
+Mono.CodeGeneration/CodeArrayLength.cs
+Mono.CodeGeneration/CodeAssignment.cs
+Mono.CodeGeneration/CodeBinaryComparison.cs
+Mono.CodeGeneration/CodeBinaryOperation.cs
+Mono.CodeGeneration/CodeBlock.cs
+Mono.CodeGeneration/CodeBuilder.cs
+Mono.CodeGeneration/CodeCast.cs
+Mono.CodeGeneration/CodeClass.cs
+Mono.CodeGeneration/CodeCustomAttribute.cs
+Mono.CodeGeneration/CodeDecrement.cs
+Mono.CodeGeneration/CodeEquals.cs
+Mono.CodeGeneration/CodeExpression.cs
+Mono.CodeGeneration/CodeFieldReference.cs
+Mono.CodeGeneration/CodeFor.cs
+Mono.CodeGeneration/CodeForeach.cs
+Mono.CodeGeneration/CodeGenerationHelper.cs
+Mono.CodeGeneration/CodeIf.cs
+Mono.CodeGeneration/CodeIncrement.cs
+Mono.CodeGeneration/CodeIs.cs
+Mono.CodeGeneration/CodeItem.cs
+Mono.CodeGeneration/CodeLiteral.cs
+Mono.CodeGeneration/CodeMethod.cs
+Mono.CodeGeneration/CodeMethodCall.cs
+Mono.CodeGeneration/CodeModule.cs
+Mono.CodeGeneration/CodeNew.cs
+Mono.CodeGeneration/CodeNewArray.cs
+Mono.CodeGeneration/CodeNotEquals.cs
+Mono.CodeGeneration/CodeOr.cs
+Mono.CodeGeneration/CodeProperty.cs
+Mono.CodeGeneration/CodePropertyReference.cs
+Mono.CodeGeneration/CodeReturn.cs
+Mono.CodeGeneration/CodeSelect.cs
+Mono.CodeGeneration/CodeSelfIncrement.cs
+Mono.CodeGeneration/CodeUnaryOperation.cs
+Mono.CodeGeneration/CodeValueReference.cs
+Mono.CodeGeneration/CodeVariableDeclaration.cs
+Mono.CodeGeneration/CodeVariableReference.cs
+Mono.CodeGeneration/CodeWhen.cs
+Mono.CodeGeneration/CodeWhile.cs
+Mono.CodeGeneration/CodeWriter.cs
+Mono.CodeGeneration/Exp.cs
+Mono.Security.Cryptography/MD5SHA1.cs
+Mono.Security.Cryptography/TlsHMAC.cs
+Mono.Security.Protocol.Ntlm/BitConverterLE.cs
+Mono.Security.Protocol.Ntlm/ChallengeResponse.cs
+Mono.Security.Protocol.Ntlm/MessageBase.cs
+Mono.Security.Protocol.Ntlm/NtlmFlags.cs
+Mono.Security.Protocol.Ntlm/NtlmTargetInformation.cs
+Mono.Security.Protocol.Ntlm/NtlmVersion.cs
+Mono.Security.Protocol.Ntlm/Type1Message.cs
+Mono.Security.Protocol.Ntlm/Type2Message.cs
+Mono.Security.Protocol.Ntlm/Type3Message.cs
+Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs
+Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs
+Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs
+Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs
+Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs
+Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs
+Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs
+Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs
+Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs
+Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs
+Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs
+Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs
+Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs
+Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs
+Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs
+Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs
+Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs
+Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs
+Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs
+Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs
+Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs
+Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs
+Mono.Security.Protocol.Tls.Handshake/ClientCertificateType.cs
+Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs
+Mono.Security.Protocol.Tls.Handshake/HandshakeType.cs
+Mono.Security.Protocol.Tls/Alert.cs
+Mono.Security.Protocol.Tls/CipherAlgorithmType.cs
+Mono.Security.Protocol.Tls/CipherSuite.cs
+Mono.Security.Protocol.Tls/CipherSuiteCollection.cs
+Mono.Security.Protocol.Tls/CipherSuiteFactory.cs
+Mono.Security.Protocol.Tls/ClientContext.cs
+Mono.Security.Protocol.Tls/ClientRecordProtocol.cs
+Mono.Security.Protocol.Tls/ClientSessionCache.cs
+Mono.Security.Protocol.Tls/ContentType.cs
+Mono.Security.Protocol.Tls/Context.cs
+Mono.Security.Protocol.Tls/DebugHelper.cs
+Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs
+Mono.Security.Protocol.Tls/HandshakeState.cs
+Mono.Security.Protocol.Tls/HashAlgorithmType.cs
+Mono.Security.Protocol.Tls/HttpsClientStream.cs
+Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs
+Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs
+Mono.Security.Protocol.Tls/RecordProtocol.cs
+Mono.Security.Protocol.Tls/SecurityCompressionType.cs
+Mono.Security.Protocol.Tls/SecurityParameters.cs
+Mono.Security.Protocol.Tls/SecurityProtocolType.cs
+Mono.Security.Protocol.Tls/ServerContext.cs
+Mono.Security.Protocol.Tls/ServerRecordProtocol.cs
+Mono.Security.Protocol.Tls/SslCipherSuite.cs
+Mono.Security.Protocol.Tls/SslClientStream.cs
+Mono.Security.Protocol.Tls/SslHandshakeHash.cs
+Mono.Security.Protocol.Tls/SslServerStream.cs
+Mono.Security.Protocol.Tls/SslStreamBase.cs
+Mono.Security.Protocol.Tls/TlsCipherSuite.cs
+Mono.Security.Protocol.Tls/TlsClientSettings.cs
+Mono.Security.Protocol.Tls/TlsException.cs
+Mono.Security.Protocol.Tls/TlsServerSettings.cs
+Mono.Security.Protocol.Tls/TlsStream.cs
+Mono.Xml.XPath/DTMXPathDocument2.cs
+Mono.Xml.XPath/DTMXPathDocumentBuilder2.cs
+Mono.Xml.XPath/DTMXPathDocumentWriter2.cs
+Mono.Xml.XPath/DTMXPathNavigator2.cs
+Mono.Xml.XPath/DTMXPathNode2.cs
+System.Collections.Generic/KeyedByTypeCollection.cs
+System.Collections.Generic/SynchronizedCollection.cs
+System.Collections.Generic/SynchronizedKeyedCollection.cs
+System.Collections.Generic/SynchronizedReadOnlyCollection.cs
+System.ServiceModel.Activation/AspNetIntegrationRequirementsAttribute.cs
+System.ServiceModel.Activation/IServiceHostFactory.cs
+System.ServiceModel.Activation/ServiceHostFactory.cs
+System.ServiceModel.Activation/ServiceHostFactoryBase.cs
+System.ServiceModel.Channels/AddressHeader.cs
+System.ServiceModel.Channels/AddressHeaderCollection.cs
+System.ServiceModel.Channels/AddressingVersion.cs
+System.ServiceModel.Channels/AspNetReplyChannel.cs
+System.ServiceModel.Channels/AspNetRequestContext.cs
+System.ServiceModel.Channels/AsymmetricSecurityBindingElement.cs
+System.ServiceModel.Channels/BinaryMessageEncoder.cs
+System.ServiceModel.Channels/BinaryMessageEncoderFactory.cs
+System.ServiceModel.Channels/BinaryMessageEncodingBindingElement.cs
+System.ServiceModel.Channels/Binding.cs
+System.ServiceModel.Channels/BindingContext.cs
+System.ServiceModel.Channels/BindingElement.cs
+System.ServiceModel.Channels/BindingElementCollection.cs
+System.ServiceModel.Channels/BindingParameterCollection.cs
+System.ServiceModel.Channels/BodyWriter.cs
+System.ServiceModel.Channels/BufferManager.cs
+System.ServiceModel.Channels/CachingCompiler.cs
+System.ServiceModel.Channels/ChannelBase.cs
+System.ServiceModel.Channels/ChannelFactoryBase.cs
+System.ServiceModel.Channels/ChannelListenerBase.cs
+System.ServiceModel.Channels/ChannelListenerBase_1.cs
+System.ServiceModel.Channels/ChannelManagerBase.cs
+System.ServiceModel.Channels/ChannelParameterCollection.cs
+System.ServiceModel.Channels/ChannelPoolSettings.cs
+System.ServiceModel.Channels/CommunicationObject.cs
+System.ServiceModel.Channels/CompilationException.cs
+System.ServiceModel.Channels/CompositeDuplexBindingElement.cs
+System.ServiceModel.Channels/CompositeDuplexBindingElementImporter.cs
+System.ServiceModel.Channels/ConnectionOrientedTransportBindingElement.cs
+System.ServiceModel.Channels/CustomBinding.cs
+System.ServiceModel.Channels/DeliveryFailure.cs
+System.ServiceModel.Channels/DeliveryStatus.cs
+System.ServiceModel.Channels/DirectionalAction.cs
+System.ServiceModel.Channels/DuplexSessionChannelBase.cs
+System.ServiceModel.Channels/FaultConverter.cs
+System.ServiceModel.Channels/HostedTransportConfiguration.cs
+System.ServiceModel.Channels/HtmlizedException.cs
+System.ServiceModel.Channels/HttpChannelFactory.cs
+System.ServiceModel.Channels/HttpChannelListener.cs
+System.ServiceModel.Channels/HttpChannelManager.cs
+System.ServiceModel.Channels/HttpReplyChannel.cs
+System.ServiceModel.Channels/HttpRequestChannel.cs
+System.ServiceModel.Channels/HttpRequestContext.cs
+System.ServiceModel.Channels/HttpRequestMessageProperty.cs
+System.ServiceModel.Channels/HttpResponseMessageProperty.cs
+System.ServiceModel.Channels/HttpTransportBindingElement.cs
+System.ServiceModel.Channels/HttpsTransportBindingElement.cs
+System.ServiceModel.Channels/IBindingDeliveryCapabilities.cs
+System.ServiceModel.Channels/IBindingMulticastCapabilities.cs
+System.ServiceModel.Channels/IBindingRuntimePreferences.cs
+System.ServiceModel.Channels/IChannel.cs
+System.ServiceModel.Channels/IChannelFactory.cs
+System.ServiceModel.Channels/IChannelListener.cs
+System.ServiceModel.Channels/IDuplexChannel.cs
+System.ServiceModel.Channels/IDuplexSession.cs
+System.ServiceModel.Channels/IDuplexSessionChannel.cs
+System.ServiceModel.Channels/IInputChannel.cs
+System.ServiceModel.Channels/IInputSession.cs
+System.ServiceModel.Channels/IInputSessionChannel.cs
+System.ServiceModel.Channels/IMessageProperty.cs
+System.ServiceModel.Channels/IOutputChannel.cs
+System.ServiceModel.Channels/IOutputSession.cs
+System.ServiceModel.Channels/IOutputSessionChannel.cs
+System.ServiceModel.Channels/IReplyChannel.cs
+System.ServiceModel.Channels/IReplySessionChannel.cs
+System.ServiceModel.Channels/IRequestChannel.cs
+System.ServiceModel.Channels/IRequestSessionChannel.cs
+System.ServiceModel.Channels/ISecurityCapabilities.cs
+System.ServiceModel.Channels/ISession.cs
+System.ServiceModel.Channels/ISessionChannel.cs
+System.ServiceModel.Channels/ITransactedBindingElement.cs
+System.ServiceModel.Channels/ITransportTokenAssertionProvider.cs
+System.ServiceModel.Channels/InputChannelBase.cs
+System.ServiceModel.Channels/InvalidChannelBindingException.cs
+System.ServiceModel.Channels/LayeredCommunicationObject.cs
+System.ServiceModel.Channels/LayeredOutputChannel.cs
+System.ServiceModel.Channels/LayeredReplyChannel.cs
+System.ServiceModel.Channels/LayeredRequestChannel.cs
+System.ServiceModel.Channels/LocalClientSecuritySettings.cs
+System.ServiceModel.Channels/Message.cs
+System.ServiceModel.Channels/MessageBuffer.cs
+System.ServiceModel.Channels/MessageBufferImpl.cs
+System.ServiceModel.Channels/MessageEncoder.cs
+System.ServiceModel.Channels/MessageEncoderFactory.cs
+System.ServiceModel.Channels/MessageEncodingBindingElement.cs
+System.ServiceModel.Channels/MessageEncodingBindingElementImporter.cs
+System.ServiceModel.Channels/MessageFault.cs
+System.ServiceModel.Channels/MessageFaultBodyWriter.cs
+System.ServiceModel.Channels/MessageHeader.cs
+System.ServiceModel.Channels/MessageHeaderInfo.cs
+System.ServiceModel.Channels/MessageHeaders.cs
+System.ServiceModel.Channels/MessageImpl.cs
+System.ServiceModel.Channels/MessageProperties.cs
+System.ServiceModel.Channels/MessageSecurityBindingSupport.cs
+System.ServiceModel.Channels/MessageVersion.cs
+System.ServiceModel.Channels/MsmqBindingElementBase.cs
+System.ServiceModel.Channels/MsmqChannelFactory.cs
+System.ServiceModel.Channels/MsmqChannelListener.cs
+System.ServiceModel.Channels/MsmqInputChannel.cs
+System.ServiceModel.Channels/MsmqMessageProperty.cs
+System.ServiceModel.Channels/MsmqOutputChannel.cs
+System.ServiceModel.Channels/MsmqTransportBindingElement.cs
+System.ServiceModel.Channels/MtomMessageEncoder.cs
+System.ServiceModel.Channels/MtomMessageEncoderFactory.cs
+System.ServiceModel.Channels/MtomMessageEncodingBindingElement.cs
+System.ServiceModel.Channels/NamedPipeConnectionPoolSettings.cs
+System.ServiceModel.Channels/NamedPipetransportBindingElement.cs
+System.ServiceModel.Channels/OneWayBindingElement.cs
+System.ServiceModel.Channels/OneWayBindingElementImporter.cs
+System.ServiceModel.Channels/OutputChannelBase.cs
+System.ServiceModel.Channels/PeerResolverBindingElement.cs
+System.ServiceModel.Channels/PeerTransportBindingElement.cs
+System.ServiceModel.Channels/PnrpPeerResolverBindingElement.cs
+System.ServiceModel.Channels/ReliableSessionBindingElementImporter.cs
+System.ServiceModel.Channels/ReplyChannelBase.cs
+System.ServiceModel.Channels/RequestChannelBase.cs
+System.ServiceModel.Channels/RequestContext.cs
+System.ServiceModel.Channels/SecureMessageDecryptor.cs
+System.ServiceModel.Channels/SecureMessageGenerator.cs
+System.ServiceModel.Channels/SecurityBindingElement.cs
+System.ServiceModel.Channels/SecurityBindingElementImporter.cs
+System.ServiceModel.Channels/SecurityChannelFactory.cs
+System.ServiceModel.Channels/SecurityChannelListener.cs
+System.ServiceModel.Channels/SecurityOutputChannel.cs
+System.ServiceModel.Channels/SecurityRequestChannel.cs
+System.ServiceModel.Channels/SecurityRequestContext.cs
+System.ServiceModel.Channels/ServiceHostParser.cs
+System.ServiceModel.Channels/SslStreamSecurityBindingElement.cs
+System.ServiceModel.Channels/SslStreamSecurityUpgradeAcceptor.cs
+System.ServiceModel.Channels/SslStreamSecurityUpgradeProvider.cs
+System.ServiceModel.Channels/StandardBindingImporter.cs
+System.ServiceModel.Channels/StreamSecurityUpgradeAcceptor.cs
+System.ServiceModel.Channels/StreamSecurityUpgradeInitiator.cs
+System.ServiceModel.Channels/StreamSecurityUpgradeProvider.cs
+System.ServiceModel.Channels/StreamUpgradeAcceptor.cs
+System.ServiceModel.Channels/StreamUpgradeBindingElement.cs
+System.ServiceModel.Channels/StreamUpgradeInitiator.cs
+System.ServiceModel.Channels/StreamUpgradeProvider.cs
+System.ServiceModel.Channels/SvcHttpHandler.cs
+System.ServiceModel.Channels/SvcHttpHandlerFactory.cs
+System.ServiceModel.Channels/SymmetricSecurityBindingElement.cs
+System.ServiceModel.Channels/TcpChannelFactory.cs
+System.ServiceModel.Channels/TcpChannelListener.cs
+System.ServiceModel.Channels/TcpConnectionPoolSettings.cs
+System.ServiceModel.Channels/TcpDuplexSessionChannel.cs
+System.ServiceModel.Channels/TcpTransportBindingElement.cs
+System.ServiceModel.Channels/TextMessageEncoder.cs
+System.ServiceModel.Channels/TextMessageEncoderFactory.cs
+System.ServiceModel.Channels/TextMessageEncodingBindingElement.cs
+System.ServiceModel.Channels/TransactionFlowBindingElement.cs
+System.ServiceModel.Channels/TransactionFlowBindingElementImporter.cs
+System.ServiceModel.Channels/TransactionMessageProperty.cs
+System.ServiceModel.Channels/TransportBindingElement.cs
+System.ServiceModel.Channels/TransportBindingElementImporter.cs
+System.ServiceModel.Channels/TransportSecurityBindingElement.cs
+System.ServiceModel.Channels/UnderstoodHeaders.cs
+System.ServiceModel.Channels/UseManagedPresentationBindingElement.cs
+System.ServiceModel.Channels/WSEncryptedXml.cs
+System.ServiceModel.Channels/WSSecurityMessageHeader.cs
+System.ServiceModel.Channels/WSSignedXml.cs
+System.ServiceModel.Channels/WindowsStreamSecurityBindingElement.cs
+System.ServiceModel.Channels/XmlObjectSerializerBodyWriter.cs
+System.ServiceModel.Channels/XmlReaderBodyWriter.cs
+System.ServiceModel.ComIntegration/Dummy.cs
+System.ServiceModel.Configuration/AddressHeaderCollectionElement.cs
+System.ServiceModel.Configuration/AllowedAudienceUriElement.cs
+System.ServiceModel.Configuration/AllowedAudienceUriElementCollection.cs
+System.ServiceModel.Configuration/AuthenticationMode.cs
+System.ServiceModel.Configuration/AuthorizationPolicyTypeElement.cs
+System.ServiceModel.Configuration/AuthorizationPolicyTypeElementCollection.cs
+System.ServiceModel.Configuration/BaseAddressElement.cs
+System.ServiceModel.Configuration/BaseAddressElementCollection.cs
+System.ServiceModel.Configuration/BasicHttpBindingCollectionElement.cs
+System.ServiceModel.Configuration/BasicHttpBindingElement.cs
+System.ServiceModel.Configuration/BasicHttpMessageSecurityElement.cs
+System.ServiceModel.Configuration/BasicHttpSecurityElement.cs
+System.ServiceModel.Configuration/BehaviorExtensionElement.cs
+System.ServiceModel.Configuration/BehaviorsSection.cs
+System.ServiceModel.Configuration/BinaryMessageEncodingElement.cs
+System.ServiceModel.Configuration/BindingCollectionElement.cs
+System.ServiceModel.Configuration/BindingElementExtensionElement.cs
+System.ServiceModel.Configuration/BindingsSection.cs
+System.ServiceModel.Configuration/CallbackDebugElement.cs
+System.ServiceModel.Configuration/CallbackTimeoutsElement.cs
+System.ServiceModel.Configuration/CertificateElement.cs
+System.ServiceModel.Configuration/CertificateReferenceElement.cs
+System.ServiceModel.Configuration/ChannelEndpointElement.cs
+System.ServiceModel.Configuration/ChannelEndpointElementCollection.cs
+System.ServiceModel.Configuration/ChannelPoolSettingsElement.cs
+System.ServiceModel.Configuration/ClaimTypeElement.cs
+System.ServiceModel.Configuration/ClaimTypeElementCollection.cs
+System.ServiceModel.Configuration/ClientCredentialsElement.cs
+System.ServiceModel.Configuration/ClientSection.cs
+System.ServiceModel.Configuration/ClientViaElement.cs
+System.ServiceModel.Configuration/ComContractElement.cs
+System.ServiceModel.Configuration/ComContractElementCollection.cs
+System.ServiceModel.Configuration/ComContractsSection.cs
+System.ServiceModel.Configuration/ComMethodElement.cs
+System.ServiceModel.Configuration/ComMethodElementCollection.cs
+System.ServiceModel.Configuration/ComPersistableTypeElement.cs
+System.ServiceModel.Configuration/ComPersistableTypeElementCollection.cs
+System.ServiceModel.Configuration/ComUdtElement.cs
+System.ServiceModel.Configuration/ComUdtElementCollection.cs
+System.ServiceModel.Configuration/CommonBehaviorsSection.cs
+System.ServiceModel.Configuration/CommonEndpointBehaviorElement.cs
+System.ServiceModel.Configuration/CommonServiceBehaviorElement.cs
+System.ServiceModel.Configuration/CompositeDuplexElement.cs
+System.ServiceModel.Configuration/ConfigUtil.cs
+System.ServiceModel.Configuration/ConnectionOrientedTransportElement.cs
+System.ServiceModel.Configuration/CustomBindingCollectionElement.cs
+System.ServiceModel.Configuration/CustomBindingElement.cs
+System.ServiceModel.Configuration/CustomBindingElementCollection.cs
+System.ServiceModel.Configuration/DataContractSerializerElement.cs
+System.ServiceModel.Configuration/DiagnosticSection.cs
+System.ServiceModel.Configuration/DnsElement.cs
+System.ServiceModel.Configuration/EncodingConverter.cs
+System.ServiceModel.Configuration/EndpointAddressElementBase.cs
+System.ServiceModel.Configuration/EndpointBehaviorElement.cs
+System.ServiceModel.Configuration/EndpointBehaviorElementCollection.cs
+System.ServiceModel.Configuration/ExtensionElement.cs
+System.ServiceModel.Configuration/ExtensionElementCollection.cs
+System.ServiceModel.Configuration/ExtensionsSection.cs
+System.ServiceModel.Configuration/FederatedMessageSecurityOverHttpElement.cs
+System.ServiceModel.Configuration/HostElement.cs
+System.ServiceModel.Configuration/HostTimeoutsElement.cs
+System.ServiceModel.Configuration/HttpDigestClientElement.cs
+System.ServiceModel.Configuration/HttpTransportElement.cs
+System.ServiceModel.Configuration/HttpTransportSecurityElement.cs
+System.ServiceModel.Configuration/HttpsTransportElement.cs
+System.ServiceModel.Configuration/IBindingConfigurationElement.cs
+System.ServiceModel.Configuration/IdentityElement.cs
+System.ServiceModel.Configuration/IPAddressConverter.cs
+System.ServiceModel.Configuration/IssuedTokenClientBehaviorsElement.cs
+System.ServiceModel.Configuration/IssuedTokenClientBehaviorsElementCollection.cs
+System.ServiceModel.Configuration/IssuedTokenClientElement.cs
+System.ServiceModel.Configuration/IssuedTokenParametersElement.cs
+System.ServiceModel.Configuration/IssuedTokenParametersEndpointAddressElement.cs
+System.ServiceModel.Configuration/IssuedTokenServiceElement.cs
+System.ServiceModel.Configuration/LocalClientSecuritySettingsElement.cs
+System.ServiceModel.Configuration/LocalServiceSecuritySettingsElement.cs
+System.ServiceModel.Configuration/MessageLoggingElement.cs
+System.ServiceModel.Configuration/MessageSecurityOverHttpElement.cs
+System.ServiceModel.Configuration/MessageSecurityOverMsmqElement.cs
+System.ServiceModel.Configuration/MessageSecurityOverTcpElement.cs
+System.ServiceModel.Configuration/MessageSecurityVersionConverter.cs
+System.ServiceModel.Configuration/MetadataElement.cs
+System.ServiceModel.Configuration/MessageVersionConverter.cs
+System.ServiceModel.Configuration/MethodStubs.cs
+System.ServiceModel.Configuration/MexBindingBindingCollectionElement.cs
+System.ServiceModel.Configuration/MexBindingElement.cs
+System.ServiceModel.Configuration/MexHttpBindingCollectionElement.cs
+System.ServiceModel.Configuration/MexHttpBindingElement.cs
+System.ServiceModel.Configuration/MexHttpsBindingCollectionElement.cs
+System.ServiceModel.Configuration/MexHttpsBindingElement.cs
+System.ServiceModel.Configuration/MexNamedPipeBindingCollectionElement.cs
+System.ServiceModel.Configuration/MexNamedPipeBindingElement.cs
+System.ServiceModel.Configuration/MexTcpBindingCollectionElement.cs
+System.ServiceModel.Configuration/MexTcpBindingElement.cs
+System.ServiceModel.Configuration/MsmqBindingElementBase.cs
+System.ServiceModel.Configuration/MsmqElementBase.cs
+System.ServiceModel.Configuration/MsmqIntegrationBindingCollectionElement.cs
+System.ServiceModel.Configuration/MsmqIntegrationBindingElement.cs
+System.ServiceModel.Configuration/MsmqIntegrationElement.cs
+System.ServiceModel.Configuration/MsmqIntegrationSecurityElement.cs
+System.ServiceModel.Configuration/MsmqTransportElement.cs
+System.ServiceModel.Configuration/MsmqTransportSecurityElement.cs
+System.ServiceModel.Configuration/MtomMessageEncodingElement.cs
+System.ServiceModel.Configuration/NamedPipeConnectionPoolSettingsElement.cs
+System.ServiceModel.Configuration/NamedPipeTransportElement.cs
+System.ServiceModel.Configuration/NamedPipeTransportSecurityElement.cs
+System.ServiceModel.Configuration/NamedServiceModelExtensionCollectionElement.cs
+System.ServiceModel.Configuration/NetMsmqBindingCollectionElement.cs
+System.ServiceModel.Configuration/NetMsmqBindingElement.cs
+System.ServiceModel.Configuration/NetMsmqSecurityElement.cs
+System.ServiceModel.Configuration/NetNamedPipeBindingCollectionElement.cs
+System.ServiceModel.Configuration/NetNamedPipeBindingElement.cs
+System.ServiceModel.Configuration/NetNamedPipeSecurityElement.cs
+System.ServiceModel.Configuration/NetPeerTcpBindingCollectionElement.cs
+System.ServiceModel.Configuration/NetPeerTcpBindingElement.cs
+System.ServiceModel.Configuration/NetTcpBindingCollectionElement.cs
+System.ServiceModel.Configuration/NetTcpBindingElement.cs
+System.ServiceModel.Configuration/NetTcpSecurityElement.cs
+System.ServiceModel.Configuration/NonDualMessageSecurityOverHttpElement.cs
+System.ServiceModel.Configuration/OneWayElement.cs
+System.ServiceModel.Configuration/PeerCredentialElement.cs
+System.ServiceModel.Configuration/PeerCustomResolverElement.cs
+System.ServiceModel.Configuration/PeerResolverElement.cs
+System.ServiceModel.Configuration/PeerSecurityElement.cs
+System.ServiceModel.Configuration/PeerTransportElement.cs
+System.ServiceModel.Configuration/PeerTransportSecurityElement.cs
+System.ServiceModel.Configuration/PnrpPeerResolverElement.cs
+System.ServiceModel.Configuration/PolicyImporterElement.cs
+System.ServiceModel.Configuration/PolicyImporterElementCollection.cs
+System.ServiceModel.Configuration/PolicyVersionConverter.cs
+System.ServiceModel.Configuration/PrivacyNoticeElement.cs
+System.ServiceModel.Configuration/ReliableMessagingVersionConverter.cs
+System.ServiceModel.Configuration/ReliableSessionElement.cs
+System.ServiceModel.Configuration/RsaElement.cs
+System.ServiceModel.Configuration/SecureConversationServiceElement.cs
+System.ServiceModel.Configuration/SecurityAlgorithmSuiteConverter.cs
+System.ServiceModel.Configuration/SecurityElement.cs
+System.ServiceModel.Configuration/SecurityElementBase.cs
+System.ServiceModel.Configuration/ServiceAuthorizationElement.cs
+System.ServiceModel.Configuration/ServiceBehaviorElement.cs
+System.ServiceModel.Configuration/ServiceBehaviorElementCollection.cs
+System.ServiceModel.Configuration/ServiceCredentialsElement.cs
+System.ServiceModel.Configuration/ServiceDebugElement.cs
+System.ServiceModel.Configuration/ServiceElement.cs
+System.ServiceModel.Configuration/ServiceElementCollection.cs
+System.ServiceModel.Configuration/ServiceEndpointElement.cs
+System.ServiceModel.Configuration/ServiceEndpointElementCollection.cs
+System.ServiceModel.Configuration/ServiceHostingEnvironmentSection.cs
+System.ServiceModel.Configuration/ServiceMetadataPublishingElement.cs
+System.ServiceModel.Configuration/ServiceModelConfigurationElementCollection.cs
+System.ServiceModel.Configuration/ServiceModelEnhancedConfigurationElementCollection.cs
+System.ServiceModel.Configuration/ServiceModelExtensionCollectionElement.cs
+System.ServiceModel.Configuration/ServiceModelExtensionElement.cs
+System.ServiceModel.Configuration/ServiceModelSectionGroup.cs
+System.ServiceModel.Configuration/ServicePrincipalNameElement.cs
+System.ServiceModel.Configuration/ServiceSecurityAuditElement.cs
+System.ServiceModel.Configuration/ServiceThrottlingElement.cs
+System.ServiceModel.Configuration/ServiceTimeoutsElement.cs
+System.ServiceModel.Configuration/ServicesSection.cs
+System.ServiceModel.Configuration/SslStreamSecurityElement.cs
+System.ServiceModel.Configuration/StandardBindingCollectionElement.cs
+System.ServiceModel.Configuration/StandardBindingElement.cs
+System.ServiceModel.Configuration/StandardBindingElementCollection.cs
+System.ServiceModel.Configuration/StandardBindingOptionalReliableSessionElement.cs
+System.ServiceModel.Configuration/StandardBindingReliableSessionElement.cs
+System.ServiceModel.Configuration/SynchronousReceiveElement.cs
+System.ServiceModel.Configuration/TcpConnectionPoolSettingsElement.cs
+System.ServiceModel.Configuration/TcpTransportElement.cs
+System.ServiceModel.Configuration/TcpTransportSecurityElement.cs
+System.ServiceModel.Configuration/TextMessageEncodingElement.cs
+System.ServiceModel.Configuration/TransactedBatchingElement.cs
+System.ServiceModel.Configuration/TransactionFlowElement.cs
+System.ServiceModel.Configuration/TransactionProtocolConverter.cs
+System.ServiceModel.Configuration/TransportConfigurationTypeElement.cs
+System.ServiceModel.Configuration/TransportConfigurationTypeElementCollection.cs
+System.ServiceModel.Configuration/TransportElement.cs
+System.ServiceModel.Configuration/UseManagedPresentationElement.cs
+System.ServiceModel.Configuration/UserNameServiceElement.cs
+System.ServiceModel.Configuration/UserPrincipalNameElement.cs
+System.ServiceModel.Configuration/WS2007FederationHttpBindingCollectionElement.cs
+System.ServiceModel.Configuration/WS2007FederationHttpBindingElement.cs
+System.ServiceModel.Configuration/WS2007HttpBindingCollectionElement.cs
+System.ServiceModel.Configuration/WS2007HttpBindingElement.cs
+System.ServiceModel.Configuration/WSDualHttpBindingCollectionElement.cs
+System.ServiceModel.Configuration/WSDualHttpBindingElement.cs
+System.ServiceModel.Configuration/WSDualHttpSecurityElement.cs
+System.ServiceModel.Configuration/WSFederationHttpBindingCollectionElement.cs
+System.ServiceModel.Configuration/WSFederationHttpBindingElement.cs
+System.ServiceModel.Configuration/WSFederationHttpSecurityElement.cs
+System.ServiceModel.Configuration/WSHttpBindingBaseElement.cs
+System.ServiceModel.Configuration/WSHttpBindingCollectionElement.cs
+System.ServiceModel.Configuration/WSHttpBindingElement.cs
+System.ServiceModel.Configuration/WSHttpSecurityElement.cs
+System.ServiceModel.Configuration/WSHttpTransportSecurityElement.cs
+System.ServiceModel.Configuration/WindowsClientElement.cs
+System.ServiceModel.Configuration/WindowsServiceElement.cs
+System.ServiceModel.Configuration/WindowsStreamSecurityElement.cs
+System.ServiceModel.Configuration/WsdlImporterElement.cs
+System.ServiceModel.Configuration/WsdlImporterElementCollection.cs
+System.ServiceModel.Configuration/X509CertificateTrustedIssuerElement.cs
+System.ServiceModel.Configuration/X509CertificateTrustedIssuerElementCollection.cs
+System.ServiceModel.Configuration/X509ClientCertificateAuthenticationElement.cs
+System.ServiceModel.Configuration/X509ClientCertificateCredentialsElement.cs
+System.ServiceModel.Configuration/X509DefaultServiceCertificateElement.cs
+System.ServiceModel.Configuration/X509InitiatorCertificateClientElement.cs
+System.ServiceModel.Configuration/X509InitiatorCertificateServiceElement.cs
+System.ServiceModel.Configuration/X509PeerCertificateAuthenticationElement.cs
+System.ServiceModel.Configuration/X509PeerCertificateElement.cs
+System.ServiceModel.Configuration/X509RecipientCertificateClientElement.cs
+System.ServiceModel.Configuration/X509RecipientCertificateServiceElement.cs
+System.ServiceModel.Configuration/X509ScopedServiceCertificateElement.cs
+System.ServiceModel.Configuration/X509ScopedServiceCertificateElementCollection.cs
+System.ServiceModel.Configuration/X509ServiceCertificateAuthenticationElement.cs
+System.ServiceModel.Configuration/XPathMessageFilterElement.cs
+System.ServiceModel.Configuration/XPathMessageFilterElementCollection.cs
+System.ServiceModel.Configuration/XPathMessageFilterElementComparer.cs
+System.ServiceModel.Configuration/XmlDictionaryReaderQuotasElement.cs
+System.ServiceModel.Configuration/XmlElementElement.cs
+System.ServiceModel.Configuration/XmlElementElementCollection.cs
+System.ServiceModel.Description/CallbackDebugBehavior.cs
+System.ServiceModel.Description/CallbackTimeoutsBehavior.cs
+System.ServiceModel.Description/ClientCredentials.cs
+System.ServiceModel.Description/ClientViaBehavior.cs
+System.ServiceModel.Description/ContractDescription.cs
+System.ServiceModel.Description/ContractDescriptionGenerator.cs
+System.ServiceModel.Description/DataContractSerializerMessageContractImporter.cs
+System.ServiceModel.Description/DataContractSerializerOperationBehavior.cs
+System.ServiceModel.Description/FaultDescription.cs
+System.ServiceModel.Description/FaultDescriptionCollection.cs
+System.ServiceModel.Description/HostedBindingBehavior.cs
+System.ServiceModel.Description/IContractBehavior.cs
+System.ServiceModel.Description/IContractBehaviorAttribute.cs
+System.ServiceModel.Description/IEndpointBehavior.cs
+System.ServiceModel.Description/IMetadataExchange.cs
+System.ServiceModel.Description/IOperationBehavior.cs
+System.ServiceModel.Description/IOperationContractGenerationExtension.cs
+System.ServiceModel.Description/IPolicyImporter.cs
+System.ServiceModel.Description/IServiceBehavior.cs
+System.ServiceModel.Description/IServiceContractGenerationExtension.cs
+System.ServiceModel.Description/IWsdlExporter.cs
+System.ServiceModel.Description/IWsdlImporter.cs
+System.ServiceModel.Description/IpolicyExporter.cs
+System.ServiceModel.Description/LocalServiceSecuritySettings.cs
+System.ServiceModel.Description/MessageBodyDescription.cs
+System.ServiceModel.Description/MessageDescription.cs
+System.ServiceModel.Description/MessageDescriptionCollection.cs
+System.ServiceModel.Description/MessageHeaderDescription.cs
+System.ServiceModel.Description/MessageHeaderDescriptionCollection.cs
+System.ServiceModel.Description/MessagePartDescription.cs
+System.ServiceModel.Description/MessagePartDescriptionCollection.cs
+System.ServiceModel.Description/MessagePropertyDescription.cs
+System.ServiceModel.Description/MessagePropertyDescriptionCollection.cs
+System.ServiceModel.Description/MetadataBundle.cs
+System.ServiceModel.Description/MetadataConversionError.cs
+System.ServiceModel.Description/MetadataExchangeBindings.cs
+System.ServiceModel.Description/MetadataExchangeClient.cs
+System.ServiceModel.Description/MetadataExporter.cs
+System.ServiceModel.Description/MetadataImporter.cs
+System.ServiceModel.Description/MetadataLocation.cs
+System.ServiceModel.Description/MetadataReference.cs
+System.ServiceModel.Description/MetadataResolver.cs
+System.ServiceModel.Description/MetadataSection.cs
+System.ServiceModel.Description/MetadataSectionSerializerBase.cs
+System.ServiceModel.Description/MustUnderstandBehavior.cs
+System.ServiceModel.Description/OperationContractGenerationContext.cs
+System.ServiceModel.Description/OperationDescription.cs
+System.ServiceModel.Description/OperationDescriptionCollection.cs
+System.ServiceModel.Description/PolicyAssertionCollection.cs
+System.ServiceModel.Description/PolicyConversionContext.cs
+System.ServiceModel.Description/PolicyVersion.cs
+System.ServiceModel.Description/ServiceAuthorizationBehavior.cs
+System.ServiceModel.Description/ServiceContractGenerationContext.cs
+System.ServiceModel.Description/ServiceContractGenerator.cs
+System.ServiceModel.Description/ServiceCredentials.cs
+System.ServiceModel.Description/ServiceDebugBehavior.cs
+System.ServiceModel.Description/ServiceDescription.cs
+System.ServiceModel.Description/ServiceEndpoint.cs
+System.ServiceModel.Description/ServiceEndpointCollection.cs
+System.ServiceModel.Description/ServiceMetadataBehavior.cs
+System.ServiceModel.Description/ServiceMetadataExtension.cs
+System.ServiceModel.Description/ServiceSecurityAuditBehavior.cs
+System.ServiceModel.Description/ServiceThrottlingBehavior.cs
+System.ServiceModel.Description/ServiceTimeoutsBehavior.cs
+System.ServiceModel.Description/SynchronousReceiveBehavior.cs
+System.ServiceModel.Description/TransactedBatchingBehavior.cs
+System.ServiceModel.Description/TypedMessageConverter.cs
+System.ServiceModel.Description/WSTrustMessageConverters.cs
+System.ServiceModel.Description/WSTrustSTSContract.cs
+System.ServiceModel.Description/WebServiceHelper.cs
+System.ServiceModel.Description/WsdlContractConversionContext.cs
+System.ServiceModel.Description/WsdlEndpointConversionContext.cs
+System.ServiceModel.Description/WsdlExporter.cs
+System.ServiceModel.Description/WsdlImporter.cs
+System.ServiceModel.Description/XmlSerializerMessageContractImporter.cs
+System.ServiceModel.Description/XmlSerializerOperationBehavior.cs
+System.ServiceModel.Diagnostics/PerformanceCounterScope.cs
+System.ServiceModel.Dispatcher/ActionMessageFilter.cs
+System.ServiceModel.Dispatcher/ActionMessageFilterTable.cs
+System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs
+System.ServiceModel.Dispatcher/BaseRequestProcessor.cs
+System.ServiceModel.Dispatcher/BaseRequestProcessorHandler.cs
+System.ServiceModel.Dispatcher/ChannelDispatcher.cs
+System.ServiceModel.Dispatcher/ChannelDispatcherBase.cs
+System.ServiceModel.Dispatcher/ChannelDispatcherCollection.cs
+System.ServiceModel.Dispatcher/ClientOperation.cs
+System.ServiceModel.Dispatcher/ClientRuntime.cs
+System.ServiceModel.Dispatcher/DataContractSerializerServiceBehavior.cs
+System.ServiceModel.Dispatcher/DefaultInstanceContextProvider.cs
+System.ServiceModel.Dispatcher/DispatchOperation.cs
+System.ServiceModel.Dispatcher/DispatchRuntime.cs
+System.ServiceModel.Dispatcher/EndpointAddressMessageFilter.cs
+System.ServiceModel.Dispatcher/EndpointAddressMessageFilterTable.cs
+System.ServiceModel.Dispatcher/EndpointDispatcher.cs
+System.ServiceModel.Dispatcher/ErrorProcessingHandler.cs
+System.ServiceModel.Dispatcher/ExceptionHandler.cs
+System.ServiceModel.Dispatcher/FaultContractInfo.cs
+System.ServiceModel.Dispatcher/FilterInvalidBodyAccessException.cs
+System.ServiceModel.Dispatcher/FinalizeProcessingHandler.cs
+System.ServiceModel.Dispatcher/ICallContextInitializer.cs
+System.ServiceModel.Dispatcher/IChannelInitializer.cs
+System.ServiceModel.Dispatcher/IClientMessageFormatter.cs
+System.ServiceModel.Dispatcher/IClientMessageInspector.cs
+System.ServiceModel.Dispatcher/IClientOperationSelector.cs
+System.ServiceModel.Dispatcher/IDispatchMessageFormatter.cs
+System.ServiceModel.Dispatcher/IDispatchMessageInspector.cs
+System.ServiceModel.Dispatcher/IDispatchOperationSelector.cs
+System.ServiceModel.Dispatcher/IErrorHandler.cs
+System.ServiceModel.Dispatcher/IInputSessionShutdown.cs
+System.ServiceModel.Dispatcher/IInstanceContextInitializer.cs
+System.ServiceModel.Dispatcher/IInstanceContextProvider.cs
+System.ServiceModel.Dispatcher/IInstanceProvider.cs
+System.ServiceModel.Dispatcher/IInteractiveChannelInitializer.cs
+System.ServiceModel.Dispatcher/IMessageFilterTable.cs
+System.ServiceModel.Dispatcher/InitializingHandler.cs
+System.ServiceModel.Dispatcher/IOperationInvoker.cs
+System.ServiceModel.Dispatcher/IParameterInspector.cs
+System.ServiceModel.Dispatcher/InstanceContextIdleCallback.cs
+System.ServiceModel.Dispatcher/InvalidBodyAccessException.cs
+System.ServiceModel.Dispatcher/InputOrReplyRequestProcessor.cs
+System.ServiceModel.Dispatcher/MatchAllMessageFilter.cs
+System.ServiceModel.Dispatcher/MatchNoneMessageFilter.cs
+System.ServiceModel.Dispatcher/MessageFilter.cs
+System.ServiceModel.Dispatcher/MessageFilterNodeQuotaExceededException.cs
+System.ServiceModel.Dispatcher/MessageFilterTable.cs
+System.ServiceModel.Dispatcher/MessageProcessingContext.cs
+System.ServiceModel.Dispatcher/MexInstanceContextProvider.cs
+System.ServiceModel.Dispatcher/MultipleMessageFilterMatchesException.cs
+System.ServiceModel.Dispatcher/NavigatorInvalidBodyAccessException.cs
+System.ServiceModel.Dispatcher/OperationInvokerHandler.cs
+System.ServiceModel.Dispatcher/PostReceiveRequestHandler.cs
+System.ServiceModel.Dispatcher/PrefixEndpointAddressMessageFilter.cs
+System.ServiceModel.Dispatcher/ReplyHandler.cs
+System.ServiceModel.Dispatcher/SecurityHandler.cs
+System.ServiceModel.Dispatcher/SeekableXPathNavigator.cs
+System.ServiceModel.Dispatcher/ServiceThrottle.cs
+System.ServiceModel.Dispatcher/SingletonInstanceContextProvider.cs
+System.ServiceModel.Dispatcher/XPathMessageContext.cs
+System.ServiceModel.Dispatcher/XPathMessageFilter.cs
+System.ServiceModel.Dispatcher/XPathMessageFilterTable.cs
+System.ServiceModel.Dispatcher/XPathNavigatorException.cs
+System.ServiceModel.Dispatcher/InstanceBehavior.cs
+System.ServiceModel.MsmqIntegration/MsmqIntegrationBinding.cs
+System.ServiceModel.MsmqIntegration/MsmqIntegrationBindingElement.cs
+System.ServiceModel.MsmqIntegration/MsmqIntegrationMessageProperty.cs
+System.ServiceModel.MsmqIntegration/MsmqIntegrationSecurity.cs
+System.ServiceModel.MsmqIntegration/MsmqMessage.cs
+System.ServiceModel.PeerResolvers/CustomPeerResolverService.cs
+System.ServiceModel.PeerResolvers/IPeerResolverContract.cs
+System.ServiceModel.PeerResolvers/PeerCustomResolverSettings.cs
+System.ServiceModel.PeerResolvers/PeerReferralPolicy.cs
+System.ServiceModel.PeerResolvers/PeerResolverMode.cs
+System.ServiceModel.PeerResolvers/PeerResolverSettings.cs
+System.ServiceModel.PeerResolvers/RefreshInfo.cs
+System.ServiceModel.PeerResolvers/RefreshResponseInfo.cs
+System.ServiceModel.PeerResolvers/RefreshResult.cs
+System.ServiceModel.PeerResolvers/RegisterInfo.cs
+System.ServiceModel.PeerResolvers/RegisterResponseInfo.cs
+System.ServiceModel.PeerResolvers/ResolveInfo.cs
+System.ServiceModel.PeerResolvers/ResolveResponseInfo.cs
+System.ServiceModel.PeerResolvers/ServiceSettingsResponseInfo.cs
+System.ServiceModel.PeerResolvers/UnregisterInfo.cs
+System.ServiceModel.PeerResolvers/UpdateInfo.cs
+System.ServiceModel.Security.Tokens/AuthenticatorCommunicationObject.cs
+System.ServiceModel.Security.Tokens/BinarySecretSecurityToken.cs
+System.ServiceModel.Security.Tokens/ClaimTypeRequirement.cs
+System.ServiceModel.Security.Tokens/CommunicationSecurityTokenAuthenticator.cs
+System.ServiceModel.Security.Tokens/CommunicationSecurityTokenProvider.cs
+System.ServiceModel.Security.Tokens/DerivedKeySecurityToken.cs
+System.ServiceModel.Security.Tokens/IIssuanceSecurityTokenAuthenticator.cs
+System.ServiceModel.Security.Tokens/ISecurityContextSecurityTokenCache.cs
+System.ServiceModel.Security.Tokens/InitiatorServiceModelSecurityTokenRequirement.cs
+System.ServiceModel.Security.Tokens/InternalEncryptedKeyIdentifierClause.cs
+System.ServiceModel.Security.Tokens/IssuedSecurityTokenHandler.cs
+System.ServiceModel.Security.Tokens/IssuedSecurityTokenParameters.cs
+System.ServiceModel.Security.Tokens/IssuedSecurityTokenProvider.cs
+System.ServiceModel.Security.Tokens/IssuedTokenCommunicationObject.cs
+System.ServiceModel.Security.Tokens/KerberosSecurityTokenParameters.cs
+System.ServiceModel.Security.Tokens/ProviderCommunicationObject.cs
+System.ServiceModel.Security.Tokens/RecipientServiceModelSecurityTokenRequirement.cs
+System.ServiceModel.Security.Tokens/RenewedSecurityTokenHandler.cs
+System.ServiceModel.Security.Tokens/RsaSecurityTokenParameters.cs
+System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenAuthenticator.cs
+System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenParameters.cs
+System.ServiceModel.Security.Tokens/SecurityContextSecurityToken.cs
+System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenAuthenticator.cs
+System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenResolver.cs
+System.ServiceModel.Security.Tokens/SecurityTokenParameters.cs
+System.ServiceModel.Security.Tokens/SecurityTokenReferenceStyle.cs
+System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenRequirement.cs
+System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenTypes.cs
+System.ServiceModel.Security.Tokens/SpnegoSecurityTokenAuthenticator.cs
+System.ServiceModel.Security.Tokens/SpnegoSecurityTokenProvider.cs
+System.ServiceModel.Security.Tokens/SslSecurityTokenAuthenticator.cs
+System.ServiceModel.Security.Tokens/SslSecurityTokenParameters.cs
+System.ServiceModel.Security.Tokens/SslSecurityTokenProvider.cs
+System.ServiceModel.Security.Tokens/SslnegoCookieResolver.cs
+System.ServiceModel.Security.Tokens/SspiClientSecurityTokenAuthenticator.cs
+System.ServiceModel.Security.Tokens/SspiSecurityToken.cs
+System.ServiceModel.Security.Tokens/SspiSecurityTokenParameters.cs
+System.ServiceModel.Security.Tokens/SspiSession.cs
+System.ServiceModel.Security.Tokens/SupportingTokenParameters.cs
+System.ServiceModel.Security.Tokens/TlsClientSession.cs
+System.ServiceModel.Security.Tokens/TlsServerSession.cs
+System.ServiceModel.Security.Tokens/UserNameSecurityTokenParameters.cs
+System.ServiceModel.Security.Tokens/WrappedKeySecurityToken.cs
+System.ServiceModel.Security.Tokens/X509SecurityTokenParameters.cs
+System.ServiceModel.Security/BasicSecurityProfileVersion.cs
+System.ServiceModel.Security/BinarySecretKeyIdentifierClause.cs
+System.ServiceModel.Security/ChannelProtectionRequirements.cs
+System.ServiceModel.Security/DataProtectionSecurityStateEncoder.cs
+System.ServiceModel.Security/ExpiredSecurityTokenException.cs
+System.ServiceModel.Security/HttpDigestClientCredential.cs
+System.ServiceModel.Security/IEndpointIdentityProvider.cs
+System.ServiceModel.Security/ISecureConversationSession.cs
+System.ServiceModel.Security/ISecuritySession.cs
+System.ServiceModel.Security/IdentityVerifier.cs
+System.ServiceModel.Security/InfocardInteractiveChannelInitializer.cs
+System.ServiceModel.Security/IssuedTokenClientCredential.cs
+System.ServiceModel.Security/IssuedTokenServiceCredential.cs
+System.ServiceModel.Security/KeyEntropyMode.cs
+System.ServiceModel.Security/KeyNameIdentifierClause.cs
+System.ServiceModel.Security/MessagePartSpecification.cs
+System.ServiceModel.Security/MessageProtectionOrder.cs
+System.ServiceModel.Security/MessageSecurityException.cs
+System.ServiceModel.Security/PeerCredential.cs
+System.ServiceModel.Security/ScopedMessagePartSpecification.cs
+System.ServiceModel.Security/SecureConversationServiceCredential.cs
+System.ServiceModel.Security/SecurityAccessDeniedException.cs
+System.ServiceModel.Security/SecurityAlgorithmSuite.cs
+System.ServiceModel.Security/SecurityContextKeyIdentifierClause.cs
+System.ServiceModel.Security/SecurityCredentialsManager.cs
+System.ServiceModel.Security/SecurityMessageProperty.cs
+System.ServiceModel.Security/SecurityNegotiationException.cs
+System.ServiceModel.Security/SecurityStateEncoder.cs
+System.ServiceModel.Security/SecurityTokenAttachmentMode.cs
+System.ServiceModel.Security/SecurityTokenSpecification.cs
+System.ServiceModel.Security/SecurityVersion.cs
+System.ServiceModel.Security/ServiceCredentialsSecurityTokenManager.cs
+System.ServiceModel.Security/SspiSecurityTokenProvider.cs
+System.ServiceModel.Security/SupportingTokenSpecification.cs
+System.ServiceModel.Security/UnionSecurityTokenResolver.cs
+System.ServiceModel.Security/UserNamePasswordClientCredential.cs
+System.ServiceModel.Security/UserNamePasswordServiceCredential.cs
+System.ServiceModel.Security/WSSecurityTokenSerializer.cs
+System.ServiceModel.Security/WindowsClientCredential.cs
+System.ServiceModel.Security/WindowsServiceCredential.cs
+System.ServiceModel.Security/X509CertificateInitiatorClientCredential.cs
+System.ServiceModel.Security/X509CertificateInitiatorServiceCredential.cs
+System.ServiceModel.Security/X509CertificateRecipientClientCredential.cs
+System.ServiceModel.Security/X509CertificateRecipientServiceCredential.cs
+System.ServiceModel.Security/X509ClientCertificateAuthentication.cs
+System.ServiceModel.Security/X509PeerCertificateAuthentication.cs
+System.ServiceModel.Security/X509ServiceCertificateAuthentication.cs
+System.ServiceModel/ActionNotSupportedException.cs
+System.ServiceModel/AddressAccessDeniedException.cs
+System.ServiceModel/AddressAlreadyInUseException.cs
+System.ServiceModel/AllEnums.cs
+System.ServiceModel/BasicHttpBinding.cs
+System.ServiceModel/BasicHttpMessageSecurity.cs
+System.ServiceModel/BasicHttpSecurity.cs
+System.ServiceModel/CallbackBehaviorAttribute.cs
+System.ServiceModel/ChannelFactory.cs
+System.ServiceModel/ChannelFactory_1.cs
+System.ServiceModel/ClientBase.cs
+System.ServiceModel/ClientCredentialsSecurityTokenManager.cs
+System.ServiceModel/ClientProxyGenerator.cs
+System.ServiceModel/ClientRuntimeChannel.cs
+System.ServiceModel/CommunicationException.cs
+System.ServiceModel/CommunicationObjectFaultedException.cs
+System.ServiceModel/Constants.cs
+System.ServiceModel/DataContractFormatAttribute.cs
+System.ServiceModel/DefaultCommunicationTimeouts.cs
+System.ServiceModel/DeliveryRequirementsAttribute.cs
+System.ServiceModel/DnsEndpointIdentity.cs
+System.ServiceModel/Dummy.cs
+System.ServiceModel/DuplexChannelFactory.cs
+System.ServiceModel/DuplexClientBase.cs
+System.ServiceModel/EndpointAddress.cs
+System.ServiceModel/EndpointAddress10.cs
+System.ServiceModel/EndpointAddressAugust2004.cs
+System.ServiceModel/EndpointAddressBuilder.cs
+System.ServiceModel/EndpointIdentity.cs
+System.ServiceModel/EndpointNotFoundException.cs
+System.ServiceModel/EnvelopeVersion.cs
+System.ServiceModel/ExceptionDetail.cs
+System.ServiceModel/ExtensionCollection.cs
+System.ServiceModel/FaultCode.cs
+System.ServiceModel/FaultContractAttribute.cs
+System.ServiceModel/FaultException.cs
+System.ServiceModel/FaultException_1.cs
+System.ServiceModel/FaultReason.cs
+System.ServiceModel/FaultReasonText.cs
+System.ServiceModel/FederatedMessageSecurityOverHttp.cs
+System.ServiceModel/HttpTransportSecurity.cs
+System.ServiceModel/IClientChannel.cs
+System.ServiceModel/ICommunicationObject.cs
+System.ServiceModel/IContextChannel.cs
+System.ServiceModel/IDefaultCommunicationTimeouts.cs
+System.ServiceModel/IDuplexClientChannel.cs
+System.ServiceModel/IExtensibleObject.cs
+System.ServiceModel/IExtension.cs
+System.ServiceModel/IExtensionCollection.cs
+System.ServiceModel/IServiceChannel.cs
+System.ServiceModel/InstanceContext.cs
+System.ServiceModel/InvalidMessageContractException.cs
+System.ServiceModel/MessageBodyAttribute.cs
+System.ServiceModel/MessageContractAttribute.cs
+System.ServiceModel/MessageContractMemberAttribute.cs
+System.ServiceModel/MessageHeaderArrayAttribute.cs
+System.ServiceModel/MessageHeaderAttribute.cs
+System.ServiceModel/MessageHeaderException.cs
+System.ServiceModel/MessageHeader_1.cs
+System.ServiceModel/MessageParameterAttribute.cs
+System.ServiceModel/MessagePropertyAttribute.cs
+System.ServiceModel/MessageSecurityOverHttp.cs
+System.ServiceModel/MessageSecurityOverMsmq.cs
+System.ServiceModel/MessageSecurityOverTcp.cs
+System.ServiceModel/MessageSecurityVersion.cs
+System.ServiceModel/MsmqBindingBase.cs
+System.ServiceModel/MsmqException.cs
+System.ServiceModel/MsmqPoisonMessageException.cs
+System.ServiceModel/MsmqTransportSecurity.cs
+System.ServiceModel/NetMsmqBinding.cs
+System.ServiceModel/NetMsmqSecurity.cs
+System.ServiceModel/NetPeerTcpBinding.cs
+System.ServiceModel/NetTcpBinding.cs
+System.ServiceModel/NetTcpSecurity.cs
+System.ServiceModel/NonDualMessageSecurityOverHttp.cs
+System.ServiceModel/OperationBehaviorAttribute.cs
+System.ServiceModel/OperationContext.cs
+System.ServiceModel/OperationContextScope.cs
+System.ServiceModel/OperationContractAttribute.cs
+System.ServiceModel/OptionalReliableSession.cs
+System.ServiceModel/PeerMessagePropagationMessageFilter.cs
+System.ServiceModel/PeerNode.cs
+System.ServiceModel/PeerNodeAddress.cs
+System.ServiceModel/PeerResolver.cs
+System.ServiceModel/PeerResolverImpl.cs
+System.ServiceModel/PeerSecuritySettings.cs
+System.ServiceModel/PoisonMessageException.cs
+System.ServiceModel/ProtocolException.cs
+System.ServiceModel/QuotaExceededException.cs
+System.ServiceModel/ReliableMessagingVersion.cs
+System.ServiceModel/ReliableSession.cs
+System.ServiceModel/RsaEndpointIdentity.cs
+System.ServiceModel/ServiceAuthorizationManager.cs
+System.ServiceModel/ServiceBehaviorAttribute.cs
+System.ServiceModel/ServiceContractAttribute.cs
+System.ServiceModel/ServiceHost.cs
+System.ServiceModel/ServiceHostBase.cs
+System.ServiceModel/ServiceHostingEnvironment.cs
+System.ServiceModel/ServiceKnownTypeAttribute.cs
+System.ServiceModel/ServiceRuntimeChannel.cs
+System.ServiceModel/ServiceSecurityContext.cs
+System.ServiceModel/SpnEndpointIdentity.cs
+System.ServiceModel/TcpTransportSecurity.cs
+System.ServiceModel/TransactionProtocol.cs
+System.ServiceModel/TransferMode.cs
+System.ServiceModel/UnknownMessageReceivedEventArgs.cs
+System.ServiceModel/UpnEndpointIdentity.cs
+System.ServiceModel/UriSchemeKeyedCollection.cs
+System.ServiceModel/WS2007FederationHttpBinding.cs
+System.ServiceModel/WS2007HttpBinding.cs
+System.ServiceModel/WSDualHttpBinding.cs
+System.ServiceModel/WSDualHttpSecurity.cs
+System.ServiceModel/WSFederationHttpBinding.cs
+System.ServiceModel/WSFederationHttpSecurity.cs
+System.ServiceModel/WSHttpBinding.cs
+System.ServiceModel/WSHttpBindingBase.cs
+System.ServiceModel/WSHttpSecurity.cs
+System.ServiceModel/X509CertificateEndpointIdentity.cs
+System.ServiceModel/XmlSerializerFormatAttribute.cs
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ActionNotSupportedException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ActionNotSupportedException.cs
new file mode 100644 (file)
index 0000000..bd2b762
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// ActionNotSupportedException.cs
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel
+{
+       [Serializable]
+       public class ActionNotSupportedException : CommunicationException
+       {
+               public ActionNotSupportedException () : base () {}
+               public ActionNotSupportedException (string msg) : base (msg) {}
+               public ActionNotSupportedException (string msg, Exception inner) : base (msg, inner) {}
+               protected ActionNotSupportedException (SerializationInfo info, StreamingContext context) :
+                       base (info, context) {}
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/AddressAccessDeniedException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/AddressAccessDeniedException.cs
new file mode 100644 (file)
index 0000000..ac3b605
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// System.ServiceModel.AddressAccessDeniedException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel {
+       [Serializable]
+       public class AddressAccessDeniedException : CommunicationException
+       {
+               public AddressAccessDeniedException () : base () {}
+               public AddressAccessDeniedException (string msg) : base (msg) {}
+               public AddressAccessDeniedException (string msg, Exception inner) : base (msg, inner) {}
+               protected AddressAccessDeniedException (SerializationInfo info, StreamingContext context) :
+                       base (info, context) {}
+
+
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/AddressAlreadyInUseException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/AddressAlreadyInUseException.cs
new file mode 100644 (file)
index 0000000..7010306
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// System.ServiceModel.AddressAlreadyInUseException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel {
+       [Serializable]
+       public class AddressAlreadyInUseException : CommunicationException
+       {
+               public AddressAlreadyInUseException () : base () {}
+               public AddressAlreadyInUseException (string msg) : base (msg) {}
+               public AddressAlreadyInUseException (string msg, Exception inner) : base (msg, inner) {}
+               protected AddressAlreadyInUseException (SerializationInfo info, StreamingContext context) :
+                       base (info, context) {}
+
+
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/AllEnums.cs b/mcs/class/System.ServiceModel/System.ServiceModel/AllEnums.cs
new file mode 100644 (file)
index 0000000..47a210c
--- /dev/null
@@ -0,0 +1,416 @@
+//
+// AllEnums.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+namespace System.ServiceModel.Activation
+{
+       public enum AspNetCompatibilityRequirementsMode
+       {
+               NotAllowed,
+               Allowed,
+               Required,
+       }
+}
+
+namespace System.ServiceModel
+{
+       public enum AuditLevel
+       {
+               None,
+               Success,
+               Failure,
+               SuccessOrFailure,
+       }
+
+       public enum AuditLogLocation
+       {
+               Default,
+               Application,
+               Security,
+       }
+
+       public enum BasicHttpMessageCredentialType
+       {
+               UserName,
+               Certificate,
+       }
+
+       public enum BasicHttpSecurityMode
+       {
+               None,
+               Transport,
+               Message,
+               TransportWithMessageCredential,
+               TransportCredentialOnly,
+       }
+
+       public enum CommunicationState
+       {
+               Created,
+               Opening,
+               Opened,
+               Closing,
+               Closed,
+               Faulted,
+       }
+
+       public enum ConcurrencyMode
+       {
+               Single,
+               Reentrant,
+               Multiple,
+       }
+
+       public enum HostNameComparisonMode
+       {
+               StrongWildcard,
+               Exact,
+               WeakWildcard,
+       }
+
+       public enum ImpersonationOption
+       {
+               NotAllowed,
+               Allowed,
+               Required,
+       }
+
+       public enum InstanceContextMode
+       {
+               PerSession,
+               PerCall,
+               Single,
+       }
+
+       public enum NetMsmqSecurityMode
+       {
+               None,
+               Transport,
+               Message,
+               Both,
+       }
+
+       public enum NetNamedPipeSecurityMode
+       {
+               None,
+               Transport,
+       }
+
+       public enum OperationFormatStyle
+       {
+               Document,
+               Rpc,
+       }
+
+       public enum OperationFormatUse
+       {
+               Literal,
+               Encoded,
+       }
+
+       public enum PeerMessageOrigination
+       {
+               Local,
+               Remote,
+       }
+
+       public enum PeerMessagePropagation
+       {
+               None,
+               Local,
+               Remote,
+               LocalAndRemote,
+       }
+
+       public enum QueuedDeliveryRequirementsMode
+       {
+               Allowed,
+               Required,
+               NotAllowed,
+       }
+
+       public enum PeerTransportCredentialType
+       {
+               Password,
+               Certificate,
+       }
+
+       public enum ReceiveErrorHandling
+       {
+               Fault,
+               Drop,
+               Reject,
+               Move,
+       }
+
+       public enum ReleaseInstanceMode
+       {
+               None,
+               BeforeCall,
+               AfterCall,
+               BeforeAndAfterCall,
+       }
+
+       public enum SessionMode
+       {
+               Allowed,
+               Required,
+               NotAllowed,
+       }
+
+       public enum TransactionFlowOption
+       {
+               NotAllowed,
+               Allowed,
+               Mandatory,
+       }
+
+       public enum WSDualHttpSecurityMode
+       {
+               None,
+               Message,
+       }
+
+       public enum WSFederationHttpSecurityMode
+       {
+               None,
+               Message,
+               TransportWithMessageCredential,
+       }
+
+       public enum WSMessageEncoding
+       {
+               Text,
+               Mtom,
+       }
+
+}
+
+namespace System.ServiceModel // used to be S.SM.Ch
+{
+       public enum DeadLetterQueue
+       {
+               None,
+               System,
+               Custom,
+       }
+
+       public enum HttpClientCredentialType
+       {
+               None,
+               Basic,
+               Digest,
+               Ntlm,
+               Windows,
+               Certificate,
+       }
+
+       public enum HttpProxyCredentialType
+       {
+               None,
+               Basic,
+               Digest,
+               Ntlm,
+               Windows,
+       }
+
+       public enum MessageCredentialType
+       {
+               None,
+               Windows,
+               UserName,
+               Certificate,
+               IssuedToken,
+       }
+
+       public enum MsmqAuthenticationMode
+       {
+               None,
+               WindowsDomain,
+               Certificate,
+       }
+
+       public enum MsmqEncryptionAlgorithm
+       {
+               RC4Stream,
+               Aes,
+       }
+
+       public enum MsmqSecureHashAlgorithm
+       {
+               MD5,
+               Sha1,
+               Sha256,
+               Sha512,
+       }
+
+       public enum QueueTransferProtocol
+       {
+               Native,
+               Srmp,
+               SrmpSecure,
+       }
+
+       public enum SecurityMode
+       {
+               None,
+               Transport,
+               Message,
+               TransportWithMessageCredential,
+       }
+
+       public enum TcpClientCredentialType
+       {
+               None,
+               Windows,
+               Certificate,
+       }
+}
+
+namespace System.ServiceModel.Channels
+{
+       public enum MessageState
+       {
+               Created,
+               Read,
+               Written,
+               Copied,
+               Closed,
+       }
+
+       public enum SecurityHeaderLayout
+       {
+               Strict,
+               Lax,
+               LaxTimestampFirst,
+               LaxTimestampLast,
+       }
+
+       public enum TransferSession
+       {
+               None,
+               Ordered,
+               Unordered,
+       }
+
+}
+
+namespace System.ServiceModel.Description
+{
+       public enum PrincipalPermissionMode
+       {
+               None,
+               UseWindowsGroups,
+               UseAspNetRoles,
+               Custom,
+       }
+
+       public enum MessageDirection
+       {
+               Input,
+               Output,
+       }
+
+       public enum ListenUriMode
+       {
+               Explicit,
+               Unique,
+       }
+
+       public enum MetadataExchangeClientMode
+       {
+               MetadataExchange,
+               HttpGet
+       }
+
+       [Flags]
+       public enum ServiceContractGenerationOptions
+       {
+               None,
+               AsynchronousMethods = 1,
+               ChannelInterface = 2,
+               InternalTypes = 4,
+               ClientClass = 8,
+               TypedMessages = 16,
+       }
+}
+
+namespace System.ServiceModel.MsmqIntegration
+{
+       public enum MsmqIntegrationSecurityMode
+       {
+               None,
+               Transport,
+       }
+
+       public enum MsmqMessageSerializationFormat
+       {
+               Xml,
+               Binary,
+               ActiveX,
+               ByteArray,
+               Stream,
+       }
+}
+
+namespace System.ServiceModel.Security
+{
+       public enum UserNamePasswordValidationMode
+       {
+               Windows,
+               MembershipProvider,
+               Custom,
+       }
+
+       public enum X509CertificateValidationMode
+       {
+               None,
+               PeerTrust,
+               ChainTrust,
+               PeerOrChainTrust,
+               Custom,
+       }
+}
+
+namespace System.ServiceModel.Security.Tokens
+{
+       public enum SecurityTokenInclusionMode
+       {
+               AlwaysToRecipient,
+               Never,
+               Once,
+               AlwaysToInitiator,
+       }
+
+       public enum X509KeyIdentifierClauseType
+       {
+               Any,
+               Thumbprint,
+               IssuerSerial,
+               SubjectKeyIdentifier,
+               RawDataKeyIdentifier,
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpBinding.cs
new file mode 100644 (file)
index 0000000..2f0ebaf
--- /dev/null
@@ -0,0 +1,242 @@
+//
+// BasicHttpBinding.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+using System.ServiceModel.Configuration;
+
+namespace System.ServiceModel
+{
+       public class BasicHttpBinding : Binding,
+               IBindingRuntimePreferences
+       {
+               bool allow_cookies, bypass_proxy_on_local;
+               HostNameComparisonMode host_name_comparison_mode
+                       = HostNameComparisonMode.StrongWildcard;
+               long max_buffer_pool_size = 0x80000;
+               int max_buffer_size = 0x10000;
+               long max_recv_message_size = 0x10000;
+               WSMessageEncoding message_encoding
+                       = WSMessageEncoding.Text;
+               Uri proxy_address;
+               XmlDictionaryReaderQuotas reader_quotas
+                       = new XmlDictionaryReaderQuotas ();
+               EnvelopeVersion env_version = EnvelopeVersion.Soap11;
+               Encoding text_encoding = new UTF8Encoding ();
+               TransferMode transfer_mode
+                        = TransferMode.Buffered;
+               bool use_default_web_proxy = true;
+               BasicHttpSecurity security;
+
+               public BasicHttpBinding ()
+                       : this (BasicHttpSecurityMode.None)
+               {
+               }
+
+               public BasicHttpBinding (string configurationName)
+                       : this ()
+               {
+                       BindingsSection bindingsSection = ConfigUtil.BindingsSection;
+                       BasicHttpBindingElement el = 
+                               bindingsSection.BasicHttpBinding.Bindings [configurationName];
+
+                       el.ApplyConfiguration (this);
+               }
+
+               public BasicHttpBinding (
+                       BasicHttpSecurityMode securityMode)
+               {
+                       security = new BasicHttpSecurity (securityMode);
+               }
+
+               public bool AllowCookies {
+                       get { return allow_cookies; }
+                       set { allow_cookies = value; }
+               }
+
+               public bool BypassProxyOnLocal {
+                       get { return bypass_proxy_on_local; }
+                       set { bypass_proxy_on_local = value; }
+               }
+
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return host_name_comparison_mode; }
+                       set { host_name_comparison_mode = value; }
+               }
+
+               public long MaxBufferPoolSize {
+                       get { return max_buffer_pool_size; }
+                       set {
+                               if (value <= 0)
+                                       throw new ArgumentOutOfRangeException ();
+                               max_buffer_pool_size = value;
+                       }
+               }
+
+               public int MaxBufferSize {
+                       get { return max_buffer_size; }
+                       set {
+                               if (value <= 0)
+                                       throw new ArgumentOutOfRangeException ();
+                               max_buffer_size = value;
+                       }
+               }
+
+               public long MaxReceivedMessageSize {
+                       get { return max_recv_message_size; }
+                       set {
+                               if (value <= 0)
+                                       throw new ArgumentOutOfRangeException ();
+                               max_recv_message_size = value;
+                       }
+               }
+
+               public WSMessageEncoding MessageEncoding {
+                       get { return message_encoding; }
+                       set { message_encoding = value; }
+               }
+
+               public Uri ProxyAddress {
+                       get { return proxy_address; }
+                       set { proxy_address = value; }
+               }
+
+               public XmlDictionaryReaderQuotas ReaderQuotas {
+                       get { return reader_quotas; }
+                       set { reader_quotas = value; }
+               }
+
+               public override string Scheme {
+                       get {
+                               switch (Security.Mode) {
+                               case BasicHttpSecurityMode.Transport:
+                               case BasicHttpSecurityMode.TransportWithMessageCredential:
+                                       return Uri.UriSchemeHttps;
+                               default:
+                                       return Uri.UriSchemeHttp;
+                               }
+                       }
+               }
+
+               public BasicHttpSecurity Security {
+                       get { return security; }
+               }
+
+               public EnvelopeVersion EnvelopeVersion {
+                       get { return env_version; }
+               }
+
+               public Encoding TextEncoding {
+                       get { return text_encoding; }
+                       set { text_encoding = value; }
+               }
+
+               public TransferMode TransferMode {
+                       get { return transfer_mode; }
+                       set { transfer_mode = value; }
+               }
+
+               public bool UseDefaultWebProxy {
+                       get { return use_default_web_proxy; }
+                       set { use_default_web_proxy = value; }
+               }
+
+               public override BindingElementCollection
+                       CreateBindingElements ()
+               {
+                       switch (Security.Mode) {
+                       case BasicHttpSecurityMode.Message:
+                       case BasicHttpSecurityMode.TransportWithMessageCredential:
+                               if (Security.Message.ClientCredentialType != BasicHttpMessageCredentialType.Certificate)
+                                       throw new InvalidOperationException ("When Message security is enabled in a BasicHttpBinding, the message security credential type must be BasicHttpMessageCredentialType.Certificate.");
+                               return new BindingElementCollection (new BindingElement [] {
+                                       // FIXME: pass proper security token parameters.
+                                       new AsymmetricSecurityBindingElement (),
+                                       BuildMessageEncodingBindingElement (),
+                                       GetTransport ()});
+
+                       default:
+                               return new BindingElementCollection (new BindingElement [] {
+                                       BuildMessageEncodingBindingElement (),
+                                       GetTransport ()});
+                       }
+
+               }
+
+               MessageEncodingBindingElement BuildMessageEncodingBindingElement ()
+               {
+                       if (MessageEncoding == WSMessageEncoding.Text) {
+                               TextMessageEncodingBindingElement tm = new TextMessageEncodingBindingElement (
+                                       MessageVersion.CreateVersion (EnvelopeVersion, AddressingVersion.None), TextEncoding);
+                               ReaderQuotas.CopyTo (tm.ReaderQuotas);
+                               return tm;
+                       }
+                       else
+                               return new MtomMessageEncodingBindingElement (
+                                       MessageVersion.CreateVersion (EnvelopeVersion, AddressingVersion.None), TextEncoding);
+               }
+
+               TransportBindingElement GetTransport ()
+               {
+                       HttpTransportBindingElement transportBindingElement;
+                       switch (Security.Mode) {
+                       case BasicHttpSecurityMode.Transport:
+                       case BasicHttpSecurityMode.TransportWithMessageCredential:
+                               transportBindingElement
+                                       = new HttpsTransportBindingElement ();
+                               break;
+                       default:
+                               transportBindingElement
+                                       = new HttpTransportBindingElement ();
+                               break;
+                       }
+
+                       transportBindingElement.AllowCookies = AllowCookies;
+                       transportBindingElement.BypassProxyOnLocal = BypassProxyOnLocal;
+                       transportBindingElement.HostNameComparisonMode = HostNameComparisonMode;
+                       transportBindingElement.MaxBufferPoolSize = MaxBufferPoolSize;
+                       transportBindingElement.MaxBufferSize = MaxBufferSize;
+                       transportBindingElement.MaxReceivedMessageSize = MaxReceivedMessageSize;
+                       transportBindingElement.ProxyAddress = ProxyAddress;
+                       transportBindingElement.UseDefaultWebProxy = UseDefaultWebProxy;
+                       transportBindingElement.TransferMode = TransferMode;
+
+                       return transportBindingElement;
+               }
+
+               // explicit interface implementations
+
+               bool IBindingRuntimePreferences.ReceiveSynchronously {
+                       get { return false; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpMessageSecurity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpMessageSecurity.cs
new file mode 100644 (file)
index 0000000..66db062
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// BasicHttpMessageSecurity.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net.Security;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       public sealed class BasicHttpMessageSecurity
+       {
+               internal BasicHttpMessageSecurity ()
+               {
+               }
+
+               SecurityAlgorithmSuite alg = SecurityAlgorithmSuite.Default;
+               BasicHttpMessageCredentialType ctype;
+
+               public SecurityAlgorithmSuite AlgorithmSuite {
+                       get { return alg; }
+                       set { alg = value; }
+               }
+
+               public BasicHttpMessageCredentialType ClientCredentialType {
+                       get { return ctype; }
+                       set { ctype = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpSecurity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpSecurity.cs
new file mode 100644 (file)
index 0000000..e4516bc
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// BasicHttpSecurity.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public sealed class BasicHttpSecurity
+       {
+               internal BasicHttpSecurity (BasicHttpSecurityMode mode)
+               {
+                       this.mode = mode;
+                       this.message = new BasicHttpMessageSecurity ();
+                       this.transport = new HttpTransportSecurity ();
+               }
+
+               BasicHttpMessageSecurity message;
+               BasicHttpSecurityMode mode;
+               HttpTransportSecurity transport;
+
+               public BasicHttpMessageSecurity Message {
+                       get { return message; }
+               }
+
+               public BasicHttpSecurityMode Mode {
+                       get { return mode; }
+                       set { mode = value; }
+               }
+
+               public HttpTransportSecurity Transport {
+                       get { return transport; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/CallbackBehaviorAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/CallbackBehaviorAttribute.cs
new file mode 100644 (file)
index 0000000..629bce8
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// CallbackBehaviorAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       [AttributeUsage (AttributeTargets.Class)]
+       public sealed class CallbackBehaviorAttribute : Attribute,
+               IEndpointBehavior
+       {
+               bool shutdown, ignore_ext, return_unknown_as_faults,
+                       use_sync_context, validate_must_understand;
+               ConcurrencyMode concurrency;
+
+               public bool AutomaticSessionShutdown {
+                       get { return shutdown; }
+                       set { shutdown = value; }
+               }
+
+               public ConcurrencyMode ConcurrencyMode {
+                       get { return concurrency; }
+                       set { concurrency = value; }
+               }
+
+               public bool IgnoreExtensionDataObject {
+                       get { return ignore_ext; }
+                       set { ignore_ext = value; }
+               }
+
+               public bool ReturnUnknownExceptionsAsFaults {
+                       get { return return_unknown_as_faults; }
+                       set { return_unknown_as_faults = value; }
+               }
+
+               public bool UseSynchronizationContext {
+                       get { return use_sync_context; }
+                       set { use_sync_context = value; }
+               }
+
+               public bool ValidateMustUnderstand {
+                       get { return validate_must_understand; }
+                       set { validate_must_understand = value; }
+               }
+
+               void IEndpointBehavior.AddBindingParameters (
+                       ServiceEndpoint endpoint,
+                       BindingParameterCollection parameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IEndpointBehavior.ApplyDispatchBehavior (
+                       ServiceEndpoint serviceEndpoint,
+                       EndpointDispatcher dispatcher)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IEndpointBehavior.ApplyClientBehavior (
+                       ServiceEndpoint serviceEndpoint,
+                       ClientRuntime behavior)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IEndpointBehavior.Validate (
+                       ServiceEndpoint serviceEndpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog b/mcs/class/System.ServiceModel/System.ServiceModel/ChangeLog
new file mode 100755 (executable)
index 0000000..cd60c3c
--- /dev/null
@@ -0,0 +1,2497 @@
+2008-05-28  Noam Lampert <noaml@mainsoft.com>
+       * ServiceHost.cs: Allow services to implement more than one contract.
+
+2008-05-22  Noam Lampert <noaml@mainsoft.com>
+       * ServiceBehaviorAttribute.cs: Propagate IncludeExceptionDetailsInFaults
+       * ExceptionDetail.cs: Modify implementation so that deserialized instance will also work
+       * ClientRuntimeChannel.cs: Throw correct fault exception
+       
+2008-05-01  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ClientProxyGenerator.cs: Add explicit casts for allowing boxing.
+       * ServiceHostBase.cs: Simplified in/out parameter handling.
+
+2008-04-22  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceHostBase.cs: initialize DispatchOperation's Invoker and Formater.
+       
+2008-04-21  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceHostBase.cs: consider refactoring of HttpGetWsdl.
+
+2008-04-17  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceHostBase.cs: fixed BuildChannelDispatcher, init of
+       endpoint dispatcher's ContractFilter
+
+2008-04-17  Vladmir Krasnov  <vladmimir@mainsoft.com>
+
+       * ServiceRuntimeChannel.cs: refactoring, consider chganges in channel
+       dispatcher and endpoint dispatcher
+
+2008-04-17  Vladmir Krasnov  <vladmimir@mainsoft.com>
+
+       * ServiceHostBase.cs: fixed BuildChannelDispatcher, init of
+       endpoint dispatcher's ContractFilter
+
+2008-04-14  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ExtensionCollection.cs:
+       fix ClearItems, InsertItem, RemoveItem and SetItem,
+       call Attach/Detach of items.                    
+
+2008-04-13  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * BasicHttpBinding.cs:
+       * NetMsmqBinding.cs:
+       * NetPeerTcpBinding.cs:
+       consider fixed API in BindingElementCollection class.                   
+
+2008-04-10  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ClientProxyGenerator.cs: Add support for out and by ref params.
+
+2008-04-08  Roei Erez <roeie@mainsoft.com>
+
+       * ServiceHostBase.cs:
+       - Refactoring of InitializeRuntime method:
+         -- Build ChanneldDispatcher correctly
+         -- Build EndPointDispatchers
+         -- Fix the order of applying behaviors
+
+2008-04-03  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceHostBase.cs:
+       - implement InitializeRuntime.
+       - load behaviors configuration properly.
+
+2008-04-04  Vladmir Krasnov  <vladmimir@mainsoft.com>
+
+       * BasicHttpBinding.cs: fixed GetTransport method
+
+2008-04-03  Roei Erez <roeie@mainsoft.com>
+
+       * ServiceHostBase.cs: fix ApplyConfiguration to consider only the current
+       service according to the 'Description' attribute.
+
+2008-04-02  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceHost.cs:
+       * ServiceHostBase.cs:
+       ServiceAuthorizationBehavior and ServiceDebugBehavior are added during
+       ApplyConfiguration. 
+
+2008-04-01  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * UriSchemeKeyedCollection.cs: fix API (.ctor signature).
+
+2008-04-01  Vladmir Krasnov  <vladmimir@mainsoft.com>
+
+       * BasicHttpBinding.cs: fixed ReaderQuotas in
+       BuildMessageEncodingBindingElement
+
+2008-03-31  Vladmir Krasnov  <vladmimir@mainsoft.com>
+
+       * BasicHttpBinding.cs: fixed GetTransport, TransportBindingElement init
+
+2008-03-31  Vladmir Krasnov  <vladmimir@mainsoft.com>
+
+       * BasicHttpBinding.cs: fixed configuration issues
+
+2008-03-27  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ReliableMessagingVersion.cs: add missing API.
+
+2008-03-25  Vladmir Krasnov  <vladmimir@mainsoft.com>
+
+       * ServiceHostBase.cs: implemented ApplyConfiguration, fixed service 
+       hosting
+
+2008-03-04  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ChannelBase.cs: Move configuration handling to ChannelFactory.
+       * ChannelFactory_1.cs: Add arguments checks.
+       * ChannelFactory.cs: Implement ApplyConfiguration.
+
+2008-02-28  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ChannelBase.cs: Handle better configuration lookup and contract
+         attributes.
+         Add argument null checks.
+       * ChannelFactory_1.cs: Indentation chnges.
+
+2008-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DuplexChannelFactory.cs : CreateChannel() is extra.
+
+2008-02-27  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ChannelBase.cs: Handle case where contract configuration name is set
+         in the 'TChannel' type custom attributes.
+
+2008-02-27  Eyal Alaluf <eyala@mainsoft.com>
+
+       * WSHttpBindingBase.cs DuplexChannelFactory.cs: Fix compilation warnings.
+
+2008-02-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * NetTcpBinding.cs : store transport and use it for some properties.
+       * EnvelopeVersion.cs : updated destinations to 3.0 SP1.
+
+2008-02-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OperationContext.cs : implemented OutgoingMessageHeaders and
+         OutgoingMessageProperties.
+       * ExtensionCollection.cs : Pass syncRoot to base.
+         Implemented Find(), FindAll() and IsReadOnly.
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs : reject relative Uri.
+
+2008-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory_1.cs : populate ClientOperations before applying
+         IEndpointBehavior and IContractBehavior so that they can access to
+         ClientOperations.
+
+2008-02-14  Igor Zelmanovich  <igorz@mainsoft.com>
+
+       * ServiceContractAttribute.cs: fixed public API
+       added property "ConfigurationName"      
+
+2008-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : build fix.
+
+2008-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBase.cs, ClientProxyGenerator.cs : the client proxy does not
+         have to be generic, so removed the type argument.
+       * ChannelFactory_1.cs : ditto.
+         EnsureOpened() when creating a channel (it
+         used to do so, but disappeared at some point ...).
+       * ClientRuntimeChannel.cs : ditto (type argument).
+         Factory must have been opened before creating this channel, so
+         do not try to open factory here.
+
+2008-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : when listenUri is not absolute, make it
+         absolute before being passed to ServiceEndpoint.
+         Tiny message string fix ("string + string" is hard to translate).
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressBuilder.cs ServiceBehaviorAttribute.cs :
+         some more cosmetic API fixes and missing MonoTODOs.
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHost.cs : ServiceBehaviorAttribute must be first retrieved
+         from the service type (or instance).
+       * ServiceBehaviorAttribute.cs : InstanceContextMode default is
+         PerCall. Implement support for well-known instance.
+
+2007-08-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PeerNodeAddress.cs : add private .ctor() for deserialization.
+
+2007-08-16 Marcos Cobena (marcoscobena@gmail.com)
+
+       * AllEnums.cs: PeerReferralPolicy lives now inside System.ServiceModel.PeerResolvers.
+
+2007-08-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageContractAttribute.cs : IsWrapped = true by default.
+
+2007-07-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PeerNodeAddress.cs : with private members it is always possible
+         to hack around non-datacontract types.
+
+2007-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DuplexChannelFactory.cs: New static method.
+
+2007-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MsmqBindingBase.cs NetMsmqBinding.cs : initialize some fields.
+         implemented NetMsmqBinding.CreateBindingElements().
+
+2007-07-24 Marcos Cobena (marcoscobena@gmail.com)
+
+       * DuplexChannelFactory.cs: New static method.
+
+2007-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * NetMsmqSecurity.cs PoisonMessageException.cs
+         MsmqException.cs MsmqPoisonMessageException.cs
+         MsmqBindingBase.cs MessageSecurityOverMsmq.cs
+         NetMsmqBinding.cs MsmqTransportSecurity.cs :
+         couple of msmq stubs.
+       * Dummy.cs : removed newly stubbed ones.
+
+2007-04-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs, EndpointAddress10.cs :
+         more refactoring.
+         read Metadata element.
+
+2007-04-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs,
+         EndpointAddress10.cs,
+         EndpointAddressAugust2004.cs :
+         some rewrite on WriteXml(). For WSA10, it is now based on XML
+         serializer. (Read methods won't go that way btw.)
+         IXmlSerializable.GetSchema() in both versions return null.
+         public GetSchema() returns schema from W3C.
+
+2007-04-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added couple of consts.
+
+2007-04-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added WsaIdentityUri.
+       * EndpointIdentity.cs : implemented ToString().
+       * X509CertificateEndpointIdentity.cs : Initialize() was missing.
+       * EndpointAddress.cs : implemented WriteContentsTo(), which is
+         actually what WriteTo() should just call. Handle X509 identity
+         as its own way to be serialized.
+
+2007-04-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs : support mutual sslnego.
+
+2007-04-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceKnownTypeAttribute.cs : added.
+
+2007-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added soem OIDs.
+
+2007-03-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs :
+         support spnego authenticator and provider. Provider should not be
+         SspiSecurityTokenProvider, as it is not for spnego.
+       * Constants.cs : added some spnego constants.
+
+2007-03-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added LifetimeFormat.
+
+2007-03-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added Tlsnego WST proof token type.
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added namespace for dnse:Cookie in ssl negotiation.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ExceptionDetail.cs : new file.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs :
+         moved code for applying behavior to ChannelDispatcher.cs.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBase.cs : added DisplayInitializationUI() stub.
+       * ServiceHostBase.cs : raise an error when no channel could be built.
+
+2007-03-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added consts for ssl and negotiation bindings.
+       * ClientCredentialsSecurityTokenManager.cs :
+         IsIssuedSecurityTokenRequirement() should not return true for
+         non-IssuedToken parameters.
+
+2007-03-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs :
+         internalize IsIssuedSecurityTokenRequirement().
+         Use SecurityTokenRequirement.ToString().
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBinding.cs : for UserName credentials, don't require
+         signature confirmations.
+
+2007-02-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added WssdDefaultLabel.
+
+2007-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceRuntimeChannel.cs : ... and largely implemented.
+
+2007-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceRuntimeChannel.cs-tmp, ServiceRuntimeChannel.cs :
+         renamed former to latter.
+
+2007-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OperationContext.cs, OperationContextScope.cs : implemented some
+         members and fixed some misimplementations. (They cannot be in use
+         until I create IServiceChannel implementation, like 
+         ClientRuntimeChannel but for services.)
+
+2007-02-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : so, we didn't add ChannelProtectionRequirements
+         and subsequently the reply message was not signed at all.
+
+2007-01-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added wsse EncryptedKeySHA1.
+
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityVersion.cs, Constants.cs :
+         Use constants in MessageSecurityTokenVersion.
+       * ClientCredentialsSecurityTokenManager.cs :
+         CreateSecurityTokenSerializer() should consider securityVersion
+         and emitBspRequiredAttributes based on SecurityTokenVersion.
+
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added WSSEncryptedKeyToken.
+
+2007-01-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added WssBase64BinaryEncodingType (but I cannot
+         enable the code that uses it :| )
+
+2006-12-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : moved ChannelProtectionRequirements
+         population to ChannelProtectionRequirements.cs with some fixes.
+
+2006-12-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added WS-Security X509 thumbprint identifier
+         value type.
+
+2006-12-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EnvelopeVersion.cs : added Soap12UltimateReceiver to be used in
+         MessageHeader.
+
+2006-12-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : (GetContract) If the service type is
+         IMetadataExchange, don't require ServiceMetadataBehavior.
+
+2006-10-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : on closing channel dispatchers, they will
+         remove themselves from dispatchers, so don't iterate directly.
+
+2006-10-18  Ankit Jain  <jankit@novell.com>
+
+       * ServiceHostBase.cs (GetContract): Add HttpGetWsdl contract by default
+       to ImplementedContracts.
+
+2006-10-18  Ankit Jain  <jankit@novell.com>
+
+       * ServiceHostBase.cs (GetContract): Throw if adding a IMetadataExchange
+       endpoint but ServiceMetadataBehavior has not been added.
+       Add contract for HttpGetWsdl to ImplementedContracts.
+
+2006-10-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceSecurityContext.cs : added some members for testing
+         SecurityMessageProperty.
+       * WSHttpBinding.cs : some fixes for X509 token modes.
+
+2006-10-06  Ankit Jain  <jankit@novell.com>
+
+       * ServiceHostBase.cs (PopulateDispatchOperation): Identify 'catch all'
+       operation and set UnhandledDispatchOperation accordingly.
+
+2006-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBinding.cs : Fixed x509 parameter initialization.
+       * ClientRuntimeChannel.cs : get max fault size from ClientRuntime.
+
+2006-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : when fault happened, don't parse it as
+         the expected result but throw FaultException instead.
+
+2006-10-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientProxyGenerator.cs, ClientRuntimeChannel : pass operation name
+         to ClientRuntimeChannel.Process() explicitly, to get correct 
+         OperationDescription.
+
+2006-10-04  Ankit Jain  <jankit@novell.com>
+
+       * ServiceHostBase.cs (Extensions): Implement.
+       (GetContract): HACK to allow IMetadataExchange as the contract for an
+       endpoint.
+       (DoOpen): Call IServiceBehavior.ApplyDispatchBehavior
+       * ServiceBehaviorAttribute.cs (ApplyDispatchBehavior): Remove NYI
+       exception.
+       * InstanceContext.cs (GetServiceInstance): Implement.
+
+2006-10-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceBehaviorAttribute.cs : added IncludeExceptionDetailInFaults
+         and removed old ReturnUnknownExceptionsAsFaults.
+       * Constants.cs : added WsaAnonymousUri.
+       * EndpointAddress.cs : use above.
+       * ClientRuntimeChannel.cs : comment on FIXME.
+
+2006-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : setup the channel before inspection.
+
+2006-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs : implemented some of
+         CreateSecurityTokenAuthenticator(), which seems used in
+         IRequestChannel for security.
+
+2006-09-27  Ankit Jain  <jankit@novell.com>
+
+       * Dummy.cs (ServiceHostingEnvironment): Remove.
+       * ServiceHostingEnvironment.cs: New.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : HasProtectionLevel computation for
+         ChannelProtectionRequirements was more complex.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : pass proper IsBodyIncluded argument.
+         Fix warnings.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : MessagePartSpecification is created for
+         every message i.e. per action, not per message part.
+       * ServiceContractAttribute.cs, FaultContractAttribute.cs,
+         OperationContractAttribute.cs, MessageContractAttribute.cs :
+         Fixed HasProtectionLevel. It is always true when ProtectionLevel is set.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory.cs : default timeouts could be retrieved from Binding.
+       * ServiceContractAttribute.cs : added [Has]ProtectionLevel.
+       * ChannelFactory_1.cs, ClientRuntimeChannel.cs :
+         ChannelProtectionRequirements is needed for BindingParameterCollection.
+         Actually it was created but was going nowhere.
+       * ClientBase.cs : removed some MonoTODOs.
+
+2006-09-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBase.cs : pass binding and endpoint address directly to 
+         ChannelFactory.ctor() so that it does not miss ClientCredentials.
+
+2006-09-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSDualHttpSecurity.cs, DnsEndpointIdentity.cs, SpnEndpointIdentity.cs,
+         MessageSecurityOverTcp.cs, NetTcpSecurity.cs, UpnEndpointIdentity.cs,
+         TcpTransportSecurity.cs : added missing types.
+       * Dummy.cs : removed all above.
+       * EndpointIdentity.cs : implemented.
+       * BasicHttpBinding.cs : consider HTTPS.
+       * MessageSecurityOverHttp.cs : IsSecureConversationEnabled() always
+         returns true unless overriden.
+       * WSDualHttpBinding.cs : added Security.
+       * NetTcpBinding.cs : assorted API fixes and some implementation code.
+
+2006-09-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBase.cs : remove ClientCredential addition.
+
+2006-09-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory_1.cs :
+         oops, MessageBodyDescription.ReturnValue could be null.
+
+2006-09-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs : support kerberos provider
+         creation (though it won't work anyways).
+       * ChannelFactory_1.cs : add client credentials to the endpoint _here_,
+         not only in ClientBase. Also support ChannelProtectionRequirements
+         which will be required by message security support.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityVersion.cs : SecurityTokenVersion is implemented.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs : null credential check.
+         Make "missing credential error" message correct (the missing 
+         certificate might be service certificate while it always blamed
+         client certificate).
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : by default, use non-session channel i.e.
+         use session channels only for those bindings that does not allow
+         sessionless channels.
+
+2006-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs : more implementation in
+         CreateSecurityTokenProvider().
+
+2006-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs : refactored
+         communication-based token provider creation. See S.SM.S.Tokens
+         change as well.
+
+2006-09-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBinding.cs : set X509ReferenceStyle to Thumbprint in
+         x509 ProtectionTokenParameters by default.
+
+2006-09-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : fixed IOutputChannel support as well to
+         open in prior to issue an output (send).
+
+2006-09-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : wrong message to inspect response.
+
+2006-09-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : Binding.MessageVersion could be null, so
+         set default in such case.
+
+2006-09-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHost.cs : seems like RC1 does not automatically attach
+         ServiceMetadataBehavior.
+       * ServiceHostBase.cs : use const instead of literal.
+
+2006-09-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs, ClientBase.cs :
+         implemented IClientMessageInspector support.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs :
+         implement service certificate acquisition: it depends on the
+         KeyUsage and IsInitiator whether it uses client certificate or
+         service certificate. (And service certificate acquisition is a bit
+         complex.)
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory_1.cs : now it is this type that creates the inner
+         proxy type (CreateRuntime() and its usage are moved from
+         ClientBase). CreateChannel() should create an actual proxy
+         instance instead of just an IChannel.
+       * ClientBase.cs : inner_proxy and inner_channel are thus filled
+         just using ChannelFactory.CreateChannel() now.
+       * ClientProxyGenerator.cs : it now generates the proxy type from
+         ChannelFactory, not ClientBase<T>.
+       * ClientRuntimeChannel.cs : now that Binding.MessageVersion could
+         return null, it must fill default version by itself.
+         Updated .ctor() arguments and fields.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory.cs : implement EnsureOpened().
+       * ChannelFactory_1.cs : open the factory before creating a channel.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * RsaEndpointIdentity.cs, WSFederationHttpSecurity.cs,
+         WSFederationHttpBinding.cs, ServiceAuthorizationManager.cs :
+         more new files.
+       * WSFederationBinding.cs : removed obsolete file.
+       * EndpointIdentity.cs : implemented some.
+       * FederatedMessageSecurityOverHttp.cs : some default value settings.
+       * Dummy.cs : removed some new files, and added S.SM.PR classes.
+
+2006-09-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TransactionProtocol.cs : changing default tx will anyways cause 
+         problem, so just change it to default borking OleTx.
+
+2006-08-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory.cs : there's a big todo on this class.
+       * ClientBase.cs : minor MonoTODO comment.
+       * Constants.cs : added ws-secureconv namespace.
+       * ClientRuntimeChannel.cs : implemented several members.
+
+2006-08-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : apply ServiceBehavior.AddBindingParameters().
+         Renamed Initialize() -> OnOpen().
+       * Dummy.cs : removed RsaSecurityTokenParameters.
+
+2006-08-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHost.cs : (CreateDescription) add ServiceDebugBehavior to 
+         ServiceDescription. Note that it does not mean it is "enabled".
+
+2006-08-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : use endpoint behaviors to collect binding
+         parameters which is used in BuildChannelFactory().
+
+2006-08-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AllEnums.cs : fixed UserNamePasswordValidationMode values.
+       * Dummy.cs : removed security classes that are added this time.
+
+2006-08-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs :
+         implemented AnonymousSslnego provider creation.
+         Use SecurityTokenVersion for CreateSecurityTokenSerializer().
+       * WSHttpBinding.cs : when NegotiateServiceCredential is false,
+         it does not use AnonymousSslnego but uses X509. Similarly, when 
+         ClientCredentialType is Windows not SSPI but Kerberos.
+       * Dummy.cs : removed KeberosSecurityTokenParameters.
+
+2006-08-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs :
+         more CreateSecureConversationProvider() implementation.
+
+2006-08-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs :
+         ongoing SecureConversation requirement support.
+       * Constants.cs : imported some constants from ../../tools/sts.
+       * WSHttpBinding.cs : tiny comments.
+
+2006-08-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : removed SecurityContextSecurityToken.
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs :
+         improved CreateSecurityTokenProvider(). Split into some methods.
+         (Next thing to do is to implement secure conversation stuff here.)
+       * AllEnums.cs : added X509KeyIdentifierClauseType.
+       * WSHttpBinding.cs : default message security version is
+         WSS11+BasicProfile. Set ProtectionTokenParameters, either of
+         the returned element itself or of the secure conversation element.
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : removed MessagePartSpecification and
+         SecureConversationSecurityTokenParameters.
+       * WSHttpBinding.cs : turned out that it basically create 
+         SecureConversationSecurityTokenParameters for 
+         ProtectionTokenParameters of the security binding element.
+         (still needs more love here.)
+
+2006-08-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageContractAttribute.cs : added IsWrapped, WrapperName and 
+         WrapperNamespace.
+       * MessageSecurityVersion.cs : default is WSS11 w/o Basic Profile.
+
+2006-08-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBinding.cs : if Message security does not say
+         EstablishSecurityContext, call SetKeyDerivation(false).
+
+2006-08-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added WSS token URIs. modified X509v3 constant.
+       * Dummy.cs : added SspiSecurityToken.
+
+2006-08-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OperationContractAttribute.cs : added missing [Has]ProtectionLevel.
+       * ClientCredentialsSecurityTokenManager.cs : implementes some members
+         for client side security token creation.
+       * WSHttpBinding.cs : in CreateMessageSecurity(), create proper
+         security token parameters depending on its credential type. Also
+         for non-message security, return null.
+       * WSHttpBindingBase.cs : consider the case that
+         CreateMessageSecurity() returns null. Create proper messaging
+         encoding binding element that considers EnvelopeVersion,
+         MessageEncoding and TextEncoding.
+       * ClientRuntimeChannel.cs : channel factory must be opened before
+         creating a channel. Some more input check.
+
+2006-08-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs :
+         Credentials -> ClientCredentials.
+
+2006-08-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManager.cs : new file.
+       * Dummy.cs : removed above.
+       * ChannelFactory.cs : return ClientCredentials from endpoint's
+         behavior.
+       * ClientBase.cs : removed extra field.
+
+2006-08-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs, ServiceHost.cs : minor API fixes.
+
+2006-08-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory.cs : do nothing on OnClose().
+       * ChannelFactory_1.cs : fixed some method signatures.
+       * X509CertificateEndpointIdentity : implemented public members.
+       * EndpointIdentity.cs : implemented CreateX509CertificateIdentity().
+
+2006-08-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : more removal.
+
+2006-08-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : remove added type.
+
+2006-08-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OperationContext.cs, FederatedMessageSecurityOverHttp.cs :
+         cosmetic API fixes.
+
+2006-08-01  Ankit Jain  <jankit@novell.com>
+
+       * EndpointAddress.cs (ReadFrom): Move the code ..
+       (ReadFromInternal): .. to here. Use this in all ReadFrom overloads.
+       * EndpointAddress10.cs (ReadXml):
+       (WriteXml): Use EndpointAddress's methods.
+       * EndpointAddressAugust2004.cs (ReadXml):
+       (WriteXml): Use EndpointAddress's methods.
+
+2006-08-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added XmlDsig.
+
+2006-08-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added some WS-Security constants.
+
+2006-07-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : removed some security classes that are newly added.
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * X509CertificateEndpointIdentity.cs : new file.
+       * Dummy.cs : removed above.
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : added some new X509 types.
+       * Identity.cs, EndpointIdentity.cs : renamed former to latter.
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AllEnums.cs : added SecurityTokenInclusionMode.
+       * Dummy.cs :
+         removed SecurityTokenParameters and IssuedSecurityTokenParameters.
+       * BasicHttpBinding.cs : removed some todos.
+
+2006-07-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BasicHttpSecurity.cs : implemented.
+       * BasicHttpMessageSecurity.cs : API fix. Fill default security suite.
+       * BasicHttpBinding.cs : implemented Security. When Message security
+         is enabled, create a security binding element.
+       * HttpTransportSecurity.cs : Realm is "" by default.
+
+2006-07-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : added MSSerialization.
+
+2006-07-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Constants.cs : new file.
+
+2006-07-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs : WriteTo() implementation. Only Uri is supported
+         for now.
+
+2006-07-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs : implemented ReadFrom(). Added missing MonoTODO.
+       * EndpointAddressBuilder.cs : implemented some members.
+
+2006-07-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSDualHttpBinding.cs : it is not ISecurityCapabilities anymore.
+
+2006-07-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBinding.cs :
+         Implemented Security property.
+         CreateBindingElements() not omits SecurityBindingElement when
+         message security is not enabled.
+         GetTransport() returns HttpsTransportBindingElement when transport
+         security is enabled.
+       * WSHttpBindingBase.cs : get_Scheme() returns https when appropriate.
+       * HttpTransportSecurity.cs, MessageSecurityOverHttp.cs,
+         WSHttpSecurity.cs, NonDualMessageSecurityOverHttp.cs : new files.
+       * Dummy.cs : removed above.
+
+2006-07-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EnvelopeVersion.cs, ChannelFactory_1.cs, MessageSecurityVersion.cs,
+         Identity.cs, ChannelFactory.cs, InstanceContext.cs :
+         more June CTP changes.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DeliveryRequirementsAttribute.cs,
+         ServiceHostBase.cs : IContractBehavior API updates.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientProxyGenerator.cs : assembly.Save() does not seem to be
+         required anymore. Maybe it was a runtime bug.
+
+2006-07-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : fix warning.
+
+2006-07-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : don't create ClientOperation while we
+         already created corresponding ones.
+       * ServiceHostBase.cs : When input parameter is only Message, set
+         SerializeRequest as false. When output parameter is Message, set
+         DeserializeReply as false.
+       * ClientBase.cs : When input parameter is only Message, set
+         DeserializeRequest as false. When output parameter is Message, set
+         SerializeReply as false.
+         Both of those changes are to remove hack in DefaultOperationFormatter
+
+2006-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : IMetadataExchange is the only case that
+         requires non fulltype name in AddServiceEndpoint(), so handle it
+         as a special case.
+
+2006-07-12  Ankit Jain  <jankit@novell.com>
+
+       * EndpointAddress10.cs: New.
+
+2006-07-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientProxyGenerator.cs :
+         Generate BeginMethod and EndMethod as well. To do so, extract
+         some code block into another method.
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AllEnums.cs : fix some binary compat.
+       * Dummy.cs : some June CTP updates.
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ReliableSession.cs,
+         OptionalReliableSession.cs : new implementation files.
+       * Dummy.cs : The above are not dummy now.
+       * MessageSecurityVersion.cs : implemented public properties.
+       * WSHttpBindingBase.cs,
+         WSHTtpBinding.cs : implemented some parts so that at least .ctor()
+         and CreateBindingElements() do not raise an error.
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingBase.cs, WSHttpBinding.cs :
+         June CTP API fixes. Implemented CreateBindingElements() (it does
+         not work since some binding elements will raise an exception).
+       * Dummy.cs :
+         Removed TransactionFlowBindingElement.
+       * TransactionProtocol.cs :
+         New file.
+       * AllEnums.cs :
+         Removed TransactionProtocol which became a class, not enum.
+
+2006-07-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBase.cs, ServiceHostBase.cs : S.SM.Dispatcher dependent fix.
+
+2006-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBase.cs : InnerProxy -> Channel.
+
+2006-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BasicHttpBinding.cs : AddressingVersion is now None.
+       * MessageHeaderException.cs : new exception type.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultCommunicationTimeouts.cs : receive timeout is 10 minutes
+         in June CTP.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs : oops, misreplaced Identity.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Identity.cs, EndpointAddress.cs, Dummy.cs,
+         EndpointAddressBuilder.cs : Identity -> EndpointIdentity.
+       * MessageBodyAttribute.cs :
+         MessageBodyAttribute -> MessageBodyMemberAttribute.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * NodeQuotaExceededException.cs : removed unused code.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs, ServiceHostBase.cs, ChannelFactory.cs :
+         CommunicationObject abstract changes brought this madness.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OperationContext.cs : IRequestContext -> RequestContext.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IContextChannel.cs, PeerNode.cs,
+         IDuplexClientChannel.cs, BasicHttpBinding.cs, ChannelFactory_1.cs,
+         ServiceContractAttribute.cs, ICommunicationObject.cs,
+         IClientChannel.cs, DuplexChannelFactory.cs, IServiceChannel.cs,
+         AllEnums.cs, ChannelFactory.cs, BasicHttpSecurity.cs:
+         several June CTP interface changes.
+       * ClientRuntimeChannel.cs : In reflection to June CTP updates, it
+         needed several internal changes. Channels are created at first
+         request time as there is no way to predict whether request and/or
+         output is used.
+
+2006-07-03  Ankit Jain  <jankit@novell.com>
+
+       * TransferMode.cs: Move from System.ServiceModel.Channels to here.
+       * AllEnums.cs: Move QueueTransferProtocol from
+       System.ServiceModel.Channels to System.ServiceModel .
+       Remove PoisonMessageHandling.
+
+2006-07-03  Ankit Jain  <jankit@novell.com>
+
+       * AllEnums.cs: Update to June CTP changes.
+
+2006-06-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AllEnums.cs : added ReceiveErrorHandling.
+
+2006-06-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBase.cs : pass bindingConfiguration from configuration element
+         to create Binding. It's not considered though.
+
+2006-06-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBase.cs : quick workaround for some config class weirdness.
+
+2006-06-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBase.cs : some configuration support implementation.
+
+2006-06-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientProxyGenerator.cs : oops, parameter 0 is the instance itself.
+
+2006-06-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientProxyGenerator.cs : new file to generate InnerProxy type.
+       * ClientRuntimeChannel.cs : implemented some members. New Process()
+         method handles actual request/response binding.
+       * ClientBase.cs,
+         ChannelFactory_1.cs : moved CreateRuntime() from
+         ChannelFactory<T> to ClientBase<T>. ClientBase<T> is abstract in
+         WCF beta2. Reordered some internal field creation.
+         Renamed some "channel" to "contract". Those MS misnamings s__k.
+
+2006-06-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory_1.cs : only interface can be the Type argument in
+         ChannelFactory<T>#.ctor(Type).
+
+2006-06-16  Ankit Jain  <jankit@novell.com>
+
+       * AllEnumcs.cs (MetadataResolverMode.WsTransferGet): Update to case fix
+       in beta2.
+
+2006-06-12  Ankit Jain  <jankit@novell.com>
+
+       * EndpointAddressAugust2004.cs (.ctor): Change from private to internal.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultException.cs, FaultException_1.cs : in beta2 default action
+         here is null.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingBase.cs, Identity.cs, AllEnums.cs
+         WSDualHttpBinding.cs : updated API fixes.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EnvelopeVersion.cs : moved back from S.SM.Channels.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       moved to proper namespace dirs:
+       * ServiceCredentials.cs, ClientCredentials.cs,
+         ServiceMetadataBehavior.cs :
+         - to S.SM.Description.
+       * AspNetIntegrationRequirementsAttribute.cs,
+         IServiceHostFactory.cs, ServiceHostFactory.cs :
+         - to S.SM.Activation.
+       * EndpointDispatcher.cs : - to S.SM.Dispatcher.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AllEnums.cs, Dummy.cs, ClientCredentials.cs, ServiceCredentials.cs,
+         InstanceContext.cs, EndpointDispatcher.cs, ServiceHostFactory.cs,
+         IServiceHostFactory.cs, ServiceMetadataBehavior.cs,
+         AspNetIntegrationRequirementsAttribute.cs :
+          namespace changes. Removed Obsoleted.
+       * BasicHttpBinding.cs, NetTcpBinding.cs, WSHttpBindingBase.cs :
+         IBindingManualAddressing vanished in beta2.
+
+2006-04-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientRuntimeChannel.cs : missing file.
+
+2006-04-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory.cs : CreateFactory return IChannelFactory.
+       * ServiceHostBase.cs : Fixed incorrect iterations to populate 
+         DispatchOperations.
+       * ClientBase.cs,
+         ClientRuntimeChannel.cs : I'm not sure if this is the right
+         approach, but here is an approach to implement ClientBase.
+       * ChannelFactory_1.cs : ongoing implementation for ClientBase.
+
+2006-04-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory.cs : GetContract() now rejects operation-less
+         cotnract, so added dummy operation as well in the dummy contract.
+
+2006-03-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : removed some extra security classes.
+
+2006-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ActionNotSupportedException.cs : new file.
+       * EndpointDispatcher.cs : removed comment.
+       * ServiceHostBase.cs :
+         create EndpointDispatcher in ChannelDispatcher.Attach().
+         Added GetContract() for internal use.
+
+2006-03-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory.cs ChannelFactory_1.cs :
+         removed extraneous contructors.
+       * EndpointDispatcher.cs : removed extra channel list.
+       * ServiceHost.cs : added field for contracts and use it when
+         contracts are created in AddServiceEndpoint().
+       * ServiceHostBase.cs : add opened channel dispatchers to its list.
+
+2006-03-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OperationContext.cs OperationContextScope.cs
+         ServiceMetadataBehavior.cs ServiceBehaviorAttribute.cs
+         ServiceHostFactory.cs : Feb. CTP API fixes.
+
+2006-03-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : removed some S.S.Channels classes.
+       * BasicHttpBinding.cs : message encoding could be Mtom. Also its
+         arguments (version and encoding) could be configurable.
+
+2006-03-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InstanceContext.cs : added some missing members. few implementation.
+       * BasicHttpSecurity.cs BasicHttpMessageSecurity.cs : new files.
+       * Dummy.cs : removed above.
+
+2006-03-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeader_1.cs : added IsReferenceParameter arg (and comment).
+
+2006-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : OnOpened() is overriden, not virtual.
+
+2006-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingBase.cs WSHttpBinding.cs WSFederationBinding.cs
+         NetPeerTcpBinding.cs NetTcpBinding.cs WSDualHttpBinding.cs :
+         removed OnInitialize() and OnApplyConfiguration.
+
+2006-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostBase.cs : populate type from type name as expected (still
+         not sure but this implementation would mostly make sense).
+
+2006-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostFactory.cs : new file.
+       * ServiceHostBase.cs, ServiceHost.cs : they were still missing some
+         members. Updated implementation to work in Feb. CTP way.
+
+2006-03-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory.cs : no need to call CreateDescription() in
+         InitializeEndpoint().
+       * ChannelFactory_1.cs : .ctor(Type) could invoke InitializeEndpoint()
+         as well as other .ctors.
+
+2006-03-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultException_1.cs : removed extra fields that are moved to
+         non-generic type.
+       * Faultexception.cs : Added missing members. Null arg check.
+       * FaultContractAttribute.cs : removed extra set_HasProtectionLevel.
+
+2006-03-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BasicHttpBinding.cs : implemented some members to pass the tests.
+
+2006-03-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultReason.cs FaultContractAttribute.cs FaultException.cs
+         FaultException_1.cs : MessageFault related API fixes.
+
+2006-03-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs : more API fix. Anonymous URI has changed to
+         reasonable URI which does not pretend standards.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentials.cs Identity.cs ServiceSecurityContext.cs
+         X509CertificateInitiatorServiceCredential.cs
+         X509CertificateRecipientClientCredential.cs :
+
+         Dependent fixes for System.IdentityModel reorgainzation.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * moved several files to new namespace directoties.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ActionFilter.cs ActionFilterTable.cs AddressHeader.cs
+         AddressHeaderCollection.cs AddressingVersion.cs
+         AspNetIntegrationRequirementsAttribute.cs
+         AsymmetricSecurityBindingElement.cs
+         BasicHttpBinding.cs BehaviorCollection.cs
+         BinaryMessageEncodingBindingElement.cs Binding.cs BindingElement.cs
+         BindingElementCollection.cs BindingParameterCollection.cs
+         BindingRequirementsAttribute.cs ChannelBehaviorCollection.cs
+         ChannelDescription.cs ChannelFactory.cs ChannelFactory_1.cs
+         ClientBase.cs ClientCredentials.cs CompositeDuplexBindingElement.cs
+         ConnectionOrientedTransportBindingElement.cs
+         ContractBehaviorCollection.cs ContractDescription.cs
+         CustomBinding.cs DispatchBehavior.cs DispatchOperation.cs
+         Dispatcher.cs Dummy.cs EmptyFaultException.cs EndpointAddress.cs
+         EndpointAddressBuilder.cs EndpointAddressFilter.cs
+         EndpointAddressFilterTable.cs EndpointBehaviorCollection.cs
+         EndpointFilter.cs EndpointFilterTable.cs EndpointListener.cs
+         FaultDescription.cs FaultDescriptionCollection.cs
+         FaultException.cs Filter.cs FilterInvalidBodyAccessException.cs
+         FilterNodeQuotaExceededException.cs FilterTable.cs
+         GenericWrapperChannelFactory.cs GetMetadataRequest.cs
+         GetMetadataRequestParameters.cs GetMetadataResponse.cs
+         GetRequest.cs GetResponse.cs HostedBindingBehavior.cs
+         HttpTransportBindingElement.cs HttpsTransportBindingElement.cs
+         IBindingCapabilities.cs IBindingManualAddressing.cs
+         IBindingRuntimePreferences.cs IChannel.cs IChannelBehavior.cs
+         IChannelFactory.cs IChannelInitializer.cs IChannelListener.cs
+         IChannelManager.cs IClientChannel.cs IContractBehavior.cs
+         IContractBehaviorAttribute.cs IDispatchOperationSelector.cs
+         IDuplexChannel.cs IDuplexClientChannel.cs IDuplexSession.cs
+         IDuplexSessionChannel.cs IEndpointBehavior.cs
+         IEndpointDispatcher.cs IErrorHandler.cs IFilterTable.cs
+         IInputChannel.cs IInputSession.cs IInputSessionChannel.cs
+         IInputSessionShutdown.cs IInstanceContextInitializer.cs
+         IInstanceProvider.cs IMessageHeaderInfo.cs IMessageProperty.cs
+         IMetadataExchange.cs IOperationBehavior.cs IOperationInvoker.cs
+         IOutputChannel.cs IOutputSession.cs IOutputSessionChannel.cs
+         IProxyFormatter.cs IProxyMessageInspector.cs
+         IProxyOperationSelector.cs IReplyChannel.cs
+         IReplySessionChannel.cs IRequestChannel.cs IRequestContext.cs
+         IRequestSessionChannel.cs IServiceBehavior.cs ISession.cs
+         ISessionChannel.cs IStubFormatter.cs IStubMessageInspector.cs
+         ITransportBindingElement.cs InstanceListener.cs
+         InvalidBodyAccessException.cs IssuedTokenClientCredential.cs
+         ListenUriBehavior.cs MatchAllEndpointBehavior.cs MatchAllFilter.cs
+         MatchNoneFilter.cs Message.cs MessageBodyDescription.cs
+         MessageBuffer.cs MessageContractAttribute.cs
+         MessageDescription.cs MessageDescriptionCollection.cs
+         MessageEncodingBindingElement.cs MessageFault.cs
+         MessageFaultBodyWriter.cs MessageHeader.cs
+         MessageHeaderDescription.cs MessageHeaderDescriptionCollection.cs
+         MessageHeaders.cs MessageImpl.cs MessageInterceptorEventArgs.cs
+         MessagePartDescription.cs MessagePartDescriptionCollection.cs
+         MessageProperties.cs MessagePropertyDescription.cs
+         MessagePropertyDescriptionCollection.cs MessageVersion.cs
+         MetadataDialect.cs MetadataReference.cs MetadataSection.cs
+         MtomMessageEncodingBindingElement.cs
+         MultipleFilterMatchesException.cs MustUnderstandBehavior.cs
+         NamedPipetransportBindingElement.cs
+         NavigatorInvalidBodyAccessException.cs NetPeerTcpBinding.cs
+         NetTcpBinding.cs OperationBehaviorAttribute.cs
+         OperationBehaviorCollection.cs OperationContext.cs
+         OperationDescription.cs OperationDescriptionCollection.cs
+         PeerResolverBindingElement.cs PeerSecurityBehavior.cs
+         PeerTransportBindingElement.cs PnrpPeerResolverBindingElement.cs
+         ProxyBehavior.cs ProxyOperation.cs ReflectedContractCollection.cs
+         SecurityBindingElement.cs ServiceAuthorizationBehavior.cs
+         ServiceBehaviorAttribute.cs ServiceBehaviorCollection.cs
+         ServiceCredentials.cs ServiceDescription.cs ServiceEndpoint.cs
+         ServiceEndpointCollection.cs ServiceHost.cs
+         ServiceMetadataBehavior.cs ServiceSecurityAuditBehavior.cs
+         SymmetricSecurityBindingElement.cs TcpTransportBindingElement.cs
+         TextMessageEncodingBindingElement.cs TransportBindingElement.cs
+         TypedMessageConverter.cs UnderstoodHeaders.cs
+         UnknownFaultException.cs UnknownMessageReceivedEventArgs.cs
+         UserNamePasswordClientCredential.cs
+         UserNamePasswordServiceCredential.cs ViaUriBehavior.cs
+         WSDualHttpBinding.cs WSFederationBinding.cs WSFederationSecurity.cs
+         WSHttpBinding.cs WSHttpBindingBase.cs
+         X509CertificateInitiatorClientCredential.cs
+         X509CertificateInitiatorServiceCredential.cs
+         X509CertificateRecipientClientCredential.cs
+         X509CertificateRecipientServiceCredential.cs
+         XPathFilter.cs XPathFilterTable.cs XPathMessageContext.cs
+         XmlFormatterOperationBehavior.cs
+         XmlSerializerOperationBehavior.cs :
+         Feb. CTP API chapter 1 - changes are so massive :-(
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dispatcher.cs : filter is defaulted to MatchNoneFilter.
+       * EndpointListener.cs : null address in .ctor() is rejected.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElement.cs : no need to provide
+         IDefaultCommunicationTimeout here. Binding implements it.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchOperation.cs DispatchBehavior.cs
+         ProxyOperation.cs ProxyBehavior.cs : initialize Operations property
+         with a collection. We need concrete SynchronizedKeyedCollection
+         implemantation classes for each.
+       * ServiceDescription.cs : apply IOperationBehaviors stored in
+         OperationDescription.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XPathMessageContext.cs EndpointAddressBuilder.cs : new files.
+       * Dummy.cs : removed above.
+       * XPathFilterTable.cs FilterTable.cs ClientBase.cs :
+         added missing bits.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FederatedMessageSecurityOverHttp.cs WSFederationSecurity.cs
+         WSFederationBinding.cs : new files.
+       * Dummy.cs : removed above.
+       * XPathFilterTable.cs : added some missing bits.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ProxyBehavior.cs : another .ctor() that can be used at client side.
+       * ChannelFactory_1.cs : call ApplyBehavior for each ChannelBehavior.
+         Call OnCreateDescription() (it can be probably used in derived
+         classes to add custom behaviors etc.)
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHost.cs :
+         Initialize() handles listener creation (so it's cleaner now).
+       * ServiceDescription.cs :
+         Implemented and updated behavior processing.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointListener.cs : removed unused code.
+       * ServiceEndpoint.cs : binding could be null in .ctor()
+       * AddressHeaderCollection.cs : implemented AddHeadersTo().
+         Null argument check in FindHeader().
+       * ServiceDescription.cs : tiny todo cleanup.
+
+2006-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageImpl.cs : implemented Headers.
+       * ActionFilter.cs : null check. uncommented Headers-dependent code.
+
+2006-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XPathFilterTable.cs MatchAllEndpointBehavior.cs
+         MustUnderstandBehavior.cs : new files.
+       * MtomMessageEncodingBindingElement.cs
+         TextMessageEncodingBindingElement.cs
+         BinaryMessageEncodingBindingElement.cs : IWsdlExporter fixes.
+       * ProxyBehavior.cs : added some of the missing properties.
+
+2006-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IBindingManualAddressing.cs, EndpointAddressFilterTable.cs
+         EndpointFilterTable.cs : new files.
+       * Dispatcher.cs
+         TextMessageEncodingBindingElement.cs
+         BinaryMessageEncodingBindingElement.cs
+         MessageEncodingBindingElement.cs : some API fixes.
+
+2006-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ReflectedContractCollection.cs : added internal Add().
+       * ServiceMetadataBehavior.cs : for now just pass ApplyBehavior().
+       * ServiceBehaviorAttribute.cs :
+         Implemented ApplyBehaviors() a bit more.
+       * ServiceHostBase.cs, ServiceHost.cs, ServiceDescription.cs :
+         Several API fixes to match Jan. CTP. Processing model around
+         Initialize and Open are fixed.
+
+2006-02-11  Ankit Jain  <jankit@novell.com>
+
+       * ServiceHost.cs (ServiceHost.AddServiceEndpoint): Build endpoint
+       address using a matching base address, if the one specified is relative.
+       * UriSchemeKeyedCollection.cs (UriSchemeKeyedCollection.ctor): Base
+       address cannot contain a query string.
+
+2006-02-11  Ankit Jain  <jankit@novell.com>
+
+       * ServiceHost.cs (ServiceHost.ConstructorInit): ServiceType must be a
+       class.
+       * UriSchemeKeyedCollection.cs (UriSchemeKeyedCollection.ctor): Insert
+       URIs into the collection, while ensuring that only one URI per Scheme is
+       allowed.
+
+2006-02-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingElement.cs : (BuildChannelListener) null argument check.
+       * EndpointListener.cs : updated to match the latest CTP. It does not
+         use CreateListener() anymore. Use "timeout".
+       * HttpTransportBindingElement.cs : Support BuildChannelListener().
+       * ServiceDescription.cs : updated InitializeServiceHost() to match
+         the latest CTP.
+       * ServiceHost.cs : thus re-enabled InitializeServiceHost() again.
+
+2006-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultReason.cs : make use of alias. The first argument for
+         SynchronizedReadOnlyCollection is a lock object, not a list.
+       * SynchronizedReadOnlyCollection.cs :
+         The argument string for ArgumentNullException is a parameter name,
+         not a message. Implementation is collected to one .ctor().
+       * MessageFault.cs : serialize details, not Reason. To write Reason
+         element, use the envelope's namespace.
+
+2006-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Message.cs : More comments. Implemented Create(version, fault).
+       * MessageImpl.cs : Fixed virtual->override.
+       * FaultReason.cs : argument check.
+       * FaultReasonText.cs : it should use full name instead of ISO 2 letter
+         name. Matches() should match if the argument culture is a "child"
+         culture (i.e. it should return true if its Parent matches).
+       * MessageFault.cs :
+         When it does not have Details then do not try to write it.
+         has_detail was not correctly used.
+         It should not write xmlns attributes for fault code namespace URI if
+         it is empty.
+
+2006-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Message.cs : implemented couple of members.
+       * MessageImpl.cs : new file that contains couple of Message 
+         implementation classes.
+       * MessageFault.cs : make use of WriteXmlnsAttribute().
+
+2006-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlReaderBodyWriter.cs
+         XmlFormatterBodyWriter.cs
+         MessageFaultBodyWriter.cs : BodyWriter implementation classes.
+       * Message.cs : implemented most of CreateMessage() as to call another
+         one, using above BodyWriter impl. classes.
+
+2006-02-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * GenericWrapperChannelFactory.cs : forgot to set the "inner" field.
+
+2006-02-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * GenericWrapperChannelFactory.cs : new file for
+         BindingElement.BuildChannelFactory<TChannel>().
+       * BindingElement.cs : use above.
+       * ChannelDescription.cs : .ctor() argument null check.
+       * ChannelFactory_1.cs : because of above, pass the generic type
+         argument.
+
+2006-02-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDescription.cs : Behaviors instance is needed.
+       * ChannelFactory_1.cs : check some null args. ChannelDescription
+         initially does not hold any type info.
+       * ChannelFactory.cs : removed some NotImplementedException for
+         further implementation.
+       * ServiceEndpoint.cs : EndpointAddress in .ctor() could be null.
+
+2006-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ConnectionOrientedTransportBindingElement.cs,
+         TcpTransportBindingElement.cs : easy .ctor() implementation.
+
+2006-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElement.cs : HttpChannelFactory() does not
+         need ChannelBuildContext anymore (... for now).
+       * MessageEncodingBindingElement.cs :
+         Simple use context.(Can)BuildBlah() for each corresponding method.
+         GetProtectionRequirements() returns null here.
+
+2006-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory_1.cs : get rid of ChannelLoader and create
+         ChannelDescription directly.
+       * MessageEncodingBindingElement.cs : implemented BuildChannelFactory()
+         (not sure if it is correct, but seems like it does nothing there.)
+
+2006-01-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceDescription.cs : removed debugging code.
+       * FilterNodeQuotaExceededException.cs
+         FilterInvalidBodyAccessException.cs
+         CommunicationObjectFaultedException.cs
+         AddressAccessDeniedException.cs EndpointNotFoundException.cs
+         OperationRequirement.cs NetTcpBinding.cs FaultException.cs
+         InvalidBodyAccessException.cs NodeQuotaExceededException.cs
+         CommunicationException.cs AddressHeaderCollection.cs
+         MetadataDocument.cs ProtocolException.cs
+         QuotaExceededException.cs NetPeerTcpBinding.cs
+         InvalidMessageContractException.cs
+         AddressAlreadyInUseException.cs PeerTransportBindingElement.cs
+         NavigatorInvalidBodyAccessException.cs
+         NavigatorNodeQuotaExceededException.cs
+         MetadataReference.cs MetadataSection.cs
+         MultipleFilterMatchesException.cs DuplexClientBase.cs
+         ChannelFactory.cs PeerSecurityBehavior.cs :
+         several API fixes found by corcompare update.
+
+2006-01-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceDescription.cs : don't Add ContractDescription twice inside
+         AddServiceEndpoint. Got sample service working.
+
+2006-01-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs BehaviorCollection.cs Message.cs
+         GetResponse.cs ServiceHostBase.cs
+         XmlSerializerOperationBehavior.cs TransportBindingElement.cs
+         TextMessageEncodingBindingElement.cs MessageHeaders.cs
+         ServiceMetadataExtension.cs HttpTransportBindingElement.cs
+         MessageHeaderDescriptionCollection.cs
+         MessageInterceptorEventArgs.cs ChannelFactory_1.cs
+         HttpsTransportBindingElement.cs ServiceDescription.cs
+         BinaryMessageEncodingBindingElement.cs MessageFault.cs
+         MessageEncodingBindingElement.cs ChannelFactory.cs
+         MessageDescriptionCollection.cs :
+         several updates to catch up Jan. CTP API.
+
+2006-01-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AddressHeader.cs : null Name and Namespace are just ignored.
+
+2006-01-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs : fixed incorrect Equals(). Set empty headers
+         for .ctor()s without AddressHeaders.
+
+2006-01-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs : never use == for Uri.
+
+2006-01-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs ClientBase.cs ServiceDescription.cs
+         ServiceHost.cs CustomBinding.cs :
+         several updates for Dec.CTP.
+
+2005-11-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory.cs, ChannelFactory_1.cs : several updates on .ctor().
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceMetadataBehavior.cs : removed DataContract stuff.
+       * ServiceDescription.cs :
+         Use Contains() to query item from collections.
+       * ContractDescription.cs :
+         Added new constructors. Session->UsesSession.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ReflectedContractCollection.cs : new file.
+       * ChannelBehaviorCollection.cs BindingParameterCollection.cs :
+         Removed vanished DataContract attributes.
+       * BehaviorCollection.cs :
+         Updated Remove()/RemoveAll() signatures to Nov. CTP.
+       * ServiceDescription.cs
+         ServiceHost.cs ServiceEndpoint.cs :
+         Changes caused by the removal of ServiceLoader and TypeLoader.
+         Those types are unified into ServiceDescription.cs.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointListener.cs, InstanceListener.cs : updated to Nov. CTP.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IListener.cs, IListenerFactory.cs : vanished in Nov. CTP.
+       * CompositeDuplexBindingElement.cs InstanceListener.cs
+         AsymmetricSecurityBindingElement.cs BindingElement.cs
+         EndpointListener.cs IChannelListener.cs Binding.cs
+         HttpTransportBindingElement.cs SymmetricSecurityBindingElement.cs
+         PnrpPeerResolverBindingElement.cs TcpTransportBindingElement.cs
+         NamedPipetransportBindingElement.cs HttpsTransportBindingElement.cs
+         ServiceDescription.cs SecurityBindingElement.cs
+         PeerTransportBindingElement.cs ServiceHost.cs
+         MessageEncodingBindingElement.cs :
+         IListener related updates to Nov. CTP.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlFormatterOperationBehavior.cs,
+         XmlSerializerOperationBehavior.cs : more updates to Nov. CTP.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AllEnums.cs : updated to Nov. CTP.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SessionFaultedEventArgs.cs, PrimitiveOperationFormatter.cs :
+         removed in Nov. CTP
+
+       * FaultDescription.cs MessageDescription.cs
+         ContractBehaviorCollection.cs XmlFormatterOperationBehavior.cs
+         Dummy.cs MessageHeaderDescription.cs
+         OperationDescriptionCollection.cs OperationDescription.cs
+         MessageHeaderDescriptionCollection.cs
+         OperationBehaviorCollection.cs ServiceAuthorizationBehavior.cs
+         MessageBodyDescription.cs ContractDescription.cs
+         FaultDescriptionCollection.cs IClientChannel.cs
+         ServiceBehaviorCollection.cs MessagePartDescription.cs ISession.cs
+         ServiceSecurityContext.cs ServiceBehaviorAttribute.cs
+         MessageDescriptionCollection.cs : some updates to Nov. CTP.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IFaultProvider.cs MessageException.cs IPersistentSession.cs
+         IFaultContext.cs MessageOperationFormatter.cs 
+         IOneWayMessageAsyncIntermediary.cs IntermediaryBinding.cs 
+         ChannelIOException.cs ChannelException.cs EndpointFilterProvider.cs 
+         IPersistentInputSession.cs IRequestReplyMessageAsyncIntermediary.cs 
+         ChannelListenException.cs IEndpointFilterProvider.cs 
+         MessageIOException.cs IRequestReplyMessageIntermediary.cs 
+         ConnectionRefusedException.cs CommunicationErrorEventArgs.cs 
+         ISessionRecovery.cs IPersistentOutputSession.cs 
+         ChannelConnectException.cs IOneWayMessageIntermediary.cs : 
+         removed in Nov. CTP.
+
+       * Dispatcher.cs, Dummy.cs, AddressAccessDeniedException.cs,
+         EndpointNotFoundException.cs, InvalidBodyAccessException.cs,
+         ProtocolException.cs, ICommunicationObject.cs,
+         InvalidMessageContractException.cs,
+         AddressAlreadyInUseException.cs, IEndpointDispatcher.cs :
+         updated to Nov. CTP.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHost.cs : internalized ServiceLoader (removed in Nov. CTP).
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CustomBinding.cs : implemented most of the members.
+       * BindingElement.cs : was seeing
+         http://savas.parastatidis.name/2005/04/08/4b0b99b1-92c6-4442-ab2e-4c4951009ef4.aspx
+         and modified channel build logic a bit.
+
+2005-11-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElement.cs : new stub.
+       * Dummy.cs : removed above.
+       * Filter.cs : data contracts.
+       * EndpointListener.cs : (CreateListener) enabled commented code with
+         explicit casts.
+       * BehaviorCollection.cs : added missing members.
+
+2005-11-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TextMessageEncodingBindingElement.cs,
+         ChannelBehaviorCollection.cs,
+         BinaryMessageEncodingBindingElement.cs :
+         Implemented CreateMessageEncoderFactory().
+       * EndpointListener.cs : CreateListener() does not compile until
+         #76625 got fixed.
+
+2005-11-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InstanceContext.cs : it cannot override (now that) non-virtual
+         OnClose().
+
+2005-11-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PeerResolverBindingElement.cs : new file, which should be here
+         (MS puts it under sys.sm.design).
+       * PnrpPeerResolverBindingElement.cs,
+         ChannelBehaviorCollection.cs : new file.
+       * Dummy.cs : removed above.
+
+       A set of minor fixes:
+       * ConnectionOrientedTransportBindingElement.cs : internal copy .ctor().
+       * CustomBinding.cs : non-virtual Initialize().
+       * ViaUriBehavior.cs : implemented.
+       * ServiceHost.cs : some AddEndpoint() are virtual.
+       * PeerNodeAddress.cs,
+         ActionFilter.cs : [DataContract].
+       * EmptyFaultDescription.cs, UnknownFaultException.cs : sealed.
+       * FaultDescriptionCollection.cs,
+         ServiceBehaviorCollection.cs,
+         ContractBehaviorCollection.cs,
+         OperationBehaviorCollection.cs,
+         : [KnownType]. Hide public .ctor() for some.
+       * WSDualHttpBinding.cs : missing set_ClientBaseAddress().
+       * FaultContractAttribute.cs : extraneous set_DetailType().
+       * BindingElementCollection.cs : removed extraneous Contains<T>().
+       * AspNetIntegrationRequirementsAttribute.cs : fixed AttributeUsage.
+
+2005-11-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UserNamePasswordServiceCredential.cs,
+         X509CertificateInitiatorClientCredential.cs,
+         UserNamePasswordClientCredential.cs,
+         X509CertificateInitiatorServiceCredential.cs,
+         X509CertificateRecipientClientCredential.cs,
+         X509CertificateRecipientServiceCredential.cs : new files.
+       * Dummy.cs : removed above.
+       * ServiceCredentials.cs, ClientCredentials.cs :
+         use them in those credential aggregators.
+
+2005-11-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TypedMessageConverter.cs, PeerResolverImpl.cs, PeerResolver.cs,
+         PeerNodeAddress.cs, HttpDigestClientCredential.cs,
+         ExtensionCollection.cs, IssuedTokenClientCredential.cs : new files.
+       * Dummy.cs : removed above.
+
+       * Binding.cs, BasicHttpBinding.cs, NetTcpBinding.cs, WSHttpBinding.cs,
+         WSDualHttpBinding.cs, IntermediaryBinding.cs, CustomBinding.cs :
+         .ctor(string).
+       * MessageEncodingBindingElement.cs : init XmlDictionaryReaderQuotas.
+       * TcpTransportBindingElement.cs,
+         PeerTransportBindingElement.cs : scheme.
+       * NetPeerTcpBinding.cs : some implementation.
+       * ClientCredentials.cs : Implemented some properties. It seems like
+         an aggregated security info.
+       * AsymmetricSecurityBindingElement.cs,
+         SymmetricSecurityBindingElement.cs : ToString().
+       * HttpTransportBindingElement.cs :
+         Removed extraneous BuildChannelFactory().
+       * OperationDescriptionCollection.cs : attribute fix.
+       * OperationContext.cs : Extensions is not that simple.
+       * CompositeDuplexBindingElement.cs : set_ClientBaseAddress().
+
+2005-11-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElement.cs,
+         LocalServiceSecuritySettings.cs,
+         SymmetricSecurityBindingElement.cs,
+         ServiceCredentials.cs, LocalClientSecuritySettings.cs : new files.
+       * Dummy.cs : removed above.
+       * SecurityBindingElement.cs : added internal .ctor().
+       * ServiceBehaviorAttribute.cs, ServiceContractAttribute.cs,
+         ServiceAuthorizationBehavior.cs : tiny API fixes.
+
+2005-11-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceSecurityContext.cs, ServiceBehaviorAttribute.cs : new files.
+       * Dummy.cs : removed above.
+       * SecurityBindingElement.cs,
+         ServiceAuthorizationBehavior.cs : signature fix.
+
+2005-10-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElement.cs,
+         BodyWriter.cs : new files.
+       * Dummy.cs : removed above.
+       * ServiceSecurityAuditBehaviot.cs : implemented.
+
+2005-10-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InstanceContext.cs, ChannelFactory_1.cs, ServiceHostBase.cs,
+         EndpointListener.cs : now timeouts are protected internal.
+       * HttpTransportBindingElement.cs : use HttpListenerFactory for
+         BuildListenerFactory().
+
+2005-10-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FilterNodeQuotaExceededException.cs,
+         NodeQuotaExceededException.cs,
+         NavigatorNodeQuotaExceededException.cs : removed internal .ctor()
+         since it will just result in messageless exception.
+
+2005-10-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dispatcher.cs :
+         Attach() adds the listener to ServiceHostBase.EndpointListeners.
+         Same for Detach(). Attach() sets supported channels (maybe the
+         actual player is in another place though).
+         Use ReadOnlyCollection<Type> for SupportedChannels.
+       * BindingElementCollection.cs : InsertItem() and SetItem() caused
+         infinite loop. Use Items.
+       * EndpointListener.cs : kinda implemented CreateListener(). It's still
+         not working due to runtime bug (not sure if I can create repro).
+       * Binding.cs : Name and Namespaces have their default values.
+       * ServiceDescription.cs : ServiceHostBase.EndpointListeners.Add() is
+         now done in Dispatcher.Attach().
+
+2005-10-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddress.cs : == should check null.
+       * BindingRequirementsAttribute.cs : new file.
+       * Dummy.cs : removed above.
+       * EndpointBehaviorCollection.cs, EndpointAddress.cs,
+         EndpointListener.cs, ServiceEndpoint.cs : (.ctor) null arg check.
+
+2005-10-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dispatcher.cs : implemented some members.
+       * EndpointListenerCollection.cs : now it exposes Items as "internal".
+       * EndpointFilterProvider.cs : InitialActions was missing.
+
+2005-10-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessagePropertyDescriptionCollection.cs,
+         MessageHeaderDescriptionCollection.cs,
+         MessagePartDescriptionCollection.cs,
+         BehaviorCollection.cs : Fixed misunderstood GetKeyForItem().
+       * EndpointListener.cs : kinda asynced.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BinaryMessageEncodingBindingElement.cs,
+         MtomMessageEncodingBindingElement.cs,
+         TextMessageEncodingBindingElement.cs,
+         MessageEncodingBindingElement.cs : implemented some members. Now
+         this base class takes MessageVersion in its .ctor().
+       * AddressingVersion.cs : Use Equals(). operator == does not work.
+       * ServiceDescription.cs : Open created EndpointListener at 
+         InitializeServiceHost() (I'm not 100% sure about it).
+       * EndpointListener.cs : implemented some members.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Binding.cs : implemented .ctor(name, ns).
+       * CustomBinding.cs : fixed .ctor() process.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescription.cs : added duplicate contract check.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHost.cs, ServiceHostBase.cs : actually OnInitialize() should
+         be used to trigger loader.Description.InitializeServiceHost().
+       * ContractDescription.cs : search ServiceContractAttribute through 
+         interfaces as well.
+       * SynchronizedCollection.cs : use (consistent) InsertItem() in Add().
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHost.cs : hook Open event.
+       * TransportBindingElement.cs,
+         HttpTransportBindingElement.cs : fixed default values.
+       * BasicHttpBinding.cs : fixed default values. implemented 
+         CreateBindingElements().
+       * BindingElementCollection.cs : AddRange() was not working.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Binding.cs : set timeouts inside .ctor().
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingElement.cs, Binding.cs, IChannelManager.cs,
+         ChannelFactory_1.cs, ChannelFactory.cs :
+         several API fixes detected by improved corcompare.
+
+2005-10-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Message.cs : CreateReplyMessage() are not static.
+
+2005-10-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingElement.cs, IListener.cs, IChannelListener.cs, Binding.cs :
+         added missing generic class constraints.
+
+2005-10-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IListenerFactory.cs : class constraints were missing for generic args.
+
+2005-10-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescription.cs : (GetContract) by default http://tempuri.org/
+         is used for Namespace.
+
+2005-10-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceAuthorizationBehavior.cs : PrincipalPermissionMode default
+         value is .UseWindowsGroups (funky).
+
+2005-10-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OperationRequirement.cs : new file.
+       * Dummy.cs : removed above.
+       * ServiceHostBase.cs : implemented EndpointListeners.
+       * ServiceDescription.cs : implemented InitializeServiceHost(). It is
+         still not incorrect.
+
+2005-10-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CompositeDuplexBindingElement.cs, WSDualHttpBinding.cs :
+         tiny API fixes.
+
+2005-10-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageVersion.cs : ditto.
+
+2005-10-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultCode.cs : fixed infinite loop.
+
+2005-10-23  Duncan Mak  <duncan@novell.com>
+
+       * MessageHeaders.cs (WriteHeader, WriteHeaderContents):
+       (WriteStartHeader): Implemented.
+       (Action, FaultTo, From, MessageId, RelatesTo, ReplyTo, To): Added
+       fields for these properties. I'm guessing that Message sets these
+       in the Message.Headers property.
+
+2005-10-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IExtensibleObject.cs, IExtension.cs, IExtensionCollection.cs :
+         Now that #76363 got fixed, we can fix interface signatures.
+       * ServiceMetadataExtension.cs : new file.
+       * Dummy.cs : removed above.
+
+2005-10-22  Duncan Mak  <duncan@novell.com>
+
+       * AddressAccessDeniedException.cs:
+       * AddressAlreadyInUseException.cs:
+       * FilterInvalidBodyAccessException.cs:
+       * InvalidBodyAccessException.cs:
+       * MessageException.cs:
+       * MessageIOException.cs:
+       * NavigatorInvalidBodyAccessException.cs:
+       * ProtocolException.cs:
+       * QuotaExceededException.cs: Fixed various signature bugs.
+
+       * EndpointNotFoundException.cs:
+       * InvalidMessageContractException.cs: Missed these two in the last
+       commit.
+
+       * EmptyFaultException.cs: 
+       * FaultException.cs:
+       * UnknownFaultException.cs: Implemented these classes except for
+       the 'GetObjectData'. Run TestGetObjectData to see how it comes out
+       with XmlFormatter. We need to implement the serialization of
+       FaultCode and FaultDetail (as FaultCodeData and FaultCodeReason).
+
+       All Exceptions are now implemented.
+       
+2005-10-22  Duncan Mak  <duncan@novell.com>
+
+       * AddressAccessDeniedException.cs:
+       * AddressAlreadyInUseException.cs:
+       * ChannelConnectException.cs:
+       * ChannelException.cs:
+       * ChannelIOException.cs:
+       * ChannelListenException.cs:
+       * CommunicationException.cs:
+       * CommunicationObjectFaultedException.cs:
+       * ConnectionRefusedException.cs:
+       * FilterInvalidBodyAccessException.cs:
+       * FilterNodeQuotaExceededException.cs:
+       * InvalidBodyAccessException.cs:
+       * MessageException.cs:
+       * MessageIOException.cs:
+       * MultipleFilterMatchesException.cs:
+       * NavigatorInvalidBodyAccessException.cs:
+       * NavigatorNodeQuotaExceededException.cs:
+       * NodeQuotaExceededException.cs:
+       * ProtocolException.cs:
+       * QuotaExceededException.cs: Added all missing Exceptions except
+       for those in the family of FaultException.
+
+       * FaultCode.cs: New implementation. I wrote some test cases for
+       this class, and this fixes some of the things in the existing implementation.
+
+2005-10-21  Duncan Mak  <duncan@novell.com>
+
+       * FilterTable.cs: Implemented, but for the Match* methods, I need
+       to look into how priority works.
+
+2005-10-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultCode.cs:
+       * FaultReason.cs:
+       * System.ServiceModel/MessageFault.cs:
+       * System.ServiceModel/FaultReasonText.cs: new files for MessageFault implementation.
+       * Dummy.cs : removed above.
+       * Message.cs : some overload resolution.
+       * MessageHeader.cs : tiny returntype fix.
+
+2005-10-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InstanceListenerCollection.cs : rough impl.
+       * InstanceContext.cs : sealed.
+
+2005-10-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Message.cs : filled all missing members.
+       * HttpTransportBindingElement.cs:
+       * TcpTransportBindingElement.cs:
+       * NamedPipetransportBindingElement.cs:
+       * PeerTransportBindingElement.cs:
+       * MessageEncodingBindingElement.cs : Now that bug #76382 is gone,
+         we can define BuildChannelFactory().
+       * IExtensionCollection.cs : tiny generic parameter name fix.
+
+2005-10-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DefaultCommunicationTimeouts.cs : new internal class.
+       * ChannelFactory_1.cs, ServiceHostBase.cs : a bit of implementations.
+       * OperationBehaviorAttribute.cs : implemented IOperationBehavior.
+       * OperationContext.cs, InstanceContext.cs : a bit of implementations.
+
+2005-10-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointListenerReadOnlyCollection.cs : new file.
+       * Dummy.cs : removed above.
+       * EndpointListenerCollection.cs : correct inheritance.
+       * ChannelFactory.cs : tiny argname fix
+       * ChannelFactory_1.cs : implemented some .ctor()s.
+       * ServiceAuthorizationBehavior.cs : implemented. This shows how
+         IServiceBehavior works (quite simple).
+
+2005-10-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dispatcher.cs : connect dispatcher and dispatchbehavior here.
+       * EndpointBehaviorCollection.cs : fix base class.
+
+2005-10-14  Duncan Mak  <duncan@novell.com>
+
+       * MessageHeaders.cs: I started implementing this awhile ago, but
+       it's been sitting on my machine doing nothing for a while now. So
+       I finished stubbing it and I'm committing it. 
+
+       Remaining work:
+       Understand WS-Addressing and figure out how to handle
+       RelatesTo/ReplyTo, and what it means to that headers are
+       understood.
+
+       * UnderstoodHeaders.cs: Implemented.
+
+2005-10-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressFilter.cs : new file.
+       * Dummy.cs : removed above.
+       * EndpointListener.cs, DispatchBehavior.cs, ProxyBehavior.cs :
+         modified some impl. code to match DispatchBehavior dependency graph.
+
+2005-10-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointFilterProvider.cs, EndpointFilter.cs : new files.
+       * Dummy.cs : removed above.
+       * EndpointListener.cs : implemented some.
+       * InstanceListener.cs, XPathFilter.cs : signature fixes.
+       * MessageOperationFormatter.cs : ditto.
+
+2005-10-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescription.cs : message contract support implementation
+         in GetContract() implementation.
+
+2005-10-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescription.cs : more GetContract() implementation.
+
+2005-10-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultDescription.cs, MessageDescription.cs, FaultContractAttribute.cs
+         OperationContractAttribute.cs, OperationDescription.cs,
+         ContractDescription.cs :
+         implemented some part of ContractDescription.GetContract().
+       * ServiceHost.cs : improved AddEndpoint() overload solution.
+
+2005-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentials.cs : new (and last) public IChannelBehavior file.
+       * Dummy.cs : removed above.
+       * UriSchemeKeyedCollection.cs : removed incorrect code (almost all).
+       * ServiceHostBase.cs, ServiceHost.cs, OperationDescription.cs, 
+         ContractDescription.cs : implemented some.
+
+2005-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OperationBehaviorAttribute.cs : new file.
+       * Dummy.cs : removed above.
+       * ServiceContractAttribute.cs, ActionFilterTable.cs : attribute fix
+       * XmlSerializerOperationBehaviro.cs : tiny fix.
+
+2005-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CompositeDuplexBindingElement.cs, SynchronizedCollection.cs
+         InstanceListenerCollection.cs : added more files.
+       * Dummy.cs : removed above.
+       * SynchronizedKeyedCollection.cs : roughly implemented.
+       * SynchronizedReadOnlyCollection.cs : tiny attribute fix.
+
+2005-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultDescription.cs, ContractBehaviorCollection.cs,
+         FaultContractAttribute.cs, MessageOperationFormatter.cs,
+         BindingParameterCollection.cs, OperationBehaviorCollection.cs,
+         FaultDescriptionCollection.cs, PrimitiveOperationFormatter.cs,
+         ServiceBehaviorCollection.cs, DuplexClientBase.cs : new files.
+       * Dummy.cs : removed above.
+       * CommunicationErrorEventArgs.cs, HostedBindingBehavior.cs,
+         ProxyBehavior.cs, MetadataDialect.cs : tiny fixes.
+
+2005-10-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MtomMessageEncodingBindingElement.cs :
+         one more missing message encoding binding element.
+       * MessageBodyArrayAttribute.cs, MessageDescription.cs
+         MessagePropertyDescriptionCollection.cs,
+         MessageContractMemberAttribute.cs,
+         MessageHeaderDescription.cs, MessagePropertyAttribute.cs,
+         MessageParameterAttribute.cs, MessageHeaderDescriptionCollection.cs,
+         MessagePartDescriptionCollection.cs, MessageBodyDescription.cs,
+         MessageHeaderAttribute.cs, MetadataDialect.cs,
+         MessagePartDescription.cs, MessageHeaderArrayAttribute.cs
+         MessagePropertyDescription.cs, MessageDescriptionCollection.cs :
+         new files for message serialization stuff.
+       * Dummy.cs : removed all above.
+       * ChannelDescription.cs, MessageBodyAttribute.cs,
+         MessageContractAttribute.cs : attribute fixes.
+
+2005-10-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dispatcher.cs, DispatchOperation.cs : new files.
+       * Dummy.cs : removed above.
+       * GetMetadataRequestParameters.cs : serialization attributes fix.
+       * HostedBindingBehavior.cs : hacky impl.
+       * InstanceContext.cs : added missing OnBlah() methods.
+
+2005-10-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AspNetIntegrationRequirementsAttribute.cs, MessageProperties.cs,
+         TextMessageEncodingBindingElement.cs, ProxyOperation.cs,
+         BinaryMessageEncodingBindingElement.cs,
+         MessageEncodingBindingElement.cs : new files.
+       * Dummy.cs : removed above.
+       * DispatchBehavior.cs : stubbed.
+       * GetMetadataRequestParameters.cs : tiny API fix.
+
+2005-10-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ConnectionOrientedTransportBindingElement.cs,
+         TcpTransportBindingElement.cs, NamedPipetransportBindingElement.cs,
+         PeerTransportBindingElement.cs :
+         Now all transport but MSMQ crap are added.
+       * Dummy.cs : removed above.
+
+2005-10-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BehaviorCollection.cs, ChannelDescription.cs,
+         SynchronizedKeyedCollection.cs : new files.
+       * Dummy.cs : removed above.
+       * BindingElementCollection.cs : warning fix.
+       * ProxyBehavior.cs : API fixes.
+
+2005-10-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TransportBindingElement.cs, HttpTransportBindingElement.cs :
+         new channel files.
+       * Dummy.cs : removed above.
+       * MessageBodyAttribute.cs : default order is -1.
+       * GetMetadataRequest.cs : added [MessageBody]
+       * MessageVersion.cs : fixed name.
+       * ChannelFactory_1.cs, ChannelFactory.cs : some channel factory impl.
+
+2005-10-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingElement.cs : new file.
+       * Dummy.cs : removed above.
+       * Binding.cs, WSDualHttpBinding.cs, WSHttpBinding.cs,
+          ChannelFactory.cs, CustomBinding.cs, ViaUriBehavior.cs :
+          implemented a bit.
+
+2005-10-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBinding.cs : new file.
+       * Dummy.cs : removed above.
+       * WSHttpBindingBase.cs :implemented some.
+
+2005-10-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IReplyChannel.cs, IRequestContext.cs, IRequestChannel.cs:
+         moved from ../System.ServiceModel.Channels.
+       * Dummy.cs : reflected above changes.
+       * BasicHttpBinding.cs : added some impl. code.
+       * ChannelFactory_1.cs: added missing OnInitialize().
+
+2005-10-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AllEnumcs.cs : all enums in one file.
+       * Dummy.cs : removed all enums.
+       * CommunicationState.cs, OperationFormatUse.cs,
+         OperationFormatStyle.cs : thus removed.
+
+2005-10-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IInputSession.cs, IInstanceContextInitializer.cs,
+         IRequestSessionChannel.cs,IReplySessionChannel.cs,
+         IStubFormatter.cs,IProxyOperationSelector.cs,
+         IRequestReplyMessageIntermediary.cs,IOperationInvoker.cs,
+         IPersistentSession.cs,IParameterInspector.cs,
+         IOneWayMessageAsyncIntermediary.cs,IInstanceProvider.cs,
+         ISessionRecovery.cs,IOutputSession.cs,IProxyFormatter.cs,
+         ISessionChannel.cs,IPersistentOutputSession.cs,
+         IInputSessionChannel.cs,IMessageProperty.cs,IInputSessionShutdown.cs,
+         InstanceContextIdleCallback.cs,IProxyMessageInspector.cs,
+         IOneWayMessageIntermediary.cs,ISharedSessionLifetime.cs,
+         ITransportBindingElement.cs,ITransactedTransportListenerFactory.cs,
+         IStubMessageInspector.cs,ISession.cs,
+         IRequestReplyMessageAsyncIntermediary.cs,IPersistentInputSession.cs,
+         IOutputSessionChannel.cs : added almost all interfaces.
+       * Dummy.cs : removed above ifaces.
+       * IChannelListener.cs, IExtensionCollection.cs,
+         ISecurityCapabilities.cs : fixed some signatures.
+       * BasicHttpBinding.cs, NetPeerTcpBinding.cs, NetTcpBinding.cs,
+         IntermediaryBinding.cs, WSDualHttpBinding.cs, CustomBinding.cs :
+         dependent fixes on those iface fixes.
+
+2005-10-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : some stubbing in this file for config stuff.
+
+2005-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IListener.cs : fixed generic constraints.
+
+2005-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XmlSerializerFormatAttribute.cs, DataContractFormatAttribute.cs,
+         XmlFormatterOperationBehavior.cs, XmlSerializerOperationBehavior.cs,
+         OperationFormatUse.cs, IOperationBehavior.cs,
+         OperationFormatStyle.cs : new files
+       * Dummy.cs : removed above types.
+       * DispatchBehavior.cs, EndpointListenerCollection.cs,
+         InstanceListener.cs, EndpointListener.cs, IMetadataExchange.cs,
+         Binding.cs, OperationContractAttribute.cs, PeerSecurityBehavior.cs,
+         OperationDescription.cs : fixed several signatures.
+
+2005-10-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IListener.cs, IListenerFactory.cs : added listener supprot files.
+       * Dummy.cs : removed above.
+
+2005-10-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * Dummy.cs : OperationContextScope was not removed. Fixed typo.
+
+2005-10-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OperationContextScope.cs, OperationContext.cs : new files.
+       * Dummy.cs : removed above.
+       * IErrorHandler.cs : signature fix.
+
+2005-10-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory_1.cs : new file for generic ChannelFactory.
+       * CommunicationState.cs : new file for CommunicationObject impl.
+       * Dummy.cs : removed above.
+       * ServiceMetadataBehavior.cs : stubbed up.
+
+2005-10-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * GetMetadataRequest.cs, GetMetadataResponse.cs, MetadataBundle.cs,
+         MetadataDocument.cs, IMetadataExchange.cs, GetResponse.cs,
+         GetMetadataRequestParameters.cs, MessageBodyAttribute.cs,
+         GetRequest.cs, MetadataReference.cs, MetadataSection.cs,
+         MessageContractAttribute.cs : added ws-mex stuff.
+       * Dummy.cs : removed above types.
+
+2005-09-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IDefaultCommunicationTimeouts.cs, IDuplexClientChannel.cs,
+         IDuplexSessionChannel.cs, IExtension.cs, IInputChannel.cs,
+         IChannelBehavior.cs, IOutputChannel.cs, IDuplexSession.cs,
+         IClientChannel.cs, IChannelInitializer.cs, IChannelListener.cs,
+         IEndpointDispatcher.cs, IDispatchOperationSelector.cs,
+         IContractBehaviorAttribute.cs, IErrorHandler.cs,
+         IDuplexChannel.cs, IEndpointFilterProvider.cs : new files.
+       * Dummy.cs : removed new types above.
+       * IExtensibleObject.cs, ServiceHostBase.cs IExtensionCollection.cs:
+         fixed incorrect signatures.
+
+2005-09-30  Duncan Mak  <duncan@novell.com>
+
+       * EnvelopeVersion.cs (Namespace): Renamed from 'Uri' to be
+       consistent with AddressingVersion.Namespace property (they are
+       both internal).
+
+2005-09-29  Duncan Mak  <duncan@novell.com>
+
+       * EndpointAddress.cs: Added missing Attributes.
+       (ReadFrom): Added missing overload.
+       (Identity): Added missing property.
+       (GetSchema): Implemented.
+
+       * MatchAllFilter.cs, MatchNoneFilter.cs: Added [DataContract]
+       attribute.
+
+       * MessageHeader.cs: Implemented MessageHeader<T>.
+
+2005-09-29  Duncan Mak  <duncan@novell.com>
+       
+       * ActionFilterTable (TryGetValue): Remember to assign to data,
+       even in the 'false' case.
+
+       * MessageBuffer.cs (WriteMessage): Write it out using a
+       Binary XmlDictionaryWriter.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XPathFilter.cs : so, more stubs.
+
+2005-09-29  Duncan Mak  <duncan@novell.com>
+
+       * ActionFilterTable.cs (CreateFilterTable): Removed extraneous
+       method.
+
+       * AddressHeader.cs (Equals, GetAddressHeaderReader):
+       (GetHashCode, GetValue): Added missing methods.
+
+       * AddressHeaderCollection.cs (.ctor, FindHeader): Uncommented.
+
+       * EnvelopeVersion.cs (GetHashCode): Added missing method.
+
+       * FilterTable.cs (Remove): Removed extraneous overload.
+
+       * IChannel.cs: Updated to Sept. CTP definition.
+
+       * IChannelFactory.cs: Moved IChannelFactory<T> to here
+       * IChannelFactory_1.cs:  from here.
+
+       * MessageBuffer.cs (WriteMessage): Added missing method.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XPathFilter.cs : new file.
+       * Dummy.cs : removed above.
+       * MessageHeader.cs : fixed some members as static.
+       * ContractDescription.cs : added DataContract attributes.
+       * BindingElementCollection.cs : added SetItem().
+       * ChannelFactory.cs : fixed .ctor().
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ICommunicationObject.cs, IChannelFactory_1.cs,
+         OperationDescription.cs : some signature fixes.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSDualHttpBinding.cs : and actual class rename after svn mv.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpDualBinding.cs, WSDualHttpBinding.cs : from former to latter.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IChannelFactory_1.cs, ChannelFactory.cs :
+         new files for ChannelFactory.
+       * Dummy.cs : removed extraneous stubs.
+       * IChannelFactory.cs : added two more overloads.
+
+2005-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingBase.cs, BindingElementCollection.cs, ClientBase.cs,
+         IBindingRuntimePreferences.cs, BasicHttpBinding.cs,
+         IBindingCapabilities.cs, NetPeerTcpBinding.cs, NetTcpBinding.cs,
+         Binding.cs, IntermediaryBinding.cs, ISecurityCapabilities.cs,
+         WSHttpDualBinding.cs, CustomBinding.cs : new files.
+       * Dummy.cs : removed the above types.
+         Added some of the missing generic interfaces.
+
+2005-09-29  Duncan Mak  <duncan@novell.com>
+
+       * SynchronizedReadOnlyCollection.cs: Added checks for
+       ArgumentNullException to the constructors.
+
+2005-09-29  Duncan Mak  <duncan@novell.com>    
+
+       * ActionFilter.cs: Implemented, except for 'Match', which requires
+       MessageHeaders to be implemented.
+
+       * ActionFilterTable.cs: Implemented, except for the IFilterTable
+       parts.
+
+       * FilterTable.cs: Stubbed out.  
+
+       * Filter.cs, MatchAllFilter.cs, MatchNoneFilter.cs:
+       * SeekableXPathNavigator.cs: Implemented.
+
+2005-09-28  Duncan Mak  <duncan@novell.com>
+
+       * SynchronizedReadOnlyCollection.cs
+       (IList.Contains, IList.IndexOf): Fixed the conditions for throwing
+       Exceptions. GMCS was allowing incorrect code (bug #76267). Removed
+       the test for null, as it is unnecessary (see test cases).
+
+2005-09-28  Duncan Mak  <duncan@novell.com>
+
+       * AddressHeaderCollection.cs:
+       * IChannelManager: Added using statement to
+       System.Collections.ObjectModel.
+
+       * SynchronizedReadOnlyCollection.cs: Implemented.
+
+2005-09-28  Duncan Mak  <duncan@novell.com>    
+
+       * EnvelopeVersion.cs (Soap11, Soap12): Store them as singletons
+       instead of creating a new one everytime.
+       (Soap12.UltimateDestinationActorValues): Added missing
+       String.Empty.
+       
+       * IMessageHeaderInfo.cs: Added interface.
+
+       * MessageHeader.cs: Implemented.        
+
+2005-09-28  Duncan Mak  <duncan@novell.com>    
+
+       * AddressHeader.cs (CreateAddressHeader): Implemented.
+       (OnWriteAddressHeaderContents): Fixed typo.
+       (OnWriteStartAddressHeader): Fixed visibility.
+       (WriterAddressHeader, WriteAddressHeaderContents): Implemented.
+       (WriteStartAddressHeader): Implemented.
+       (DefaultAddressHeader): new internal class used by
+       CreateAddressHeader.
+
+       * IFilterTable.cs: Added interface.     
+
+       * MessageBuffer.cs: Added stubs.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceThrottlingBehavior.cs : moved to *.Design directory.
+
+2005-09-28  Duncan Mak  <duncan@novell.com>
+
+        * ServiceSecurityBehavior.cs: Fixed typo. 
+        
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHost.cs : now it holds ServiceLoader, and ServiceDescription
+         comes from the loader.
+       * ListenUriBehavior.cs : fixed inheritance, signature and members.
+       * ServiceThrottlingBehavior.cs : fixed namespace (so this file is
+         being moved) and implemented some props.
+       * ServiceDescription.cs : MonoTODO.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IContractBehavior.cs, OperationDescriptionCollection.cs,
+         ContractDescription.cs, OperationDescription.cs,
+         IEndpointBehavior.cs : new files.
+       * Dummy.cs : removed added types above.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceEndpoint.cs, EndpointBehaviorCollection.cs,
+         IServiceBehavior.cs, DispatchBehavior.cs, ServiceMetadataBehavior.cs,
+         ListenUriBehavior.cs, ProxyBehavior.cs,
+         HostedBindingBehavior.cs, ServiceAuthorizationBehavior.cs,
+         ServiceSecuiryAuditBehavior.cs, ServiceEndpointCollection.cs,
+         ViaUriBehavior.cs, ServiceThrottlingBehavior.cs,
+         PeerSecurityBehavior.cs, ServiceDescription.cs : new files.
+       * ServiceHost.cs : added Description.
+       * ServiceHostBase.cs : base type fix.
+
+2005-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceAuthorization.cs, ServiceThrottle.cs : new files.
+       * Dummy.cs : removed newly-added types.
+       * ServiceHost.cs, ServiceHostBase.cs : implemented a bit.
+       * UriSchemeKeyedCollecion.cs : copyright lines.
+
+2005-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationErrorEventArgs.cs : new file.
+       * CommunicationObject.cs, EndpointListener.cs,
+         InstanceContext.cs, ServiceHostBase.cs : signature fixes.
+       * Dummy.cs : removed one for new class.
+
+2005-09-27  Duncan Mak  <duncan@novell.com>
+
+       * IFaultContext.cs
+       * IFaultProvider.cs: Added these interfaces.
+
+       * MessageInterceptorEventArgs.cs:
+       * SessionFaultedEventArgs.cs:
+       * UnknownMessageReceivedEventArgs.cs: Added the EventArgs.
+       
+2005-09-27  Duncan Mak  <duncan@novell.com>
+
+       * AddressHeader.cs: 
+       * EndpointAddress.cs: Stubbed.
+       
+       * AddressHeaderCollection.cs: Implemented, waiting for Message to
+       be implemented, and for the generic Collections class to be completed.
+
+       * AddressingVersion.cs:
+       * EnvelopeVersion.cs:
+       * MessageVersion.cs: Implemented.
+
+       * Dummy.cs: Added ReadOnlyCollection<T> and SynchronizedCollection<T>.  
+
+       * IChannel.cs:
+       * IChannelFactory.cs:
+       * IChannelManager.cs:
+       * ICommunicationObject.cs: Added these interfaces.
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs
new file mode 100644 (file)
index 0000000..fa39af1
--- /dev/null
@@ -0,0 +1,212 @@
+//
+// ChannelFactory.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Configuration;
+using System.ServiceModel.Configuration;
+
+namespace System.ServiceModel
+{
+       [MonoTODO ("Actually it should work like existing ClientBase minus the impact of proxying. Separate TChannel from IChannel")]
+       public abstract class ChannelFactory : CommunicationObject,
+               IChannelFactory, ICommunicationObject, IDisposable
+       {
+               // instance members
+
+               ServiceEndpoint service_endpoint;
+
+               protected ChannelFactory ()
+               {
+               }
+
+               public ServiceEndpoint Endpoint {
+                       get { return service_endpoint; }
+               }
+
+               public ClientCredentials Credentials {
+                       get { return Endpoint.Behaviors.Find<ClientCredentials> (); }
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return Endpoint.Binding.CloseTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return Endpoint.Binding.OpenTimeout; }
+               }
+
+               protected virtual void ApplyConfiguration (string endpointConfig)
+               {
+                       if (endpointConfig == null)
+                               return;
+
+                       string contractName = Endpoint.Contract.ConfigurationName;
+                       ClientSection client = (ClientSection) ConfigurationManager.GetSection ("system.serviceModel/client");
+                       ChannelEndpointElement res = null;
+                       foreach (ChannelEndpointElement el in client.Endpoints) {
+                               if (el.Contract == contractName && (endpointConfig == el.Name || endpointConfig == "*")) {
+                                       if (res != null)
+                                               throw new InvalidOperationException (String.Format ("More then one endpoint matching contract {0} was found.", contractName));
+                                       res = el;
+                               }
+                       }
+
+                       if (res == null)
+                               throw new InvalidOperationException (String.Format ("Client endpoint configuration '{0}' was not found in {1} endpoints.", endpointConfig, client.Endpoints.Count));
+
+                       if (Endpoint.Binding == null)
+                               Endpoint.Binding = ConfigUtil.CreateBinding (res.Binding, res.BindingConfiguration);
+                       if (Endpoint.Address == null)
+                               Endpoint.Address = new EndpointAddress (res.Address);
+
+                       if (res.BehaviorConfiguration != "")
+                               ApplyBehavior (res.BehaviorConfiguration);
+               }
+
+               private void ApplyBehavior (string behaviorConfig)
+               {
+                       BehaviorsSection behaviorsSection = (BehaviorsSection) ConfigurationManager.GetSection ("system.serviceModel/behaviors");
+                       EndpointBehaviorElement behaviorElement = behaviorsSection.EndpointBehaviors [behaviorConfig];
+                       int i = 0;
+                       foreach (BehaviorExtensionElement el in behaviorElement) {
+                               IEndpointBehavior behavior = (IEndpointBehavior) el.CreateBehavior ();
+                               Endpoint.Behaviors.Remove (behavior.GetType ());
+                               Endpoint.Behaviors.Add (behavior);
+                       }
+               }
+
+               [MonoTODO]
+               protected virtual IChannelFactory CreateFactory ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected abstract ServiceEndpoint CreateDescription ();
+
+               void IDisposable.Dispose ()
+               {
+                       Close ();
+               }
+
+               [MonoTODO]
+               public T GetProperty<T> () where T : class
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected void EnsureOpened ()
+               {
+                       if (State != CommunicationState.Opened)
+                               Open ();
+               }
+
+               protected void InitializeEndpoint (
+                       string endpointConfigurationName,
+                       EndpointAddress remoteAddress)
+               {
+                       InitializeEndpoint (CreateDescription ());
+                       service_endpoint.Address = remoteAddress;
+                       ApplyConfiguration (endpointConfigurationName);
+               }
+
+               protected void InitializeEndpoint (Binding binding,
+                       EndpointAddress remoteAddress)
+               {
+                       InitializeEndpoint (CreateDescription ());
+                       service_endpoint.Binding = binding;
+                       service_endpoint.Address = remoteAddress;
+               }
+
+               protected void InitializeEndpoint (ServiceEndpoint endpoint)
+               {
+                       service_endpoint = endpoint;
+               }
+
+               [MonoTODO]
+               protected override void OnAbort ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginClose (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override IAsyncResult OnBeginOpen (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnClose (TimeSpan timeout)
+               {
+               }
+
+               [MonoTODO]
+               protected override void OnOpen (TimeSpan timeout)
+               {
+               }
+
+               [MonoTODO]
+               protected override void OnOpening ()
+               {
+               }
+
+               [MonoTODO]
+               protected override void OnOpened ()
+               {
+               }
+       }
+
+       [ServiceContract]
+       interface UninitializedContract
+       {
+               [OperationContract]
+               void ItShouldReallyGone ();
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs
new file mode 100644 (file)
index 0000000..53bc023
--- /dev/null
@@ -0,0 +1,192 @@
+//
+// generic ChannelFactory_1.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel
+{
+       // I really dislike those TChannels which are rather contract.
+       // If I were to design WCF, I'd rather name them as TContract.
+       public class ChannelFactory<TChannel>
+               : ChannelFactory, IChannelFactory<TChannel>
+       {
+               public ChannelFactory ()
+                       : this ("*")
+               {
+               }
+
+               protected ChannelFactory (Type type)
+               {
+                       if (type == null)
+                               throw new ArgumentNullException ("type");
+                       if (!type.IsInterface)
+                               throw new InvalidOperationException ("The type argument to the generic ChannelFactory constructor must be an interface type.");
+
+                       InitializeEndpoint (CreateDescription ());
+               }
+
+               public ChannelFactory (string endpointConfigurationName)
+               {
+                       if (endpointConfigurationName == null)
+                               throw new ArgumentNullException ("endpointConfigurationName");
+
+                       InitializeEndpoint (endpointConfigurationName, null);
+               }
+
+               public ChannelFactory (string endpointConfigurationName,
+                       EndpointAddress remoteAddress)
+               {
+                       if (endpointConfigurationName == null)
+                               throw new ArgumentNullException ("endpointConfigurationName");
+
+                       InitializeEndpoint (endpointConfigurationName, remoteAddress);
+               }
+
+               public ChannelFactory (ServiceEndpoint endpoint)
+               {
+                       if (endpoint == null)
+                               throw new ArgumentNullException ("serviceEndpoint");
+
+                       InitializeEndpoint (endpoint);
+               }
+
+               public ChannelFactory (Binding binding, string remoteAddress)
+                       : this (binding, new EndpointAddress (remoteAddress))
+               {
+               }
+
+               public ChannelFactory (Binding binding)
+                       : this (binding, (EndpointAddress) null)
+               {
+               }
+
+               public ChannelFactory (Binding binding, EndpointAddress remoteAddress)
+                       : this (typeof (TChannel))
+               {
+                       if (binding == null)
+                               throw new ArgumentNullException ();
+
+                       Endpoint.Binding = binding;
+                       Endpoint.Address = remoteAddress;
+               }
+
+               [MonoTODO]
+               public TChannel CreateChannel ()
+               {
+                       return CreateChannel (Endpoint.Address);
+               }
+
+               public TChannel CreateChannel (EndpointAddress address)
+               {
+                       return CreateChannel (address, null);
+               }
+
+               public static TChannel CreateChannel (Binding binding, EndpointAddress address)
+               {
+                       return new ChannelFactory<TChannel> (binding, address).CreateChannel ();
+               }
+
+               public static TChannel CreateChannel (Binding binding, EndpointAddress address, Uri via)
+               {
+                       return new ChannelFactory<TChannel> (binding).CreateChannel (address, via);
+               }
+
+               [MonoTODO]
+               public virtual TChannel CreateChannel (EndpointAddress address, Uri via)
+               {
+                       EnsureOpened ();
+                       Type type = ClientProxyGenerator.CreateProxyType (Endpoint.Contract);
+                       object proxy = Activator.CreateInstance (type,
+                               new object [] {CreateRuntime (Endpoint), this});
+                       return (TChannel) proxy;
+               }
+
+               protected static TChannel CreateChannel (string endpointConfigurationName)
+               {
+                       return new ChannelFactory<TChannel> (endpointConfigurationName).CreateChannel ();
+               }
+
+               protected override ServiceEndpoint CreateDescription ()
+               {
+                       ContractDescription cd = ContractDescription.GetContract (typeof (TChannel));
+                       ServiceEndpoint ep = new ServiceEndpoint (cd);
+                       ep.Behaviors.Add (new ClientCredentials ());
+                       return ep;
+               }
+
+               static ClientRuntime CreateRuntime (ServiceEndpoint se)
+               {
+                       ClientRuntime proxy = new ClientRuntime (se);
+                       proxy.ContractClientType = typeof (TChannel);
+
+                       foreach (OperationDescription od in se.Contract.Operations)
+                               if (!proxy.Operations.Contains (od.Name))
+                                       PopulateClientOperation (proxy, od);
+
+                       foreach (IEndpointBehavior b in se.Behaviors)
+                               b.ApplyClientBehavior (se, proxy);
+
+                       foreach (IContractBehavior b in se.Contract.Behaviors)
+                               b.ApplyClientBehavior (se.Contract, se, proxy);
+                       foreach (OperationDescription od in se.Contract.Operations)
+                               foreach (IOperationBehavior ob in od.Behaviors)
+                                       ob.ApplyClientBehavior (od, proxy.Operations [od.Name]);
+
+                       return proxy;
+               }
+
+               static void PopulateClientOperation (ClientRuntime proxy, OperationDescription od)
+               {
+                       string reqA = null, resA = null;
+                       foreach (MessageDescription m in od.Messages) {
+                               if (m.Direction == MessageDirection.Input)
+                                       reqA = m.Action;
+                               else
+                                       resA = m.Action;
+                       }
+                       ClientOperation o =
+                               od.IsOneWay ?
+                               new ClientOperation (proxy, od.Name, reqA) :
+                               new ClientOperation (proxy, od.Name, reqA, resA);
+                       foreach (MessageDescription md in od.Messages) {
+                               if (md.Direction == MessageDirection.Input &&
+                                   md.Body.Parts.Count == 1 &&
+                                   md.Body.Parts [0].Type == typeof (Message))
+                                       o.SerializeRequest = false;
+                               if (md.Direction == MessageDirection.Output &&
+                                   md.Body.ReturnValue != null &&
+                                   md.Body.ReturnValue.Type == typeof (Message))
+                                       o.DeserializeReply = false;
+                       }
+                       proxy.Operations.Add (o);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs
new file mode 100644 (file)
index 0000000..fba2576
--- /dev/null
@@ -0,0 +1,275 @@
+//
+// generic ClientBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel
+{
+       [MonoTODO ("It somehow rejects classes, but dunno how we can do that besides our code level.")]
+       public abstract class ClientBase<TChannel>
+               : IDisposable, ICommunicationObject
+       {
+               static InstanceContext initialContxt = new InstanceContext (null);
+
+               ChannelFactory<TChannel> factory;
+               ClientRuntimeChannel inner_channel;
+               CommunicationState state;
+
+               protected ClientBase ()
+                       : this (initialContxt)
+               {
+               }
+
+               protected ClientBase (string configname)
+                       : this (initialContxt, configname)
+               {
+               }
+
+               protected ClientBase (Binding binding, EndpointAddress remoteAddress)
+                       : this (initialContxt, binding, remoteAddress)
+               {
+               }
+
+               protected ClientBase (string configname, EndpointAddress remoteAddress)
+                       : this (initialContxt, configname, remoteAddress)
+               {
+               }
+
+               protected ClientBase (string configname, string remoteAddress)
+                       : this (initialContxt, configname, remoteAddress)
+               {
+               }
+
+               protected ClientBase (InstanceContext instance)
+                       : this (instance, "*")
+               {
+               }
+
+               protected ClientBase (InstanceContext instance, string configname)
+               {
+                       if (instance == null)
+                               throw new ArgumentNullException ("instanceContext");
+                       if (configname == null)
+                               throw new ArgumentNullException ("configurationName");
+
+                       Initialize (instance, configname, null);
+               }
+
+               protected ClientBase (InstanceContext instance,
+                       string configname, EndpointAddress remoteAddress)
+               {
+                       if (instance == null)
+                               throw new ArgumentNullException ("instanceContext");
+                       if (configname == null)
+                               throw new ArgumentNullException ("configurationName");
+                       if (remoteAddress == null)
+                               throw new ArgumentNullException ("remoteAddress");
+
+                       Initialize (instance, configname, remoteAddress);
+               }
+
+               protected ClientBase (InstanceContext instance,
+                       string configname, string remoteAddress)
+               {
+                       if (instance == null)
+                               throw new ArgumentNullException ("instanceContext");
+                       if (remoteAddress == null)
+                               throw new ArgumentNullException ("endpointAddress");
+                       if (configname == null)
+                               throw new ArgumentNullException ("configurationname");
+
+                       Initialize (instance, configname, new EndpointAddress (remoteAddress));
+               }
+
+               protected ClientBase (InstanceContext instance,
+                       Binding binding, EndpointAddress remoteAddress)
+               {
+                       if (instance == null)
+                               throw new ArgumentNullException ("instanceContext");
+                       if (binding == null)
+                               throw new ArgumentNullException ("binding");
+                       if (remoteAddress == null)
+                               throw new ArgumentNullException ("remoteAddress");
+
+                       Initialize (instance, binding, remoteAddress);
+               }
+
+               void Initialize (InstanceContext instance,
+                       string configName, EndpointAddress remoteAddress)
+               {
+                       factory = new ChannelFactory<TChannel> (configName, remoteAddress);
+               }
+
+               void Initialize (InstanceContext instance,
+                       Binding binding, EndpointAddress remoteAddress)
+               {
+                       factory = new ChannelFactory<TChannel> (binding, remoteAddress);
+               }
+
+               public ChannelFactory<TChannel> ChannelFactory {
+                       get { return factory; }
+               }
+
+               public ClientCredentials ClientCredentials {
+                       get { return ChannelFactory.Credentials; }
+               }
+
+               public ServiceEndpoint Endpoint {
+                       get { return factory.Endpoint; }
+               }
+
+               public IClientChannel InnerChannel {
+                       get {
+                               if (inner_channel == null)
+                                       inner_channel = (ClientRuntimeChannel) (object) factory.CreateChannel ();
+                               return inner_channel;
+                       }
+               }
+
+               protected TChannel Channel {
+                       get { return (TChannel) (object) InnerChannel; }
+               }
+
+               public CommunicationState State {
+                       get { return InnerChannel.State; }
+               }
+
+               [MonoTODO]
+               public void Abort ()
+               {
+                       InnerChannel.Abort ();
+               }
+
+               [MonoTODO]
+               public void Close ()
+               {
+                       InnerChannel.Close ();
+               }
+
+               [MonoTODO]
+               public void DisplayInitializationUI ()
+               {
+               }
+
+               [MonoTODO]
+               void IDisposable.Dispose ()
+               {
+                       Close ();
+               }
+
+               protected virtual TChannel CreateChannel ()
+               {
+                       return ChannelFactory.CreateChannel ();
+               }
+
+               public void Open ()
+               {
+                       InnerChannel.Open ();
+               }
+
+               #region ICommunicationObject implementation
+
+               [MonoTODO]
+               IAsyncResult ICommunicationObject.BeginOpen (
+                       AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginOpen (callback, state);
+               }
+
+               [MonoTODO]
+               IAsyncResult ICommunicationObject.BeginOpen (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginOpen (timeout, callback, state);
+               }
+
+               [MonoTODO]
+               void ICommunicationObject.EndOpen (IAsyncResult result)
+               {
+                       InnerChannel.EndOpen (result);
+               }
+
+               [MonoTODO]
+               IAsyncResult ICommunicationObject.BeginClose (
+                       AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginClose (callback, state);
+               }
+
+               [MonoTODO]
+               IAsyncResult ICommunicationObject.BeginClose (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return InnerChannel.BeginClose (timeout, callback, state);
+               }
+
+               [MonoTODO]
+               void ICommunicationObject.EndClose (IAsyncResult result)
+               {
+                       InnerChannel.EndClose (result);
+               }
+
+               [MonoTODO]
+               void ICommunicationObject.Close (TimeSpan timeout)
+               {
+                       InnerChannel.Close (timeout);
+               }
+
+               [MonoTODO]
+               void ICommunicationObject.Open (TimeSpan timeout)
+               {
+                       InnerChannel.Open (timeout);
+               }
+
+               event EventHandler ICommunicationObject.Opening {
+                       add { InnerChannel.Opening += value; }
+                       remove { InnerChannel.Opening -= value; }
+               }
+               event EventHandler ICommunicationObject.Opened {
+                       add { InnerChannel.Opened += value; }
+                       remove { InnerChannel.Opened -= value; }
+               }
+               event EventHandler ICommunicationObject.Closing {
+                       add { InnerChannel.Closing += value; }
+                       remove { InnerChannel.Closing -= value; }
+               }
+               event EventHandler ICommunicationObject.Closed {
+                       add { InnerChannel.Closed += value; }
+                       remove { InnerChannel.Closed -= value; }
+               }
+               event EventHandler ICommunicationObject.Faulted {
+                       add { InnerChannel.Faulted += value; }
+                       remove { InnerChannel.Faulted -= value; }
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ClientCredentialsSecurityTokenManager.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ClientCredentialsSecurityTokenManager.cs
new file mode 100644 (file)
index 0000000..df2c715
--- /dev/null
@@ -0,0 +1,345 @@
+//
+// ClientCredentialsSecurityTokenManager.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Principal;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       public class ClientCredentialsSecurityTokenManager : SecurityTokenManager
+       {
+               ClientCredentials credentials;
+
+               public ClientCredentialsSecurityTokenManager (ClientCredentials credentials)
+               {
+                       if (credentials == null)
+                               throw new ArgumentNullException ("credentials");
+                       this.credentials = credentials;
+               }
+
+               public ClientCredentials ClientCredentials {
+                       get { return credentials; }
+               }
+
+               [MonoTODO]
+               public override SecurityTokenAuthenticator CreateSecurityTokenAuthenticator (
+                       SecurityTokenRequirement requirement,
+                       out SecurityTokenResolver outOfBandTokenResolver)
+               {
+                       outOfBandTokenResolver = null;
+                       if (requirement == null)
+                               throw new ArgumentNullException ("requirement");
+                       if (requirement.TokenType == SecurityTokenTypes.UserName) {
+                               // unsupported
+                       }
+                       else if (requirement.TokenType == SecurityTokenTypes.Rsa)
+                               return new RsaSecurityTokenAuthenticator ();
+                       else if (requirement.TokenType == SecurityTokenTypes.X509Certificate)
+                               return CreateX509Authenticator (requirement);
+                       else if (requirement.TokenType == ServiceModelSecurityTokenTypes.Spnego)
+                               return new SspiClientSecurityTokenAuthenticator (this, requirement);
+                       else
+                               throw new NotImplementedException ();
+
+                       throw new NotSupportedException (String.Format ("Security token requirement '{0}' is not supported to create SecurityTokenAuthenticator.", requirement));
+               }
+
+
+               X509SecurityTokenAuthenticator CreateX509Authenticator (SecurityTokenRequirement requirement)
+               {
+                       X509CertificateRecipientClientCredential c = ClientCredentials.ServiceCertificate;
+                       switch (c.Authentication.CertificateValidationMode) {
+                       case X509CertificateValidationMode.Custom:
+                               if (c.Authentication.CustomCertificateValidator == null)
+                                       throw new InvalidOperationException ("For Custom certificate validation mode, CustomCertificateValidator is required to create a token authenticator for X509 certificate.");
+                               return new X509SecurityTokenAuthenticator (c.Authentication.CustomCertificateValidator);
+                       case X509CertificateValidationMode.None:
+                               return new X509SecurityTokenAuthenticator (X509CertificateValidator.None);
+                       case X509CertificateValidationMode.PeerOrChainTrust:
+                               return new X509SecurityTokenAuthenticator (X509CertificateValidator.PeerOrChainTrust);
+                       case X509CertificateValidationMode.ChainTrust:
+                               return new X509SecurityTokenAuthenticator (X509CertificateValidator.ChainTrust);
+                       default:
+                               return new X509SecurityTokenAuthenticator (X509CertificateValidator.PeerTrust);
+                       }
+               }
+
+               #region CreateSecurityTokenProvider()
+
+               [MonoTODO]
+               public override SecurityTokenProvider CreateSecurityTokenProvider (SecurityTokenRequirement requirement)
+               {
+                       if (IsIssuedSecurityTokenRequirement (requirement))
+                               return CreateIssuedTokenProvider (requirement);
+
+                       bool isInitiator;
+
+                       // huh, they are not constants but properties.
+                       if (requirement.TokenType == SecurityTokenTypes.X509Certificate)
+                               return CreateX509SecurityTokenProvider (requirement);
+                       else if (requirement.TokenType == ServiceModelSecurityTokenTypes.SecureConversation)
+                               return CreateSecureConversationProvider (requirement);
+                       else if (requirement.TokenType == ServiceModelSecurityTokenTypes.AnonymousSslnego) {
+                               if (requirement.TryGetProperty<bool> (ReqType.IsInitiatorProperty, out isInitiator) && isInitiator)
+                                       return CreateSslnegoProvider (requirement);
+                       } else if (requirement.TokenType == ServiceModelSecurityTokenTypes.MutualSslnego) {
+                               if (requirement.TryGetProperty<bool> (ReqType.IsInitiatorProperty, out isInitiator) && isInitiator)
+                                       return CreateSslnegoProvider (requirement);
+                       } else if (requirement.TokenType == ServiceModelSecurityTokenTypes.SecurityContext) {
+                               // FIXME: implement
+                       } else if (requirement.TokenType == ServiceModelSecurityTokenTypes.Spnego) {
+                               return CreateSpnegoProvider (requirement);
+                       } else if (requirement.TokenType == ServiceModelSecurityTokenTypes.SspiCredential) {
+                               // FIXME: implement
+                       } else if (requirement.TokenType == SecurityTokenTypes.Rsa) {
+                               // FIXME: implement
+                       } else if (requirement.TokenType == SecurityTokenTypes.Saml) {
+                               // FIXME: implement
+                       } else if (requirement.TokenType == SecurityTokenTypes.UserName)
+                               return CreateUserNameProvider (requirement);
+                       else if (requirement.TokenType == SecurityTokenTypes.Kerberos) {
+                               return CreateKerberosProvider (requirement);
+                       }
+                       throw new NotSupportedException (String.Format ("Token type '{0}' is not supported", requirement.TokenType));
+               }
+
+               UserNameSecurityTokenProvider CreateUserNameProvider (
+SecurityTokenRequirement requirement)
+               {
+                       UserNamePasswordClientCredential c =
+                               credentials.UserName;
+                       if (c.UserName == null)
+                               throw new InvalidOperationException ("User name is not specified in ClientCredentials.");
+                       UserNameSecurityTokenProvider p =
+                               new UserNameSecurityTokenProvider (c.UserName, c.Password);
+                       return p;
+               }
+
+               KerberosSecurityTokenProvider CreateKerberosProvider (SecurityTokenRequirement requirement)
+               {
+                       // FIXME: how to get SPN?
+                       return new KerberosSecurityTokenProvider (
+                               "", credentials.Windows.AllowedImpersonationLevel, credentials.Windows.ClientCredential);
+               }
+
+               X509SecurityTokenProvider CreateX509SecurityTokenProvider (SecurityTokenRequirement requirement)
+               {
+                       // - When the request is as an initiator, then
+                       //   - if the purpose is key exchange, then
+                       //     the initiator wants the service certificate
+                       //     to encrypt the message with its public key.
+                       //   - otherwise, the initiator wants the client
+                       //     certificate to sign the message with the
+                       //     private key.
+                       // - otherwise
+                       //   - if the purpose is key exchange, then
+                       //     the recipient wants the client certificate
+                       //     to encrypt the message with its public key.
+                       //   - otherwise, the recipient wants the service
+                       //     certificate to sign the message with the
+                       //     private key.
+                       bool isInitiator;
+                       if (!requirement.TryGetProperty<bool> (ReqType.IsInitiatorProperty, out isInitiator))
+                               isInitiator = false;
+                       X509Certificate2 cert;
+                       bool isClient;
+                       if (isInitiator)
+                               isClient = requirement.KeyUsage == SecurityKeyUsage.Signature;
+                       else {
+                               if (!requirement.Properties.ContainsKey (SecurityTokenRequirement.KeyUsageProperty))
+                                       throw new NotSupportedException (String.Format ("Cannot create a security token provider from this requirement '{0}'", requirement));
+                               isClient = requirement.KeyUsage == SecurityKeyUsage.Exchange;
+                       }
+                       if (isClient)
+                               cert = credentials.ClientCertificate.Certificate;
+                       else
+                               cert = GetServiceCertificate (requirement);
+
+                       if (cert == null) {
+                               if (isClient)
+                                       throw new InvalidOperationException ("Client certificate is not provided in ClientCredentials.");
+                               else
+                                       throw new InvalidOperationException ("Service certificate is not provided.");
+                       }
+                       X509SecurityTokenProvider p =
+                               new X509SecurityTokenProvider (cert);
+                       return p;
+               }
+
+               X509Certificate2 GetServiceCertificate (SecurityTokenRequirement requirement)
+               {
+                       // try X509CertificateEndpointIdentity,
+                       // ServiceCertificate.ScopedCertificate and
+                       // ServiceCertificate.DefaultCertificate.
+
+                       X509Certificate2 cert = null;
+                       EndpointAddress address = null;
+                       requirement.TryGetProperty (ReqType.TargetAddressProperty, out address);
+
+                       if (address != null) {
+                               X509CertificateEndpointIdentity ident = address.Identity as X509CertificateEndpointIdentity;
+                               if (ident != null && ident.Certificates.Count > 0)
+                                       cert = ident.Certificates [0];
+                               if (cert == null)
+                                       credentials.ServiceCertificate.ScopedCertificates.TryGetValue (address.Uri, out cert);
+                       }
+                       if (cert == null)
+                               cert = credentials.ServiceCertificate.DefaultCertificate;
+                       return cert;
+               }
+
+               void InitializeProviderCommunicationObject (ProviderCommunicationObject p, SecurityTokenRequirement r)
+               {
+                       p.TargetAddress = r.GetProperty<EndpointAddress> (ReqType.TargetAddressProperty);
+
+                       // FIXME: use it somewhere, probably to build 
+                       // IssuerBinding. However, there is also IssuerBinding 
+                       // property. SecureConversationSecurityBindingElement
+                       // as well.
+                       SecurityBindingElement sbe =
+                               r.GetProperty<SecurityBindingElement> (ReqType.SecurityBindingElementProperty);
+
+                       // I doubt the binding is acquired this way ...
+                       Binding binding;
+                       if (!r.TryGetProperty<Binding> (ReqType.IssuerBindingProperty, out binding))
+                               binding = new CustomBinding (
+                                       new TextMessageEncodingBindingElement (),
+                                       new HttpTransportBindingElement ());
+                       p.IssuerBinding = binding;
+
+                       // not sure if it is used only for this purpose though ...
+                       BindingContext ctx = r.GetProperty<BindingContext> (ReqType.IssuerBindingContextProperty);
+                       foreach (IEndpointBehavior b in ctx.BindingParameters.FindAll<IEndpointBehavior> ())
+                               p.IssuerChannelBehaviors.Add (b);
+
+                       SecurityTokenVersion ver =
+                               r.GetProperty<SecurityTokenVersion> (ReqType.MessageSecurityVersionProperty);
+                       p.SecurityTokenSerializer =
+                               CreateSecurityTokenSerializer (ver);
+
+                       // seems like they are optional here ... (but possibly
+                       // used later)
+                       EndpointAddress address;
+                       if (!r.TryGetProperty<EndpointAddress> (ReqType.IssuerAddressProperty, out address))
+                               address = p.TargetAddress;
+                       p.IssuerAddress = address;
+
+                       // It is somehow not checked as mandatory ...
+                       SecurityAlgorithmSuite suite = null;
+                       r.TryGetProperty<SecurityAlgorithmSuite> (ReqType.SecurityAlgorithmSuiteProperty, out suite);
+                       p.SecurityAlgorithmSuite = suite;
+               }
+
+               // FIXME: it is far from done.
+               SecurityTokenProvider CreateSecureConversationProvider (SecurityTokenRequirement r)
+               {
+                       IssuedSecurityTokenProvider p =
+                               new IssuedSecurityTokenProvider ();
+                       InitializeProviderCommunicationObject (p.Communication, r);
+
+                       // FIXME: use it somewhere.
+                       int keySize = r.KeySize;
+
+                       return p;
+               }
+
+               SecurityTokenProvider CreateSslnegoProvider (SecurityTokenRequirement r)
+               {
+                       SslSecurityTokenProvider p = new SslSecurityTokenProvider (this, r.TokenType == ServiceModelSecurityTokenTypes.MutualSslnego);
+                       InitializeProviderCommunicationObject (p.Communication, r);
+
+                       return p;
+               }
+
+               SecurityTokenProvider CreateSpnegoProvider (SecurityTokenRequirement r)
+               {
+                       SpnegoSecurityTokenProvider p = new SpnegoSecurityTokenProvider (this, r);
+                       InitializeProviderCommunicationObject (p.Communication, r);
+
+                       return p;
+               }
+
+               IssuedSecurityTokenProvider CreateIssuedTokenProvider (SecurityTokenRequirement requirement)
+               {
+                       IssuedSecurityTokenProvider p =
+                               new IssuedSecurityTokenProvider ();
+                       // FIXME: fill properties
+                       EndpointAddress address;
+                       if (requirement.TryGetProperty<EndpointAddress> (ReqType.IssuerAddressProperty, out address))
+                               p.IssuerAddress = address;
+                       if (requirement.TryGetProperty<EndpointAddress> (ReqType.TargetAddressProperty, out address))
+                               p.TargetAddress = address;
+                       Binding binding;
+                       if (requirement.TryGetProperty<Binding> (ReqType.IssuerBindingProperty, out binding))
+                               p.IssuerBinding = binding;
+                       MessageSecurityVersion ver;
+                       if (requirement.TryGetProperty<MessageSecurityVersion> (ReqType.MessageSecurityVersionProperty, out ver))
+                               p.SecurityTokenSerializer = CreateSecurityTokenSerializer (ver.SecurityVersion);
+                       SecurityAlgorithmSuite suite;
+                       if (requirement.TryGetProperty<SecurityAlgorithmSuite> (ReqType.SecurityAlgorithmSuiteProperty, out suite))
+                               p.SecurityAlgorithmSuite = suite;
+                       return p;
+               }
+
+               #endregion
+
+               public override SecurityTokenSerializer CreateSecurityTokenSerializer (SecurityTokenVersion version)
+               {
+                       bool bsp = version.GetSecuritySpecifications ().Contains (Constants.WSBasicSecurityProfileCore1);
+                       SecurityVersion ver =
+                               version.GetSecuritySpecifications ().Contains (Constants.Wss11Namespace) ?
+                               SecurityVersion.WSSecurity11 :
+                               SecurityVersion.WSSecurity10;
+                       return new WSSecurityTokenSerializer (ver, bsp);
+               }
+
+               protected SecurityTokenSerializer CreateSecurityTokenSerializer (SecurityVersion version)
+               {
+                       return new WSSecurityTokenSerializer (version);
+               }
+
+               protected internal bool IsIssuedSecurityTokenRequirement (
+                       SecurityTokenRequirement requirement)
+               {
+                       SecurityTokenParameters ret;
+                       if (!requirement.TryGetProperty<SecurityTokenParameters> (ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty, out ret))
+                               return false;
+                       return ret is IssuedSecurityTokenParameters;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ClientProxyGenerator.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ClientProxyGenerator.cs
new file mode 100644 (file)
index 0000000..ff7bb4d
--- /dev/null
@@ -0,0 +1,136 @@
+//
+// ClientProxyGenerator.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using Mono.CodeGeneration;
+
+namespace System.ServiceModel
+{
+       internal class ClientProxyGenerator
+       {
+               public static Type CreateProxyType (ContractDescription cd)
+               {
+                       string modname = "dummy";
+
+                       // public class __clientproxy_MyContract : ClientRuntimeChannel, [ContractType]
+                       CodeClass c = new CodeModule (modname).CreateClass (
+                               "__clientproxy_" + cd.Name,
+                               typeof (ClientRuntimeChannel),
+                               new Type [] {cd.ContractType});
+
+                       //
+                       // public __clientproxy_MyContract (
+                       //      ClientRuntime arg1, ChannelFactory arg2)
+                       //      : base (arg1, arg2)
+                       // {
+                       // }
+                       //
+                       Type [] ctorargs = new Type [] {typeof (ClientRuntime),
+                               typeof (ChannelFactory)};
+                       CodeMethod ctor = c.CreateConstructor (
+                               MethodAttributes.Public, ctorargs);
+                       CodeBuilder b = ctor.CodeBuilder;
+                       MethodBase baseCtor = typeof (ClientRuntimeChannel).GetConstructor (ctorargs);
+                       if (baseCtor == null) throw new Exception ("INTERNAL ERROR: ClientRuntimeChannel#.ctor(ClientRuntime,ChannelFactory) does not exist.");
+                       b.Call (
+                               ctor.GetThis (),
+                               baseCtor,
+                               new CodeArgumentReference (typeof (ClientRuntime), 1, "arg0"),
+                               new CodeArgumentReference (typeof (ChannelFactory), 2, "arg1"));
+
+                       // member implementation
+                       foreach (OperationDescription od in cd.Operations) {
+                               // FIXME: handle properties and events.
+                               if (od.SyncMethod != null)
+                                       GenerateMethodImpl (c, typeof (ClientRuntimeChannel).GetMethod ("Process"), od.Name, od.SyncMethod);
+                               if (od.BeginMethod != null)
+                                       GenerateMethodImpl (c, typeof (ClientRuntimeChannel).GetMethod ("BeginProcess"), od.Name, od.BeginMethod);
+                               if (od.EndMethod != null)
+                                       GenerateMethodImpl (c, typeof (ClientRuntimeChannel).GetMethod ("EndProcess"), od.Name, od.EndMethod);
+                       }
+
+                       //Type zzz = c.CreateType ();
+                       //((System.Reflection.Emit.AssemblyBuilder) zzz.Assembly).Save (modname + ".dll");
+                       //return zzz;
+                       return c.CreateType ();
+               }
+
+               static void GenerateMethodImpl (CodeClass c, MethodInfo processMethod, string name, MethodInfo mi)
+               {
+                       CodeMethod m = c.ImplementMethod (mi);
+                       CodeBuilder b = m.CodeBuilder;
+                       // object [] parameters = new object [x];
+                       // parameters [0] = arg1;
+                       // parameters [1] = arg2;
+                       // ...
+                       // (return) Process (MethodBase.GetCurrentMethod(), operName, parameters);
+                       ParameterInfo [] pinfos = mi.GetParameters ();
+                       CodeVariableDeclaration paramsDecl = new CodeVariableDeclaration (typeof (object []), "parameters");
+                       b.CurrentBlock.Add (paramsDecl);
+                       CodeVariableReference paramsRef = paramsDecl.Variable;
+                       b.Assign (paramsRef,
+                                 new CodeNewArray (typeof (object), new CodeLiteral (pinfos.Length)));
+                       for (int i = 0; i < pinfos.Length; i++) {
+                               ParameterInfo par = pinfos [i];
+                               if (!par.IsOut)
+                                       b.Assign (
+                                               new CodeArrayItem (paramsRef, new CodeLiteral (i)),
+                                               new CodeCast (typeof (object),
+                                                       new CodeArgumentReference (par.ParameterType, par.Position + 1, "arg" + i)));
+                       }
+                       CodeMethodCall argMethodInfo = new CodeMethodCall (typeof (MethodBase), "GetCurrentMethod");
+                       CodeLiteral argOperName = new CodeLiteral (name);
+                       CodeVariableReference retValue = null;
+                       if (mi.ReturnType == typeof (void))
+                               b.Call (m.GetThis (), processMethod, argMethodInfo, argOperName, paramsRef);
+                       else {
+                               CodeVariableDeclaration retValueDecl = new CodeVariableDeclaration (mi.ReturnType, "retValue");
+                               b.CurrentBlock.Add (retValueDecl);
+                               retValue = retValueDecl.Variable;
+                               b.Assign (retValue,
+                                       new CodeCast (mi.ReturnType,
+                                               b.CallFunc (m.GetThis (), processMethod, argMethodInfo, argOperName, paramsRef)));
+                       }
+                       for (int i = 0; i < pinfos.Length; i++) {
+                               ParameterInfo par = pinfos [i];
+                               if (par.IsOut || par.ParameterType.IsByRef)
+                                       b.Assign (
+                                               new CodeArgumentReference (par.ParameterType, par.Position + 1, "arg" + i),
+                                               new CodeCast (par.ParameterType.GetElementType (),
+                                                       new CodeArrayItem (paramsRef, new CodeLiteral (i))));
+                       }
+                       if (retValue != null)
+                               b.Return (retValue);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs
new file mode 100644 (file)
index 0000000..ae63565
--- /dev/null
@@ -0,0 +1,404 @@
+//
+// ClientRuntimeChannel.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Reflection;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+#if TARGET_DOTNET
+       [MonoTODO]
+       public
+#else
+       internal
+#endif
+       class ClientRuntimeChannel
+               : CommunicationObject, IClientChannel
+       {
+               ClientRuntime runtime;
+               ChannelFactory factory;
+               IRequestChannel request_channel;
+               IOutputChannel output_channel;
+               readonly ProcessDelegate _processDelegate;
+
+               delegate object ProcessDelegate (MethodBase method, string operationName, object [] parameters);
+
+               public ClientRuntimeChannel (ClientRuntime runtime,
+                       ChannelFactory factory)
+               {
+                       this.runtime = runtime;
+                       this.factory = factory;
+                       _processDelegate = new ProcessDelegate (Process);
+               }
+
+               public ClientRuntime Runtime {
+                       get { return runtime; }
+               }
+
+               #region IClientChannel
+
+               [MonoTODO]
+               public bool AllowInitializationUI {
+                       get { throw new NotImplementedException (); }
+                       set { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public bool DidInteractiveInitialization {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public Uri Via {
+                       get { return runtime.Via; }
+               }
+
+               [MonoTODO]
+               public IAsyncResult BeginDisplayInitializationUI (
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void EndDisplayInitializationUI (
+                       IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public void DisplayInitializationUI ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void Dispose ()
+               {
+                       Close ();
+               }
+
+               public event EventHandler<UnknownMessageReceivedEventArgs> UnknownMessageReceived;
+
+               #endregion
+
+               #region IContextChannel
+
+               [MonoTODO]
+               public bool AllowOutputBatching {
+                       get { throw new NotImplementedException (); }
+                       set { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public IInputSession InputSession {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public EndpointAddress LocalAddress {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public TimeSpan OperationTimeout {
+                       get { throw new NotImplementedException (); }
+                       set { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public IOutputSession OutputSession {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public EndpointAddress RemoteAddress {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               public string SessionId {
+                       get { throw new NotImplementedException (); }
+               }
+
+               #endregion
+
+               // CommunicationObject
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return factory.DefaultOpenTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return factory.DefaultCloseTimeout; }
+               }
+
+               protected override void OnAbort ()
+               {
+                       factory.Abort ();
+               }
+
+               protected override IAsyncResult OnBeginClose (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return factory.BeginClose (timeout, callback, state);
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       factory.EndClose (result);
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       factory.Close (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new SystemException ("INTERNAL ERROR: this should not be called (or not supported yet)");
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+               }
+
+               // IChannel
+               public T GetProperty<T> () where T : class
+               {
+                       return factory.GetProperty<T> ();
+               }
+
+               // IExtensibleObject<IContextChannel>
+               [MonoTODO]
+               public IExtensionCollection<IContextChannel> Extensions {
+                       get { throw new NotImplementedException (); }
+               }
+
+               #region Request/Output processing
+
+               public IAsyncResult BeginProcess (MethodBase method, string operationName, object [] parameters) {
+                       object [] param = new object [parameters.Length - 2];
+                       for (int i = 0; i < param.Length; i++)
+                               param [i] = parameters [i];
+                       return _processDelegate.BeginInvoke (method, operationName, param, (AsyncCallback) parameters [parameters.Length - 2], parameters [parameters.Length - 1]);
+               }
+
+               public object EndProcess (MethodBase method, string operationName, object [] parameters) {
+                       return _processDelegate.EndInvoke ((IAsyncResult) parameters [0]);
+               }
+
+               public object Process (MethodBase method, string operationName, object [] parameters)
+               {
+                       OperationDescription od = SelectOperation (method, operationName, parameters);
+                       if (!od.IsOneWay)
+                               return Request (od, parameters);
+                       else {
+                               Output (od, parameters);
+                               return null;
+                       }
+               }
+
+               OperationDescription SelectOperation (MethodBase method, string operationName, object [] parameters)
+               {
+                       string operation;
+                       if (Runtime.OperationSelector != null)
+                               operation = Runtime.OperationSelector.SelectOperation (method, parameters);
+                       else
+                               operation = operationName;
+                       OperationDescription od = factory.Endpoint.Contract.Operations.Find (operation);
+                       if (od == null)
+                               throw new Exception (String.Format ("OperationDescription for operation '{0}' was not found in its internally-generated contract.", operation));
+                       return od;
+               }
+
+               BindingParameterCollection CreateBindingParameters ()
+               {
+                       BindingParameterCollection pl =
+                               new BindingParameterCollection ();
+
+                       ContractDescription cd = factory.Endpoint.Contract;
+                       pl.Add (ChannelProtectionRequirements.CreateFromContract (cd));
+
+                       foreach (IEndpointBehavior behavior in factory.Endpoint.Behaviors)
+                               behavior.AddBindingParameters (factory.Endpoint, pl);
+
+                       return pl;
+               }
+
+               void SetupOutputChannel ()
+               {
+                       if (output_channel != null)
+                               return;
+                       BindingParameterCollection pl =
+                               CreateBindingParameters ();
+                       bool session = false;
+                       switch (factory.Endpoint.Contract.SessionMode) {
+                       case SessionMode.Required:
+                               session = factory.Endpoint.Binding.CanBuildChannelFactory<IOutputSessionChannel> (pl);
+                               if (!session)
+                                       throw new InvalidOperationException ("The contract requires session support, but the binding does not support it.");
+                               break;
+                       case SessionMode.Allowed:
+                               session = !factory.Endpoint.Binding.CanBuildChannelFactory<IOutputChannel> (pl);
+                               break;
+                       }
+
+                       EndpointAddress address = factory.Endpoint.Address;
+                       Uri via = Runtime.Via;
+
+                       if (session) {
+                               IChannelFactory<IOutputSessionChannel> f =
+                                       factory.Endpoint.Binding.BuildChannelFactory<IOutputSessionChannel> (pl);
+                               f.Open ();
+                               output_channel = f.CreateChannel (address, via);
+                       } else {
+                               IChannelFactory<IOutputChannel> f =
+                                       factory.Endpoint.Binding.BuildChannelFactory<IOutputChannel> (pl);
+                               f.Open ();
+                               output_channel = f.CreateChannel (address, via);
+                       }
+
+                       output_channel.Open ();
+               }
+
+               void SetupRequestChannel ()
+               {
+                       if (request_channel != null)
+                               return;
+
+                       BindingParameterCollection pl =
+                               CreateBindingParameters ();
+                       bool session = false;
+                       switch (factory.Endpoint.Contract.SessionMode) {
+                       case SessionMode.Required:
+                               session = factory.Endpoint.Binding.CanBuildChannelFactory<IRequestSessionChannel> (pl);
+                               if (!session)
+                                       throw new InvalidOperationException ("The contract requires session support, but the binding does not support it.");
+                               break;
+                       case SessionMode.Allowed:
+                               session = !factory.Endpoint.Binding.CanBuildChannelFactory<IRequestChannel> (pl);
+                               break;
+                       }
+
+                       EndpointAddress address = factory.Endpoint.Address;
+                       Uri via = Runtime.Via;
+
+                       if (session) {
+                               IChannelFactory<IRequestSessionChannel> f =
+                                       factory.Endpoint.Binding.BuildChannelFactory<IRequestSessionChannel> (pl);
+                               f.Open ();
+                               request_channel = f.CreateChannel (address, via);
+                       } else {
+                               IChannelFactory<IRequestChannel> f =
+                                       factory.Endpoint.Binding.BuildChannelFactory<IRequestChannel> (pl);
+                               f.Open ();
+                               request_channel = f.CreateChannel (address, via);
+                       }
+
+                       request_channel.Open ();
+               }
+
+               void Output (OperationDescription od, object [] parameters)
+               {
+                       SetupOutputChannel ();
+
+                       ClientOperation op = runtime.Operations [od.Name];
+                       Output (CreateRequest (op, parameters));
+               }
+
+               object Request (OperationDescription od, object [] parameters)
+               {
+                       SetupRequestChannel ();
+
+                       ClientOperation op = runtime.Operations [od.Name];
+                       object [] inspections = new object [runtime.MessageInspectors.Count];
+                       Message req = CreateRequest (op, parameters);
+
+                       for (int i = 0; i < inspections.Length; i++)
+                               inspections [i] = runtime.MessageInspectors [i].BeforeSendRequest (ref req, this);
+
+                       Message res = Request (req);
+                       if (res.IsFault) {
+                               MessageFault fault = MessageFault.CreateFault (res, runtime.MaxFaultSize);
+                               if (fault.HasDetail && fault is MessageFault.SimpleMessageFault) {
+                                       MessageFault.SimpleMessageFault simpleFault = fault as MessageFault.SimpleMessageFault;
+                                       object detail = simpleFault.Detail;
+                                       Type t = detail.GetType ();
+                                       Type faultType = typeof (FaultException<>).MakeGenericType (t);
+                                       object [] constructorParams = new object [] { detail, fault.Reason, fault.Code, fault.Actor };
+                                       FaultException fe = (FaultException) Activator.CreateInstance (faultType, constructorParams);
+                                       throw fe;
+                               }
+                               else {
+                                       // given a MessageFault, it is hard to figure out the type of the embedded detail
+                                       throw new FaultException(fault);
+                               }
+                       }
+
+                       for (int i = 0; i < inspections.Length; i++)
+                               runtime.MessageInspectors [i].AfterReceiveReply (ref res, inspections [i]);
+
+                       if (op.DeserializeReply)
+                               return op.GetFormatter ().DeserializeReply (res, parameters);
+                       else
+                               return res;
+               }
+
+               Message Request (Message msg)
+               {
+                       return request_channel.Request (msg, factory.Endpoint.Binding.SendTimeout);
+               }
+
+               void Output (Message msg)
+               {
+                       output_channel.Send (msg, factory.Endpoint.Binding.SendTimeout);
+               }
+
+               Message CreateRequest (ClientOperation op, object [] parameters)
+               {
+                       MessageVersion version = factory.Endpoint.Binding.MessageVersion;
+                       if (version == null)
+                               version = MessageVersion.Default;
+
+                       if (op.SerializeRequest)
+                               return op.GetFormatter ().SerializeRequest (
+                                       version, parameters);
+                       else
+                               return (Message) parameters [0];
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/CommunicationException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/CommunicationException.cs
new file mode 100644 (file)
index 0000000..a41db9a
--- /dev/null
@@ -0,0 +1,42 @@
+//
+// System.ServiceModel.CommunicationException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel {
+       [Serializable]
+       public class CommunicationException : SystemException
+       {
+               public CommunicationException () : base () {}
+               public CommunicationException (string msg) : base (msg) {}
+               public CommunicationException (string msg, Exception inner) : base (msg, inner) {}
+               protected CommunicationException (SerializationInfo info, StreamingContext context)
+                       : base (info, context) {}
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/CommunicationObjectFaultedException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/CommunicationObjectFaultedException.cs
new file mode 100644 (file)
index 0000000..c6fb51e
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// System.ServiceModel.CommunicationObjectFaultedException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel {
+       [Serializable]
+       public class CommunicationObjectFaultedException : CommunicationException
+       {
+               public CommunicationObjectFaultedException () : base () {}
+               public CommunicationObjectFaultedException (string msg) : base (msg) {}
+               public CommunicationObjectFaultedException (string msg, Exception inner)
+                       : base (msg, inner) {}
+               protected CommunicationObjectFaultedException (SerializationInfo info, StreamingContext context)
+                       : base (info, context) {}
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/Constants.cs b/mcs/class/System.ServiceModel/System.ServiceModel/Constants.cs
new file mode 100644 (file)
index 0000000..239a22d
--- /dev/null
@@ -0,0 +1,106 @@
+//
+// Constants.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+namespace System.ServiceModel
+{
+       internal class Constants
+       {
+               public const string WSA1 = "http://www.w3.org/2005/08/addressing";
+
+               public const string WSBasicSecurityProfileCore1 = "http://ws-i.org/profiles/basic-security/core/1.0";
+
+               public const string WsaAnonymousUri = "http://www.w3.org/2005/08/addressing/anonymous";
+               public const string WsaIdentityUri = "http://schemas.xmlsoap.org/ws/2006/02/addressingidentity";
+
+               public const string MSSerialization = "http://schemas.microsoft.com/2003/10/Serialization/";
+
+               public const string WssKeyIdentifierX509Thumbptint = "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1";
+
+               public const string WssBase64BinaryEncodingType = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary";
+
+               public const string WssKeyIdentifierEncryptedKey = "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKeySHA1";
+
+               public const string XmlDsig = "http://www.w3.org/2000/09/xmldsig#";
+
+               public const string WSSSamlToken = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1";
+               public const string WSSX509Token = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3";
+               public const string WssKeyIdentifierSamlAssertion = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID";
+               public const string WSSUserNameToken = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken";
+               public const string WsscContextToken = "http://schemas.xmlsoap.org/ws/2005/02/sc/sct";
+               public const string WSSKerberosToken = "http://docs.oasis-open.org/wss/oasis-wss-kerberos-token-profile-1.1#GSS_Kerberosv5_AP_REQ";
+               public const string WSSEncryptedKeyToken = "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey";
+
+               public const string WstNamespace = "http://schemas.xmlsoap.org/ws/2005/02/trust";
+               public const string WssNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
+               public const string Wss11Namespace = "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd";
+               public const string WspNamespace = "http://schemas.xmlsoap.org/ws/2004/09/policy";
+               public const string WsaNamespace = "http://www.w3.org/2005/08/addressing";
+               public const string WsuNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
+               public const string WsscNamespace = "http://schemas.xmlsoap.org/ws/2005/02/sc";
+               public const string WsidNamespace = "http://schemas.xmlsoap.org/ws/2005/05/identity";
+
+               public const string WstIssueAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue";
+               public const string WstRenewAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Renew";
+               public const string WstCancelAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Cancel";
+               public const string WstValidateAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Validate";
+               public const string WstIssueReplyAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue";
+               public const string WstRenewReplyAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Renew";
+               public const string WstCancelReplyAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Cancel";
+               public const string WstValidateReplyAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Validate";
+
+               public const string WsscDefaultLabel = "WS-SecureConversationWS-SecureConversation";
+
+               // .NET BUG: it requires extra white space !
+               public const string WstBinaryExchangeValueTls = " http://schemas.xmlsoap.org/ws/2005/02/trust/tlsnego";
+               public const string WstBinaryExchangeValueGss = "http://schemas.xmlsoap.org/ws/2005/02/trust/spnego";
+
+               public const string MSTlsnegoTokenContent = "http://schemas.microsoft.com/ws/2006/05/security";
+
+               public const string WstTlsnegoProofTokenType = "http://schemas.xmlsoap.org/2005/02/trust/tlsnego#TLS_Wrap";
+               public const string WstSpnegoProofTokenType = "http://schemas.xmlsoap.org/2005/02/trust/spnego#TLS_Wrap";
+
+               public const string WstIssueRequest = "http://schemas.xmlsoap.org/ws/2005/02/trust/Issue";
+               public const string WstRenewRequest = "http://schemas.xmlsoap.org/ws/2005/02/trust/Renew";
+               public const string WstCancelRequest = "http://schemas.xmlsoap.org/ws/2005/02/trust/Cancel";
+               public const string WstValidateRequest = "http://schemas.xmlsoap.org/ws/2005/02/trust/Validate";
+
+               public const string WstSymmetricKeyTypeUri = "http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey";
+               public const string WstAsymmetricKeyTypeUri = "http://schemas.xmlsoap.org/ws/2005/02/trust/AsymmetricKey";
+
+               public const string LifetimeFormat = "yyyy-MM-dd'T'HH:mm:ss.fffZ";
+
+               // Those OIDs except for Kerberos5 are described here:
+               // http://www.alvestrand.no/objectid/
+               // (searching web for those OIDs would give you pointers.)
+               public const string OidSpnego = "1.3.6.1.5.5.2";
+               public const string OidNtlmSsp = "1.3.6.1.4.1.311.2.2.10";
+               public const string OidKerberos5 = "1.2.840.48018.1.2.2";
+               public const string OidMIT = "1.2.840.113554.1.2.2";
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/DataContractFormatAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/DataContractFormatAttribute.cs
new file mode 100644 (file)
index 0000000..b17c48b
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// DataContractFormatAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Class | AttributeTargets.Interface |
+               AttributeTargets.Method, Inherited = false)]
+       public sealed class DataContractFormatAttribute : Attribute
+       {
+               OperationFormatStyle style;
+
+               public OperationFormatStyle Style {
+                       get { return style; }
+                       set { style = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/DefaultCommunicationTimeouts.cs b/mcs/class/System.ServiceModel/System.ServiceModel/DefaultCommunicationTimeouts.cs
new file mode 100644 (file)
index 0000000..9140e2d
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// DefaultCommunicationTimeouts.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       internal class DefaultCommunicationTimeouts
+               : IDefaultCommunicationTimeouts
+       {
+               public static DefaultCommunicationTimeouts Instance =
+                       new DefaultCommunicationTimeouts ();
+
+               private DefaultCommunicationTimeouts ()
+               {
+                       close = open = send = TimeSpan.FromMinutes (1);
+                       receive = TimeSpan.FromMinutes (10);
+               }
+
+               readonly TimeSpan close, open, receive, send;
+
+               public TimeSpan CloseTimeout {
+                       get { return close; }
+               }
+               public TimeSpan OpenTimeout {
+                       get { return open; }
+               }
+               public TimeSpan ReceiveTimeout {
+                       get { return receive; }
+               }
+               public TimeSpan SendTimeout {
+                       get { return send; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/DeliveryRequirementsAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/DeliveryRequirementsAttribute.cs
new file mode 100644 (file)
index 0000000..6dbfb2c
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// DeliveryRequirementsAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       [AttributeUsage (AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
+       public sealed class DeliveryRequirementsAttribute : Attribute,
+               IContractBehaviorAttribute, IContractBehavior
+       {
+               QueuedDeliveryRequirementsMode queued_delivery_req;
+               bool require_ordered;
+               Type target_contract;
+
+               public QueuedDeliveryRequirementsMode QueuedDeliveryRequirements {
+                       get { return queued_delivery_req; }
+                       set { queued_delivery_req = value; }
+               }
+
+               public bool RequireOrderedDelivery {
+                       get { return require_ordered; }
+                       set { require_ordered = value; }
+               }
+
+               public Type TargetContract {
+                       get { return target_contract; }
+                       set { target_contract = value; }
+               }
+
+               void IContractBehavior.AddBindingParameters (
+                       ContractDescription description,
+                       ServiceEndpoint endpoint,
+                       BindingParameterCollection parameters)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IContractBehavior.ApplyClientBehavior (
+                       ContractDescription description,
+                       ServiceEndpoint endpoint,
+                       ClientRuntime proxy)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IContractBehavior.ApplyDispatchBehavior (
+                       ContractDescription description,
+                       ServiceEndpoint endpoint,
+                       DispatchRuntime dispatch)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               void IContractBehavior.Validate (
+                       ContractDescription description,
+                       ServiceEndpoint endpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/DnsEndpointIdentity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/DnsEndpointIdentity.cs
new file mode 100644 (file)
index 0000000..b5ac514
--- /dev/null
@@ -0,0 +1,50 @@
+//
+// DnsEndpointIdentity.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Claims;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Xml;
+
+
+namespace System.ServiceModel
+{
+       public class DnsEndpointIdentity : EndpointIdentity
+       {
+               public DnsEndpointIdentity (Claim identity)
+               {
+                       Initialize (identity);
+               }
+
+               public DnsEndpointIdentity (string dns)
+                       : this (Claim.CreateDnsClaim (dns))
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/Dummy.cs b/mcs/class/System.ServiceModel/System.ServiceModel/Dummy.cs
new file mode 100644 (file)
index 0000000..d7e9d07
--- /dev/null
@@ -0,0 +1,30 @@
+using System.ServiceModel.Channels;
+
+namespace System.IO
+{
+       public class PipeException : Exception { }
+}
+
+namespace System.ServiceModel
+{
+       public class NamedPipeTransportSecurity { }
+       public class NetNamedPipeBinding : Binding { public override BindingElementCollection CreateBindingElements () { throw new NotImplementedException (); }  public override string Scheme { get { return null; } } }
+       public class NetNamedPipeSecurity { }
+       public class PeerHopCountAttribute { }
+       public class TransactionFlowAttribute { }
+}
+
+namespace System.ServiceModel.Activation.Configuration
+{
+       public class Dummy { }
+}
+
+namespace System.ServiceModel.Channels
+{
+       public class PeerCustomResolverBindingElement { }
+       public class PrivacyNoticeBindingElement { }
+       public class PrivacyNoticeBindingElementImporter { }
+       public class ReliableSessionBindingElement { }
+       public class UseManagedPresentationBindingElementImporter { }
+       public class XmlSerializerImportOptions { }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/DuplexChannelFactory.cs b/mcs/class/System.ServiceModel/System.ServiceModel/DuplexChannelFactory.cs
new file mode 100644 (file)
index 0000000..f839bba
--- /dev/null
@@ -0,0 +1,130 @@
+//
+// DuplexChannelFactory.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Marcos Cobena (marcoscobena@gmail.com)
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+// 
+
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel
+{
+       public class DuplexChannelFactory<TChannel> : ChannelFactory<TChannel>
+       {
+               InstanceContext callback_instance;
+               
+               [MonoTODO]
+               public DuplexChannelFactory (object callbackInstance)
+               {
+               }
+
+               [MonoTODO]
+               public DuplexChannelFactory (object callbackInstance,
+                       string endpointConfigurationName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public DuplexChannelFactory (object callbackInstance,
+                       string endpointConfigurationName,
+                       EndpointAddress remoteAddress)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public DuplexChannelFactory (object callbackInstance,
+                       ServiceEndpoint endpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public DuplexChannelFactory (object callbackInstance,
+                       Binding binding)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public DuplexChannelFactory (object callbackInstance,
+                       Binding binding,
+                       EndpointAddress remoteAddress)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public DuplexChannelFactory (InstanceContext callbackInstance,
+                       Binding binding)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public DuplexChannelFactory (InstanceContext callbackInstance,
+                       Binding binding,
+                       EndpointAddress remoteAddress) : base (binding, remoteAddress)
+               {
+                       callback_instance = callbackInstance;
+               }
+
+               [MonoTODO]
+               public DuplexChannelFactory (InstanceContext callbackInstance,
+                       string endpointConfigurationName,
+                       EndpointAddress remoteAddress)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public DuplexChannelFactory (InstanceContext callbackInstance,
+                       string endpointConfigurationName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public DuplexChannelFactory (InstanceContext callbackInstance,
+                       ServiceEndpoint endpoint)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               [MonoTODO]
+               public static TChannel CreateChannel (InstanceContext callbackInstance, 
+                                                     Binding binding, 
+                                                     EndpointAddress endpointAddress)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/DuplexClientBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel/DuplexClientBase.cs
new file mode 100644 (file)
index 0000000..05593dc
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// DuplexClientBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public class DuplexClientBase<TChannel> : ClientBase<TChannel>
+       {
+               protected DuplexClientBase (InstanceContext instance)
+                       : this (instance, (Binding) null, null)
+               {
+               }
+
+               protected DuplexClientBase (InstanceContext instance,
+                       Binding binding, EndpointAddress address)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected DuplexClientBase (InstanceContext instance,
+                       string configurationName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected DuplexClientBase (InstanceContext instance,
+                       string configurationName, EndpointAddress address)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public IDuplexContextChannel InnerDuplexChannel {
+                       get { throw new NotImplementedException (); }
+               }
+
+               protected override TChannel CreateChannel ()
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddress.cs b/mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddress.cs
new file mode 100644 (file)
index 0000000..c8abca5
--- /dev/null
@@ -0,0 +1,376 @@
+//
+// System.ServiceModel.EndpointAddress.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//        Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005-2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Resources;
+using System.Runtime.Serialization;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel
+{
+       public class EndpointAddress
+       {
+               static readonly Uri w3c_anonymous = new Uri (Constants.WsaAnonymousUri);
+               static readonly Uri anonymous_role = new Uri ("http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/Anonymous");
+               static readonly Uri none_role = new Uri ("http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/None");
+
+               public static Uri AnonymousUri {
+                       get { return anonymous_role; }
+               }
+
+               public static Uri NoneUri {
+                       get { return none_role; }
+               }
+
+               Uri address;
+               AddressHeaderCollection headers;
+               EndpointIdentity identity;
+               XmlDictionaryReader metadata_reader;
+               XmlDictionaryReader extension_reader;
+
+               static XmlSchema schema;
+
+               public EndpointAddress (string uri)
+                       : this (new Uri (uri), new AddressHeader [0])
+               {
+               }
+
+               public EndpointAddress (Uri uri, params AddressHeader [] headers)
+                       : this (uri, null, new AddressHeaderCollection (headers), null, null) {}
+
+               public EndpointAddress (Uri uri, EndpointIdentity identity, params AddressHeader [] headers)
+                       : this (uri, identity, new AddressHeaderCollection (headers), null, null) {}
+
+               public EndpointAddress (Uri uri, EndpointIdentity identity, AddressHeaderCollection headers)
+                       : this (uri, identity, headers, null, null) {}
+
+               public EndpointAddress (
+                       Uri uri, EndpointIdentity identity,
+                       AddressHeaderCollection headers,
+                       XmlDictionaryReader metadataReader,
+                       XmlDictionaryReader extensionReader)
+               {       
+                       if (uri == null)
+                               throw new ArgumentNullException ("uri");
+                       if (!uri.IsAbsoluteUri)
+                               throw new ArgumentException ("The argument uri must be absolute");
+                       this.address = uri;
+                       this.identity = identity;
+                       this.headers = headers;
+                       metadata_reader = metadataReader;
+                       extension_reader = extensionReader;
+               }
+
+               public bool IsAnonymous {
+                       get { return address.Equals (anonymous_role); }
+               }
+
+               public bool IsNone {
+                       get { return address.Equals (none_role); }
+               }
+
+               public AddressHeaderCollection Headers {
+                       get { return headers; }
+               }
+
+               public EndpointIdentity Identity {
+                       get { return identity; }
+               }
+
+               public Uri Uri {
+                       get { return address; }
+               }
+
+               internal static XmlSchema Schema {
+                       get {
+                               if (schema == null) {
+                                       Assembly a = Assembly.GetCallingAssembly ();
+                                       Stream s = a.GetManifestResourceStream ("WS-Addressing.schema");
+                                       schema = XmlSchema.Read (s, null);
+                               }
+
+                               return schema;
+                       }
+               }
+
+               [MonoTODO]
+               public void ApplyTo (Message message)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override bool Equals (object obj)
+               {
+                       EndpointAddress other = obj as EndpointAddress;
+                       if (other == null || 
+                           other.Uri == null || !other.Uri.Equals (this.Uri) ||
+                           other.Headers.Count != this.Headers.Count)
+                               return false;
+
+                       foreach (AddressHeader h in this.Headers) {
+                               bool match = false;
+                               foreach (AddressHeader o in other.Headers)
+                                       if (h.Equals (o)) {
+                                               match = true;
+                                               break;
+                                       }
+                               if (!match)
+                                       return false;
+                       }
+
+                       return true;
+               }
+
+               public override int GetHashCode ()
+               {
+                       return address.GetHashCode ();
+               }
+
+               public XmlDictionaryReader GetReaderAtExtensions ()
+               {
+                       return extension_reader;
+               }
+
+               public XmlDictionaryReader GetReaderAtMetadata ()
+               {
+                       return metadata_reader;
+               }
+
+               public static bool operator == (EndpointAddress address1, EndpointAddress address2)
+               {
+                       if ((object) address1 == null)
+                               return (object) address2 == null;
+                       if ((object) address2 == null)
+                               return false;
+                       return address1.Equals (address2);
+               }
+
+               public static bool operator != (EndpointAddress address1, EndpointAddress address2)
+               {
+                       return ! (address1 == address2);
+               }
+
+               [MonoTODO]
+               public static EndpointAddress ReadFrom (
+                       XmlDictionaryReader reader)
+               {
+                       if (reader == null)
+                               throw new ArgumentNullException ("reader");
+
+                       return ReadFromInternal (null, reader);
+               }
+
+               [MonoTODO]
+               public static EndpointAddress ReadFrom (
+                       AddressingVersion addressingVersion,
+                       XmlDictionaryReader reader)
+               {
+                       return ReadFrom (addressingVersion, (XmlReader) reader);
+               }
+
+               [MonoTODO]
+               public static EndpointAddress ReadFrom (
+                       AddressingVersion addressingVersion,
+                       XmlReader reader)
+               {
+                       if (addressingVersion == null)
+                               throw new ArgumentNullException ("addressingVersion");
+                       if (reader == null)
+                               throw new ArgumentNullException ("reader");
+
+                       return ReadFromInternal (addressingVersion, reader);
+               }
+
+               [MonoTODO]
+               public static EndpointAddress ReadFrom (
+                       XmlDictionaryReader reader,
+                       XmlDictionaryString localName,
+                       XmlDictionaryString ns)
+               {
+                       return ReadFrom (AddressingVersion.WSAddressing10,
+                                        reader, localName, ns);
+               }
+
+
+               [MonoTODO]
+               public static EndpointAddress ReadFrom (
+                       AddressingVersion addressingVersion,
+                       XmlDictionaryReader reader,
+                       XmlDictionaryString localName,
+                       XmlDictionaryString ns)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static EndpointAddress ReadFrom (
+                       AddressingVersion addressingVersion,
+                       XmlReader reader, string localname, string ns)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               private static EndpointAddress ReadFromInternal (
+                       AddressingVersion addressingVersion,
+                       XmlReader reader)
+               {
+                       reader.MoveToContent ();
+                       if (reader.NodeType != XmlNodeType.Element ||
+                           reader.IsEmptyElement)
+                               throw new ArgumentException ("Cannot detect appropriate WS-Addressing Address element.");
+
+                       reader.Read ();
+                       reader.MoveToContent ();
+
+                       if (addressingVersion == null) {
+                               if (reader.NamespaceURI == AddressingVersion.WSAddressing10.Namespace)
+                                       addressingVersion = AddressingVersion.WSAddressing10;
+                               else
+                               if (reader.NamespaceURI == AddressingVersion.WSAddressingAugust2004.Namespace)
+                                       addressingVersion = AddressingVersion.WSAddressingAugust2004;
+                               else
+                                       throw new ArgumentException ("Cannot detect appropriate WS-Addressing version.");
+                       }
+
+                       EndpointAddress ea = ReadContents (addressingVersion, reader);
+
+                       reader.MoveToContent ();
+                       reader.ReadEndElement ();
+                       return ea;
+               }
+               
+               private static EndpointAddress ReadContents (
+                       AddressingVersion addressingVersion, XmlReader reader)
+               {
+                       Uri uri = null;
+                       MetadataSet metadata = null;
+                       EndpointIdentity identity = null;
+                       reader.MoveToContent ();
+                       if (reader.LocalName == "Address" && 
+                           reader.NamespaceURI == addressingVersion.Namespace &&
+                           reader.NodeType == XmlNodeType.Element &&
+                           !reader.IsEmptyElement)
+                               uri = new Uri (reader.ReadElementContentAsString ());
+                       else
+                               throw new XmlException (String.Format (
+                                       "Expecting 'Address' from namespace '{0}', but found '{1}' from namespace '{2}'",
+                                       addressingVersion.Namespace, reader.LocalName, reader.NamespaceURI));
+
+                       reader.MoveToContent ();
+                       if (reader.LocalName == "Metadata" &&
+                           reader.NamespaceURI == addressingVersion.Namespace &&
+                           !reader.IsEmptyElement) {
+                               reader.Read ();
+                               metadata = (MetadataSet) new XmlSerializer (typeof (MetadataSet)).Deserialize (reader);
+                               reader.MoveToContent ();
+                               reader.ReadEndElement ();
+                       }
+                       reader.MoveToContent ();
+                       if (reader.LocalName == "Identity" &&
+                           reader.NamespaceURI == Constants.WsaIdentityUri) {
+                               // FIXME: implement
+                               reader.Skip ();
+                       }
+
+                       if (addressingVersion == AddressingVersion.WSAddressing10 && uri == w3c_anonymous)
+                               uri = anonymous_role;
+
+                       if (metadata == null)
+                               return new EndpointAddress (uri, identity);
+                       return new EndpointAddress (uri, identity,
+                               AddressHeader.CreateAddressHeader (metadata));
+               }
+
+               public override string ToString ()
+               {
+                       return address.ToString (); 
+               }
+
+               [MonoTODO]
+               public void WriteContentsTo (
+                       AddressingVersion addressingVersion,
+                       XmlDictionaryWriter writer)
+               {
+                       if (addressingVersion == AddressingVersion.WSAddressing10) {
+                               ((IXmlSerializable) EndpointAddress10.FromEndpointAddress (this)).WriteXml (writer);
+                       } else {
+                               writer.WriteString (Uri.AbsoluteUri);
+                       }
+               }
+
+               public void WriteContentsTo (
+                       AddressingVersion addressingVersion,
+                       XmlWriter writer)
+               {
+                       WriteContentsTo (addressingVersion,
+                               XmlDictionaryWriter.CreateDictionaryWriter (writer));
+               }
+
+               public void WriteTo (
+                       AddressingVersion addressingVersion,
+                       XmlDictionaryWriter writer)
+               {
+                       WriteTo (addressingVersion, writer, "EndpointReference", addressingVersion.Namespace);
+               }
+
+               public void WriteTo (
+                       AddressingVersion addressingVersion, XmlWriter writer)
+               {
+                       WriteTo (addressingVersion,
+                               XmlDictionaryWriter.CreateDictionaryWriter (writer));
+               }
+
+               public void WriteTo (
+                       AddressingVersion addressingVersion,
+                       XmlDictionaryWriter writer,
+                       XmlDictionaryString localname,
+                       XmlDictionaryString ns)
+               {
+                       writer.WriteStartElement (localname, ns);
+                       WriteContentsTo (addressingVersion, writer);
+                       writer.WriteEndElement ();
+               }
+
+               public void WriteTo (
+                       AddressingVersion addressingVersion,
+                       XmlWriter writer, string localname, string ns)
+               {
+                       writer.WriteStartElement (localname, ns);
+                       WriteContentsTo (addressingVersion, writer);
+                       writer.WriteEndElement ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddress10.cs b/mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddress10.cs
new file mode 100644 (file)
index 0000000..8d7ae77
--- /dev/null
@@ -0,0 +1,121 @@
+//
+// EndpointAddress10.cs
+//
+// Author:
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.Reflection;
+using System.Runtime.Serialization;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel
+{
+       [XmlSchemaProvider ("GetSchema")]
+       [XmlRoot ("EndpointReference", Namespace = "http://www.w3.org/2005/08/addressing")]
+       public class EndpointAddress10 : IXmlSerializable
+       {
+               static readonly Uri w3c_anonymous = new Uri (Constants.WsaAnonymousUri);
+               EndpointAddress address;
+
+               private EndpointAddress10 () // for serialization
+               {
+               }
+
+               internal EndpointAddress10 (EndpointAddress address)
+               {
+                       this.address = address;
+               }
+               
+               public static EndpointAddress10 FromEndpointAddress (EndpointAddress address)
+               {
+                       return new EndpointAddress10 (address);
+               }
+
+               public static XmlQualifiedName GetSchema (XmlSchemaSet xmlSchemaSet)
+               {
+                       if (xmlSchemaSet == null)
+                               throw new ArgumentNullException ("xmlSchemaSet");
+                       xmlSchemaSet.Add (XmlSchema.Read (typeof (EndpointAddress10).Assembly.GetManifestResourceStream ("ws-addr.xsd"), null));
+                       return new XmlQualifiedName ("EndpointReferenceType", Constants.WSA1);
+               }
+
+               public EndpointAddress ToEndpointAddress ()
+               {
+                       return address;
+               }
+
+               XmlSchema IXmlSerializable.GetSchema ()
+               {
+                       return null;
+               }
+
+               void IXmlSerializable.ReadXml (XmlReader reader)
+               {
+                       address = EndpointAddress.ReadFrom (AddressingVersion.WSAddressing10, reader);
+               }
+
+               void IXmlSerializable.WriteXml (XmlWriter writer)
+               {
+                       if (writer == null)
+                               throw new ArgumentNullException ("writer");
+                       writer.WriteStartElement ("Address", Constants.WSA1);
+                       writer.WriteString (address.Uri.AbsoluteUri);
+                       writer.WriteEndElement ();
+
+                       if (address.Identity == null)
+                               return;
+
+                       if (address.Headers != null)
+                               foreach (AddressHeader ah in address.Headers)
+                                       ah.WriteAddressHeader (writer);
+
+                       writer.WriteStartElement ("Identity", Constants.WsaIdentityUri);
+                       X509CertificateEndpointIdentity x509 =
+                               address.Identity as X509CertificateEndpointIdentity;
+                       if (x509 != null) {
+                               KeyInfo ki = new KeyInfo ();
+                               KeyInfoX509Data x = new KeyInfoX509Data ();
+                               foreach (X509Certificate2 cert in x509.Certificates)
+                                       x.AddCertificate (cert);
+                               ki.AddClause (x);
+                               ki.GetXml ().WriteTo (writer);
+                       } else {
+                               DataContractSerializer ds = new DataContractSerializer (address.Identity.IdentityClaim.GetType ());
+                               ds.WriteObject (writer, address.Identity.IdentityClaim);
+                       }
+                       writer.WriteEndElement ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddressAugust2004.cs b/mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddressAugust2004.cs
new file mode 100644 (file)
index 0000000..b28c1af
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// EndpointAddressAugust2004.cs
+//
+// Author:
+//     Ankit Jain <jankit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       [XmlSchemaProvider ("GetSchema")]
+       [XmlRoot ("EndpointReference", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
+       public class EndpointAddressAugust2004 : IXmlSerializable
+       {
+               EndpointAddress address;
+
+               internal EndpointAddressAugust2004 ()
+               {
+               }
+
+               internal EndpointAddressAugust2004 (EndpointAddress address)
+               {
+                       this.address = address;
+               }
+               
+               public static EndpointAddressAugust2004 FromEndpointAddress (EndpointAddress address)
+               {
+                       return new EndpointAddressAugust2004 (address);
+               }
+
+               public static XmlQualifiedName GetSchema (XmlSchemaSet xmlSchemaSet)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public EndpointAddress ToEndpointAddress ()
+               {
+                       return address;
+               }
+
+               XmlSchema IXmlSerializable.GetSchema ()
+               {
+                       return null;
+               }
+
+               void IXmlSerializable.ReadXml (XmlReader reader)
+               {
+                       address = EndpointAddress.ReadFrom (AddressingVersion.WSAddressingAugust2004, reader);
+               }
+
+               void IXmlSerializable.WriteXml (XmlWriter writer)
+               {
+                       address.WriteTo (
+                               AddressingVersion.WSAddressingAugust2004, 
+                               writer, 
+                               "Address", 
+                               AddressingVersion.WSAddressingAugust2004.Namespace);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddressBuilder.cs b/mcs/class/System.ServiceModel/System.ServiceModel/EndpointAddressBuilder.cs
new file mode 100644 (file)
index 0000000..a801c57
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// EndpointAddressBuilder.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Xml;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public class EndpointAddressBuilder
+       {
+               Collection<AddressHeader> headers = new Collection<AddressHeader> ();
+               EndpointIdentity identity;
+               Uri uri;
+               XmlDictionaryReader ext, meta;
+
+               public EndpointAddressBuilder ()
+               {
+               }
+
+               public EndpointAddressBuilder (EndpointAddress address)
+               {
+                       identity = address.Identity;
+                       uri = address.Uri;
+                       foreach (AddressHeader h in address.Headers)
+                               headers.Add (h);
+               }
+
+               public Collection<AddressHeader> Headers {
+                       get { return headers; }
+               }
+
+               [MonoTODO]
+               public EndpointIdentity Identity {
+                       get { return identity; }
+                       set { identity = value; }
+               }
+
+               [MonoTODO]
+               public Uri Uri {
+                       get { return uri; }
+                       set { uri = value; }
+               }
+
+               [MonoTODO]
+               public XmlDictionaryReader GetReaderAtExtensions ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public XmlDictionaryReader GetReaderAtMetadata ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void SetExtensionReader (XmlDictionaryReader reader)
+               {
+                       ext = reader;
+               }
+
+               public void SetMetadataReader (XmlDictionaryReader reader)
+               {
+                       meta = reader;
+               }
+
+               public EndpointAddress ToEndpointAddress ()
+               {
+                       return new EndpointAddress (uri, identity,
+                               new AddressHeaderCollection (headers), meta, ext);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/EndpointIdentity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/EndpointIdentity.cs
new file mode 100644 (file)
index 0000000..71ff2f0
--- /dev/null
@@ -0,0 +1,144 @@
+//
+// EndpointIdentity.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Claims;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Xml;
+
+
+namespace System.ServiceModel
+{
+       public abstract class EndpointIdentity
+       {
+               Claim claim;
+               IEqualityComparer<Claim> comparer;
+
+               protected EndpointIdentity ()
+               {
+               }
+
+               public Claim IdentityClaim {
+                       get { return claim; }
+               }
+
+               public static EndpointIdentity CreateDnsIdentity (string dnsName)
+               {
+                       return new DnsEndpointIdentity (dnsName);
+               }
+
+               public static EndpointIdentity CreateIdentity (Claim identity)
+               {
+                       if (identity == null)
+                               throw new ArgumentNullException ();
+
+                       if (identity.ClaimType == ClaimTypes.Dns)
+                               return CreateDnsIdentity ((string) identity.Resource);
+                       else if (identity.ClaimType == ClaimTypes.Rsa) {
+                               if (identity.Resource is string)
+                                       return CreateRsaIdentity ((string) identity.Resource);
+                               else if (identity.Resource is X509Certificate2)
+                                       return CreateRsaIdentity ((X509Certificate2) identity.Resource);
+                       }
+                       else if (identity.ClaimType == ClaimTypes.Thumbprint)
+                               return CreateX509CertificateIdentity ((X509Certificate2) identity.Resource);
+                       else if (identity.ClaimType == ClaimTypes.Spn)
+                               return CreateSpnIdentity ((string) identity.Resource);
+                       else if (identity.ClaimType == ClaimTypes.Upn)
+                               return CreateSpnIdentity ((string) identity.Resource);
+
+                       throw new NotSupportedException (String.Format ("Claim type '{0}' cannot be used to create an endpoint identity.", identity.ClaimType));
+               }
+
+               public static EndpointIdentity CreateRsaIdentity (string publicKey)
+               {
+                       return new RsaEndpointIdentity (publicKey);
+               }
+
+               public static EndpointIdentity CreateRsaIdentity (
+                       X509Certificate2 certificate)
+               {
+                       return new RsaEndpointIdentity (certificate);
+               }
+
+               public static EndpointIdentity CreateSpnIdentity (string spnName)
+               {
+                       return new SpnEndpointIdentity (spnName);
+               }
+
+               public static EndpointIdentity CreateUpnIdentity (string upnName)
+               {
+                       return new UpnEndpointIdentity (upnName);
+               }
+
+               public static EndpointIdentity CreateX509CertificateIdentity (
+                       X509Certificate2 certificate)
+               {
+                       return new X509CertificateEndpointIdentity (certificate);
+               }
+
+               public static EndpointIdentity CreateX509CertificateIdentity (
+                       X509Certificate2 primaryCertificate,
+                       X509Certificate2Collection supportingCertificates)
+               {
+                       return new X509CertificateEndpointIdentity (primaryCertificate, supportingCertificates);
+               }
+
+               public override bool Equals (object other)
+               {
+                       EndpointIdentity e = other as EndpointIdentity;
+                       return e != null && comparer.Equals (claim, e.claim);
+               }
+
+               public override int GetHashCode ()
+               {
+                       return comparer.GetHashCode (claim);
+               }
+
+               public override string ToString ()
+               {
+                       return String.Concat ("identity(", claim, ")");
+               }
+
+               protected void Initialize (Claim claim)
+               {
+                       Initialize (claim, Claim.DefaultComparer);
+               }
+
+               protected void Initialize (Claim claim, IEqualityComparer<Claim> comparer)
+               {
+                       if (claim == null)
+                               throw new ArgumentNullException ("claim");
+                       if (comparer == null)
+                               throw new ArgumentNullException ("comparer");
+                       this.claim = claim;
+                       this.comparer = comparer;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/EndpointNotFoundException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/EndpointNotFoundException.cs
new file mode 100644 (file)
index 0000000..a3b6448
--- /dev/null
@@ -0,0 +1,42 @@
+//
+// System.ServiceModel.EndpointNotFoundException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel {
+       [Serializable]
+       public class EndpointNotFoundException : CommunicationException
+       {
+               public EndpointNotFoundException () : base () {}
+               public EndpointNotFoundException (string msg) : base (msg) {}
+               public EndpointNotFoundException (string msg, Exception inner) : base (msg, inner) {}
+               protected EndpointNotFoundException (SerializationInfo info, StreamingContext context) :
+                       base (info, context) {}
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/EnvelopeVersion.cs b/mcs/class/System.ServiceModel/System.ServiceModel/EnvelopeVersion.cs
new file mode 100644 (file)
index 0000000..9b0e535
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// System.ServiceModel.EnvelopeVersion.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+
+namespace System.ServiceModel
+{
+
+       public sealed class EnvelopeVersion
+       {
+               const string Soap11NextReceiver = "http://schemas.xmlsoap.org/soap/actor/next";
+               const string Soap12NextReceiver = "http://www.w3.org/2003/05/soap-envelope/role/next";
+               internal const string Soap12UltimateReceiver = "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver";
+
+               string name, uri, next_destination;
+               string [] ultimate_destination;
+
+               static EnvelopeVersion soap11 = new EnvelopeVersion ("Soap11",
+                                                                    "http://schemas.xmlsoap.org/soap/envelope/",
+                                                                    Soap11NextReceiver,
+                                                                    String.Empty,
+                                                                    Soap11NextReceiver);
+
+               static EnvelopeVersion soap12 = new EnvelopeVersion ("Soap12",
+                                                                    "http://www.w3.org/2003/05/soap-envelope",
+                                                                    Soap12NextReceiver,
+                                                                    String.Empty,
+                                                                    Soap12UltimateReceiver,
+                                                                    Soap12NextReceiver);
+
+               static EnvelopeVersion none = new EnvelopeVersion ("None",
+                                                                    String.Empty,
+                                                                    String.Empty,
+                                                                    null);
+
+               EnvelopeVersion (string name, string uri, string next_destination, params string [] ultimate_destination)
+               {
+                       this.name = name;
+                       this.uri = uri;
+                       this.next_destination = next_destination;
+                       this.ultimate_destination = ultimate_destination;
+               }
+
+
+               internal string Namespace { get { return uri; }}
+
+               public static EnvelopeVersion Soap11 {
+                       get {  return soap11; }
+               }
+
+               public static EnvelopeVersion Soap12 {
+                       get { return soap12; }
+               }
+
+               public static EnvelopeVersion None {
+                       get { return none; }
+               }
+
+               public string NextDestinationActorValue {
+                       get { return next_destination; }
+               }
+
+               public string [] GetUltimateDestinationActorValues ()
+               {
+                       return ultimate_destination;
+               }
+
+               public override string ToString ()
+               {
+                       return name + "(" + uri + ")";
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ExceptionDetail.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ExceptionDetail.cs
new file mode 100644 (file)
index 0000000..962df69
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// OperationContext.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005,2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security;
+using System.Threading;
+
+namespace System.ServiceModel
+{
+       [DataContract]
+       public class ExceptionDetail
+       {
+               
+               public ExceptionDetail (Exception exception)
+               {
+                       if (exception == null)
+                               throw new ArgumentNullException ("exception");\r
+                       Message = exception.Message;\r
+                       StackTrace = exception.StackTrace;\r
+                       Type = exception.GetType ().FullName;
+                       if (exception.InnerException != null)\r
+                               InnerException = new ExceptionDetail (exception.InnerException);
+               }
+
+               [DataMember]
+               public string HelpLink {
+                       get; 
+                       private set;
+               }
+
+               //[DataMember]\r
+               public ExceptionDetail InnerException {\r
+                       get;\r
+                       private set;\r
+               }
+
+               [DataMember]
+               public string Message {
+                       get;
+                       private set;
+               }
+
+               [DataMember]
+               public string StackTrace {
+                       get;
+                       private set;
+               }
+
+               [DataMember]
+               public string Type {
+                       get;
+                       private set;
+               }
+
+               public override string ToString ()
+               {
+                       return Message;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ExtensionCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ExtensionCollection.cs
new file mode 100644 (file)
index 0000000..570362c
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// ExtensionCollection.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace System.ServiceModel
+{
+       public sealed class ExtensionCollection<T>
+               : SynchronizedCollection<IExtension<T>>,
+               IExtensionCollection<T>, ICollection<IExtension<T>>, 
+               IEnumerable<IExtension<T>>, IEnumerable
+               where T : IExtensibleObject<T>
+       {
+               T owner;
+
+               public ExtensionCollection (T owner)
+                       : this (owner, new object ())
+               {
+               }
+
+               public ExtensionCollection (T owner, object syncRoot)
+                       : base (syncRoot)
+               {
+                       this.owner = owner;
+               }
+
+               public E Find<E> ()
+               {
+                       foreach (IExtension<T> item in this)
+                               if (item is E)
+                                       return (E) (object) item;
+                       return default (E);
+               }
+
+               public Collection<E> FindAll<E> ()
+               {
+                       Collection<E> c = new Collection<E> ();
+                       foreach (IExtension<T> item in this)
+                               if (item is E)
+                                       c.Add ((E) (object) item);
+                       return c;
+               }
+
+               bool ICollection<IExtension<T>>.IsReadOnly {
+                       get { return false; }
+               }
+
+               [MonoTODO]
+               protected override void ClearItems ()
+               {
+                       // FIXME: threadsafe?
+                       for (int i = 0; i < Count; i++) {
+                               this [i].Detach (owner);
+                       }
+                       base.ClearItems ();
+               }
+
+               [MonoTODO]
+               protected override void InsertItem (int index, IExtension<T> item)
+               {
+                       // FIXME: threadsafe?
+                       item.Attach (owner);
+                       base.InsertItem (index, item);
+               }
+
+               [MonoTODO]
+               protected override void RemoveItem (int index)
+               {
+                       // FIXME: threadsafe?
+                       this [index].Detach (owner);
+                       base.RemoveItem (index);
+               }
+
+               [MonoTODO]
+               protected override void SetItem (int index, IExtension<T> item)
+               {
+                       // FIXME: threadsafe?
+                       this [index].Detach (owner);
+                       item.Attach (owner);
+                       base.SetItem (index, item);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/FaultCode.cs b/mcs/class/System.ServiceModel/System.ServiceModel/FaultCode.cs
new file mode 100644 (file)
index 0000000..c33159b
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// System.ServiceModel.FaultCode.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel
+{
+       public class FaultCode
+       {
+               string name, ns;
+               FaultCode subcode;
+               
+               public FaultCode (string name)
+                       : this (name, String.Empty)
+               {
+               }
+
+               public FaultCode (string name, string ns)
+                       : this (name, ns, null)
+               {
+               }
+
+               public FaultCode (string name, FaultCode subcode)
+                       : this (name, String.Empty, subcode)
+               {
+               }
+
+               public FaultCode (string name, string ns, FaultCode subcode)
+               {
+                       this.name = name;
+                       this.ns = ns;
+                       this.subcode = subcode;
+               }
+
+               public bool IsPredefinedFault {
+                       get { return ns == String.Empty; }
+               }
+
+               public bool IsReceiverFault {
+                       get { return name == "Receiver"; }
+               }
+       
+               public bool IsSenderFault {
+                       get { return name == "Sender"; }
+               }
+               
+               public string Name {
+                       get { return name; }
+               }
+
+               public string Namespace {
+                       get { return ns; }
+               }
+
+               public FaultCode SubCode {
+                       get { return subcode; }
+               }
+
+               public static FaultCode CreateReceiverFaultCode (FaultCode subcode)
+               {
+                       return new FaultCode ("Receiver", subcode);
+               }
+
+               public static FaultCode CreateReceiverFaultCode (string name, string ns)
+               {
+                       return CreateReceiverFaultCode (new FaultCode (name, ns));
+               }
+               
+               public static FaultCode CreateSenderFaultCode (FaultCode subcode)
+               {
+                       return new FaultCode ("Sender", subcode);
+               }
+
+               public static FaultCode CreateSenderFaultCode (string name, string ns)
+               {
+                       return CreateSenderFaultCode (new FaultCode (name, ns));
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/FaultContractAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/FaultContractAttribute.cs
new file mode 100644 (file)
index 0000000..1e25f2c
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// FaultContractAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Net.Security;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Method, Inherited = false, AllowMultiple = true)]
+       public sealed class FaultContractAttribute : Attribute
+       {
+               string action, name, ns;
+               Type detail_type;
+               ProtectionLevel protection_level;
+               bool has_protection_level;
+
+               public FaultContractAttribute (Type detailType)
+               {
+                       detail_type = detailType;
+               }
+
+               public string Action {
+                       get { return action; }
+                       set { action = value; }
+               }
+
+               public Type DetailType {
+                       get { return detail_type; }
+               }
+
+               public bool HasProtectionLevel {
+                       get { return has_protection_level; }
+               }
+
+               public ProtectionLevel ProtectionLevel {
+                       get { return protection_level; }
+                       set {
+                               protection_level = value;
+                               has_protection_level = true;
+                       }
+               }
+
+               public string Name {
+                       get { return name; }
+                       set { name = value; }
+               }
+
+               public string Namespace {
+                       get { return ns; }
+                       set { ns = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/FaultException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/FaultException.cs
new file mode 100644 (file)
index 0000000..cd00fef
--- /dev/null
@@ -0,0 +1,137 @@
+//
+// System.ServiceModel.FaultException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//        Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       [Serializable]
+       public class FaultException : CommunicationException
+       {
+               MessageFault fault;
+               string action;
+
+               public FaultException ()
+                       : this ("Communication has faulted.")
+               {
+               }
+
+               public FaultException (string msg)
+                       : this (new FaultReason (msg))
+               {
+               }
+
+               public FaultException (string msg, FaultCode code)
+                       : this (new FaultReason (msg), code)
+               {
+               }
+
+               [MonoTODO]
+               protected FaultException (SerializationInfo info, StreamingContext context)
+                       : base (info, context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public FaultException (MessageFault fault)
+                       : this (fault, String.Empty)
+               {
+               }
+
+               public FaultException (MessageFault fault, string action)
+               {
+                       if (fault == null)
+                               throw new ArgumentNullException ("fault");
+                       //if (action == null)
+                       //      throw new ArgumentNullException ("action");
+
+                       this.fault = fault;
+                       this.action = action;
+               }
+
+               [MonoTODO]
+               public FaultException (FaultReason reason)
+                       : this (reason, new FaultCode (String.Empty))
+               {
+               }
+
+               public FaultException (FaultReason reason, FaultCode code)
+                       : this (MessageFault.CreateFault (code, reason))
+               {
+               }
+
+               public FaultException (string reason, FaultCode code, string action)
+                       : this (MessageFault.CreateFault (code, reason), action)
+               {
+               }
+
+               public FaultException (FaultReason reason, FaultCode code, string action)
+                       : this (MessageFault.CreateFault (code, reason), action)
+               {
+               }
+
+               [MonoTODO]
+               public static FaultException CreateFault (MessageFault fault,  params Type [] details)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public virtual MessageFault CreateMessageFault ()
+               {
+                       return fault;
+               }
+
+               [MonoTODO]
+               public override void GetObjectData (SerializationInfo info, StreamingContext context)
+               {
+                       // How could it be Serializable while none of
+                       // FaultReason and FaultCode are serializable.
+                       throw new NotImplementedException ();
+               }
+
+               public string Action {
+                       get { return action; }
+               }
+
+               public FaultCode Code {
+                       get { return fault.Code; }
+               }
+
+               public FaultReason Reason {
+                       get{ return fault.Reason; }
+               }
+
+               public override string Message {
+                       get { return Reason.GetMatchingTranslation ().Text; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/FaultException_1.cs b/mcs/class/System.ServiceModel/System.ServiceModel/FaultException_1.cs
new file mode 100644 (file)
index 0000000..9727098
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// System.ServiceModel.FaultException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       [Serializable]
+       public class FaultException<TDetail> : FaultException
+       {
+               TDetail detail;
+
+               public FaultException (TDetail detail)
+                       : this (detail, "Unspecified ServiceModel Fault.")
+               {
+               }
+
+               [MonoTODO]
+               protected FaultException (SerializationInfo info, StreamingContext context)
+                       : base (info, context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public FaultException (TDetail detail, string reason)
+                       : this (detail, new FaultReason (reason)) {}
+               
+               public FaultException (TDetail detail, FaultReason reason)
+                       : this (detail, reason, FaultCode.CreateSenderFaultCode (null)) {}
+
+               public FaultException (TDetail detail, string reason, FaultCode code)
+                       : this (detail, new FaultReason (reason), code) {}
+               
+               public FaultException (TDetail detail, FaultReason reason, FaultCode code)
+                       : this (detail, reason, code, null) {}
+
+               public FaultException (TDetail detail, string reason, FaultCode code, string action)
+                       : this (detail, new FaultReason (reason), code, action) {}
+
+               public FaultException (TDetail detail, FaultReason reason, FaultCode code, string action)
+                       : base (reason, code, action)
+               {
+                       this.detail = detail;
+               }
+
+               public override MessageFault CreateMessageFault ()
+               {
+                       return MessageFault.CreateFault (Code, Reason, detail);
+               }
+
+               [MonoTODO ("see FaultException.TestGetObjectData to see how it's serialized")]
+               public override void GetObjectData (SerializationInfo info, StreamingContext context)
+               {
+                       base.GetObjectData (info, context);
+                       info.AddValue ("detail", detail);
+               }
+
+               public override string ToString ()
+               {
+                       return String.Format ("{0}: {1} (Fault Detail is equal to {2}).",
+                                             this.GetType (), Message, Detail);
+               }
+
+               public TDetail Detail { get { return detail ; } }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/FaultReason.cs b/mcs/class/System.ServiceModel/System.ServiceModel/FaultReason.cs
new file mode 100644 (file)
index 0000000..a865a94
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// FaultReason.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Globalization;
+
+using TextList = System.Collections.Generic.SynchronizedReadOnlyCollection<System.ServiceModel.FaultReasonText>;
+
+namespace System.ServiceModel
+{
+       public class FaultReason
+       {
+               List<FaultReasonText> trans = new List<FaultReasonText> ();
+               TextList public_trans;
+
+               public FaultReason (FaultReasonText translation)
+               {
+                       if (translation == null)
+                               throw new ArgumentNullException ("translation");
+                       trans.Add (translation);
+               }
+
+               public FaultReason (IEnumerable<FaultReasonText> translations)
+               {
+                       if (translations == null)
+                               throw new ArgumentNullException ("translations");
+                       foreach (FaultReasonText t in translations)
+                               trans.Add (t);
+                       if (trans.Count == 0)
+                               throw new ArgumentException ("The argument list should contain at least one fault reason text.");
+               }
+
+               public FaultReason (string text)
+                       : this (new FaultReasonText (text))
+               {
+               }
+
+               public TextList Translations {
+                       get {
+                               if (public_trans == null)
+                                       public_trans = new TextList (new object (), trans);
+                               return public_trans;
+                       }
+               }
+
+               public FaultReasonText GetMatchingTranslation ()
+               {
+                       return GetMatchingTranslation (CultureInfo.CurrentCulture);
+               }
+
+               public FaultReasonText GetMatchingTranslation (
+                       CultureInfo cultureInfo)
+               {
+                       foreach (FaultReasonText t in trans)
+                               if (t.Matches (cultureInfo))
+                                       return t;
+                       return trans [0];
+               }
+
+               public override string ToString ()
+               {
+                       return GetMatchingTranslation ().Text;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/FaultReasonText.cs b/mcs/class/System.ServiceModel/System.ServiceModel/FaultReasonText.cs
new file mode 100644 (file)
index 0000000..4d0773b
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// FaultReasonText.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Globalization;
+
+namespace System.ServiceModel
+{
+       public class FaultReasonText
+       {
+               readonly string text, xmllang;
+
+               public FaultReasonText (string text)
+                       : this (text, CultureInfo.CurrentCulture)
+               {
+               }
+
+               public FaultReasonText (string text, CultureInfo cultureInfo)
+                       : this (text, cultureInfo.Name)
+               {
+               }
+
+               public FaultReasonText (string text, string xmlLang)
+               {
+                       this.text = text;
+                       this.xmllang = xmlLang;
+               }
+
+               public string Text {
+                       get { return text; }
+               }
+
+               public string XmlLang {
+                       get { return xmllang; }
+               }
+
+               public bool Matches (CultureInfo cultureInfo)
+               {
+                       if (cultureInfo.Name == xmllang)
+                               return true;
+                       if (cultureInfo.Parent != null)
+                               return cultureInfo.Parent.Name == xmllang;
+                       else
+                               return false;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/FederatedMessageSecurityOverHttp.cs b/mcs/class/System.ServiceModel/System.ServiceModel/FederatedMessageSecurityOverHttp.cs
new file mode 100644 (file)
index 0000000..b32db8c
--- /dev/null
@@ -0,0 +1,101 @@
+//
+// FederatedMessageSecurityOverHttp.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       public sealed class FederatedMessageSecurityOverHttp
+       {
+               SecurityAlgorithmSuite algorithm =
+                       SecurityAlgorithmSuite.Default;
+               SecurityKeyType issued_key_type;
+               string issued_token_type;
+               EndpointAddress issuer_address, metadata_address;
+               Binding issuer_binding;
+               bool negotiate = true;
+               Collection<ClaimTypeRequirement> claim_type_reqs =
+                       new Collection<ClaimTypeRequirement> ();
+               Collection<XmlElement> request_params = new Collection<XmlElement> ();
+
+               internal FederatedMessageSecurityOverHttp ()
+               {
+               }
+
+               public SecurityAlgorithmSuite AlgorithmSuite {
+                       get { return algorithm; }
+                       set { algorithm = value; }
+               }
+
+               public SecurityKeyType IssuedKeyType {
+                       get { return issued_key_type; }
+                       set { issued_key_type = value; }
+               }
+
+               public string IssuedTokenType {
+                       get { return issued_token_type; }
+                       set { issued_token_type = value; }
+               }
+
+               public EndpointAddress IssuerAddress {
+                       get { return issuer_address; }
+                       set { issuer_address = value; }
+               }
+
+               public Binding IssuerBinding {
+                       get { return issuer_binding; }
+                       set { issuer_binding = value; }
+               }
+
+               public EndpointAddress IssuerMetadataAddress {
+                       get { return metadata_address; }
+                       set { metadata_address = value; }
+               }
+
+               public bool NegotiateServiceCredential {
+                       get { return negotiate; }
+                       set { negotiate = value; }
+               }
+
+               public Collection<ClaimTypeRequirement> ClaimTypeRequirements {
+                       get { return claim_type_reqs; }
+               }
+
+               public Collection<XmlElement> TokenRequestParameters {
+                       get { return request_params; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/HttpTransportSecurity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/HttpTransportSecurity.cs
new file mode 100644 (file)
index 0000000..0a39b2e
--- /dev/null
@@ -0,0 +1,62 @@
+//
+// HttpTransportSecurity.cs
+//
+// Author:
+//     Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       public sealed class HttpTransportSecurity
+       {
+               HttpClientCredentialType client;
+               HttpProxyCredentialType proxy;
+               string realm = String.Empty;
+
+               internal HttpTransportSecurity ()
+               {
+               }
+
+               [MonoTODO]
+               public HttpClientCredentialType ClientCredentialType {
+                       get { return client; }
+                       set { client = value; }
+               }
+
+               [MonoTODO]
+               public HttpProxyCredentialType ProxyCredentialType {
+                       get { return proxy; }
+                       set { proxy = value; }
+               }
+
+               [MonoTODO]
+               public string Realm {
+                       get { return realm; }
+                       set { realm = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/IClientChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel/IClientChannel.cs
new file mode 100644 (file)
index 0000000..4bdac49
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// IClientChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public interface IClientChannel : IContextChannel, ICommunicationObject,
+               IDisposable
+       {
+               // Properties
+
+               bool AllowInitializationUI { get; set; }
+
+               bool DidInteractiveInitialization { get; }
+
+               Uri Via { get; }
+
+               // Methods
+
+               IAsyncResult BeginDisplayInitializationUI (AsyncCallback callback, object state);
+               void EndDisplayInitializationUI(IAsyncResult result);
+
+               void DisplayInitializationUI ();
+
+               // Event
+
+               event EventHandler<UnknownMessageReceivedEventArgs>
+                       UnknownMessageReceived;
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ICommunicationObject.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ICommunicationObject.cs
new file mode 100644 (file)
index 0000000..d06d51a
--- /dev/null
@@ -0,0 +1,62 @@
+//
+// System.ServiceModel.ICommunicationObject.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel {
+
+       public interface ICommunicationObject
+       {
+               CommunicationState State { get; }
+
+               void Abort ();
+
+               IAsyncResult BeginClose (AsyncCallback callback, object state);
+
+               IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state);
+
+               IAsyncResult BeginOpen (AsyncCallback callback, object state);
+
+               IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state);
+
+               void Close ();
+
+               void Close (TimeSpan timeout);
+
+               void EndClose (IAsyncResult result);
+
+               void EndOpen (IAsyncResult result);
+
+               void Open ();
+
+               void Open (TimeSpan timeout);
+
+               event EventHandler Closed;
+               event EventHandler Closing;
+               event EventHandler Faulted;
+               event EventHandler Opened;
+               event EventHandler Opening;
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/IContextChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel/IContextChannel.cs
new file mode 100644 (file)
index 0000000..ab34cf3
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// IContextChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public interface IContextChannel : IChannel, ICommunicationObject,
+               IExtensibleObject<IContextChannel>
+       {
+               // Properties
+
+               bool AllowOutputBatching { get; set; }
+
+               IInputSession InputSession { get; }
+
+               EndpointAddress LocalAddress { get; }
+
+               TimeSpan OperationTimeout { get; set; }
+
+               IOutputSession OutputSession { get; }
+
+               EndpointAddress RemoteAddress { get; }
+
+               string SessionId { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/IDefaultCommunicationTimeouts.cs b/mcs/class/System.ServiceModel/System.ServiceModel/IDefaultCommunicationTimeouts.cs
new file mode 100644 (file)
index 0000000..d0ede99
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// IDefaultCommunicationTimeouts.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       public interface IDefaultCommunicationTimeouts
+       {
+               TimeSpan CloseTimeout { get; }
+               TimeSpan OpenTimeout { get; }
+               TimeSpan ReceiveTimeout { get; }
+               TimeSpan SendTimeout { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/IDuplexClientChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel/IDuplexClientChannel.cs
new file mode 100644 (file)
index 0000000..96f6e5f
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// IDuplexContextChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public interface IDuplexContextChannel : IContextChannel, IChannel,
+               ICommunicationObject
+       {
+               bool AutomaticInputSessionShutdown { get; set; }
+
+               InstanceContext CallbackInstance { get; set; }
+
+               IAsyncResult BeginCloseOutputSession (TimeSpan timeout,
+                       AsyncCallback callback, object state);
+
+               void CloseOutputSession (TimeSpan timeout);
+
+               void EndCloseOutputSession (IAsyncResult result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/IExtensibleObject.cs b/mcs/class/System.ServiceModel/System.ServiceModel/IExtensibleObject.cs
new file mode 100644 (file)
index 0000000..64789ba
--- /dev/null
@@ -0,0 +1,34 @@
+//
+// IExtensibleObject.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+namespace System.ServiceModel
+{
+       public interface IExtensibleObject<T> where T : IExtensibleObject<T>
+       {
+               IExtensionCollection<T> Extensions { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/IExtension.cs b/mcs/class/System.ServiceModel/System.ServiceModel/IExtension.cs
new file mode 100644 (file)
index 0000000..a9efe46
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// IExtension<T>.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       public interface IExtension<T> where T : IExtensibleObject<T>
+       {
+               void Attach (T owner);
+               void Detach (T owner);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/IExtensionCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel/IExtensionCollection.cs
new file mode 100644 (file)
index 0000000..bad102e
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// IExtensionCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace System.ServiceModel
+{
+       public interface IExtensionCollection<T> : ICollection<IExtension<T>>,
+               IEnumerable<IExtension<T>>, IEnumerable
+               where T : IExtensibleObject<T>
+       {
+               E Find<E> ();
+               Collection<E> FindAll<E> ();
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/IServiceChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel/IServiceChannel.cs
new file mode 100644 (file)
index 0000000..1084627
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// IServiceChannel.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public interface IServiceChannel : IContextChannel, ICommunicationObject
+       {
+               Uri ListenUri { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/InstanceContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel/InstanceContext.cs
new file mode 100644 (file)
index 0000000..a881e16
--- /dev/null
@@ -0,0 +1,212 @@
+//
+// InstanceContext.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       public sealed class InstanceContext : CommunicationObject,
+               IExtensibleObject<InstanceContext>
+       {
+               ServiceHostBase host;
+               object implementation;
+               int manual_flow_limit;
+               InstanceBehavior _behavior;
+               bool is_user_instance_provider;
+               bool is_user_context_provider;
+
+               static InstanceContextIdleCallback idle_callback = new InstanceContextIdleCallback(NotifyIdle);
+
+               public InstanceContext (object implementation)
+                       : this (null, implementation)
+               {
+               }
+
+               public InstanceContext (ServiceHostBase host)
+                       : this (host, null)
+               {
+               }
+
+               public InstanceContext (ServiceHostBase host,
+                       object implementation) : this(host, implementation, true)
+               {}
+
+               internal InstanceContext(ServiceHostBase host, 
+                       object implementation, bool userContextProvider)
+               {
+                       this.host = host;
+                       this.implementation = implementation;
+                       is_user_context_provider = userContextProvider;
+               }
+
+               internal bool IsUserProvidedInstance {
+                       get {
+                               return is_user_instance_provider;
+                       }
+               }
+
+               internal bool IsUserProvidedContext {
+                       get {
+                               return is_user_context_provider;                                
+                       }
+               }
+
+               internal InstanceBehavior Behavior {
+                       get {
+                               return _behavior;
+                       }
+                       set {
+                               _behavior = value;
+                       }
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return host.DefaultCloseTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return host.DefaultOpenTimeout; }
+               }
+
+               public IExtensionCollection<InstanceContext> Extensions {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public ServiceHostBase Host {
+                       get { return host; }
+               }
+
+               public ICollection<IChannel> IncomingChannels {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public int ManualFlowControlLimit {
+                       get { return manual_flow_limit; }
+                       set { manual_flow_limit = value; }
+               }
+
+               public ICollection<IChannel> OutgoingChannels {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public object GetServiceInstance ()
+               {
+                       return GetServiceInstance (null);
+               }
+
+               public object GetServiceInstance (Message message)
+               {
+                       if (implementation == null && Behavior != null) {
+                               implementation = Behavior.GetServiceInstance (this, message, ref is_user_instance_provider);                            
+                       }
+                       return implementation;                          
+               }
+
+               public void IncrementManualFlowControlLimit (int incrementBy)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               internal void CloseIfIdle () {
+                       if (Behavior.InstanceContextProvider != null && !IsUserProvidedContext) {
+                               if (!Behavior.InstanceContextProvider.IsIdle (this)) {
+                                       Behavior.InstanceContextProvider.NotifyIdle (IdleCallback, this);
+                               }
+                               else {
+                                       if (State != CommunicationState.Closed)
+                                               Close ();
+                               }
+                       }
+               }
+
+               static void NotifyIdle (InstanceContext ctx) {
+                       ctx.CloseIfIdle ();
+               }               
+
+               internal InstanceContextIdleCallback IdleCallback {
+                       get {
+                               return idle_callback;
+                       }
+               }
+
+               public void ReleaseServiceInstance ()
+               {                       
+                       Behavior.ReleaseServiceInstance (this, implementation);
+                       implementation = null;
+               }
+
+               protected override void OnAbort ()
+               {
+               }
+
+               protected override void OnClosed ()
+               {
+               }
+
+               protected override void OnOpened ()
+               {
+               }
+
+               protected override void OnOpening () {
+                       if (Behavior != null)
+                               Behavior.Initialize (this);
+                       base.OnOpening ();
+               }
+
+               protected override IAsyncResult OnBeginOpen (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+               }
+
+               protected override IAsyncResult OnBeginClose (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+               }               
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/InvalidMessageContractException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/InvalidMessageContractException.cs
new file mode 100644 (file)
index 0000000..fe787f2
--- /dev/null
@@ -0,0 +1,42 @@
+//
+// System.ServiceModel.InvalidMessageContractException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel {
+       [Serializable]
+       public class InvalidMessageContractException : SystemException
+       {
+               public InvalidMessageContractException () : base () {}
+               public InvalidMessageContractException (string msg) : base (msg) {}
+               public InvalidMessageContractException (string msg, Exception inner) : base (msg, inner) {}
+               protected InvalidMessageContractException (SerializationInfo info, StreamingContext context) :
+                       base (info, context) {}
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageBodyAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageBodyAttribute.cs
new file mode 100644 (file)
index 0000000..18edc5b
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// MessageBodyMemberAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Property | AttributeTargets.Field,
+               Inherited = false)]
+       public class MessageBodyMemberAttribute : MessageContractMemberAttribute
+       {
+               int order = -1;
+
+               public int Order {
+                       get { return order; }
+                       set { order = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageContractAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageContractAttribute.cs
new file mode 100644 (file)
index 0000000..36d2716
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// MessageContractAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net.Security;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct)]
+       public sealed class MessageContractAttribute : Attribute
+       {
+               bool has_protection_level, is_wrapped = true;
+               string name, ns;
+               ProtectionLevel protection_level;
+
+               public bool HasProtectionLevel {
+                       get { return has_protection_level; }
+               }
+
+               public ProtectionLevel ProtectionLevel {
+                       get { return protection_level; }
+                       set {
+                               protection_level = value;
+                               has_protection_level = true;
+                       }
+               }
+
+               public bool IsWrapped {
+                       get { return is_wrapped; }
+                       set { is_wrapped = value; }
+               }
+
+               public string WrapperName {
+                       get { return name; }
+                       set { name = value; }
+               }
+
+               public string WrapperNamespace {
+                       get { return ns; }
+                       set { ns = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageContractMemberAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageContractMemberAttribute.cs
new file mode 100644 (file)
index 0000000..8f5b1e4
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// MessageContractMemberAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net.Security;
+
+namespace System.ServiceModel
+{
+       public abstract class MessageContractMemberAttribute : Attribute
+       {
+               bool has_protection_level;
+               string name, ns;
+               ProtectionLevel protection_level;
+
+               public bool HasProtectionLevel {
+                       get { return has_protection_level; }
+               }
+
+               public string Name {
+                       get { return name; }
+                       set { name = value; }
+               }
+
+               public string Namespace {
+                       get { return ns; }
+                       set { ns = value; }
+               }
+
+               public ProtectionLevel ProtectionLevel {
+                       get { return protection_level; }
+                       set {
+                               has_protection_level = true;
+                               protection_level = value;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageHeaderArrayAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageHeaderArrayAttribute.cs
new file mode 100644 (file)
index 0000000..13c6f86
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// MessageHeaderArrayAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Property | AttributeTargets.Field,
+               Inherited = false)]
+       public sealed class MessageHeaderArrayAttribute : MessageHeaderAttribute
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageHeaderAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageHeaderAttribute.cs
new file mode 100644 (file)
index 0000000..c2fef6c
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// MessageHeaderAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Property | AttributeTargets.Field,
+               Inherited = false)]
+       public class MessageHeaderAttribute : MessageContractMemberAttribute
+       {
+               string actor;
+               bool must_understand, relay;
+
+               public string Actor {
+                       get { return actor; }
+                       set { actor = value; }
+               }
+
+               public bool MustUnderstand {
+                       get { return must_understand; }
+                       set { must_understand = value; }
+               }
+
+               public bool Relay {
+                       get { return relay; }
+                       set { relay = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageHeaderException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageHeaderException.cs
new file mode 100644 (file)
index 0000000..3adc589
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// MessageHeaderException.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel {
+       [Serializable]
+       public class MessageHeaderException : ProtocolException
+       {
+               public MessageHeaderException () : base () {}
+               public MessageHeaderException (string msg) : base (msg) {}
+               public MessageHeaderException (string msg, Exception inner) : base (msg, inner) {}
+               protected MessageHeaderException (SerializationInfo info, StreamingContext context) :
+                       base (info, context) {}
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageHeader_1.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageHeader_1.cs
new file mode 100644 (file)
index 0000000..0481478
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// System.ServiceModel.MessageHeader.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Text;
+using System.Xml;
+
+// I think it is incorrectly put in this namespace ...
+namespace System.ServiceModel
+{
+       public class MessageHeader<T>
+       {
+               T content;
+               string actor;
+               bool must_understand, relay;
+
+               XmlObjectSerializer formatter;
+               
+               public MessageHeader ()
+                       : this (default (T), false, null, false)
+               {
+               }
+
+               public MessageHeader (T content)
+                       : this (content, false, null, false)
+               {
+               }
+
+               public MessageHeader (T content, bool must_understand, string actor, bool relay)
+               {
+                       this.content = content;
+                       this.must_understand = must_understand;
+                       this.actor = actor;
+                       this.relay = relay;
+               }
+
+               public MessageHeader GetUntypedHeader (string name, string ns)
+               {
+                       if (formatter == null)
+                               formatter = new DataContractSerializer (typeof (T));
+                       // FIXME: how to handle IsReferenceParameter
+                       return new MessageHeader.DefaultMessageHeader (
+                               name, ns, content, formatter, false, must_understand, actor, relay);
+               }
+
+               public string Actor {
+                       get { return actor; }
+                       set { actor = value; }
+               }
+
+               public T Content {
+                       get { return content; }
+                       set { content = value; }
+               }
+
+               public bool MustUnderstand {
+                       get { return must_understand; }
+                       set { must_understand = value; }
+               }
+
+               public bool Relay {
+                       get { return relay; }
+                       set { relay = value; }
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageParameterAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageParameterAttribute.cs
new file mode 100644 (file)
index 0000000..e691b6b
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// MessageParameterAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Parameter | AttributeTargets.ReturnValue,
+               Inherited = false)]
+       public sealed class MessageParameterAttribute : Attribute
+       {
+               string name;
+
+               public MessageParameterAttribute ()
+               {
+               }
+
+               public string Name {
+                       get { return name; }
+                       set { name = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessagePropertyAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessagePropertyAttribute.cs
new file mode 100644 (file)
index 0000000..8f55904
--- /dev/null
@@ -0,0 +1,47 @@
+//
+// MessagePropertyAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Property | AttributeTargets.Field,
+               Inherited = false)]
+       public sealed class MessagePropertyAttribute : Attribute
+       {
+               string name;
+
+               public MessagePropertyAttribute ()
+               {
+               }
+
+               public string Name {
+                       get { return name; }
+                       set { name = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityOverHttp.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityOverHttp.cs
new file mode 100644 (file)
index 0000000..5b226a7
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// MessageSecurityOverHttp.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+       public class MessageSecurityOverHttp
+       {
+               SecurityAlgorithmSuite alg_suite;
+               MessageCredentialType client_credential_type;
+               bool negotiate_service_credential;
+
+               internal MessageSecurityOverHttp ()
+               {
+                       alg_suite = SecurityAlgorithmSuite.Default;
+                       // This default value is *silly* but anyways such
+                       // it is silly to expect that such code that does not 
+                       // change ClientCredentialType works on Mono.
+                       client_credential_type = MessageCredentialType.Windows;
+                       negotiate_service_credential = true;
+               }
+
+               public SecurityAlgorithmSuite AlgorithmSuite {
+                       get { return alg_suite; }
+                       set { alg_suite = value; }
+               }
+
+               public MessageCredentialType ClientCredentialType {
+                       get { return client_credential_type; }
+                       set { client_credential_type = value; }
+               }
+
+               public bool NegotiateServiceCredential {
+                       get { return negotiate_service_credential; }
+                       set { negotiate_service_credential = value; }
+               }
+
+               protected virtual bool IsSecureConversationEnabled ()
+               {
+                       return true;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityOverMsmq.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityOverMsmq.cs
new file mode 100644 (file)
index 0000000..f466e01
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// MessageSecurityOverMsmq.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+       public sealed class MessageSecurityOverMsmq
+       {
+               SecurityAlgorithmSuite suite;
+               MessageCredentialType cred;
+
+               internal MessageSecurityOverMsmq ()
+               {
+               }
+
+               public SecurityAlgorithmSuite AlgorithmSuite {
+                       get { return suite; }
+                       set { suite = value; }
+               }
+
+               public MessageCredentialType ClientCredentialType {
+                       get { return cred; }
+                       set { cred = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityOverTcp.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityOverTcp.cs
new file mode 100644 (file)
index 0000000..c7852cd
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// MessageSecurityOverTcp.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+       public sealed class MessageSecurityOverTcp
+       {
+               SecurityAlgorithmSuite alg_suite;
+               MessageCredentialType client_credential_type;
+
+               internal MessageSecurityOverTcp ()
+               {
+                       alg_suite = SecurityAlgorithmSuite.Default;
+                       // This default value is *silly* but anyways
+                       // such code that does not change this ClientCredentialType 
+                       // won't work on Mono.
+                       client_credential_type = MessageCredentialType.Windows;
+               }
+
+               public SecurityAlgorithmSuite AlgorithmSuite {
+                       get { return alg_suite; }
+                       set { alg_suite = value; }
+               }
+
+               public MessageCredentialType ClientCredentialType {
+                       get { return client_credential_type; }
+                       set { client_credential_type = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityVersion.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MessageSecurityVersion.cs
new file mode 100644 (file)
index 0000000..414a07d
--- /dev/null
@@ -0,0 +1,163 @@
+//
+// MessageSecurityVersion.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel.Description;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel
+{
+       public abstract class MessageSecurityVersion
+       {
+               // Types
+               class MessageSecurityTokenVersion : SecurityTokenVersion
+               {
+                       static string [] specs10_profile_source, specs11_source, specs11_profile_source;
+                       static readonly MessageSecurityTokenVersion wss10basic, wss11, wss11basic;
+
+
+                       static MessageSecurityTokenVersion ()
+                       {
+                               specs10_profile_source = new string [] {
+                                       Constants.WssNamespace,
+                                       Constants.WstNamespace,
+                                       Constants.WsscNamespace,
+                                       Constants.WSBasicSecurityProfileCore1,
+                                       };
+                               specs11_source = new string [] {
+                                       Constants.Wss11Namespace,
+                                       Constants.WstNamespace,
+                                       Constants.WsscNamespace,
+                                       };
+                               specs11_profile_source = new string [] {
+                                       Constants.Wss11Namespace,
+                                       Constants.WstNamespace,
+                                       Constants.WsscNamespace,
+                                       Constants.WSBasicSecurityProfileCore1,
+                                       };
+
+                               wss10basic = new MessageSecurityTokenVersion (false, true);
+                               wss11basic = new MessageSecurityTokenVersion (true, true);
+                               wss11 = new MessageSecurityTokenVersion (true, false);
+                       }
+
+                       public static MessageSecurityTokenVersion GetVersion (bool isWss11, bool basicProfile)
+                       {
+                               if (isWss11)
+                                       return basicProfile ? wss11basic : wss11;
+                               else
+                                       return wss10basic;
+                       }
+
+                       ReadOnlyCollection<string> specs;
+
+                       MessageSecurityTokenVersion (bool wss11, bool basicProfile)
+                       {
+                               string [] src;
+                               if (wss11)
+                                       src = basicProfile ? specs11_profile_source : specs11_source;
+                               else
+                                       src = basicProfile ? specs10_profile_source : null;
+                               specs = new ReadOnlyCollection<string> (src);
+                       }
+
+                       public override ReadOnlyCollection<string> GetSecuritySpecifications ()
+                       {
+                               return specs;
+                       }
+               }
+
+               class MessageSecurityVersionImpl : MessageSecurityVersion
+               {
+                       bool wss11, basic_profile;
+
+                       public MessageSecurityVersionImpl (bool wss11, bool basicProfile)
+                       {
+                               this.wss11 = wss11;
+                               this.basic_profile = basicProfile;
+                       }
+
+                       public override BasicSecurityProfileVersion BasicSecurityProfileVersion {
+                               get { return basic_profile ? BasicSecurityProfileVersion.BasicSecurityProfile10 : null; }
+                       }
+
+                       public override SecurityTokenVersion SecurityTokenVersion {
+                               get { return MessageSecurityTokenVersion.GetVersion (wss11, basic_profile); }
+                       }
+
+                       public override SecurityVersion SecurityVersion {
+                               get { return wss11 ? SecurityVersion.WSSecurity11 : SecurityVersion.WSSecurity10; }
+                       }
+               }
+
+               // Static members
+
+               static MessageSecurityVersion wss10_basic, wss11, wss11_basic;
+
+               static MessageSecurityVersion ()
+               {
+                       wss10_basic = new MessageSecurityVersionImpl (false, true);
+                       wss11 = new MessageSecurityVersionImpl (true, false);
+                       wss11_basic = new MessageSecurityVersionImpl (true, true);
+               }
+
+               public static MessageSecurityVersion Default {
+                       get { return wss11; }
+               }
+
+               // guys, have you ever seen such silly member names??
+
+               public static MessageSecurityVersion WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10 {
+                       get { return wss10_basic; }
+               }
+
+               public static MessageSecurityVersion WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11 {
+                       get { return wss11; }
+               }
+
+               public static MessageSecurityVersion WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10 {
+                       get { return wss11_basic; }
+               }
+
+               // Instance members
+
+               MessageSecurityVersion ()
+               {
+               }
+
+               public abstract BasicSecurityProfileVersion BasicSecurityProfileVersion { get; }
+
+               public abstract SecurityTokenVersion SecurityTokenVersion { get; }
+
+               public abstract SecurityVersion SecurityVersion { get; }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MsmqBindingBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MsmqBindingBase.cs
new file mode 100644 (file)
index 0000000..cfca728
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// MsmqBindingBase.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel
+{
+       public abstract class MsmqBindingBase : Binding, IBindingRuntimePreferences
+       {
+               Uri custom_dead_letter_queue;
+               DeadLetterQueue dead_letter_queue = DeadLetterQueue.System;
+               bool durable = true, exactly_once = true, use_msmq_trace, use_source_journal;
+               int max_retry_cycles = 2, receive_retry_count = 5;
+               long max_recv_msg_size = 0x10000;
+               ReceiveErrorHandling receive_error_handling;
+               TimeSpan retry_cycle_delay = TimeSpan.FromMinutes (30), ttl = TimeSpan.FromDays (1);
+
+               public Uri CustomDeadLetterQueue {
+                       get { return custom_dead_letter_queue; }
+                       set { custom_dead_letter_queue = value; }
+               }
+
+               public DeadLetterQueue DeadLetterQueue {
+                       get { return dead_letter_queue; }
+                       set { dead_letter_queue = value; }
+               }
+
+               public bool Durable {
+                       get { return durable; }
+                       set { durable = value; }
+               }
+
+               public bool ExactlyOnce {
+                       get { return exactly_once; }
+                       set { exactly_once = value; }
+               }
+
+               public long MaxReceivedMessageSize {
+                       get { return max_recv_msg_size; }
+                       set { max_recv_msg_size = value; }
+               }
+
+               public int MaxRetryCycles {
+                       get { return max_retry_cycles; }
+                       set { max_retry_cycles = value; }
+               }
+
+               public ReceiveErrorHandling ReceiveErrorHandling {
+                       get { return receive_error_handling; }
+                       set { receive_error_handling = value; }
+               }
+
+               public int ReceiveRetryCount {
+                       get { return receive_retry_count; }
+                       set { receive_retry_count = value; }
+               }
+
+               public TimeSpan RetryCycleDelay {
+                       get { return retry_cycle_delay; }
+                       set { retry_cycle_delay = value; }
+               }
+
+               public TimeSpan TimeToLive {
+                       get { return ttl; }
+                       set { ttl = value; }
+               }
+
+               public override string Scheme {
+                       get {
+                               foreach (BindingElement be in CreateBindingElements ())
+                                       if (be is TransportBindingElement)
+                                               return ((TransportBindingElement) be).Scheme;
+                               throw new Exception ("INTERNAL ERROR: no TransportBindingElement was created.");
+                       }
+               }
+
+               public bool UseMsmqTracing {
+                       get { return use_msmq_trace; }
+                       set { use_msmq_trace = value; }
+               }
+
+               public bool UseSourceJournal {
+                       get { return use_source_journal; }
+                       set { use_source_journal = value; }
+               }
+
+               [MonoTODO]
+               bool IBindingRuntimePreferences.ReceiveSynchronously {
+                       get { throw new NotImplementedException (); }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MsmqException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MsmqException.cs
new file mode 100644 (file)
index 0000000..223cd81
--- /dev/null
@@ -0,0 +1,45 @@
+//
+// MsmqException.cs
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel
+{
+       [Serializable]
+       public class MsmqException : ExternalException
+       {
+               public MsmqException () : base () {}
+               public MsmqException (string msg) : base (msg) {}
+               public MsmqException (string msg, int win32ErrorCode) : base (msg, win32ErrorCode) {}
+               public MsmqException (string msg, Exception inner) : base (msg, inner) {}
+               protected MsmqException (SerializationInfo info, StreamingContext context) :
+                       base (info, context) {}
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MsmqPoisonMessageException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MsmqPoisonMessageException.cs
new file mode 100644 (file)
index 0000000..57fc6fe
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// MsmqPoisonMessageException.cs
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel
+{
+       [Serializable]
+       public class MsmqPoisonMessageException : PoisonMessageException
+       {
+               public MsmqPoisonMessageException () : base () {}
+               public MsmqPoisonMessageException (string msg) : base (msg) {}
+               public MsmqPoisonMessageException (string msg, Exception inner) : base (msg, inner) {}
+               protected MsmqPoisonMessageException (SerializationInfo info, StreamingContext context) :
+                       base (info, context) {}
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/MsmqTransportSecurity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/MsmqTransportSecurity.cs
new file mode 100644 (file)
index 0000000..f6732c4
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// MsmqTransportSecurity.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Net.Security;
+
+namespace System.ServiceModel
+{
+       public sealed class MsmqTransportSecurity
+       {
+               MsmqAuthenticationMode auth;
+               MsmqEncryptionAlgorithm enc;
+               MsmqSecureHashAlgorithm hash;
+               ProtectionLevel protection_level;
+
+               public MsmqTransportSecurity ()
+               {
+               }
+
+               public MsmqTransportSecurity (MsmqTransportSecurity other)
+               {
+               }
+
+               public MsmqAuthenticationMode MsmqAuthenticationMode {
+                       get { return auth; }
+                       set { auth = value; }
+               }
+
+               public MsmqEncryptionAlgorithm MsmqEncryptionAlgorithm {
+                       get { return enc; }
+                       set { enc = value; }
+               }
+
+               public MsmqSecureHashAlgorithm MsmqSecureHashAlgorithm {
+                       get { return hash; }
+                       set { hash = value; }
+               }
+
+               public ProtectionLevel MsmqProtectionLevel {
+                       get { return protection_level; }
+                       set { protection_level = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/NetMsmqBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel/NetMsmqBinding.cs
new file mode 100644 (file)
index 0000000..3b3d8a2
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// NetMsmqBinding.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Xml;
+
+namespace System.ServiceModel
+{
+       public class NetMsmqBinding : MsmqBindingBase
+       {
+               NetMsmqSecurity security;
+               bool use_ad;
+               long max_buffer_pool_size = 0x80000;
+               QueueTransferProtocol queue_tr_protocol;
+               XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas ();
+               EnvelopeVersion envelope_version = EnvelopeVersion.Soap12;
+
+               public NetMsmqBinding ()
+                       : this (NetMsmqSecurityMode.None)
+               {
+               }
+
+               public NetMsmqBinding (NetMsmqSecurityMode securityMode)
+               {
+                       security = new NetMsmqSecurity (securityMode);
+               }
+
+               [MonoTODO]
+               public NetMsmqBinding (string configurationName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public NetMsmqSecurity Security {
+                       get { return security; }
+               }
+
+               public EnvelopeVersion EnvelopeVersion {
+                       get { return envelope_version; }
+               }
+
+               public long MaxBufferPoolSize {
+                       get { return max_buffer_pool_size; }
+                       set { max_buffer_pool_size = value; }
+               }
+
+               public QueueTransferProtocol QueueTransferProtocol {
+                       get { return queue_tr_protocol; }
+                       set { queue_tr_protocol = value; }
+               }
+
+               public XmlDictionaryReaderQuotas ReaderQuotas {
+                       get { return quotas; }
+                       set { quotas = value; }
+               }
+
+               public bool UseActiveDirectory {
+                       get { return use_ad; }
+                       set { use_ad = value; }
+               }
+
+               public override BindingElementCollection CreateBindingElements ()
+               {
+                       BinaryMessageEncodingBindingElement be =
+                               new BinaryMessageEncodingBindingElement ();
+                       quotas.CopyTo (be.ReaderQuotas);
+                       MsmqTransportBindingElement te =
+                               new MsmqTransportBindingElement ();
+                       te.MaxPoolSize = (int) MaxBufferPoolSize;
+                       te.QueueTransferProtocol = QueueTransferProtocol;
+                       te.UseActiveDirectory = UseActiveDirectory;
+                       te.CustomDeadLetterQueue = CustomDeadLetterQueue;
+                       te.DeadLetterQueue = DeadLetterQueue;
+                       te.Durable = Durable;
+                       te.ExactlyOnce = ExactlyOnce;
+                       te.MaxReceivedMessageSize = MaxReceivedMessageSize;
+                       te.MaxRetryCycles = MaxRetryCycles;
+                       te.MsmqTransportSecurity.MsmqAuthenticationMode = Security.Transport.MsmqAuthenticationMode;
+                       te.MsmqTransportSecurity.MsmqEncryptionAlgorithm = Security.Transport.MsmqEncryptionAlgorithm;
+                       te.MsmqTransportSecurity.MsmqProtectionLevel = Security.Transport.MsmqProtectionLevel;
+                       te.MsmqTransportSecurity.MsmqSecureHashAlgorithm = Security.Transport.MsmqSecureHashAlgorithm;
+                       te.ReceiveErrorHandling = ReceiveErrorHandling;
+                       te.ReceiveRetryCount = ReceiveRetryCount;
+                       te.RetryCycleDelay = RetryCycleDelay;
+                       te.TimeToLive = TimeToLive;
+                       te.UseMsmqTracing = UseMsmqTracing;
+                       te.UseSourceJournal = UseSourceJournal;\r
+\r
+                       return new BindingElementCollection (new BindingElement [] { be, te });
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/NetMsmqSecurity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/NetMsmqSecurity.cs
new file mode 100644 (file)
index 0000000..737cda7
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// NetMsmqSecurity.cs
+//
+// Author: Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+       public sealed class NetMsmqSecurity
+       {
+               NetMsmqSecurityMode mode;
+               MessageSecurityOverMsmq message = new MessageSecurityOverMsmq ();
+               MsmqTransportSecurity transport = new MsmqTransportSecurity ();
+
+               internal NetMsmqSecurity (NetMsmqSecurityMode mode)
+               {
+               }
+
+               public MessageSecurityOverMsmq Message {
+                       get { return message; }
+               }
+
+               public NetMsmqSecurityMode Mode {
+                       get { return mode; }
+                       set { mode = value; }
+               }
+
+               public MsmqTransportSecurity Transport {
+                       get { return transport; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/NetPeerTcpBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel/NetPeerTcpBinding.cs
new file mode 100644 (file)
index 0000000..038100f
--- /dev/null
@@ -0,0 +1,177 @@
+//
+// NetPeerTcpBinding.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//     Marcos Cobena (marcoscobena@gmail.com)
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.PeerResolvers;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel
+{
+       public class NetPeerTcpBinding : Binding,
+               IBindingDeliveryCapabilities, IBindingMulticastCapabilities,
+               ISecurityCapabilities, IBindingRuntimePreferences
+       {
+               string listen_ip_address;
+               long max_buffer_pool_size = 0x80000;
+               long max_recv_message_size = 0x10000;
+               bool msg_auth;
+               int port;
+               XmlDictionaryReaderQuotas reader_quotas;
+//             PeerResolver resolver = new PeerResolverImpl ();
+               PeerResolverSettings resolver = new PeerResolverSettings ();
+               PeerSecuritySettings security = new PeerSecuritySettings ();
+
+               public NetPeerTcpBinding ()
+               {
+               }
+
+               [MonoTODO]
+               public NetPeerTcpBinding (string configurationName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public string ListenIPAddress {
+                       get { return listen_ip_address; }
+                       set { listen_ip_address = value; }
+               }
+
+               public long MaxBufferPoolSize {
+                       get { return max_buffer_pool_size; }
+                       set { max_buffer_pool_size = value; }
+               }
+
+               public bool MessageAuthentication {
+                       get { return msg_auth; }
+                       set { msg_auth = value; }
+               }
+
+               public long MaxReceivedMessageSize {
+                       get { return max_recv_message_size; }
+                       set { max_recv_message_size = value; }
+               }
+
+               [MonoTODO]
+               public int Port {
+                       get { return port; }
+                       set { port = value; }
+               }
+
+               [MonoTODO]
+               public PeerResolverSettings Resolver {
+                       get { return resolver; }
+                       set { resolver = value; }
+               }
+
+               public XmlDictionaryReaderQuotas ReaderQuotas {
+                       get { return reader_quotas; }
+                       set { reader_quotas = value; }
+               }
+
+               public override string Scheme {
+                       get { return "net.p2p"; }
+               }
+               
+               public PeerSecuritySettings Security {
+                       get { return security; }
+               }
+
+               public EnvelopeVersion SoapVersion {
+                       get { return EnvelopeVersion.Soap12; }
+               }
+
+               public override BindingElementCollection
+                       CreateBindingElements ()
+               {
+                       BinaryMessageEncodingBindingElement mbe = 
+                               new BinaryMessageEncodingBindingElement ();
+                       ReaderQuotas.CopyTo (mbe.ReaderQuotas);
+
+                       PeerTransportBindingElement tbe =
+                               new PeerTransportBindingElement ();
+                       tbe.ListenIPAddress = ListenIPAddress;
+                       tbe.MaxBufferPoolSize = MaxBufferPoolSize;
+                       tbe.MaxReceivedMessageSize = MaxReceivedMessageSize;
+                       tbe.MessageAuthentication = MessageAuthentication;
+
+                       return new BindingElementCollection (new BindingElement [] { mbe, tbe });
+               }
+
+               // explicit interface implementations
+
+               [MonoTODO]
+               bool IBindingDeliveryCapabilities.AssuresOrderedDelivery {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               bool IBindingDeliveryCapabilities.QueuedDelivery {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               bool IBindingRuntimePreferences.ReceiveSynchronously {
+                       get { throw new NotImplementedException (); }
+               }
+
+               bool IBindingMulticastCapabilities.IsMulticast {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               ProtectionLevel ISecurityCapabilities.SupportedRequestProtectionLevel {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               ProtectionLevel ISecurityCapabilities.SupportedResponseProtectionLevel {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               bool ISecurityCapabilities.SupportsClientAuthentication {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               bool ISecurityCapabilities.SupportsClientWindowsIdentity {
+                       get { throw new NotImplementedException (); }
+               }
+
+               [MonoTODO]
+               bool ISecurityCapabilities.SupportsServerAuthentication {
+                       get { throw new NotImplementedException (); }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/NetTcpBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel/NetTcpBinding.cs
new file mode 100644 (file)
index 0000000..28a000c
--- /dev/null
@@ -0,0 +1,217 @@
+//
+// NetTcpBinding.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security.Tokens;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       public class NetTcpBinding : Binding, IBindingRuntimePreferences
+       {
+               HostNameComparisonMode comparison_mode;
+               long max_pool_size;
+               int max_buf_size;
+               int max_conn;
+               long max_msg_size;
+               OptionalReliableSession reliable_session;
+               NetTcpSecurity security;
+               XmlDictionaryReaderQuotas reader_quotas;
+               EnvelopeVersion soap_version;
+               bool transaction_flow;
+               TransactionProtocol transaction_protocol;
+               TransferMode transfer_mode;
+               TcpTransportBindingElement transport = new TcpTransportBindingElement ();
+
+               public NetTcpBinding ()
+                       : this (SecurityMode.Message)
+               {
+               }
+
+               public NetTcpBinding (SecurityMode securityMode)
+                       : this (securityMode, false)
+               {
+               }
+
+               public NetTcpBinding (SecurityMode securityMode,
+                       bool reliableSessionEnabled)
+               {
+                       security = new NetTcpSecurity (securityMode);
+               }
+
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return comparison_mode; }
+                       set { comparison_mode = value; }
+               }
+
+               public int ListenBacklog {
+                       get { return transport.ListenBacklog; }
+                       set { transport.ListenBacklog = value; }
+               }
+
+               public long MaxBufferPoolSize {
+                       get { return max_pool_size; }
+                       set { max_pool_size = value; }
+               }
+
+               public int MaxBufferSize {
+                       get { return max_buf_size; }
+                       set { max_buf_size = value; }
+               }
+
+               public int MaxConnections {
+                       get { return max_conn; }
+                       set { max_conn = value; }
+               }
+
+               public long MaxReceivedMessageSize {
+                       get { return max_msg_size; }
+                       set { max_msg_size = value; }
+               }
+
+               public bool PortSharingEnabled {
+                       get { return transport.PortSharingEnabled; }
+                       set { transport.PortSharingEnabled = value; }
+               }
+
+               public OptionalReliableSession ReliableSession {
+                       get { return reliable_session; }
+               }
+
+               public XmlDictionaryReaderQuotas ReaderQuotas {
+                       get { return reader_quotas; }
+                       set { reader_quotas = value; }
+               }
+
+               public NetTcpSecurity Security {
+                       get { return security; }
+               }
+
+               public EnvelopeVersion EnvelopeVersion {
+                       get { return soap_version; }
+               }
+
+               public TransferMode TransferMode {
+                       get { return transfer_mode; }
+                       set { transfer_mode = value; }
+               }
+
+               public bool TransactionFlow {
+                       get { return transaction_flow; }
+                       set { transaction_flow = value; }
+               }
+
+               public TransactionProtocol TransactionProtocol {
+                       get { return transaction_protocol; }
+                       set { transaction_protocol = value; }
+               }
+
+               // overrides
+
+               public override string Scheme {
+                       get { return "net.tcp"; }
+               }
+
+               public override BindingElementCollection CreateBindingElements ()
+               {
+                       BindingElement tx = new TransactionFlowBindingElement (TransactionProtocol.WSAtomicTransactionOctober2004);
+                       SecurityBindingElement sec = CreateMessageSecurity ();
+                       BindingElement msg = new BinaryMessageEncodingBindingElement ();
+                       BindingElement tr = GetTransport ();
+                       List<BindingElement> list = new List<BindingElement> ();
+                       if (tx != null)
+                               list.Add (tx);
+                       if (sec != null)
+                               list.Add (sec);
+                       list.Add (msg);
+                       list.Add (tr);
+                       return new BindingElementCollection (list.ToArray ());
+               }
+
+               BindingElement GetTransport ()
+               {
+                       return transport.Clone ();
+               }
+
+               // based on WSHttpBinding.CreateMessageSecurity()
+               SecurityBindingElement CreateMessageSecurity ()
+               {
+                       if (Security.Mode == SecurityMode.Transport ||
+                           Security.Mode == SecurityMode.None)
+                               return null;
+
+                       SymmetricSecurityBindingElement element =
+                               new SymmetricSecurityBindingElement ();
+
+                       element.MessageSecurityVersion = MessageSecurityVersion.Default;
+
+                       element.SetKeyDerivation (false);
+
+                       switch (Security.Message.ClientCredentialType) {
+                       case MessageCredentialType.Certificate:
+                               element.EndpointSupportingTokenParameters.Endorsing.Add (
+                                       new X509SecurityTokenParameters ());
+                               goto default;
+                       case MessageCredentialType.IssuedToken:
+                               IssuedSecurityTokenParameters istp =
+                                       new IssuedSecurityTokenParameters ();
+                               // FIXME: issuer binding must be secure.
+                               istp.IssuerBinding = new CustomBinding (
+                                       new TextMessageEncodingBindingElement (),
+                                       GetTransport ());
+                               element.EndpointSupportingTokenParameters.Endorsing.Add (istp);
+                               goto default;
+                       case MessageCredentialType.UserName:
+                               element.EndpointSupportingTokenParameters.SignedEncrypted.Add (
+                                       new UserNameSecurityTokenParameters ());
+                               goto default;
+                       case MessageCredentialType.Windows:
+                               element.ProtectionTokenParameters =
+                                       new KerberosSecurityTokenParameters ();
+                               break;
+                       default: // including .None
+                               X509SecurityTokenParameters p =
+                                       new X509SecurityTokenParameters ();
+                               p.X509ReferenceStyle = X509KeyIdentifierClauseType.Thumbprint;
+                               element.ProtectionTokenParameters = p;
+                               break;
+                       }
+
+                       return element;
+               }
+
+               bool IBindingRuntimePreferences.ReceiveSynchronously {
+                       get { throw new NotImplementedException (); }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/NetTcpSecurity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/NetTcpSecurity.cs
new file mode 100644 (file)
index 0000000..c5065a1
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// NetTcpSecurity.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public sealed class NetTcpSecurity
+       {
+               internal NetTcpSecurity (SecurityMode mode)
+               {
+                       this.mode = mode;
+                       this.message = new MessageSecurityOverTcp ();
+                       this.transport = new TcpTransportSecurity ();
+               }
+
+               MessageSecurityOverTcp message;
+               SecurityMode mode;
+               TcpTransportSecurity transport;
+
+               public MessageSecurityOverTcp Message {
+                       get { return message; }
+               }
+
+               public SecurityMode Mode {
+                       get { return mode; }
+                       set { mode = value; }
+               }
+
+               public TcpTransportSecurity Transport {
+                       get { return transport; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/NonDualMessageSecurityOverHttp.cs b/mcs/class/System.ServiceModel/System.ServiceModel/NonDualMessageSecurityOverHttp.cs
new file mode 100644 (file)
index 0000000..ac5880f
--- /dev/null
@@ -0,0 +1,45 @@
+//
+// NonDualMessageSecurityOverHttp.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       public sealed class NonDualMessageSecurityOverHttp : MessageSecurityOverHttp
+       {
+               bool establish_sec_ctx = true;
+
+               internal NonDualMessageSecurityOverHttp ()
+               {
+               }
+
+               [MonoTODO]
+               public bool EstablishSecurityContext {
+                       get { return establish_sec_ctx; }
+                       set { establish_sec_ctx = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/OperationBehaviorAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/OperationBehaviorAttribute.cs
new file mode 100644 (file)
index 0000000..fd88fe9
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// OperationBehaviorAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Runtime.Serialization;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Method)]
+       public sealed class OperationBehaviorAttribute : Attribute,
+               IOperationBehavior
+       {
+               ImpersonationOption impersonation;
+               bool tx_auto_complete, tx_scope_required;
+               ReleaseInstanceMode mode;
+
+               public ImpersonationOption Impersonation {
+                       get { return impersonation; }
+                       set { impersonation = value; }
+               }
+
+               public ReleaseInstanceMode ReleaseInstanceMode {
+                       get { return mode; }
+                       set { mode = value; }
+               }
+
+               public bool TransactionAutoComplete {
+                       get { return tx_auto_complete; }
+                       set { tx_auto_complete = value; }
+               }
+
+               public bool TransactionScopeRequired {
+                       get { return tx_scope_required; }
+                       set { tx_scope_required = value; }
+               }
+
+               [MonoTODO]
+               void IOperationBehavior.AddBindingParameters (
+                       OperationDescription description,
+                       BindingParameterCollection parameters)
+               {
+                       //throw new NotImplementedException ();
+               }
+
+               void IOperationBehavior.ApplyDispatchBehavior (
+                       OperationDescription description,
+                       DispatchOperation dispatch)
+               {
+                       dispatch.Impersonation = impersonation;
+                       dispatch.ReleaseInstanceBeforeCall =
+                               mode == ReleaseInstanceMode.BeforeCall ||
+                               mode == ReleaseInstanceMode.BeforeAndAfterCall;
+                       dispatch.ReleaseInstanceAfterCall =
+                               mode == ReleaseInstanceMode.AfterCall ||
+                               mode == ReleaseInstanceMode.BeforeAndAfterCall;
+                       dispatch.TransactionAutoComplete = tx_auto_complete;
+                       // I guess they are equivalent, since tx scope nearly
+                       // equals to tx in usage.
+                       dispatch.TransactionRequired = tx_scope_required;
+               }
+
+               [MonoTODO]
+               void IOperationBehavior.ApplyClientBehavior (
+                       OperationDescription description,
+                       ClientOperation proxy)
+               {
+                       //throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               void IOperationBehavior.Validate (
+                       OperationDescription description)
+               {
+                       
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/OperationContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel/OperationContext.cs
new file mode 100644 (file)
index 0000000..790df09
--- /dev/null
@@ -0,0 +1,191 @@
+//
+// OperationContext.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005,2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security;
+using System.Threading;
+
+namespace System.ServiceModel
+{
+       public sealed class OperationContext : IExtensibleObject<OperationContext>
+       {
+               // generated guid (no special meaning)
+               const string operation_context_name = "c15795e2-bb44-4cfb-a89c-8529feb170cb";
+               Message incoming_message;
+               IDefaultCommunicationTimeouts timeouts;
+
+               public static OperationContext Current {
+                       get { return Thread.GetData (Thread.GetNamedDataSlot (operation_context_name)) as OperationContext; }
+                       set { Thread.SetData (Thread.GetNamedDataSlot (operation_context_name), value); }
+               }
+
+               EndpointDispatcher dispatcher;
+               IContextChannel channel;
+               RequestContext request_ctx;
+               ExtensionCollection<OperationContext> extensions;
+               MessageHeaders outgoing_headers;
+               MessageProperties outgoing_properties;
+               InstanceContext instance_context;
+
+               public OperationContext (IContextChannel channel)
+               {
+                       if (channel == null)
+                               throw new ArgumentNullException ("channel");
+                       this.channel = channel;
+               }
+
+               public event EventHandler OperationCompleted;
+
+               public IContextChannel Channel {
+                       get { return channel; }
+               }
+
+               public EndpointDispatcher EndpointDispatcher {
+                       get { return dispatcher; }
+                       set { dispatcher = value; }
+               }
+
+               public IExtensionCollection<OperationContext> Extensions {
+                       get {
+                               if (extensions == null)
+                                       extensions = new ExtensionCollection<OperationContext> (this);
+                               return extensions;
+                       }
+               }
+
+               public bool HasSupportingTokens {
+                       get { return SupportingTokens != null ? SupportingTokens.Count > 0 : false; }
+               }
+
+               public ServiceHostBase Host {
+                       get { return dispatcher != null ? dispatcher.ChannelDispatcher.Host : null; }
+               }
+
+               public MessageHeaders IncomingMessageHeaders {
+                       get { return request_ctx != null ? request_ctx.RequestMessage.Headers : null; }
+               }
+
+               public MessageProperties IncomingMessageProperties {
+                       get { return request_ctx != null ? request_ctx.RequestMessage.Properties : null; }
+               }
+
+               public MessageVersion IncomingMessageVersion {
+                       get { return request_ctx != null ? request_ctx.RequestMessage.Version : null; }
+               }
+
+               [MonoTODO]
+               public InstanceContext InstanceContext {
+                       get {                           
+                               return instance_context;
+                       }
+                       internal set {
+                               instance_context = value;
+                       }
+               }
+
+               [MonoTODO]
+               public bool IsUserContext {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public MessageHeaders OutgoingMessageHeaders {
+                       get {
+                               if (outgoing_headers == null)
+                                       outgoing_headers = new MessageHeaders (MessageVersion.Default);
+                               return outgoing_headers;
+                       }
+               }
+
+               public MessageProperties OutgoingMessageProperties {
+                       get {
+                               if (outgoing_properties == null)
+                                       outgoing_properties = new MessageProperties ();
+                               return outgoing_properties;
+                       }
+               }
+
+               public RequestContext RequestContext {
+                       get { return request_ctx; }
+                       set { request_ctx = value; }
+               }
+
+               public ServiceSecurityContext ServiceSecurityContext {
+                       get { return IncomingMessageProperties != null ? IncomingMessageProperties.Security.ServiceSecurityContext : null; }
+               }
+
+               [MonoTODO]
+               public string SessionId {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public ICollection<SupportingTokenSpecification> SupportingTokens {
+                       get { return IncomingMessageProperties != null ? IncomingMessageProperties.Security.IncomingSupportingTokens : null; }
+               }
+
+               public T GetCallbackChannel<T> ()
+               {
+                       if (!(channel is IDuplexContextChannel))
+                               return default (T);
+                       IDuplexContextChannel duplex = (IDuplexContextChannel) channel;
+                       foreach (IChannel ch in duplex.CallbackInstance.IncomingChannels)
+                               if (typeof (T).IsAssignableFrom (ch.GetType ()))
+                                       return (T) (object) ch;
+                       foreach (IChannel ch in duplex.CallbackInstance.OutgoingChannels)
+                               if (typeof (T).IsAssignableFrom (ch.GetType ()))
+                                       return (T) (object) ch;
+                       return default (T);
+               }
+
+               [MonoTODO]
+               public void SetTransactionComplete ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               internal Message IncomingMessage {
+                       get {
+                               return incoming_message;
+                       }
+                       set {
+                               incoming_message = value;
+                       }
+               }
+
+               internal IDefaultCommunicationTimeouts CommunicationTimeouts
+               {
+                       get {
+                               return timeouts;
+                       }
+                       set {
+                               timeouts = value;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/OperationContextScope.cs b/mcs/class/System.ServiceModel/System.ServiceModel/OperationContextScope.cs
new file mode 100644 (file)
index 0000000..089e194
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// OperationContextScope.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005,2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+       public sealed class OperationContextScope : IDisposable
+       {
+               OperationContext previous;
+
+               public OperationContextScope (IContextChannel channel)
+                       : this (new OperationContext (channel))
+               {
+               }
+
+               public OperationContextScope (OperationContext context)
+               {
+                       previous = OperationContext.Current;
+                       OperationContext.Current = context;
+               }
+
+               public void Dispose ()
+               {
+                       OperationContext.Current = previous;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/OperationContractAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/OperationContractAttribute.cs
new file mode 100644 (file)
index 0000000..79bda91
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// OperationContractAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Net.Security;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Method)]
+       public sealed class OperationContractAttribute : Attribute
+       {
+               string action, reply_action, name;
+               bool is_initiating = true, is_terminating, is_oneway, is_async;
+               ProtectionLevel protection_level = ProtectionLevel.None;
+               bool has_protection_level;
+
+               public string Action {
+                       get { return action; }
+                       set { action = value; }
+               }
+
+               public bool AsyncPattern {
+                       get { return is_async; }
+                       set { is_async = value; }
+               }
+
+               public bool IsInitiating {
+                       get { return is_initiating; }
+                       set { is_initiating = value; }
+               }
+
+               public bool IsOneWay {
+                       get { return is_oneway; }
+                       set { is_oneway = value; }
+               }
+
+               public bool IsTerminating {
+                       get { return is_terminating; }
+                       set { is_terminating = value; }
+               }
+
+               public string Name {
+                       get { return name; }
+                       set { name = value; }
+               }
+
+               public bool HasProtectionLevel {
+                       get { return has_protection_level; }
+               }
+
+               public ProtectionLevel ProtectionLevel {
+                       get { return protection_level; }
+                       set {
+                               protection_level = value;
+                               has_protection_level = true;
+                       }
+               }
+
+               public string ReplyAction {
+                       get { return reply_action; }
+                       set { reply_action = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/OptionalReliableSession.cs b/mcs/class/System.ServiceModel/System.ServiceModel/OptionalReliableSession.cs
new file mode 100644 (file)
index 0000000..1f5b965
--- /dev/null
@@ -0,0 +1,50 @@
+//
+// OptionalReliableSession.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel
+{
+       public class OptionalReliableSession : ReliableSession
+       {
+               bool enabled;
+               ReliableSessionBindingElement binding;
+
+               public OptionalReliableSession (ReliableSessionBindingElement binding)
+               {
+               }
+
+               public bool Enabled {
+                       get { return enabled; }
+                       set { enabled = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/PeerMessagePropagationMessageFilter.cs b/mcs/class/System.ServiceModel/System.ServiceModel/PeerMessagePropagationMessageFilter.cs
new file mode 100644 (file)
index 0000000..90ae815
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// PeerMessagePropagationMessageFilter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public abstract class PeerMessagePropagationFilter
+       {
+               protected PeerMessagePropagationFilter ()
+               {
+               }
+
+               public abstract PeerMessagePropagation ShouldMessagePropagate (
+                       Message message, PeerMessageOrigination origination);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/PeerNode.cs b/mcs/class/System.ServiceModel/System.ServiceModel/PeerNode.cs
new file mode 100644 (file)
index 0000000..f90b63e
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// PeerNode.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public abstract class PeerNode
+       {
+               protected PeerNode ()
+               {
+               }
+
+               public abstract event EventHandler Offline;
+               public abstract event EventHandler Online;
+
+               public abstract bool IsOnline { get; }
+
+               public abstract bool IsOpen { get; }
+
+               public abstract PeerMessagePropagationFilter MessagePropagationFilter { get; set; }
+
+               [MonoTODO]
+               public static PeerNode Get (Uri listenUri)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/PeerNodeAddress.cs b/mcs/class/System.ServiceModel/System.ServiceModel/PeerNodeAddress.cs
new file mode 100644 (file)
index 0000000..5a6db98
--- /dev/null
@@ -0,0 +1,85 @@
+//
+// PeerNodeAddress.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.Net;
+
+namespace System.ServiceModel
+{
+       [DataContract (Name = "PeerNodeAddress", Namespace = "http://schemas.microsoft.com/net/2006/05/peer")]
+       [KnownType (typeof (IPAddress []))]
+       public sealed class PeerNodeAddress
+       {
+               EndpointAddress endpoint;
+               ReadOnlyCollection<IPAddress> peer_addresses;
+
+               private PeerNodeAddress ()
+               {
+                       // It is for DataContract deserialization.
+               }
+
+               public PeerNodeAddress (EndpointAddress endpointAddress,
+                       ReadOnlyCollection<IPAddress> ipAddresses)
+               {
+                       if (endpointAddress == null)
+                               throw new ArgumentNullException ("endpointAddress");
+                       if (ipAddresses == null)
+                               throw new ArgumentNullException ("ipAddresses");
+                       this.endpoint = endpointAddress;
+                       peer_addresses = ipAddresses;
+               }
+
+               public EndpointAddress EndpointAddress {
+                       get { return endpoint; }
+               }
+
+               public ReadOnlyCollection<IPAddress> IPAddresses {
+                       get { return peer_addresses; }
+               }
+
+               [DataMember (Name = "EndpointAddress")]
+               EndpointAddress10 SerializedEndpoint {
+                       get { return EndpointAddress10.FromEndpointAddress (endpoint); }
+                       set { endpoint = value.ToEndpointAddress (); }
+               }
+
+               [DataMember (Name = "IPAddresses")]
+               IPAddress [] SerializedIPAddresses {
+                       get {
+                               IPAddress [] arr = new IPAddress [peer_addresses.Count];
+                               peer_addresses.CopyTo (arr, 0);
+                               return arr;
+                       }
+                       set {
+                               peer_addresses = new ReadOnlyCollection<IPAddress> (value);
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/PeerResolver.cs b/mcs/class/System.ServiceModel/System.ServiceModel/PeerResolver.cs
new file mode 100644 (file)
index 0000000..99764b9
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// PeerResolver.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel.Security.Tokens;
+using System.Security.Cryptography.X509Certificates;
+
+namespace System.ServiceModel
+{
+       public abstract class PeerResolver
+       {
+               protected PeerResolver ()
+               {
+               }
+
+               public abstract object Register (string meshId,
+                       PeerNodeAddress nodeAddress, TimeSpan timeout);
+
+               public abstract ReadOnlyCollection<PeerNodeAddress> Resolve (
+                       string meshId, int maxAddresses, TimeSpan timeout);
+
+               public abstract void Unregister (object registrationId,
+                       TimeSpan timeout);
+
+               public abstract void Update (object registrationId,
+                       PeerNodeAddress updatedNodeAddress, TimeSpan timeout);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/PeerResolverImpl.cs b/mcs/class/System.ServiceModel/System.ServiceModel/PeerResolverImpl.cs
new file mode 100644 (file)
index 0000000..5eb15f6
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// PeerResolverImpl.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel.Security.Tokens;
+using System.Security.Cryptography.X509Certificates;
+
+namespace System.ServiceModel
+{
+       // FIXME: implement. However, for now we don't have any prefered
+       // P2P API like Pnrp that Microsoft uses.
+       internal class PeerResolverImpl : PeerResolver
+       {
+               public PeerResolverImpl ()
+               {
+               }
+
+               public override object Register (string meshId,
+                       PeerNodeAddress nodeAddress, TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override ReadOnlyCollection<PeerNodeAddress> Resolve (
+                       string meshId, int maxAddresses, TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override void Unregister (object registrationId,
+                       TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override void Update (object registrationId,
+                       PeerNodeAddress updatedNodeAddress, TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/PeerSecuritySettings.cs b/mcs/class/System.ServiceModel/System.ServiceModel/PeerSecuritySettings.cs
new file mode 100644 (file)
index 0000000..c90feae
--- /dev/null
@@ -0,0 +1,27 @@
+// \r
+// PeerSecuritySettings.cs\r
+// \r
+// Author: \r
+//     Marcos Cobena (marcoscobena@gmail.com)\r
+// \r
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)\r
+// \r
+\r
+using System;\r
+\r
+namespace System.ServiceModel\r
+{\r
+       public class PeerSecuritySettings\r
+       {\r
+               SecurityMode mode;\r
+               \r
+               public PeerSecuritySettings()\r
+               {\r
+               }\r
+               \r
+               public SecurityMode Mode {\r
+                       get { return mode; }\r
+                       set { mode = value; }\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/PoisonMessageException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/PoisonMessageException.cs
new file mode 100644 (file)
index 0000000..9d0fc74
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// PoisonMessageException.cs
+//
+// Author: Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel
+{
+       [Serializable]
+       public class PoisonMessageException : SystemException
+       {
+               public PoisonMessageException () : base () {}
+               public PoisonMessageException (string msg) : base (msg) {}
+               public PoisonMessageException (string msg, Exception inner) : base (msg, inner) {}
+               protected PoisonMessageException (SerializationInfo info, StreamingContext context) :
+                       base (info, context) {}
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ProtocolException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ProtocolException.cs
new file mode 100644 (file)
index 0000000..e2fc290
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// System.ServiceModel.ProtocolException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel {
+       [Serializable]
+       public class ProtocolException : CommunicationException
+       {
+               public ProtocolException () : base () {}
+               public ProtocolException (string msg) : base (msg) {}
+               public ProtocolException (string msg, Exception inner)
+                       : base (msg, inner) {}          
+               protected ProtocolException (SerializationInfo info,
+                                         StreamingContext context)
+                       : base (info, context) {}
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/QuotaExceededException.cs b/mcs/class/System.ServiceModel/System.ServiceModel/QuotaExceededException.cs
new file mode 100644 (file)
index 0000000..adf08d2
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// System.ServiceModel.QuotaExceededException.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+
+namespace System.ServiceModel {
+       [Serializable]
+       public class QuotaExceededException : SystemException
+       {
+               public QuotaExceededException () : base () {}
+               public QuotaExceededException (string msg) : base (msg) {}
+               public QuotaExceededException (string msg, Exception inner)
+                       : base (msg, inner) {}          
+               protected QuotaExceededException (SerializationInfo info,
+                                              StreamingContext context)
+                       : base (info, context) {}
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ReliableMessagingVersion.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ReliableMessagingVersion.cs
new file mode 100644 (file)
index 0000000..acbc89a
--- /dev/null
@@ -0,0 +1,59 @@
+//\r
+// ReliableMessagingVersion.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel\r
+{\r
+       [MonoTODO]\r
+       public abstract class ReliableMessagingVersion\r
+       {\r
+               static ReliableMessagingVersion _default = new FakeReliableMessagingVersion ();\r
+               static ReliableMessagingVersion _wsReliableMessaging11 = new FakeReliableMessagingVersion ();\r
+               static ReliableMessagingVersion _wsReliableMessagingFebruary2005 = new FakeReliableMessagingVersion ();\r
+\r
+               public static ReliableMessagingVersion Default {\r
+                       get { return _default; }\r
+               }\r
+\r
+               public static ReliableMessagingVersion WSReliableMessaging11 {\r
+                       get { return _wsReliableMessaging11; }\r
+               }\r
+\r
+               public static ReliableMessagingVersion WSReliableMessagingFebruary2005 {\r
+                       get { return _wsReliableMessagingFebruary2005; }\r
+               }\r
+\r
+               [MonoTODO ("must be replaces with a correct implementation")]\r
+               class FakeReliableMessagingVersion : ReliableMessagingVersion\r
+               {\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ReliableSession.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ReliableSession.cs
new file mode 100644 (file)
index 0000000..441f2e0
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// ReliableSession.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace System.ServiceModel
+{
+       public class ReliableSession
+       {
+               bool ordered;
+               TimeSpan inactivity_timeout;
+
+               public ReliableSession ()
+               {
+               }
+
+               public TimeSpan InactivityTimeout {
+                       get { return inactivity_timeout; }
+               }
+
+               public bool Ordered {
+                       get { return ordered; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/RsaEndpointIdentity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/RsaEndpointIdentity.cs
new file mode 100644 (file)
index 0000000..1d0bf8f
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// RsaEndpointIdentity.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Claims;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Xml;
+
+
+namespace System.ServiceModel
+{
+       public class RsaEndpointIdentity : EndpointIdentity
+       {
+               RSA rsa;
+
+               public RsaEndpointIdentity (Claim identity)
+               {
+               }
+
+               [MonoTODO]
+               public RsaEndpointIdentity (string publicKey)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public RsaEndpointIdentity (X509Certificate2 cert)
+               {
+                       if (cert == null)
+                               throw new ArgumentNullException ("cert");
+                       rsa = (RSA) cert.PublicKey.Key;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ServiceAuthorizationManager.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ServiceAuthorizationManager.cs
new file mode 100644 (file)
index 0000000..21cf4b1
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// ServiceAuthorizationManager.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Policy;
+
+namespace System.ServiceModel
+{
+       public class ServiceAuthorizationManager
+       {
+               public bool CheckAccess (OperationContext context)
+               {
+                       return CheckAccessCore (context);
+               }
+
+               [MonoTODO]
+               public virtual bool CheckAccessCore (OperationContext context)
+               {
+                       return false;
+               }
+
+               [MonoTODO]
+               public ReadOnlyCollection<IAuthorizationPolicy> GetAuthorizationPolicies (OperationContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ServiceBehaviorAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ServiceBehaviorAttribute.cs
new file mode 100644 (file)
index 0000000..19fa4af
--- /dev/null
@@ -0,0 +1,185 @@
+//
+// ServiceBehaviorAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.Transactions;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Class)]
+       public sealed class ServiceBehaviorAttribute
+               : Attribute, IServiceBehavior
+       {
+               public ServiceBehaviorAttribute ()
+               {
+               }
+
+               bool auto_session_shutdown, ignore_ext_data,
+                       release, inc_fault_details,
+                       use_sync_ctx, tx_close, validate_must_understand;
+               ConcurrencyMode concurrency;
+               IsolationLevel tx_level;
+               string tx_timeout;
+               InstanceContextMode context_mode = InstanceContextMode.PerCall;
+               object singleton;
+
+               [MonoTODO]
+               public bool AutomaticSessionShutdown {
+                       get { return auto_session_shutdown; }
+                       set { auto_session_shutdown = value; }
+               }
+
+               [MonoTODO]
+               public ConcurrencyMode ConcurrencyMode {
+                       get { return concurrency; }
+                       set { concurrency = value; }
+               }
+
+               [MonoTODO]
+               public bool IgnoreExtensionDataObject {
+                       get { return ignore_ext_data; }
+                       set { ignore_ext_data = value; }
+               }
+
+               public InstanceContextMode InstanceContextMode {
+                       get { return context_mode; }
+                       set { context_mode = value; }
+               }
+
+               public bool ReleaseServiceInstanceOnTransactionComplete {
+                       get { return release; }
+                       set { release = value; }
+               }
+
+               [MonoTODO]
+               public bool IncludeExceptionDetailInFaults {
+                       get { return inc_fault_details; }
+                       set { inc_fault_details = value; }
+               }
+
+               [MonoTODO]
+               public bool UseSynchronizationContext {
+                       get { return use_sync_ctx; }
+                       set { use_sync_ctx = value; }
+               }
+
+               [MonoTODO]
+               public bool TransactionAutoCompleteOnSessionClose {
+                       get { return tx_close; }
+                       set { tx_close = value; }
+               }
+
+               [MonoTODO]
+               public IsolationLevel TransactionIsolationLevel {
+                       get { return tx_level; }
+                       set { tx_level = value; }
+               }
+
+               [MonoTODO]
+               public string TransactionTimeout {
+                       get { return tx_timeout; }
+                       set {
+                               if (value != null)
+                                       TimeSpan.Parse (value);
+                               tx_timeout = value;
+                       }
+               }
+
+               [MonoTODO]
+               public bool ValidateMustUnderstand {
+                       get { return validate_must_understand; }
+                       set { validate_must_understand = value; }
+               }
+
+               public object GetWellKnownSingleton ()
+               {
+                       return singleton;
+               }
+
+               public void SetWellKnownSingleton (object value)
+               {
+                       if (value == null)
+                               throw new ArgumentNullException ("value");
+                       singleton = value;
+               }
+
+               [MonoTODO]
+               void IServiceBehavior.AddBindingParameters (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase,
+                       Collection<ServiceEndpoint> endpoints,
+                       BindingParameterCollection parameters)
+               {
+               }
+
+               [MonoTODO]
+               void IServiceBehavior.ApplyDispatchBehavior (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {
+                       if (singleton != null && context_mode != InstanceContextMode.Single)
+                               throw new InvalidOperationException ("When creating a Service host with a service instance, use InstanceContext.Mode.Single in the ServiceBehaviorAttribute.");
+
+                       foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers) {
+                               ChannelDispatcher cd = cdb as ChannelDispatcher;
+                               if (cd == null)
+                                       continue;
+                               if (IncludeExceptionDetailInFaults) // may be set also in ServiceDebugBehaviorAttribute
+                                       cd.IncludeExceptionDetailInFaults = true;
+                               foreach (EndpointDispatcher ed in cd.Endpoints)
+                                       ed.DispatchRuntime.InstanceContextProvider = CreateInstanceContextProvider (serviceHostBase);
+                       }
+               }
+
+               IInstanceContextProvider CreateInstanceContextProvider (ServiceHostBase host)
+               {
+                       switch (InstanceContextMode) {
+                       case InstanceContextMode.Single:
+                               return new SingletonInstanceContextProvider (new InstanceContext (host, GetWellKnownSingleton ()));
+                       case InstanceContextMode.PerSession:
+                               // FIXME: implement
+                               throw new NotImplementedException ();
+                       //case InstanceContextMode.PerCall:
+                       default:
+                               return null; // default
+                       }
+               }
+
+               [MonoTODO]
+               void IServiceBehavior.Validate (
+                       ServiceDescription description,
+                       ServiceHostBase serviceHostBase)
+               {                       
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ServiceContractAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ServiceContractAttribute.cs
new file mode 100644 (file)
index 0000000..67a4916
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// ServiceContractAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net.Security;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
+       public sealed class ServiceContractAttribute : Attribute
+       {
+               Type callback_contract;
+               string name, ns;
+               SessionMode session;
+               ProtectionLevel protection_level;
+               bool has_protection_level;
+               string _configurationName;
+
+               public Type CallbackContract {
+                       get { return callback_contract; }
+                       set { callback_contract = value; }
+               }
+
+               public string Name {
+                       get { return name; }
+                       set { name = value; }
+               }
+
+               public string Namespace {
+                       get { return ns; }
+                       set { ns = value; }
+               }
+
+               public bool HasProtectionLevel {
+                       get { return has_protection_level; }
+               }
+
+               public ProtectionLevel ProtectionLevel {
+                       get { return protection_level; }
+                       set {
+                               protection_level = value;
+                               has_protection_level = true;
+                       }
+               }
+
+               public SessionMode SessionMode {
+                       get { return session; }
+                       set { session = value; }
+               }
+
+               public string ConfigurationName {
+                       get { return _configurationName; }
+                       set { _configurationName = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHost.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHost.cs
new file mode 100644 (file)
index 0000000..ec9b1a3
--- /dev/null
@@ -0,0 +1,171 @@
+//
+// ServiceHost.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel
+{
+       public class ServiceHost : ServiceHostBase
+       {
+               Type service_type;
+               object instance;
+               Dictionary<string,ContractDescription> contracts;
+
+               protected ServiceHost ()
+               {
+               }
+
+               public ServiceHost (object serviceInstance,
+                       params Uri [] baseAddresses)
+               {
+                       if (serviceInstance == null)
+                               throw new ArgumentNullException ("serviceInstance");
+                       InitializeDescription (serviceInstance,
+                               new UriSchemeKeyedCollection (baseAddresses));
+               }
+
+               public ServiceHost (Type serviceType,
+                       params Uri [] baseAddresses)
+               {
+                       InitializeDescription (serviceType,
+                               new UriSchemeKeyedCollection (baseAddresses));
+               }
+
+               public object SingletonInstance {
+                       get { return instance; }
+               }
+
+               [MonoTODO]
+               public ServiceEndpoint AddServiceEndpoint (
+                       Type implementedContract, Binding binding, string address)
+               {
+                       return AddServiceEndpoint (implementedContract, binding,
+                               new Uri (address, UriKind.RelativeOrAbsolute));
+               }
+
+               [MonoTODO]
+               public ServiceEndpoint AddServiceEndpoint (
+                       Type implementedContract, Binding binding, string address, Uri listenUri)
+               {
+                       return AddServiceEndpoint (implementedContract, binding,
+                               new Uri (address, UriKind.RelativeOrAbsolute), listenUri);
+               }
+
+               [MonoTODO]
+               public ServiceEndpoint AddServiceEndpoint (
+                       Type implementedContract, Binding binding, Uri address)
+               {
+                       return AddServiceEndpoint (implementedContract,
+                               binding, address, address);
+               }
+
+               [MonoTODO]
+               public ServiceEndpoint AddServiceEndpoint (
+                       Type implementedContract, Binding binding, Uri address, Uri listenUri)
+               {
+                       EndpointAddress ea = BuildEndpointAddress (address, binding);
+
+                       ContractDescription cd = GetExistingContract (implementedContract);
+                       if (cd == null) {
+                               cd = ContractDescription.GetContract (implementedContract);
+                               contracts.Add (cd.ContractType.FullName, cd);
+                       }
+
+                       return AddServiceEndpointCore (cd, binding, ea, listenUri);
+               }
+
+               ContractDescription GetExistingContract (Type implementedContract)
+               {
+                       foreach (ContractDescription cd in ImplementedContracts.Values)
+                               if (cd.ContractType == implementedContract)
+                                       return cd;
+                       return null;
+               }
+
+               protected override ServiceDescription CreateDescription (
+                       out IDictionary<string,ContractDescription> implementedContracts)
+               {
+                       contracts = new Dictionary<string,ContractDescription> ();
+                       implementedContracts = contracts;
+                       ServiceDescription sd;
+                       foreach (ContractDescription cd in GetServiceContractDescriptions())
+                               contracts.Add (cd.ContractType.FullName, cd);
+
+                       if (SingletonInstance != null) {
+                               sd = ServiceDescription.GetService (instance);                          
+                       } else {
+                               sd = ServiceDescription.GetService (service_type);                              
+                       }
+
+                       ServiceBehaviorAttribute sba = PopulateAttribute<ServiceBehaviorAttribute> ();
+                       if (SingletonInstance != null)
+                               sba.SetWellKnownSingleton (SingletonInstance);
+                       sd.Behaviors.Add (sba);
+
+                       return sd;
+               }
+
+               IEnumerable<ContractDescription> GetServiceContractDescriptions () {
+                       List<ContractDescription> contracts = new List<ContractDescription> ();
+                       Type contractType = null;
+                       Dictionary<Type, ServiceContractAttribute> contractAttributes = ContractDescriptionGenerator.GetServiceContractAttributes (service_type);
+                       foreach (Type contract in contractAttributes.Keys)
+                               contracts.Add( ContractDescriptionGenerator.GetContract (contract, service_type));
+                       return contracts;
+               }
+
+               TAttr PopulateAttribute<TAttr> ()
+               {
+                       object [] atts = service_type.GetCustomAttributes (typeof (TAttr), false);
+                       return (TAttr) (atts.Length > 0 ? atts [0] : Activator.CreateInstance (typeof (TAttr)));
+               }
+
+               [MonoTODO]
+               protected void InitializeDescription (Type serviceType, UriSchemeKeyedCollection baseAddresses)
+               {
+                       if (!serviceType.IsClass)
+                               throw new ArgumentException ("ServiceHost only supports 'class' service types.");
+
+                       service_type = serviceType;
+
+                       InitializeDescription (baseAddresses);
+               }
+
+               [MonoTODO]
+               protected void InitializeDescription (object serviceInstance, UriSchemeKeyedCollection baseAddresses)
+               {
+                       instance = serviceInstance;
+                       InitializeDescription (serviceInstance.GetType (), baseAddresses);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs
new file mode 100644 (file)
index 0000000..1f419bc
--- /dev/null
@@ -0,0 +1,669 @@
+//
+// ServiceHostBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security;
+using System.Reflection;
+
+namespace System.ServiceModel
+{
+       public abstract class ServiceHostBase
+               : CommunicationObject, IExtensibleObject<ServiceHostBase>, IDisposable
+       {
+               ServiceCredentials credentials;
+               ServiceDescription description;
+               UriSchemeKeyedCollection base_addresses;
+               TimeSpan open_timeout, close_timeout, instance_idle_timeout;
+               ServiceThrottle throttle;
+               List<InstanceContext> contexts;
+               ReadOnlyCollection<InstanceContext> exposed_contexts;
+               ChannelDispatcherCollection channel_dispatchers;
+               IDictionary<string,ContractDescription> contracts;
+               int flow_limit = int.MaxValue;
+               IExtensionCollection<ServiceHostBase> extensions;
+
+               protected ServiceHostBase ()
+               {
+                       open_timeout = DefaultOpenTimeout;
+                       close_timeout = DefaultCloseTimeout;
+
+                       credentials = new ServiceCredentials ();
+                       throttle = new ServiceThrottle ();
+                       contexts = new List<InstanceContext> ();
+                       exposed_contexts = new ReadOnlyCollection<InstanceContext> (contexts);
+                       channel_dispatchers = new ChannelDispatcherCollection (this);
+               }
+
+               public event EventHandler<UnknownMessageReceivedEventArgs>
+                       UnknownMessageReceived;
+
+               public ReadOnlyCollection<Uri> BaseAddresses {
+                       get { return new ReadOnlyCollection<Uri> (base_addresses.InternalItems); }
+               }
+
+               internal Uri CreateUri (string sheme, Uri relatieUri) {
+                       Uri baseUri = base_addresses.Contains (sheme) ? base_addresses [sheme] : null;
+
+                       if (relatieUri == null)
+                               return baseUri;
+                       if (relatieUri.IsAbsoluteUri)
+                               return relatieUri;
+                       if (baseUri == null)
+                               return null;
+                       return new Uri (baseUri, relatieUri);
+               }
+
+               [MonoTODO]
+               public ChannelDispatcherCollection ChannelDispatchers {
+                       get { return channel_dispatchers; }
+               }
+
+               public ServiceAuthorizationBehavior Authorization {
+                       get;
+                       private set;
+               }
+
+               [MonoTODO]
+               public ServiceCredentials Credentials {
+                       get { return credentials; }
+               }
+
+               public ServiceDescription Description {
+                       get { return description; }
+               }
+
+               protected IDictionary<string,ContractDescription> ImplementedContracts {
+                       get { return contracts; }
+               }
+
+               [MonoTODO]
+               public IExtensionCollection<ServiceHostBase> Extensions {
+                       get {
+                               if (extensions == null)
+                                       extensions = new ExtensionCollection<ServiceHostBase> (this);
+                               return extensions;
+                       }
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return DefaultCommunicationTimeouts.Instance.CloseTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return DefaultCommunicationTimeouts.Instance.OpenTimeout; }
+               }
+
+               public TimeSpan CloseTimeout {
+                       get { return close_timeout; }
+                       set { close_timeout = value; }
+               }
+
+               public TimeSpan OpenTimeout {
+                       get { return open_timeout; }
+                       set { open_timeout = value; }
+               }
+
+               public int ManualFlowControlLimit {
+                       get { return flow_limit; }
+                       set { flow_limit = value; }
+               }
+
+               public ServiceEndpoint AddServiceEndpoint (
+                       string implementedContract, Binding binding, string address)
+               {
+                       return AddServiceEndpoint (implementedContract,
+                               binding,
+                               new Uri (address, UriKind.RelativeOrAbsolute));
+               }
+
+               [MonoTODO]
+               public ServiceEndpoint AddServiceEndpoint (
+                       string implementedContract, Binding binding,
+                       string address, Uri listenUri)
+               {
+                       Uri uri = new Uri (address, UriKind.RelativeOrAbsolute);
+                       return AddServiceEndpoint (
+                               implementedContract, binding, uri, uri);
+               }
+
+               [MonoTODO]
+               public ServiceEndpoint AddServiceEndpoint (
+                       string implementedContract, Binding binding,
+                       Uri address)
+               {
+                       return AddServiceEndpoint (implementedContract, binding, address, address);
+               }
+
+               [MonoTODO]
+               public ServiceEndpoint AddServiceEndpoint (
+                       string implementedContract, Binding binding,
+                       Uri address, Uri listenUri)
+               {
+                       EndpointAddress ea = BuildEndpointAddress (address, binding);
+                       ContractDescription cd = GetContract (implementedContract);
+                       if (cd == null)
+                               throw new InvalidOperationException (String.Format ("Contract '{0}' was not found in the implemented contracts in this service host.", implementedContract));
+                       return AddServiceEndpointCore (cd, binding, ea, listenUri);
+               }
+
+               Type PopulateType (string typeName)
+               {
+                       Type type = Type.GetType (typeName);
+                       if (type != null)
+                               return type;
+                       foreach (ContractDescription cd in ImplementedContracts.Values) {
+                               type = cd.ContractType.Assembly.GetType (typeName);
+                               if (type != null)
+                                       return type;
+                       }
+                       return null;
+               }
+
+               ContractDescription GetContract (string typeName)
+               {
+                       //FIXME: hack hack hack
+                       ImplementedContracts ["IHttpGetHelpPageAndMetadataContract"] =
+                               ContractDescription.GetContract (typeof (IHttpGetHelpPageAndMetadataContract));
+
+                       // FIXME: As long as I tried, *only* IMetadataExchange
+                       // is the exception case that does not require full
+                       // type name. Hence I treat it as a special case.
+                       if (typeName == ServiceMetadataBehavior.MexContractName) {
+                               if (!Description.Behaviors.Contains (typeof (ServiceMetadataBehavior)) && Array.IndexOf (Description.ServiceType.GetInterfaces (), typeof (IMetadataExchange)) < 0)
+                                       throw new InvalidOperationException (
+                                               "Add ServiceMetadataBehavior to the ServiceHost to add a endpoint for IMetadataExchange contract.");
+                                       
+                               ImplementedContracts [ServiceMetadataBehavior.MexContractName] =
+                                       ContractDescription.GetContract (typeof (IMetadataExchange));
+
+                               foreach (ContractDescription cd in ImplementedContracts.Values)
+                                       if (cd.ContractType == typeof (IMetadataExchange))
+                                               return cd;
+                               return null;
+                       }
+
+                       Type type = PopulateType (typeName);
+                       if (type == null)
+                               return null;
+
+                       foreach (ContractDescription cd in ImplementedContracts.Values) {
+                               // FIXME: This check is a negative side effect 
+                               // of the above hack.
+                               if (cd.ContractType == typeof (IMetadataExchange))
+                                       continue;
+
+                               if (cd.ContractType == type ||
+                                   cd.ContractType.IsSubclassOf (type) ||
+                                   type.IsInterface && cd.ContractType.GetInterface (type.FullName) == type)
+                                       return cd;
+                       }
+                       return null;
+               }
+
+               internal EndpointAddress BuildEndpointAddress (Uri address, Binding binding)
+               {
+                       if (!address.IsAbsoluteUri) {
+                               // Find a Base address with matching scheme,
+                               // and build new absolute address
+                               if (!base_addresses.Contains (binding.Scheme))
+                                       throw new InvalidOperationException (String.Format ("Could not find base address that matches Scheme {0} for endpoint {1}", binding.Scheme, binding.Name));
+
+                               Uri baseaddr = base_addresses [binding.Scheme];
+
+                               if (!baseaddr.AbsoluteUri.EndsWith ("/"))
+                                       baseaddr = new Uri (baseaddr.AbsoluteUri + "/");
+                               address = new Uri (baseaddr, address);
+                       }
+                       return new EndpointAddress (address);
+               }
+
+               internal ServiceEndpoint AddServiceEndpointCore (
+                       ContractDescription cd, Binding binding, EndpointAddress address, Uri listenUri)
+               {
+                       foreach (ServiceEndpoint e in Description.Endpoints)
+                               if (e.Contract == cd)
+                                       return e;
+                       ServiceEndpoint se = new ServiceEndpoint (cd, binding, address);
+                       se.ListenUri = listenUri.IsAbsoluteUri ? listenUri : new Uri (address.Uri, listenUri);
+                       Description.Endpoints.Add (se);
+                       return se;
+               }
+
+               [MonoTODO]
+               protected virtual void ApplyConfiguration ()
+               {
+                       if (Description == null)
+                               throw new InvalidOperationException ("ApplyConfiguration requires that the Description property be initialized. Either provide a valid ServiceDescription in the CreateDescription method or override the ApplyConfiguration method to provide an alternative implementation");
+
+                       ServiceElement service = GetServiceElement ();
+
+                       //TODO: Should we call here LoadServiceElement ?
+                       if (service != null) {
+                               
+                               //base addresses
+                               HostElement host = service.Host;
+                               foreach (BaseAddressElement baseAddress in host.BaseAddresses) {
+                                       this.base_addresses.Add (new Uri (baseAddress.BaseAddress));
+                               }
+
+                               // services
+                               foreach (ServiceEndpointElement endpoint in service.Endpoints) {
+                                       // FIXME: consider BindingName as well
+                                       ServiceEndpoint se = AddServiceEndpoint (
+                                               endpoint.Contract,
+                                               ConfigUtil.CreateBinding (endpoint.Binding, endpoint.BindingConfiguration),
+                                               endpoint.Address.ToString ());
+                               }
+                               // behaviors
+                               // TODO: use EvaluationContext of ServiceElement.
+                               ServiceBehaviorElement behavior = ConfigUtil.BehaviorsSection.ServiceBehaviors.Find (service.BehaviorConfiguration);
+                               if (behavior != null) {
+                                       for (int i = 0; i < behavior.Count; i++) {
+                                               BehaviorExtensionElement bxel = behavior [i];
+                                               IServiceBehavior b = (IServiceBehavior) behavior [i].CreateBehavior ();
+                                               if (b != null)
+                                                       Description.Behaviors.Add (b);
+                                       }
+                               }
+                       }
+                       // TODO: consider commonBehaviors here
+
+                       // ensure ServiceAuthorizationBehavior
+                       Authorization = Description.Behaviors.Find<ServiceAuthorizationBehavior> ();
+                       if (Authorization == null) {
+                               Authorization = new ServiceAuthorizationBehavior ();
+                               Description.Behaviors.Add (Authorization);
+                       }
+
+                       // ensure ServiceDebugBehavior
+                       ServiceDebugBehavior debugBehavior = Description.Behaviors.Find<ServiceDebugBehavior> ();
+                       if (debugBehavior == null) {
+                               debugBehavior = new ServiceDebugBehavior ();
+                               Description.Behaviors.Add (debugBehavior);
+                       }
+               }
+
+               private ServiceElement GetServiceElement() {
+                       Type serviceType = Description.ServiceType;
+                       if (serviceType == null)
+                               return null;
+
+                       return ConfigUtil.ServicesSection.Services [serviceType.FullName];                      
+               }
+
+               internal ContractDescription GetContract (string name, string ns)
+               {
+                       foreach (ContractDescription d in ImplementedContracts.Values)
+                               if (d.Name == name && d.Namespace == ns)
+                                       return d;
+                       return null;
+               }
+
+               protected abstract ServiceDescription CreateDescription (
+                       out IDictionary<string,ContractDescription> implementedContracts);
+
+               [MonoTODO]
+               protected void InitializeDescription (UriSchemeKeyedCollection baseAddresses)
+               {
+                       this.base_addresses = baseAddresses;
+                       IDictionary<string,ContractDescription> retContracts;
+                       description = CreateDescription (out retContracts);
+                       contracts = retContracts;
+
+                       ApplyConfiguration ();
+               }
+
+               [MonoTODO]
+               protected virtual void InitializeRuntime ()
+               {
+                       //First validate the description, which should call all behaviors
+                       //'Validate' method.
+                       ValidateDescription ();
+                       
+                       //Build all ChannelDispatchers, one dispatcher per user configured EndPoint.
+                       //We must keep thet ServiceEndpoints as a seperate collection, since the user
+                       //can change the collection in the description during the behaviors events.
+                       Dictionary<ServiceEndpoint, ChannelDispatcher> endPointToDispatcher = new Dictionary<ServiceEndpoint,ChannelDispatcher>();
+                       ServiceEndpoint[] endPoints = new ServiceEndpoint[Description.Endpoints.Count];
+                       Description.Endpoints.CopyTo (endPoints, 0);
+                       foreach (ServiceEndpoint se in endPoints) {
+                               //Let all behaviors add their binding parameters
+                               BindingParameterCollection commonParams =
+                                       new BindingParameterCollection ();
+                               AddBindingParameters (commonParams, se);
+                               ChannelDispatcher channel = BuildChannelDispatcher (se, commonParams);
+                               ChannelDispatchers.Add (channel);                               
+                               endPointToDispatcher[se] = channel;                             
+                       }
+
+                       //After the ChannelDispatchers are created, and attached to the service host
+                       //Apply dispatching behaviors.
+                       foreach (IServiceBehavior b in Description.Behaviors)
+                               b.ApplyDispatchBehavior (Description, this);
+
+                       foreach(KeyValuePair<ServiceEndpoint, ChannelDispatcher> val in endPointToDispatcher)
+                               ApplyDispatchBehavior(val.Value, val.Key);                      
+               }
+
+               private void ValidateDescription () {
+                       foreach (IServiceBehavior b in Description.Behaviors)
+                               b.Validate (Description, this);
+                       foreach (ServiceEndpoint endPoint in Description.Endpoints)
+                               endPoint.Validate ();
+               }               
+
+               private void ApplyDispatchBehavior (ChannelDispatcher dispatcher, ServiceEndpoint endPoint) {                   
+                       foreach (IContractBehavior b in endPoint.Contract.Behaviors)
+                               b.ApplyDispatchBehavior (endPoint.Contract, endPoint, dispatcher.Endpoints[0].DispatchRuntime);
+                       foreach (IEndpointBehavior b in endPoint.Behaviors)
+                               b.ApplyDispatchBehavior (endPoint, dispatcher.Endpoints [0]);
+                       foreach (OperationDescription operation in endPoint.Contract.Operations) {
+                               foreach (IOperationBehavior b in operation.Behaviors)
+                                       b.ApplyDispatchBehavior (operation, dispatcher.Endpoints [0].DispatchRuntime.Operations [operation.Name]);
+                       }
+
+               }
+
+               internal ChannelDispatcher BuildChannelDispatcher (ServiceEndpoint se, BindingParameterCollection commonParams) {
+
+                       //User the binding parameters to build the channel listener and Dispatcher
+                       IChannelListener lf = BuildListener (se, commonParams);
+                       ChannelDispatcher cd = new ChannelDispatcher (
+                               lf, se.Binding.Name);
+                       cd.MessageVersion = se.Binding.MessageVersion;
+                       if (cd.MessageVersion == null)
+                               cd.MessageVersion = MessageVersion.Default;
+
+                       //Attach one EndpointDispacher to the ChannelDispatcher
+                       EndpointDispatcher endpoint_dispatcher =
+                               new EndpointDispatcher (se.Address, se.Contract.Name, se.Contract.Namespace);
+                       endpoint_dispatcher.ContractFilter = GetContractFilter (se.Contract);
+                       endpoint_dispatcher.ChannelDispatcher = cd;
+                       cd.Endpoints.Add (endpoint_dispatcher);
+                       
+                       //Build the dispatch operations
+                       DispatchRuntime db = endpoint_dispatcher.DispatchRuntime;
+                       foreach (OperationDescription od in se.Contract.Operations)
+                               if (!db.Operations.Contains (od.Name))
+                                       PopulateDispatchOperation (db, od);
+
+                       return cd;
+               }
+
+               private MessageFilter GetContractFilter (ContractDescription contractDescription)
+               {
+                       List<string> actions = new List<string> ();
+                       foreach (OperationDescription od in contractDescription.Operations)
+                               foreach (MessageDescription md in od.Messages)
+                                       if (md.Direction == MessageDirection.Input)
+                                               if (md.Action == "*")
+                                                       return new MatchAllMessageFilter ();
+                                               else
+                                                       actions.Add (md.Action);
+
+                       return new ActionMessageFilter (actions.ToArray ());
+               }
+
+               private void AddBindingParameters (BindingParameterCollection commonParams, ServiceEndpoint endPoint) {
+
+                       commonParams.Add (ChannelProtectionRequirements.CreateFromContract (endPoint.Contract));
+                       foreach (IServiceBehavior b in Description.Behaviors)
+                               b.AddBindingParameters (Description, this, Description.Endpoints, commonParams);
+
+                       foreach (IContractBehavior b in endPoint.Contract.Behaviors)
+                               b.AddBindingParameters (endPoint.Contract, endPoint, commonParams);
+                       foreach (IEndpointBehavior b in endPoint.Behaviors)
+                               b.AddBindingParameters (endPoint, commonParams);
+                       foreach (OperationDescription operation in endPoint.Contract.Operations) {
+                               foreach (IOperationBehavior b in operation.Behaviors)
+                                       b.AddBindingParameters (operation, commonParams);
+                       }
+               }
+
+               void PopulateDispatchOperation (DispatchRuntime db, OperationDescription od) {
+                       string reqA = null, resA = null;
+                       foreach (MessageDescription m in od.Messages) {
+                               if (m.Direction == MessageDirection.Input)
+                                       reqA = m.Action;
+                               else
+                                       resA = m.Action;
+                       }
+                       DispatchOperation o =
+                               od.IsOneWay ?
+                               new DispatchOperation (db, od.Name, reqA) :
+                               new DispatchOperation (db, od.Name, reqA, resA);
+                       bool has_void_reply = false;
+                       foreach (MessageDescription md in od.Messages) {
+                               if (md.Direction == MessageDirection.Input &&
+                                       md.Body.Parts.Count == 1 &&
+                                       md.Body.Parts [0].Type == typeof (Message))
+                                       o.DeserializeRequest = false;
+                               if (md.Direction == MessageDirection.Output &&
+                                       md.Body.ReturnValue != null) {
+                                       if (md.Body.ReturnValue.Type == typeof (Message))
+                                               o.SerializeReply = false;
+                                       else if (md.Body.ReturnValue.Type == typeof (void))
+                                               has_void_reply = true;
+                               }
+                       }
+
+                       // Setup Invoker
+                       // FIXME: support async method
+                       if (od.SyncMethod != null)
+                               o.Invoker = new SyncMethodInvoker (od.SyncMethod);
+                       else
+                               o.Invoker = new AsyncMethodInvoker (od.BeginMethod, od.EndMethod);
+
+                       // Setup Formater
+                       o.Formatter = BaseMessagesFormatter.Create (od);
+
+                       if (o.Action == "*" && o.ReplyAction == "*") {
+                               //Signature : Message  (Message)
+                               //          : void  (Message)
+                               //FIXME: void (IChannel)
+                               if (!o.DeserializeRequest && (!o.SerializeReply || has_void_reply))
+                                       db.UnhandledDispatchOperation = o;
+                       }
+
+                       db.Operations.Add (o);
+               }
+
+               [MonoTODO]
+               protected void LoadConfigurationSection (ServiceElement element)
+               {
+                       ServicesSection services = ConfigUtil.ServicesSection;
+               }
+
+               void DoOpen (TimeSpan timeout)
+               {
+                       for (int i = 0; i < ChannelDispatchers.Count; i++)
+                               ChannelDispatchers [i].Open (timeout);
+               }
+
+               IChannelListener BuildListener (ServiceEndpoint se,
+                       BindingParameterCollection pl)
+               {
+                       Binding b = se.Binding;
+                       if (b.CanBuildChannelListener<IReplySessionChannel> (pl))
+                               return b.BuildChannelListener<IReplySessionChannel> (se.ListenUri, "", se.ListenUriMode, pl);
+                       if (b.CanBuildChannelListener<IReplyChannel> (pl))
+                               return b.BuildChannelListener<IReplyChannel> (se.ListenUri, "", se.ListenUriMode, pl);
+                       if (b.CanBuildChannelListener<IInputSessionChannel> (pl))
+                               return b.BuildChannelListener<IInputSessionChannel> (se.ListenUri, "", se.ListenUriMode, pl);
+                       if (b.CanBuildChannelListener<IInputChannel> (pl))
+                               return b.BuildChannelListener<IInputChannel> (se.ListenUri, "", se.ListenUriMode, pl);
+                       throw new InvalidOperationException ("None of the listener channel types is supported");
+               }
+
+               [MonoTODO]
+               protected override sealed void OnAbort ()
+               {
+               }
+
+               [MonoTODO]
+               protected override sealed IAsyncResult OnBeginClose (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override sealed IAsyncResult OnBeginOpen (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       ReleasePerformanceCounters ();
+                       List<ChannelDispatcherBase> l = new List<ChannelDispatcherBase> (ChannelDispatchers);
+                       foreach (ChannelDispatcherBase e in l)
+                               e.Close ();
+               }
+
+               protected override sealed void OnOpen (TimeSpan timeout)
+               {
+                       InitializeRuntime ();
+                       DoOpen (timeout);
+               }
+
+               [MonoTODO]
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               protected override sealed void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnOpened ()
+               {
+               }
+
+               [MonoTODO]
+               protected void ReleasePerformanceCounters ()
+               {
+               }
+
+               void IDisposable.Dispose ()
+               {
+                       Close ();
+               }
+
+               class SyncMethodInvoker : IOperationInvoker
+               {
+                       readonly MethodInfo _methodInfo;
+                       public SyncMethodInvoker (MethodInfo methodInfo) {
+                               _methodInfo = methodInfo;
+                       }
+                       
+                       #region IOperationInvoker Members
+
+                       public bool IsSynchronous {
+                               get { return true; }
+                       }
+
+                       public object [] AllocateParameters () {
+                               return new object [_methodInfo.GetParameters ().Length];
+                       }
+
+                       public object Invoke (object instance, object [] parameters)
+            {
+                               return _methodInfo.Invoke (instance, parameters);
+                       }
+
+                       public IAsyncResult InvokeBegin (object instance, object [] inputs, AsyncCallback callback, object state) {
+                               throw new NotSupportedException ();
+                       }
+
+                       public object InvokeEnd (object instance, out object [] outputs, IAsyncResult result) {
+                               throw new NotSupportedException ();
+                       }
+
+                       #endregion
+               }
+
+               class AsyncMethodInvoker : IOperationInvoker
+               {
+                       readonly MethodInfo _beginMethodInfo, _endMethodInfo;
+                       public AsyncMethodInvoker (MethodInfo beginMethodInfo, MethodInfo endMethodInfo) {
+                               _beginMethodInfo = beginMethodInfo;
+                               _endMethodInfo = endMethodInfo;
+                       }
+
+                       #region IOperationInvoker Members
+
+                       public bool IsSynchronous {
+                               get { return false; }
+                       }
+
+                       public object [] AllocateParameters () {
+                               return new object [_beginMethodInfo.GetParameters ().Length - 2 + _endMethodInfo.GetParameters().Length-1];
+                       }
+
+                       public object Invoke (object instance, object [] parameters) {
+                               throw new NotImplementedException ("Can't invoke async method synchronously");
+                               //BUGBUG: need to differentiate between input and output parameters.
+                               IAsyncResult asyncResult = InvokeBegin(instance, parameters, delegate(IAsyncResult ignore) { }, null);
+                               asyncResult.AsyncWaitHandle.WaitOne();
+                               return InvokeEnd(instance, out parameters, asyncResult);
+                       }
+
+                       public IAsyncResult InvokeBegin (object instance, object [] inputs, AsyncCallback callback, object state) {
+                               if (inputs.Length + 2 != _beginMethodInfo.GetParameters ().Length)
+                                       throw new ArgumentException ("Wrong number of input parameters");
+                               object [] fullargs = new object [_beginMethodInfo.GetParameters ().Length];
+                               Array.Copy (inputs, fullargs, inputs.Length);
+                               fullargs [inputs.Length] = callback;
+                               fullargs [inputs.Length + 1] = state;
+                               return (IAsyncResult) _beginMethodInfo.Invoke (instance, fullargs);
+                       }
+
+                       public object InvokeEnd (object instance, out object [] outputs, IAsyncResult asyncResult) {
+                               outputs = new object [_endMethodInfo.GetParameters ().Length - 1];
+                               object [] fullargs = new object [_endMethodInfo.GetParameters ().Length];
+                               fullargs [outputs.Length] = asyncResult;
+                               object result = _endMethodInfo.Invoke (instance, fullargs);
+                               Array.Copy (fullargs, outputs, outputs.Length);
+                               return result;
+                       }
+
+                       #endregion
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostingEnvironment.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostingEnvironment.cs
new file mode 100644 (file)
index 0000000..be8d854
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// ServiceHostingEnvironment.cs
+//
+// Author:
+//     Ankit Jain  <jankit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel {
+
+       public static class ServiceHostingEnvironment {
+
+               static bool aspnet_compatibility;
+               static bool in_aspnet = false;
+               
+               public static bool AspNetCompatibilityEnabled {
+                       get { return aspnet_compatibility; }
+               }
+
+               public static void EnsureServiceAvailable (string virtualPath)
+               {
+               }
+
+               internal static bool InAspNet {
+                       get { return in_aspnet; }
+                       set { in_aspnet = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ServiceKnownTypeAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ServiceKnownTypeAttribute.cs
new file mode 100644 (file)
index 0000000..5eede2c
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// ServiceKnownTypeAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+namespace System.ServiceModel {
+
+       public class ServiceKnownTypeAttribute : Attribute
+       {
+               public ServiceKnownTypeAttribute (string methodName)
+                       : this (methodName, null)
+               {
+               }
+
+               public ServiceKnownTypeAttribute (Type declaringType)
+                       : this (null, declaringType)
+               {
+               }
+
+               public ServiceKnownTypeAttribute (string methodName, Type declaringType)
+               {
+                       this.type = declaringType;
+                       this.method = methodName;
+               }
+
+               string method;
+               Type type;
+
+               public string MethodName {
+                       get { return method; }
+               }
+
+               public Type DeclaringType {
+                       get { return type; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ServiceRuntimeChannel.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ServiceRuntimeChannel.cs
new file mode 100644 (file)
index 0000000..a94b122
--- /dev/null
@@ -0,0 +1,214 @@
+//
+// ServiceRuntimeChannel.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+
+namespace System.ServiceModel
+{
+       internal class ServiceRuntimeChannel : CommunicationObject, IContextChannel, IClientChannel
+       {
+               IExtensionCollection<IContextChannel> extensions;
+               readonly IChannel channel;              
+               bool _allowInitializationUI;
+               Uri _via;
+               readonly TimeSpan _openTimeout;
+               readonly TimeSpan _closeTimeout;
+
+               public ServiceRuntimeChannel (IChannel channel, TimeSpan openTimeout, TimeSpan closeTimeout)
+               {
+                       this.channel = channel;
+                       this._openTimeout = openTimeout;
+                       this._closeTimeout = closeTimeout;
+               }
+
+               #region IContextChannel
+
+               [MonoTODO]
+               public bool AllowOutputBatching {
+                       get { throw new NotImplementedException (); }
+                       set { throw new NotImplementedException (); }
+               }
+
+               public IInputSession InputSession {
+                       get {
+                               if (channel is IInputSessionChannel)
+                                       return ((IInputSessionChannel) channel).Session;
+                               return null;
+                       }
+               }
+
+               public EndpointAddress LocalAddress {
+                       get {
+                               if (channel is IReplyChannel)
+                                       return ((IReplyChannel) channel).LocalAddress;
+                               if (channel is IInputChannel)
+                                       return ((IInputChannel) channel).LocalAddress;
+                               return null;
+                       }
+               }
+
+               [MonoTODO]
+               public TimeSpan OperationTimeout {
+                       get { throw new NotImplementedException (); }
+                       set { throw new NotImplementedException (); }
+               }
+
+               public IOutputSession OutputSession {
+                       get {
+                               if (channel is IOutputSessionChannel)
+                                       return ((IOutputSessionChannel) channel).Session;
+                               return null;
+                       }
+               }
+
+               public EndpointAddress RemoteAddress {
+                       get {
+                               if (channel is IRequestChannel)
+                                       return ((IRequestChannel) channel).RemoteAddress;
+                               if (channel is IOutputChannel)
+                                       return ((IOutputChannel) channel).RemoteAddress;
+                               return null;
+                       }
+               }
+
+               public string SessionId {
+                       get { return InputSession != null ? InputSession.Id : null; }
+               }
+
+               #endregion
+
+               // CommunicationObject
+               protected internal override TimeSpan DefaultOpenTimeout {
+                       get { return _openTimeout; }
+               }
+
+               protected internal override TimeSpan DefaultCloseTimeout {
+                       get { return _closeTimeout; }
+               }
+
+               protected override void OnAbort ()
+               {
+                       channel.Abort ();
+               }
+
+               protected override IAsyncResult OnBeginClose (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return channel.BeginClose (timeout, callback, state);
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       channel.EndClose (result);
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       channel.Close (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return channel.BeginOpen (timeout, callback, state);
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       channel.EndOpen (result);
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       channel.Open (timeout);
+               }
+
+               // IChannel
+               public T GetProperty<T> () where T : class
+               {
+                       return channel.GetProperty<T> ();
+               }
+
+               // IExtensibleObject<IContextChannel>
+               public IExtensionCollection<IContextChannel> Extensions {
+                       get {
+                               if (extensions == null)
+                                       extensions = new ExtensionCollection<IContextChannel> (this);
+                               return extensions;
+                       }
+               }
+
+
+               #region IClientChannel Members
+
+               public bool AllowInitializationUI {
+                       get {
+                               return _allowInitializationUI;
+                       }
+                       set {
+                               _allowInitializationUI = value;
+                       }
+               }
+
+               public bool DidInteractiveInitialization {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public Uri Via {
+                       get { return _via; }
+               }
+
+               public IAsyncResult BeginDisplayInitializationUI (AsyncCallback callback, object state) {
+                       throw new NotImplementedException ();
+               }
+
+               public void EndDisplayInitializationUI (IAsyncResult result) {
+                       throw new NotImplementedException ();
+               }
+
+               public void DisplayInitializationUI () {
+                       throw new NotImplementedException ();
+               }
+
+               public event EventHandler<UnknownMessageReceivedEventArgs> UnknownMessageReceived;
+
+               #endregion
+
+               #region IDisposable Members
+
+               public void Dispose () {
+                       throw new NotImplementedException ();
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/ServiceSecurityContext.cs b/mcs/class/System.ServiceModel/System.ServiceModel/ServiceSecurityContext.cs
new file mode 100644 (file)
index 0000000..e5c1ccb
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// ServiceSecurityContext.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Policy;
+using System.Security.Principal;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public class ServiceSecurityContext
+       {
+               static ServiceSecurityContext anonymous = new ServiceSecurityContext (new ReadOnlyCollection<IAuthorizationPolicy> (new IAuthorizationPolicy [0]));
+               static ServiceSecurityContext current;
+
+               [MonoTODO]
+               public static ServiceSecurityContext Anonymous {
+                       get { return anonymous; }
+               }
+
+               [MonoTODO] // null by default?
+               public static ServiceSecurityContext Current {
+                       get { return current; }
+               }
+
+               AuthorizationContext context;
+               ReadOnlyCollection<IAuthorizationPolicy> policies;
+               IIdentity primary_identity;
+
+               public ServiceSecurityContext (AuthorizationContext authorizationContext)
+                       : this (authorizationContext, new ReadOnlyCollection<IAuthorizationPolicy> (new IAuthorizationPolicy [0]))
+               {
+               }
+
+               public ServiceSecurityContext (
+                       ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies)
+                       : this (AuthorizationContext.CreateDefaultAuthorizationContext (authorizationPolicies), authorizationPolicies)
+               {
+               }
+
+               public ServiceSecurityContext (AuthorizationContext authorizationContext,
+                       ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies)
+               {
+                       if (authorizationContext == null)
+                               throw new ArgumentNullException ("authorizationContext");
+                       if (authorizationPolicies == null)
+                               throw new ArgumentNullException ("authorizationPolicies");
+                       this.policies = authorizationPolicies;
+                       this.context = authorizationContext;
+
+                       // FIXME: get correct identity
+                       primary_identity = new GenericIdentity (String.Empty);
+               }
+
+               public AuthorizationContext AuthorizationContext {
+                       get { return context; }
+               }
+
+               public ReadOnlyCollection<IAuthorizationPolicy> AuthorizationPolicies {
+                       get { return policies; }
+               }
+
+               [MonoTODO]
+               public bool IsAnonymous {
+                       get { return policies.Count == 0; }
+               }
+
+               [MonoTODO]
+               public IIdentity PrimaryIdentity {
+                       get { return primary_identity; }
+               }
+
+               [MonoTODO]
+               public WindowsIdentity WindowsIdentity {
+                       get { throw new NotImplementedException (); }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/SpnEndpointIdentity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/SpnEndpointIdentity.cs
new file mode 100644 (file)
index 0000000..cd19e90
--- /dev/null
@@ -0,0 +1,50 @@
+//
+// SpnEndpointIdentity.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Claims;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Xml;
+
+
+namespace System.ServiceModel
+{
+       public class SpnEndpointIdentity : EndpointIdentity
+       {
+               public SpnEndpointIdentity (Claim identity)
+               {
+                       Initialize (identity);
+               }
+
+               public SpnEndpointIdentity (string spn)
+                       : this (Claim.CreateSpnClaim (spn))
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/TcpTransportSecurity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/TcpTransportSecurity.cs
new file mode 100644 (file)
index 0000000..55c51b2
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// TcpTransportSecurity.cs
+//
+// Author:
+//     Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Net.Security;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       public sealed class TcpTransportSecurity
+       {
+               TcpClientCredentialType client;
+               ProtectionLevel protection_level;
+
+               internal TcpTransportSecurity ()
+               {
+               }
+
+               public TcpClientCredentialType ClientCredentialType {
+                       get { return client; }
+                       set { client = value; }
+               }
+
+               public ProtectionLevel ProtectionLevel {
+                       get { return protection_level; }
+                       set { protection_level = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/TransactionProtocol.cs b/mcs/class/System.ServiceModel/System.ServiceModel/TransactionProtocol.cs
new file mode 100644 (file)
index 0000000..d70f521
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// TransactionProtocol.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel
+{
+       public class TransactionProtocol
+       {
+               // Static members
+
+               static TransactionProtocol wsat, oletx;
+
+               static TransactionProtocol ()
+               {
+                       wsat = new WSAtomicTransactionProtocol ();
+                       oletx = new OleTransactionProtocol ();
+               }
+
+               // Thus Mono users should not depend on default transactions
+               public static TransactionProtocol Default {
+                       get { return OleTransactions; }
+               }
+
+               public static TransactionProtocol OleTransactions {
+                       get { return oletx; }
+               }
+
+               public static TransactionProtocol WSAtomicTransactionOctober2004 {
+                       get { return wsat; }
+               }
+
+               // Instance members
+
+               protected TransactionProtocol ()
+               {
+               }
+
+               class WSAtomicTransactionProtocol : TransactionProtocol
+               {
+               }
+
+               class OleTransactionProtocol : TransactionProtocol
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/TransferMode.cs b/mcs/class/System.ServiceModel/System.ServiceModel/TransferMode.cs
new file mode 100644 (file)
index 0000000..7cd6303
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// TransferMode.cs
+//
+// Author: Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       public enum TransferMode {
+               Buffered,
+               Streamed,
+               StreamedRequest,
+               StreamedResponse
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/UnknownMessageReceivedEventArgs.cs b/mcs/class/System.ServiceModel/System.ServiceModel/UnknownMessageReceivedEventArgs.cs
new file mode 100644 (file)
index 0000000..ddd64e9
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// System.ServiceModel.UnknownMessageReceivedEventArgs.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.ServiceModel.Channels;
+
+namespace System.ServiceModel {
+
+       public sealed class UnknownMessageReceivedEventArgs : EventArgs
+       {
+               Message message;
+               
+               internal UnknownMessageReceivedEventArgs (Message message)
+               {
+                       this.message = message;
+               }
+
+               public Message Message {
+                       get { return message; }
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/UpnEndpointIdentity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/UpnEndpointIdentity.cs
new file mode 100644 (file)
index 0000000..a866e93
--- /dev/null
@@ -0,0 +1,50 @@
+//
+// UpnEndpointIdentity.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Claims;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Xml;
+
+
+namespace System.ServiceModel
+{
+       public class UpnEndpointIdentity : EndpointIdentity
+       {
+               public UpnEndpointIdentity (Claim identity)
+               {
+                       Initialize (identity);
+               }
+
+               public UpnEndpointIdentity (string upn)
+                       : this (Claim.CreateUpnClaim (upn))
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/UriSchemeKeyedCollection.cs b/mcs/class/System.ServiceModel/System.ServiceModel/UriSchemeKeyedCollection.cs
new file mode 100644 (file)
index 0000000..c2ea59f
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// UriSchemeKeyedCollection.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace System.ServiceModel
+{
+       [MonoTODO ("It is untested.")]
+       public class UriSchemeKeyedCollection
+               : SynchronizedKeyedCollection<string, Uri>
+       {
+               public UriSchemeKeyedCollection (params Uri [] uris)
+                       : base (new object ())
+               {
+                       if (uris == null)
+                               /* FIXME: masterinfo says, param name should be
+                                  baseAddresses */
+                               throw new ArgumentNullException ("uris");
+
+                       for (int i = 0; i < uris.Length; i ++) {
+                               if (!uris [i].IsAbsoluteUri)
+                                       throw new ArgumentException ("Only an absolute URI can be used as a base address");
+
+                               if (Contains (uris [i].Scheme))
+                                       throw new ArgumentException ("Collection already contains an address with scheme "+ uris [i].Scheme);
+                               if (uris [i].Query != String.Empty)
+                                       throw new ArgumentException ("A base address cannot contain a query string.");
+
+                               InsertItem (i, uris [i]);
+                       }
+               }
+
+               protected override string GetKeyForItem (Uri item)
+               {
+                       return item.Scheme;
+               }
+
+               [MonoTODO ("hmm, what should I do further?")]
+               protected override void InsertItem (int index, Uri item)
+               {
+                       base.InsertItem (index, item);
+               }
+
+               [MonoTODO ("hmm, what should I do further?")]
+               protected override void SetItem (int index, Uri item)
+               {
+                       base.SetItem (index, item);
+               }
+
+               internal IList<Uri> InternalItems {
+                       get { return base.Items; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/WS2007FederationHttpBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel/WS2007FederationHttpBinding.cs
new file mode 100644 (file)
index 0000000..6c5cde9
--- /dev/null
@@ -0,0 +1,39 @@
+//\r
+// WS2007FederationHttpBinding.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel\r
+{\r
+       [MonoTODO]\r
+       public class WS2007FederationHttpBinding : WSFederationHttpBinding\r
+       {\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/WS2007HttpBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel/WS2007HttpBinding.cs
new file mode 100644 (file)
index 0000000..04c876e
--- /dev/null
@@ -0,0 +1,39 @@
+//\r
+// WS2007HttpBinding.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace System.ServiceModel\r
+{\r
+       [MonoTODO]\r
+       public class WS2007HttpBinding : WSHttpBinding\r
+       {\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/WSDualHttpBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel/WSDualHttpBinding.cs
new file mode 100644 (file)
index 0000000..a531b34
--- /dev/null
@@ -0,0 +1,149 @@
+//
+// WSDualHttpBinding.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       public class WSDualHttpBinding : Binding, IBindingRuntimePreferences
+       {
+               bool bypass_proxy_on_local;
+               HostNameComparisonMode host_name_comparison_mode;
+               long max_buffer_pool_size;
+               long max_recv_msg_size;
+               WSDualHttpSecurity security;
+               WSMessageEncoding message_encoding;
+               Uri proxy_address;
+               XmlDictionaryReaderQuotas reader_quotas;
+               ReliableSession reliable_session;
+               EnvelopeVersion env_version;
+               Encoding text_encoding;
+               bool transaction_flow;
+               bool use_default_web_proxy;
+
+               public WSDualHttpBinding ()
+                       : this (WSDualHttpSecurityMode.Message)
+               {
+               }
+
+               protected WSDualHttpBinding (WSDualHttpSecurityMode securityMode)
+               {
+                       security = new WSDualHttpSecurity (securityMode);
+               }
+
+               public Uri ClientBaseAddress {
+                       get { throw new NotImplementedException (); }
+                       set { throw new NotImplementedException (); }
+               }
+
+               public bool BypassProxyOnLocal {
+                       get { return bypass_proxy_on_local; }
+                       set { bypass_proxy_on_local = value; }
+               }
+
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return host_name_comparison_mode; }
+                       set { host_name_comparison_mode = value; }
+               }
+
+               public long MaxBufferPoolSize {
+                       get { return max_buffer_pool_size; }
+                       set { max_buffer_pool_size = value; }
+               }
+
+               public long MaxReceivedMessageSize {
+                       get { return max_recv_msg_size; }
+                       set { max_recv_msg_size = value; }
+               }
+
+               public WSMessageEncoding MessageEncoding {
+                       get { return message_encoding; }
+                       set { message_encoding = value; }
+               }
+
+               public Uri ProxyAddress {
+                       get { return proxy_address; }
+                       set { proxy_address = value; }
+               }
+
+               public XmlDictionaryReaderQuotas ReaderQuotas {
+                       get { return reader_quotas; }
+                       set { reader_quotas = value; }
+               }
+
+               public ReliableSession ReliableSession {
+                       get { return reliable_session; }
+               }
+
+               public override string Scheme {
+                       get { return Uri.UriSchemeHttp; }
+               }
+
+               public WSDualHttpSecurity Security {
+                       get { return security; }
+               }
+
+               public EnvelopeVersion EnvelopeVersion {
+                       get { return env_version; }
+               }
+
+               public Encoding TextEncoding {
+                       get { return text_encoding; }
+                       set { text_encoding = value; }
+               }
+
+               public bool TransactionFlow {
+                       get { return transaction_flow; }
+                       set { transaction_flow = value; }
+               }
+
+               public bool UseDefaultWebProxy {
+                       get { return use_default_web_proxy; }
+                       set { use_default_web_proxy = value; }
+               }
+
+               public override BindingElementCollection
+                       CreateBindingElements ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+               // explicit interface implementations
+
+               bool IBindingRuntimePreferences.ReceiveSynchronously {
+                       get { throw new NotImplementedException (); }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/WSDualHttpSecurity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/WSDualHttpSecurity.cs
new file mode 100644 (file)
index 0000000..5d7b2ab
--- /dev/null
@@ -0,0 +1,57 @@
+//
+// WSDualHttpSecurity.cs
+//
+// Author:
+//     Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+       public sealed class WSDualHttpSecurity
+       {
+               WSDualHttpSecurityMode mode;
+               MessageSecurityOverHttp message;
+
+               internal WSDualHttpSecurity (WSDualHttpSecurityMode mode)
+               {
+                       this.Mode = mode;
+                       message = new MessageSecurityOverHttp ();
+               }
+
+               [MonoTODO]
+               public MessageSecurityOverHttp Message {
+                       get { return message; }
+               }
+
+               [MonoTODO]
+               public WSDualHttpSecurityMode Mode {
+                       get { return mode; }
+                       set {
+                               mode = value;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/WSFederationHttpBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel/WSFederationHttpBinding.cs
new file mode 100644 (file)
index 0000000..01d87c5
--- /dev/null
@@ -0,0 +1,140 @@
+//
+// WSFederationHttpBinding.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel
+{
+       public class WSFederationHttpBinding : WSHttpBindingBase
+       {
+               WSFederationHttpSecurity security;
+               bool allow_cookies;
+
+               public WSFederationHttpBinding ()
+                       : this (WSFederationHttpSecurityMode.Message)
+               {
+               }
+
+               public WSFederationHttpBinding (
+                       WSFederationHttpSecurityMode securityMode)
+                       : this (securityMode, true)
+               {
+               }
+
+               public WSFederationHttpBinding (
+                       WSFederationHttpSecurityMode securityMode,
+                       bool reliableSessionEnabled)
+               {
+                       security = new WSFederationHttpSecurity (securityMode);
+               }
+
+               [MonoTODO]
+               public WSFederationHttpBinding (string configurationName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public bool AllowCookies {
+                       get { return allow_cookies; }
+                       set { allow_cookies = value; }
+               }
+
+               [MonoTODO]
+               public WSFederationHttpSecurity Security {
+                       get { return security; }
+               }
+
+               [MonoTODO]
+               public override BindingElementCollection CreateBindingElements ()
+               {
+                       return base.CreateBindingElements ();
+               }
+
+               [MonoTODO]
+               protected override SecurityBindingElement CreateMessageSecurity ()
+               {
+                       SymmetricSecurityBindingElement element =
+                               new SymmetricSecurityBindingElement ();
+
+                       element.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
+
+//                     if (!Security.Message.EstablishSecurityContext)
+//                             element.SetKeyDerivation (false);
+
+                       IssuedSecurityTokenParameters istp =
+                               new IssuedSecurityTokenParameters ();
+                       // FIXME: issuer binding must be secure.
+                       istp.IssuerBinding = new CustomBinding (
+                               new TextMessageEncodingBindingElement (),
+                               GetTransport ());
+                       element.EndpointSupportingTokenParameters.Endorsing.Add (istp);
+
+                       if (Security.Message.NegotiateServiceCredential) {
+                               element.ProtectionTokenParameters =
+                                       // FIXME: fill proper parameters
+                                       new SslSecurityTokenParameters (false, true);
+                       } else {
+                               element.ProtectionTokenParameters =
+                                       new X509SecurityTokenParameters ();
+                       }
+
+//                     if (!Security.Message.EstablishSecurityContext)
+//                             return element;
+
+                       // SecureConversation enabled
+
+                       ChannelProtectionRequirements reqs =
+                               new ChannelProtectionRequirements ();
+                       // FIXME: fill the reqs
+
+                       // FIXME: for TransportWithMessageCredential mode,
+                       // return TransportSecurityBindingElement.
+
+                       return SecurityBindingElement.CreateSecureConversationBindingElement (
+                               // FIXME: requireCancellation
+                               element, true, reqs);
+               }
+
+               [MonoTODO]
+               protected override TransportBindingElement GetTransport ()
+               {
+                       switch (Security.Mode) {
+                       case WSFederationHttpSecurityMode.TransportWithMessageCredential:
+                               return new HttpsTransportBindingElement ();
+                       default:
+                               return new HttpTransportBindingElement ();
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/WSFederationHttpSecurity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/WSFederationHttpSecurity.cs
new file mode 100644 (file)
index 0000000..80d5564
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// WSFederationHttpSecurity.cs
+//
+// Author:
+//     Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+       public sealed class WSFederationHttpSecurity
+       {
+               WSFederationHttpSecurityMode mode;
+               FederatedMessageSecurityOverHttp message;
+
+               internal WSFederationHttpSecurity (WSFederationHttpSecurityMode mode)
+               {
+                       this.Mode = mode;
+                       message = new FederatedMessageSecurityOverHttp ();
+               }
+
+               public FederatedMessageSecurityOverHttp Message {
+                       get { return message; }
+               }
+
+               public WSFederationHttpSecurityMode Mode {
+                       get { return mode; }
+                       set {
+                               mode = value;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/WSHttpBinding.cs b/mcs/class/System.ServiceModel/System.ServiceModel/WSHttpBinding.cs
new file mode 100644 (file)
index 0000000..0a56a6d
--- /dev/null
@@ -0,0 +1,178 @@
+//
+// WSHttpBinding.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+
+namespace System.ServiceModel
+{
+       public class WSHttpBinding : WSHttpBindingBase
+       {
+               WSHttpSecurity security;
+               bool allow_cookies;
+
+               public WSHttpBinding ()
+                       : this (SecurityMode.Message)
+               {
+               }
+
+               public WSHttpBinding (SecurityMode mode)
+                       : this (mode, false)
+               {
+               }
+
+               public WSHttpBinding (SecurityMode mode,
+                       bool reliableSessionEnabled)
+                       : base (reliableSessionEnabled)
+               {
+                       security = new WSHttpSecurity (mode);
+               }
+
+               [MonoTODO]
+               public WSHttpBinding (string configurationName)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public bool AllowCookies {
+                       get { return allow_cookies; }
+                       set { allow_cookies = value; }
+               }
+
+               [MonoTODO]
+               public WSHttpSecurity Security {
+                       get { return security; }
+               }
+
+               [MonoTODO]
+               public override BindingElementCollection CreateBindingElements ()
+               {
+                       BindingElementCollection bc = base.CreateBindingElements ();
+                       // message security element is returned only when
+                       // it is enabled (while CreateMessageSecurity() still
+                       // returns non-null instance).
+                       switch (Security.Mode) {
+                       case SecurityMode.None:
+                       case SecurityMode.Transport:
+                               bc.RemoveAll<SecurityBindingElement> ();
+                               break;
+                       }
+                       return bc;
+               }
+
+               [MonoTODO]
+               protected override SecurityBindingElement CreateMessageSecurity ()
+               {
+                       if (Security.Mode == SecurityMode.Transport ||
+                           Security.Mode == SecurityMode.None)
+                               return null;
+
+                       SymmetricSecurityBindingElement element =
+                               new SymmetricSecurityBindingElement ();
+
+                       element.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
+                       element.RequireSignatureConfirmation = true;
+
+                       switch (Security.Message.ClientCredentialType) {
+                       case MessageCredentialType.Certificate:
+                               X509SecurityTokenParameters p =
+                                       new X509SecurityTokenParameters (X509KeyIdentifierClauseType.Thumbprint);
+                               p.RequireDerivedKeys = false;
+                               element.EndpointSupportingTokenParameters.Endorsing.Add (p);
+                               goto default;
+                       case MessageCredentialType.IssuedToken:
+                               IssuedSecurityTokenParameters istp =
+                                       new IssuedSecurityTokenParameters ();
+                               // FIXME: issuer binding must be secure.
+                               istp.IssuerBinding = new CustomBinding (
+                                       new TextMessageEncodingBindingElement (),
+                                       GetTransport ());
+                               element.EndpointSupportingTokenParameters.Endorsing.Add (istp);
+                               goto default;
+                       case MessageCredentialType.UserName:
+                               element.EndpointSupportingTokenParameters.SignedEncrypted.Add (
+                                       new UserNameSecurityTokenParameters ());
+                               element.RequireSignatureConfirmation = false;
+                               goto default;
+                       case MessageCredentialType.Windows:
+                               if (Security.Message.NegotiateServiceCredential) {
+                                       // No SSPI on Linux though...
+                                       element.ProtectionTokenParameters =
+                                               // FIXME: fill proper parameters
+                                               new SspiSecurityTokenParameters ();
+                               } else {
+                                       // and no Kerberos ...
+                                       element.ProtectionTokenParameters =
+                                               new KerberosSecurityTokenParameters ();
+                               }
+                               break;
+                       default: // including .None
+                               if (Security.Message.NegotiateServiceCredential) {
+                                       element.ProtectionTokenParameters =
+                                               // FIXME: fill proper parameters
+                                               new SslSecurityTokenParameters (false, true);
+                               } else {
+                                       element.ProtectionTokenParameters =
+                                               new X509SecurityTokenParameters (X509KeyIdentifierClauseType.Thumbprint, SecurityTokenInclusionMode.Never);
+                                       element.ProtectionTokenParameters.RequireDerivedKeys = true;
+                               }
+                               break;
+                       }
+
+                       if (!Security.Message.EstablishSecurityContext)
+                               return element;
+
+                       // SecureConversation enabled
+
+                       ChannelProtectionRequirements reqs =
+                               new ChannelProtectionRequirements ();
+                       // FIXME: fill the reqs
+
+                       return SecurityBindingElement.CreateSecureConversationBindingElement (
+                               // FIXME: requireCancellation
+                               element, true, reqs);
+               }
+
+               [MonoTODO]
+               protected override TransportBindingElement GetTransport ()
+               {
+                       switch (Security.Mode) {
+                       case SecurityMode.Transport:
+                       case SecurityMode.TransportWithMessageCredential:
+                               return new HttpsTransportBindingElement ();
+                       default:
+                               return new HttpTransportBindingElement ();
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/WSHttpBindingBase.cs b/mcs/class/System.ServiceModel/System.ServiceModel/WSHttpBindingBase.cs
new file mode 100644 (file)
index 0000000..9f5fcac
--- /dev/null
@@ -0,0 +1,194 @@
+//
+// WSHttpBindingBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Net.Security;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.Text;
+using System.Xml;
+
+namespace System.ServiceModel
+{
+       [MonoTODO]
+       public abstract class WSHttpBindingBase : Binding, 
+               IBindingRuntimePreferences
+       {
+               bool bypass_proxy_on_local, reliable_session_enabled;
+               HostNameComparisonMode host_name_comparison_mode
+                       = HostNameComparisonMode.StrongWildcard;
+               // FIXME: could be configurable
+               long max_buffer_pool_size = 0x80000;
+               // FIXME: could be configurable
+               long max_recv_msg_size = 0x10000;
+               WSMessageEncoding message_encoding
+                       = WSMessageEncoding.Text;
+               Uri proxy_address;
+               XmlDictionaryReaderQuotas reader_quotas
+                       = new XmlDictionaryReaderQuotas ();
+               OptionalReliableSession reliable_session;
+               // FIXME: could be configurable.
+               EnvelopeVersion env_version = EnvelopeVersion.Soap12;
+               Encoding text_encoding = new UTF8Encoding ();
+               bool transaction_flow;
+               bool use_default_web_proxy = true;
+
+               ReliableSessionBindingElement rel_element =
+                       new ReliableSessionBindingElement ();
+
+               protected WSHttpBindingBase ()
+                       : this (false)
+               {
+               }
+
+               protected WSHttpBindingBase (bool reliableSessionEnabled)
+               {
+                       reliable_session = new OptionalReliableSession (rel_element);
+                       reliable_session.Enabled = reliableSessionEnabled;
+               }
+
+               internal WSHttpBindingBase (WSHttpBindingBaseElement config)
+                       : this (config.ReliableSession.Enabled)
+               {
+                       BypassProxyOnLocal = config.BypassProxyOnLocal;
+                       HostNameComparisonMode = config.HostNameComparisonMode;
+                       MaxBufferPoolSize = config.MaxBufferPoolSize;
+                       MaxReceivedMessageSize = config.MaxReceivedMessageSize;
+                       MessageEncoding = config.MessageEncoding;
+                       ProxyAddress = config.ProxyAddress;
+                       // ReaderQuotas = config.ReaderQuotas;
+
+                       TextEncoding = config.TextEncoding;
+                       TransactionFlow = config.TransactionFlow;
+                       UseDefaultWebProxy = config.UseDefaultWebProxy;
+                       throw new NotImplementedException ();
+               }
+
+               public bool BypassProxyOnLocal {
+                       get { return bypass_proxy_on_local; }
+                       set { bypass_proxy_on_local = value; }
+               }
+
+               public HostNameComparisonMode HostNameComparisonMode {
+                       get { return host_name_comparison_mode; }
+                       set { host_name_comparison_mode = value; }
+               }
+
+               public long MaxBufferPoolSize {
+                       get { return max_buffer_pool_size; }
+                       set { max_buffer_pool_size = value; }
+               }
+
+               public long MaxReceivedMessageSize {
+                       get { return max_recv_msg_size; }
+                       set { max_recv_msg_size = value; }
+               }
+
+               public WSMessageEncoding MessageEncoding {
+                       get { return message_encoding; }
+                       set { message_encoding = value; }
+               }
+
+               public Uri ProxyAddress {
+                       get { return proxy_address; }
+                       set { proxy_address = value; }
+               }
+
+               public XmlDictionaryReaderQuotas ReaderQuotas {
+                       get { return reader_quotas; }
+                       set { reader_quotas = value; }
+               }
+
+               public override string Scheme {
+                       get { return GetTransport ().Scheme; }
+               }
+
+               public OptionalReliableSession ReliableSession {
+                       get { return reliable_session; }
+               }
+
+               public EnvelopeVersion EnvelopeVersion {
+                       get { return env_version; }
+               }
+
+               public Encoding TextEncoding {
+                       get { return text_encoding; }
+                       set { text_encoding = value; }
+               }
+
+               public bool TransactionFlow {
+                       get { return transaction_flow; }
+                       set { transaction_flow = value; }
+               }
+
+               public bool UseDefaultWebProxy {
+                       get { return use_default_web_proxy; }
+                       set { use_default_web_proxy = value; }
+               }
+
+               [MonoTODO]
+               public override BindingElementCollection
+                       CreateBindingElements ()
+               {
+                       BindingElement tx = new TransactionFlowBindingElement (TransactionProtocol.WSAtomicTransactionOctober2004);
+                       SecurityBindingElement sec = CreateMessageSecurity ();
+                       BindingElement msg = null;
+                       MessageVersion msgver = MessageVersion.CreateVersion (EnvelopeVersion, AddressingVersion.WSAddressing10);
+                       switch (MessageEncoding) {
+                       case WSMessageEncoding.Mtom:
+                               msg = new MtomMessageEncodingBindingElement (msgver, TextEncoding);
+                               break;
+                       case WSMessageEncoding.Text:
+                               msg = new TextMessageEncodingBindingElement (msgver, TextEncoding);
+                               break;
+                       default:
+                               throw new NotImplementedException ("mhm, another WSMessageEncoding?");
+                       }
+                       BindingElement tr = GetTransport ();
+                       List<BindingElement> list = new List<BindingElement> ();
+                       list.Add (tx);
+                       if (sec != null)
+                               list.Add (sec);
+                       list.Add (msg);
+                       if (tr != null)
+                               list.Add (tr);
+                       return new BindingElementCollection (list.ToArray ());
+               }
+
+               protected abstract SecurityBindingElement CreateMessageSecurity ();
+
+               protected abstract TransportBindingElement GetTransport ();
+
+               // explicit interface implementations
+
+               bool IBindingRuntimePreferences.ReceiveSynchronously {
+                       get { return false; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/WSHttpSecurity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/WSHttpSecurity.cs
new file mode 100644 (file)
index 0000000..332907c
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// WSHttpSecurity.cs
+//
+// Author:
+//     Atsushi Enomoto (atsushi@ximian.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel.Security;
+
+namespace System.ServiceModel
+{
+       public sealed class WSHttpSecurity
+       {
+               SecurityMode mode;
+               NonDualMessageSecurityOverHttp message;
+               HttpTransportSecurity transport;
+
+               internal WSHttpSecurity (SecurityMode mode)
+               {
+                       this.Mode = mode;
+                       message = new NonDualMessageSecurityOverHttp ();
+                       transport = new HttpTransportSecurity ();
+               }
+
+               [MonoTODO]
+               public NonDualMessageSecurityOverHttp Message {
+                       get { return message; }
+               }
+
+               [MonoTODO]
+               public SecurityMode Mode {
+                       get { return mode; }
+                       set {
+                               mode = value;
+                       }
+               }
+
+               [MonoTODO]
+               public HttpTransportSecurity Transport {
+                       get { return transport; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/X509CertificateEndpointIdentity.cs b/mcs/class/System.ServiceModel/System.ServiceModel/X509CertificateEndpointIdentity.cs
new file mode 100644 (file)
index 0000000..88845ed
--- /dev/null
@@ -0,0 +1,76 @@
+//
+// X509CertificateEndpointIdentity.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Claims;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Xml;
+
+
+namespace System.ServiceModel
+{
+       public class X509CertificateEndpointIdentity : EndpointIdentity
+       {
+               X509Certificate2 primary;
+               X509Certificate2Collection supporting, all;
+
+               public X509CertificateEndpointIdentity (X509Certificate2 cert)
+               {
+                       if (cert == null)
+                               throw new ArgumentNullException ("cert");
+                       primary = cert;
+                       Initialize (Claim.CreateThumbprintClaim (cert.GetCertHash ()));
+               }
+
+               public X509CertificateEndpointIdentity (
+                       X509Certificate2 primaryCertificate,
+                       X509Certificate2Collection supportingCertificates)
+               {
+                       if (primaryCertificate == null)
+                               throw new ArgumentNullException ("primaryCertificate");
+                       if (supportingCertificates == null)
+                               throw new ArgumentNullException ("supportingCertificates");
+
+                       primary = primaryCertificate;
+                       supporting = supportingCertificates;
+               }
+
+               public X509Certificate2Collection Certificates {
+                       get {
+                               if (all == null) {
+                                       all = new X509Certificate2Collection ();
+                                       all.Add (primary);
+                                       if (supporting != null)
+                                               all.AddRange (supporting);
+                               }
+                               return all;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel/XmlSerializerFormatAttribute.cs b/mcs/class/System.ServiceModel/System.ServiceModel/XmlSerializerFormatAttribute.cs
new file mode 100644 (file)
index 0000000..35c781f
--- /dev/null
@@ -0,0 +1,49 @@
+//
+// XmlSerializerFormatAttribute.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+
+namespace System.ServiceModel
+{
+       [AttributeUsage (AttributeTargets.Class | AttributeTargets.Interface |
+               AttributeTargets.Method, Inherited = false)]
+       public sealed class XmlSerializerFormatAttribute : Attribute
+       {
+               OperationFormatStyle style;
+               OperationFormatUse use;
+
+               public OperationFormatStyle Style {
+                       get { return style; }
+                       set { style = value; }
+               }
+
+               public OperationFormatUse Use {
+                       get { return use; }
+                       set { use = value; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel_Test.csproj b/mcs/class/System.ServiceModel/System.ServiceModel_Test.csproj
new file mode 100644 (file)
index 0000000..4285497
--- /dev/null
@@ -0,0 +1,290 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProductVersion>9.0.21022</ProductVersion>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectGuid>{05A2DAF1-316D-4350-B07B-B73BE591DE57}</ProjectGuid>\r
+    <OutputType>Library</OutputType>\r
+    <AppDesignerFolder>Properties</AppDesignerFolder>\r
+    <RootNamespace>MonoTests.System.ServiceModel</RootNamespace>\r
+    <AssemblyName>System.ServiceModel_test_net_3_0</AssemblyName>\r
+    <TargetFrameworkVersion>v3.0</TargetFrameworkVersion>\r
+    <FileAlignment>512</FileAlignment>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>.\</OutputPath>\r
+    <DefineConstants>TRACE;DEBUG;NET_3_5</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="System" />\r
+    <Reference Include="System.configuration" />\r
+    <Reference Include="System.Drawing" />\r
+    <Reference Include="System.IdentityModel">\r
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.IdentityModel.Selectors">\r
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Messaging" />\r
+    <Reference Include="System.Runtime.Serialization">\r
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Security" />\r
+    <Reference Include="System.ServiceModel">\r
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Transactions" />\r
+    <Reference Include="System.Web" />\r
+    <Reference Include="System.Web.Services" />\r
+    <Reference Include="System.Windows.Forms" />\r
+    <Reference Include="System.Data" />\r
+    <Reference Include="System.Xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="System.ServiceModel_test_net_3_0.dll.config" />\r
+    <None Include="Test\config\basicHttpBinding" />\r
+    <None Include="Test\config\basicHttpBinding.config" />\r
+    <None Include="Test\config\ChangeLog" />\r
+    <None Include="Test\config\client.endpoint" />\r
+    <None Include="Test\config\client.endpoint.config" />\r
+    <None Include="Test\config\client.metadata" />\r
+    <None Include="Test\config\client.metadata.config" />\r
+    <None Include="Test\config\customBinding" />\r
+    <None Include="Test\config\customBinding.config" />\r
+    <None Include="Test\config\empty" />\r
+    <None Include="Test\config\empty.config" />\r
+    <None Include="Test\config\endpointBehaviors" />\r
+    <None Include="Test\config\endpointBehaviors.config" />\r
+    <None Include="Test\config\extensions" />\r
+    <None Include="Test\config\extensions.config" />\r
+    <None Include="Test\config\netTcpBinding" />\r
+    <None Include="Test\config\netTcpBinding.config" />\r
+    <None Include="Test\config\service" />\r
+    <None Include="Test\config\service.config" />\r
+    <None Include="Test\config\serviceBehaviors" />\r
+    <None Include="Test\config\serviceBehaviors.config" />\r
+    <None Include="Test\config\test1" />\r
+    <None Include="Test\config\test1.config" />\r
+    <None Include="Test\config\userBinding" />\r
+    <None Include="Test\config\userBinding.config" />\r
+    <None Include="Test\config\wsHttpBinding" />\r
+    <None Include="Test\config\wsHttpBinding.config" />\r
+    <None Include="Test\Resources\test.cer" />\r
+    <None Include="Test\Resources\test.pfx" />\r
+    <None Include="Test\Resources\test2.pfx" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <EmbeddedResource Include="Test\FeatureBased\Features.Contracts\OperationContractServer.xml" />\r
+    <Content Include="Test\System.ServiceModel.Description\dump.xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="Test\FeatureBased\Features.Client\AsyncCallTesterProxy.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Client\AsyncPatternServer.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Client\DataContractTesterProxy.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Client\ExitProcessHelperServer.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Client\FaultsTesterProxy.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Client\KnownTypeTesterProxy.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Client\MessageContractTesterProxy.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Client\OperationContractServer.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Client\PrimitiveTester.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Client\UntypedMessageTesterProxy.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Contracts\AsyncCallTester.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Contracts\AsyncPatternContract.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Contracts\DualContract.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Contracts\DataContractTester.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Contracts\ExitpProcessHelper.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Contracts\FaultsTester.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Contracts\KnownTypeTester.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Contracts\MessageContractTester.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Contracts\OperationContract.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Contracts\PrimitiveTester.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Contracts\UntypedMessageTester.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\AsyncCallTest.cs">\r
+      <SubType>Code</SubType>\r
+    </Compile>\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\AsyncPatternTester.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\DataContractSerializerTest.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\DualContractTester.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\ExitProcessHelper.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\FaultsTest.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\KnownTypeTest.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\MessageContractTest.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\OperationContractTester.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\PrimitiveTesterTest.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\UntypedMessageTest.cs" />\r
+    <Compile Include="Test\FeatureBased\Features.Serialization\XmlComparer.cs" />\r
+    <Compile Include="Test\FeatureBased\TestFixtureBase.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\AddressHeaderTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\AddressingVersionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\AsymmetricSecurityBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\BindingContextTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\BindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\CalcSampleProxy.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\CommunicationObjectTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\CustomBindingTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\DebugBindingElement.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\EmptyFaultExceptionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\EnvelopeVersionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\FaultConverterTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\FaultExceptionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\HandlerBodyWriter.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\HandlerTransportBindingElement.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\HttpTransportBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\InterceptorBindingElement.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\InvalidBindingElement.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\LocalClientSecuritySettingsTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\MessageBufferTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\MessageEncoderTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\MessageEncodingBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\MessageHeadersTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\MessageHeaderTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\MessageTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\MessageVersionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\MsmqTransportBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\NamedPipeTransportBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\OneWayBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\OutputChannelBase.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\ReplyChannelBase.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\RequestChannelBase.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\SecurityAssert.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\SecurityBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\SslStreamSecurityBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\SymmetricSecurityBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\TcpTransportBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\TextMessageEncodingBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Channels\TransactionFlowBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\AddressHeaderCollectionElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\BasicHttpBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\BehaviorsSectionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\BindingsSectionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\ChannelEndpointElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\CustomBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\EndpointBehaviorElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\ExtensionsSectionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\MetadataElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\MexBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\NetNamedPipeBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\NetPeerTcpBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\NetTcpBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\ServiceBehaviorElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\ServiceElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\ServiceModelConfigurationElementCollectionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\ServiceModelSectionGroupTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\StandardBindingCollectionElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\StandardBindingElementCollectionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\StandardBindingElementTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Configuration\UserBinding.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Description\ClientCredentialsTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Description\ContractDescriptionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Description\MetadataResolverTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Description\OperationDescriptionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Description\ServiceAuthorizationBehaviorTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Description\ServiceCredentialsTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Description\ServiceDebugBehaviorTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Description\ServiceMetadataBehaviorTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Description\TypedMessageConverterTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Description\WsdlExporterTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Description\WsdlImporterTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Dispatcher\ActionFilterTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Dispatcher\DispatchOperationTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Dispatcher\DispatchRuntimeTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Dispatcher\EndpointAddressMessageFilterTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Dispatcher\EndpointDispatcherTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Dispatcher\ExceptionHandlerTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Dispatcher\FilterTableTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Dispatcher\InvalidBodyAccessExceptionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Dispatcher\PrefixEndpointAddressMessageFilterTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.PeerResolvers\CustomPeerResolverServiceTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\IssuedSecurityTokenParametersTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\IssuedSecurityTokenProviderTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\RsaSecurityTokenParametersTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\SecureConversationSecurityTokenParametersTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\SecurityContextSecurityTokenTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\SecurityTokenParametersTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\ServiceModelSecurityTokenTypesTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\SslSecurityTokenParametersTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\SspiSecurityTokenParametersTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\UserNameSecurityTokenParametersTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\WrappedKeySecurityTokenTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\X509ListedCertificateValidator.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security.Tokens\X509SecurityTokenParametersTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security\ChannelProtectionRequirementsTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security\MessagePartSpecificationTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security\ScopedMessagePartSpecificationTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security\SecurityAlgorithmSuiteTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security\SecurityMessagePropertyTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security\SecurityTokenSpeficicationTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security\ServiceCredentialsSecurityTokenManagerTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security\ServiceSecurityContextTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security\SupportingTokenParametersTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel.Security\WSSecurityTokenSerializerTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\BasicHttpBindingTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\ChannelFactoryTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\ChannelFactory_1Test.cs" />\r
+    <Compile Include="Test\System.ServiceModel\ClientBaseTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\ClientCredentialsSecurityTokenManagerTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\CommonUseCases.cs" />\r
+    <Compile Include="Test\System.ServiceModel\EndpointAddress10Test.cs" />\r
+    <Compile Include="Test\System.ServiceModel\EndpointAddressBuilderTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\EndpointAddressTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\EndpointBehaviorCollectionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\EndpointIdentityTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\FaultCodeTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\FaultReasonTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\IntegratedConnectionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\MessageSecurityVersionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\NetMsmqBindingTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\ServiceAssert.cs" />\r
+    <Compile Include="Test\System.ServiceModel\ServiceEndpointCollectionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\ServiceEndpointTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\ServiceHostBaseTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\ServiceHostTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\SynchronizedReadOnlyCollectionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\TransactionProtocolTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\UriSchemeKeyedCollectionTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\WSFederationHttpBindingTest.cs" />\r
+    <Compile Include="Test\System.ServiceModel\WSHttpBindingTest.cs" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ProjectReference Include="..\..\nunit20\framework\nunit.framework.dll20.csproj">\r
+      <Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project>\r
+      <Name>nunit.framework.dll20</Name>\r
+    </ProjectReference>\r
+    <ProjectReference Include="..\..\nunit20\nunit-console\nunit-console20.csproj">\r
+      <Project>{9367EC89-6A38-42BA-9607-0DC288E4BC3A}</Project>\r
+      <Name>nunit-console20</Name>\r
+    </ProjectReference>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Folder Include="Properties\" />\r
+    <Folder Include="Test\FeatureBased\Features.Binding\" />\r
+    <Folder Include="Test\FeatureBased\Features.Metadata\" />\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+       Other similar extension points exist, see Microsoft.Common.targets.\r
+  <Target Name="BeforeBuild">\r
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
+  -->\r
+  <PropertyGroup>\r
+    <PostBuildEvent>copy $(TargetDir)..\..\nunit20\nunit-console\bin\$(ConfigurationName)\*.exe $(TargetDir)\r
+copy $(TargetDir)..\..\nunit20\nunit-console\bin\$(ConfigurationName)\*.dll $(TargetDir)</PostBuildEvent>\r
+  </PropertyGroup>\r
+</Project>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel_Test.csproj.user b/mcs/class/System.ServiceModel/System.ServiceModel_Test.csproj.user
new file mode 100644 (file)
index 0000000..a79f3e9
--- /dev/null
@@ -0,0 +1,10 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <ProjectView>ShowAllFiles</ProjectView>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <StartAction>Program</StartAction>\r
+    <StartProgram>nunit-console.exe</StartProgram>\r
+    <StartArguments>System.ServiceModel_test_net_3_0.dll  /out:TestResults.txt</StartArguments>\r
+  </PropertyGroup>\r
+</Project>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel_Test.sln b/mcs/class/System.ServiceModel/System.ServiceModel_Test.sln
new file mode 100644 (file)
index 0000000..51a2a3d
--- /dev/null
@@ -0,0 +1,71 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 10.00\r
+# Visual Studio 2008\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.ServiceModel_Test", "System.ServiceModel_Test.csproj", "{05A2DAF1-316D-4350-B07B-B73BE591DE57}"\r
+EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.framework.dll20", "..\..\nunit20\framework\nunit.framework.dll20.csproj", "{83DD7E12-A705-4DBA-9D71-09C8973D9382}"\r
+EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.core.dll20", "..\..\nunit20\core\nunit.core.dll20.csproj", "{EBD43A7F-AFCA-4281-BB53-5CDD91F966A3}"\r
+EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.util.dll20", "..\..\nunit20\util\nunit.util.dll20.csproj", "{61CE9CE5-943E-44D4-A381-814DC1406767}"\r
+EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit-console20", "..\..\nunit20\nunit-console\nunit-console20.csproj", "{9367EC89-6A38-42BA-9607-0DC288E4BC3A}"\r
+EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwitchMode", "Test\SwitchMode\SwitchMode.csproj", "{59F7BE17-5E8C-4FA3-BC04-56604E2F00F1}"\r
+EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WCFServers", "Test\WCFServers\WCFServers.csproj", "{88AB909A-C341-4639-B99C-729AC1581E7D}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Any CPU = Debug|Any CPU\r
+               Debug-Strong|Any CPU = Debug-Strong|Any CPU\r
+               Release|Any CPU = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {05A2DAF1-316D-4350-B07B-B73BE591DE57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {05A2DAF1-316D-4350-B07B-B73BE591DE57}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {05A2DAF1-316D-4350-B07B-B73BE591DE57}.Debug-Strong|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {05A2DAF1-316D-4350-B07B-B73BE591DE57}.Debug-Strong|Any CPU.Build.0 = Debug|Any CPU\r
+               {05A2DAF1-316D-4350-B07B-B73BE591DE57}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {05A2DAF1-316D-4350-B07B-B73BE591DE57}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Debug-Strong|Any CPU.ActiveCfg = Debug-Strong|Any CPU\r
+               {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Debug-Strong|Any CPU.Build.0 = Debug-Strong|Any CPU\r
+               {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {83DD7E12-A705-4DBA-9D71-09C8973D9382}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {EBD43A7F-AFCA-4281-BB53-5CDD91F966A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {EBD43A7F-AFCA-4281-BB53-5CDD91F966A3}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {EBD43A7F-AFCA-4281-BB53-5CDD91F966A3}.Debug-Strong|Any CPU.ActiveCfg = Debug-Strong|Any CPU\r
+               {EBD43A7F-AFCA-4281-BB53-5CDD91F966A3}.Debug-Strong|Any CPU.Build.0 = Debug-Strong|Any CPU\r
+               {EBD43A7F-AFCA-4281-BB53-5CDD91F966A3}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {EBD43A7F-AFCA-4281-BB53-5CDD91F966A3}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {61CE9CE5-943E-44D4-A381-814DC1406767}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {61CE9CE5-943E-44D4-A381-814DC1406767}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {61CE9CE5-943E-44D4-A381-814DC1406767}.Debug-Strong|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {61CE9CE5-943E-44D4-A381-814DC1406767}.Debug-Strong|Any CPU.Build.0 = Debug|Any CPU\r
+               {61CE9CE5-943E-44D4-A381-814DC1406767}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {61CE9CE5-943E-44D4-A381-814DC1406767}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {9367EC89-6A38-42BA-9607-0DC288E4BC3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {9367EC89-6A38-42BA-9607-0DC288E4BC3A}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {9367EC89-6A38-42BA-9607-0DC288E4BC3A}.Debug-Strong|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {9367EC89-6A38-42BA-9607-0DC288E4BC3A}.Debug-Strong|Any CPU.Build.0 = Debug|Any CPU\r
+               {9367EC89-6A38-42BA-9607-0DC288E4BC3A}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {9367EC89-6A38-42BA-9607-0DC288E4BC3A}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {59F7BE17-5E8C-4FA3-BC04-56604E2F00F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {59F7BE17-5E8C-4FA3-BC04-56604E2F00F1}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {59F7BE17-5E8C-4FA3-BC04-56604E2F00F1}.Debug-Strong|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {59F7BE17-5E8C-4FA3-BC04-56604E2F00F1}.Debug-Strong|Any CPU.Build.0 = Debug|Any CPU\r
+               {59F7BE17-5E8C-4FA3-BC04-56604E2F00F1}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {59F7BE17-5E8C-4FA3-BC04-56604E2F00F1}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {88AB909A-C341-4639-B99C-729AC1581E7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {88AB909A-C341-4639-B99C-729AC1581E7D}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {88AB909A-C341-4639-B99C-729AC1581E7D}.Debug-Strong|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {88AB909A-C341-4639-B99C-729AC1581E7D}.Debug-Strong|Any CPU.Build.0 = Debug|Any CPU\r
+               {88AB909A-C341-4639-B99C-729AC1581E7D}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {88AB909A-C341-4639-B99C-729AC1581E7D}.Release|Any CPU.Build.0 = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel_test.dll.sources b/mcs/class/System.ServiceModel/System.ServiceModel_test.dll.sources
new file mode 100644 (file)
index 0000000..3a799c3
--- /dev/null
@@ -0,0 +1,155 @@
+System.ServiceModel.Channels/AddressHeaderTest.cs
+System.ServiceModel.Channels/AddressingVersionTest.cs
+System.ServiceModel.Channels/AsymmetricSecurityBindingElementTest.cs
+System.ServiceModel.Channels/BindingContextTest.cs
+System.ServiceModel.Channels/BindingElementTest.cs
+System.ServiceModel.Channels/BindingTest.cs
+System.ServiceModel.Channels/CalcSampleProxy.cs
+System.ServiceModel.Channels/CommunicationObjectTest.cs
+System.ServiceModel.Channels/CustomBindingTest.cs
+System.ServiceModel.Channels/DebugBindingElement.cs
+System.ServiceModel.Channels/EmptyFaultExceptionTest.cs
+System.ServiceModel.Channels/EnvelopeVersionTest.cs
+System.ServiceModel.Channels/FaultConverterTest.cs
+System.ServiceModel.Channels/FaultExceptionTest.cs
+System.ServiceModel.Channels/HandlerBodyWriter.cs
+System.ServiceModel.Channels/HandlerTransportBindingElement.cs
+System.ServiceModel.Channels/HttpTransportBindingElementTest.cs
+System.ServiceModel.Channels/InterceptorBindingElement.cs
+System.ServiceModel.Channels/InvalidBindingElement.cs
+System.ServiceModel.Channels/LocalClientSecuritySettingsTest.cs
+System.ServiceModel.Channels/MessageBufferTest.cs
+System.ServiceModel.Channels/MessageEncoderTest.cs
+System.ServiceModel.Channels/MessageEncodingBindingElementTest.cs
+System.ServiceModel.Channels/MessageHeaderTest.cs
+System.ServiceModel.Channels/MessageHeadersTest.cs
+System.ServiceModel.Channels/MessageTest.cs
+System.ServiceModel.Channels/MessageVersionTest.cs
+System.ServiceModel.Channels/MsmqTransportBindingElementTest.cs
+System.ServiceModel.Channels/NamedPipeTransportBindingElementTest.cs
+System.ServiceModel.Channels/OneWayBindingElementTest.cs
+System.ServiceModel.Channels/OutputChannelBase.cs
+System.ServiceModel.Channels/ReplyChannelBase.cs
+System.ServiceModel.Channels/RequestChannelBase.cs
+System.ServiceModel.Channels/SecurityAssert.cs
+System.ServiceModel.Channels/SecurityBindingElementTest.cs
+System.ServiceModel.Channels/SslStreamSecurityBindingElementTest.cs
+System.ServiceModel.Channels/SymmetricSecurityBindingElementTest.cs
+System.ServiceModel.Channels/TcpTransportBindingElementTest.cs
+System.ServiceModel.Channels/TextMessageEncodingBindingElementTest.cs
+System.ServiceModel.Channels/TransactionFlowBindingElementTest.cs
+System.ServiceModel.Configuration/AddressHeaderCollectionElementTest.cs
+System.ServiceModel.Configuration/BasicHttpBindingElementTest.cs
+System.ServiceModel.Configuration/BehaviorsSectionTest.cs
+System.ServiceModel.Configuration/BindingsSectionTest.cs
+System.ServiceModel.Configuration/ChannelEndpointElementTest.cs
+System.ServiceModel.Configuration/CustomBindingElementTest.cs
+System.ServiceModel.Configuration/EndpointBehaviorElementTest.cs
+System.ServiceModel.Configuration/ExtensionsSectionTest.cs
+System.ServiceModel.Configuration/MetadataElementTest.cs
+System.ServiceModel.Configuration/MexBindingElementTest.cs
+System.ServiceModel.Configuration/NetNamedPipeBindingElementTest.cs
+System.ServiceModel.Configuration/NetPeerTcpBindingElementTest.cs
+System.ServiceModel.Configuration/NetTcpBindingElementTest.cs
+System.ServiceModel.Configuration/ServiceBehaviorElementTest.cs
+System.ServiceModel.Configuration/ServiceElementTest.cs
+System.ServiceModel.Configuration/ServiceModelConfigurationElementCollectionTest.cs
+System.ServiceModel.Configuration/ServiceModelSectionGroupTest.cs
+System.ServiceModel.Configuration/StandardBindingCollectionElementTest.cs
+System.ServiceModel.Configuration/StandardBindingElementCollectionTest.cs
+System.ServiceModel.Configuration/StandardBindingElementTest.cs
+System.ServiceModel.Configuration/UserBinding.cs
+System.ServiceModel.Description/ClientCredentialsTest.cs
+System.ServiceModel.Description/ContractDescriptionTest.cs
+System.ServiceModel.Description/MetadataResolverTest.cs
+System.ServiceModel.Description/OperationDescriptionTest.cs
+System.ServiceModel.Description/ServiceAuthorizationBehaviorTest.cs
+System.ServiceModel.Description/ServiceCredentialsTest.cs
+System.ServiceModel.Description/ServiceDebugBehaviorTest.cs
+System.ServiceModel.Description/ServiceMetadataBehaviorTest.cs
+System.ServiceModel.Description/TypedMessageConverterTest.cs
+System.ServiceModel.Description/WsdlExporterTest.cs
+System.ServiceModel.Description/WsdlImporterTest.cs
+System.ServiceModel.Dispatcher/ActionFilterTest.cs
+System.ServiceModel.Dispatcher/DispatchOperationTest.cs
+System.ServiceModel.Dispatcher/DispatchRuntimeTest.cs
+System.ServiceModel.Dispatcher/EndpointAddressMessageFilterTest.cs
+System.ServiceModel.Dispatcher/EndpointDispatcherTest.cs
+System.ServiceModel.Dispatcher/ExceptionHandlerTest.cs
+System.ServiceModel.Dispatcher/FilterTableTest.cs
+System.ServiceModel.Dispatcher/InvalidBodyAccessExceptionTest.cs
+System.ServiceModel.Dispatcher/PrefixEndpointAddressMessageFilterTest.cs
+System.ServiceModel.Dispatcher/ChannelDispatcherTest.cs
+System.ServiceModel.PeerResolvers/CustomPeerResolverServiceTest.cs
+System.ServiceModel.Security.Tokens/IssuedSecurityTokenParametersTest.cs
+System.ServiceModel.Security.Tokens/IssuedSecurityTokenProviderTest.cs
+System.ServiceModel.Security.Tokens/RsaSecurityTokenParametersTest.cs
+System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenParametersTest.cs
+System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenTest.cs
+System.ServiceModel.Security.Tokens/SecurityTokenParametersTest.cs
+System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenTypesTest.cs
+System.ServiceModel.Security.Tokens/SslSecurityTokenParametersTest.cs
+System.ServiceModel.Security.Tokens/SspiSecurityTokenParametersTest.cs
+System.ServiceModel.Security.Tokens/UserNameSecurityTokenParametersTest.cs
+System.ServiceModel.Security.Tokens/WrappedKeySecurityTokenTest.cs
+System.ServiceModel.Security.Tokens/X509ListedCertificateValidator.cs
+System.ServiceModel.Security.Tokens/X509SecurityTokenParametersTest.cs
+System.ServiceModel.Security/ChannelProtectionRequirementsTest.cs
+System.ServiceModel.Security/MessagePartSpecificationTest.cs
+System.ServiceModel.Security/ScopedMessagePartSpecificationTest.cs
+System.ServiceModel.Security/SecurityAlgorithmSuiteTest.cs
+System.ServiceModel.Security/SecurityMessagePropertyTest.cs
+System.ServiceModel.Security/SecurityTokenSpeficicationTest.cs
+System.ServiceModel.Security/ServiceCredentialsSecurityTokenManagerTest.cs
+System.ServiceModel.Security/ServiceSecurityContextTest.cs
+System.ServiceModel.Security/SupportingTokenParametersTest.cs
+System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs
+System.ServiceModel/BasicHttpBindingTest.cs
+System.ServiceModel/ChannelFactoryTest.cs
+System.ServiceModel/ChannelFactory_1Test.cs
+System.ServiceModel/ClientBaseTest.cs
+System.ServiceModel/ClientCredentialsSecurityTokenManagerTest.cs
+System.ServiceModel/CommonUseCases.cs
+System.ServiceModel/EndpointAddress10Test.cs
+System.ServiceModel/EndpointAddressBuilderTest.cs
+System.ServiceModel/EndpointAddressTest.cs
+System.ServiceModel/EndpointBehaviorCollectionTest.cs
+System.ServiceModel/EndpointIdentityTest.cs
+System.ServiceModel/ExtensionCollectionTest.cs
+System.ServiceModel/FaultCodeTest.cs
+System.ServiceModel/FaultReasonTest.cs
+System.ServiceModel/IntegratedConnectionTest.cs
+System.ServiceModel/MessageSecurityVersionTest.cs
+System.ServiceModel/NetMsmqBindingTest.cs
+System.ServiceModel/ServiceAssert.cs
+System.ServiceModel/ServiceEndpointCollectionTest.cs
+System.ServiceModel/ServiceEndpointTest.cs
+System.ServiceModel/ServiceHostBaseTest.cs
+System.ServiceModel/ServiceHostTest.cs
+System.ServiceModel/SynchronizedReadOnlyCollectionTest.cs
+System.ServiceModel/TransactionProtocolTest.cs
+System.ServiceModel/UriSchemeKeyedCollectionTest.cs
+System.ServiceModel/WSFederationHttpBindingTest.cs
+System.ServiceModel/WSHttpBindingTest.cs
+FeatureBased/TestFixtureBase.cs
+FeatureBased/Features.Client/DataContractTesterProxy.cs
+FeatureBased/Features.Client/PrimitiveTester.cs
+FeatureBased/Features.Contracts/DataContractTester.cs
+FeatureBased/Features.Contracts/DualContract.cs
+FeatureBased/Features.Contracts/MessageContractTester.cs
+FeatureBased/Features.Contracts/PrimitiveTester.cs
+FeatureBased/Features.Serialization/DataContractSerializerTest.cs
+FeatureBased/Features.Serialization/DualContractTester.cs
+FeatureBased/Features.Serialization/PrimitiveTesterTest.cs
+FeatureBased/Features.Client/FaultsTesterProxy.cs
+FeatureBased/Features.Client/KnownTypeTesterProxy.cs
+FeatureBased/Features.Client/MessageContractTesterProxy.cs
+FeatureBased/Features.Client/UntypedMessageTesterProxy.cs
+FeatureBased/Features.Contracts/FaultsTester.cs
+FeatureBased/Features.Contracts/KnownTypeTester.cs
+FeatureBased/Features.Contracts/UntypedMessageTester.cs
+FeatureBased/Features.Serialization/FaultsTest.cs
+FeatureBased/Features.Serialization/KnownTypeTest.cs
+FeatureBased/Features.Serialization/MessageContractTest.cs
+FeatureBased/Features.Serialization/UntypedMessageTest.cs
+FeatureBased/Features.Serialization/XmlComparer.cs
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel_test_net_3_0.dll.config b/mcs/class/System.ServiceModel/System.ServiceModel_test_net_3_0.dll.config
new file mode 100644 (file)
index 0000000..162fae7
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?><configuration>\r
+       <appSettings>\r
+               <add key="onlyClients" value="false" />\r
+               <add key="endpointBase" value="http://localhost:9999" />\r
+       </appSettings>\r
+  <system.serviceModel>\r
+    <behaviors>\r
+         <serviceBehaviors>\r
+                       <behavior name="MetadataBehavior">\r
+                               <serviceMetadata httpGetEnabled="true" />\r
+                       </behavior>\r
+         </serviceBehaviors>\r
+      <endpointBehaviors>\r
+        <behavior name="behavior1">\r
+          <callbackDebug includeExceptionDetailInFaults="true" />\r
+        </behavior>\r
+        <behavior name="behavior2">\r
+          <callbackDebug includeExceptionDetailInFaults="false" />\r
+        </behavior>\r
+      </endpointBehaviors>\r
+    </behaviors>\r
+       <bindings>\r
+               <basicHttpBinding>\r
+                       <binding name="basicHttp">\r
+                               <security mode="None">\r
+                               </security>\r
+                       </binding>\r
+               </basicHttpBinding>\r
+       </bindings>\r
+    <client>\r
+      <endpoint address="http://test1_1" binding="basicHttpBinding" contract="MonoTests.System.ServiceModel.ICtorUseCase1" name="CtorUseCase1_1" />\r
+      <endpoint address="http://test2_1" binding="basicHttpBinding" contract="CtorUseCase2" name="CtorUseCase2_1" />\r
+      <endpoint address="http://test2_2" binding="basicHttpBinding" contract="CtorUseCase2" name="CtorUseCase2_2" behaviorConfiguration="behavior1" />\r
+      <endpoint address="http://test2_2" binding="basicHttpBinding" contract="CtorUseCase2" name="CtorUseCase2_3" behaviorConfiguration="behavior2" />\r
+      <endpoint name="" binding="basicHttpBinding" contract="test" />\r
+    </client>\r
+\r
+       <services>\r
+       </services>\r
+  </system.serviceModel>\r
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/System.ServiceModel_test_net_3_5.dll.config b/mcs/class/System.ServiceModel/System.ServiceModel_test_net_3_5.dll.config
new file mode 100644 (file)
index 0000000..162fae7
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?><configuration>\r
+       <appSettings>\r
+               <add key="onlyClients" value="false" />\r
+               <add key="endpointBase" value="http://localhost:9999" />\r
+       </appSettings>\r
+  <system.serviceModel>\r
+    <behaviors>\r
+         <serviceBehaviors>\r
+                       <behavior name="MetadataBehavior">\r
+                               <serviceMetadata httpGetEnabled="true" />\r
+                       </behavior>\r
+         </serviceBehaviors>\r
+      <endpointBehaviors>\r
+        <behavior name="behavior1">\r
+          <callbackDebug includeExceptionDetailInFaults="true" />\r
+        </behavior>\r
+        <behavior name="behavior2">\r
+          <callbackDebug includeExceptionDetailInFaults="false" />\r
+        </behavior>\r
+      </endpointBehaviors>\r
+    </behaviors>\r
+       <bindings>\r
+               <basicHttpBinding>\r
+                       <binding name="basicHttp">\r
+                               <security mode="None">\r
+                               </security>\r
+                       </binding>\r
+               </basicHttpBinding>\r
+       </bindings>\r
+    <client>\r
+      <endpoint address="http://test1_1" binding="basicHttpBinding" contract="MonoTests.System.ServiceModel.ICtorUseCase1" name="CtorUseCase1_1" />\r
+      <endpoint address="http://test2_1" binding="basicHttpBinding" contract="CtorUseCase2" name="CtorUseCase2_1" />\r
+      <endpoint address="http://test2_2" binding="basicHttpBinding" contract="CtorUseCase2" name="CtorUseCase2_2" behaviorConfiguration="behavior1" />\r
+      <endpoint address="http://test2_2" binding="basicHttpBinding" contract="CtorUseCase2" name="CtorUseCase2_3" behaviorConfiguration="behavior2" />\r
+      <endpoint name="" binding="basicHttpBinding" contract="test" />\r
+    </client>\r
+\r
+       <services>\r
+       </services>\r
+  </system.serviceModel>\r
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/ChangeLog b/mcs/class/System.ServiceModel/Test/FeatureBased/ChangeLog
new file mode 100644 (file)
index 0000000..7cccb60
--- /dev/null
@@ -0,0 +1,15 @@
+2008-04-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TestFixtureBase.cs : Fix build.
+
+       (ChangeLog was missing in the previous build)
+
+2008-04-06  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * added 
+       FeatureBased/Features.Serialization/KnownTypeTest.cs
+       FeatureBased/Features.Client/KnownTypeTesterProxy.cs
+       FeatureBased/Features.Contracts/KnownTypeTester.cs
+
+2006-04-03  Roei Erez  <roeie@ximian.com>
+       * TextFixtureBase.cs
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/AsyncCallTesterProxy.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/AsyncCallTesterProxy.cs
new file mode 100644 (file)
index 0000000..7ad2108
--- /dev/null
@@ -0,0 +1,155 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:2.0.50727.1433
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Proxy.MonoTests.Features.Client
+{
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       [System.ServiceModel.ServiceContractAttribute (Namespace = "http://MonoTests.Features.Contracts", ConfigurationName = "IAsyncCallTesterContract")]
+       public interface IAsyncCallTesterContract
+       {
+
+        [System.ServiceModel.OperationContractAttribute(Action = "http://MonoTests.Features.Contracts/IAsyncCallTesterContract/Query", ReplyAction = "http://MonoTests.Features.Contracts/IAsyncCallTesterContract/QueryResponse")]
+               string Query (string query);
+
+        [System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "http://MonoTests.Features.Contracts/IAsyncCallTesterContract/Query", ReplyAction = "http://MonoTests.Features.Contracts/IAsyncCallTesterContract/QueryResponse")]
+               System.IAsyncResult BeginQuery (string query, System.AsyncCallback callback, object asyncState);
+
+               string EndQuery (System.IAsyncResult result);
+       }
+
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public interface IAsyncCallTesterContractChannel : IAsyncCallTesterContract, System.ServiceModel.IClientChannel
+       {
+       }
+
+       [System.Diagnostics.DebuggerStepThroughAttribute ()]
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public partial class QueryCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
+       {
+
+               private object [] results;
+
+               public QueryCompletedEventArgs (object [] results, System.Exception exception, bool cancelled, object userState) :
+                       base (exception, cancelled, userState)
+               {
+                       this.results = results;
+               }
+
+               public string Result
+               {
+                       get
+                       {
+                               base.RaiseExceptionIfNecessary ();
+                               return ((string) (this.results [0]));
+                       }
+               }
+       }
+
+       [System.Diagnostics.DebuggerStepThroughAttribute ()]
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public partial class AsyncCallTesterContractClient : System.ServiceModel.ClientBase<IAsyncCallTesterContract>, IAsyncCallTesterContract
+       {
+
+               private BeginOperationDelegate onBeginQueryDelegate;
+
+               private EndOperationDelegate onEndQueryDelegate;
+
+               private System.Threading.SendOrPostCallback onQueryCompletedDelegate;
+
+               public AsyncCallTesterContractClient ()
+               {
+               }
+
+               public AsyncCallTesterContractClient (string endpointConfigurationName) :
+                       base (endpointConfigurationName)
+               {
+               }
+
+               public AsyncCallTesterContractClient (string endpointConfigurationName, string remoteAddress) :
+                       base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public AsyncCallTesterContractClient (string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
+                       base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public AsyncCallTesterContractClient (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
+                       base (binding, remoteAddress)
+               {
+               }
+
+               public event System.EventHandler<QueryCompletedEventArgs> QueryCompleted;
+
+               public string Query (string query)
+               {
+                       return base.Channel.Query (query);
+               }
+
+               [System.ComponentModel.EditorBrowsableAttribute (System.ComponentModel.EditorBrowsableState.Advanced)]
+               public System.IAsyncResult BeginQuery (string query, System.AsyncCallback callback, object asyncState)
+               {
+                       return base.Channel.BeginQuery (query, callback, asyncState);
+               }
+
+               [System.ComponentModel.EditorBrowsableAttribute (System.ComponentModel.EditorBrowsableState.Advanced)]
+               public string EndQuery (System.IAsyncResult result)
+               {
+                       return base.Channel.EndQuery (result);
+               }
+
+               private System.IAsyncResult OnBeginQuery (object [] inValues, System.AsyncCallback callback, object asyncState)
+               {
+                       string s = ((string) (inValues [0]));
+                       return this.BeginQuery (s, callback, asyncState);
+               }
+
+               private object [] OnEndQuery (System.IAsyncResult result)
+               {
+                       string retVal = this.EndQuery (result);
+                       return new object [] {
+                    retVal};
+               }
+
+               private void OnQueryCompleted (object state)
+               {
+                       System.EventHandler<QueryCompletedEventArgs> handler = this.QueryCompleted;
+                       if ((handler != null)) {
+                               InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs) (state));
+                               handler (this, new QueryCompletedEventArgs (e.Results, e.Error, e.Cancelled, e.UserState));
+                       }
+               }
+
+               public void QueryAsync (string query)
+               {
+                       this.QueryAsync (query, null);
+               }
+
+               public void QueryAsync (string query, object userState)
+               {
+                       if ((this.onBeginQueryDelegate == null)) {
+                               this.onBeginQueryDelegate = new BeginOperationDelegate (this.OnBeginQuery);
+                       }
+                       if ((this.onEndQueryDelegate == null)) {
+                               this.onEndQueryDelegate = new EndOperationDelegate (this.OnEndQuery);
+                       }
+                       if ((this.onQueryCompletedDelegate == null)) {
+                               this.onQueryCompletedDelegate = new System.Threading.SendOrPostCallback (this.OnQueryCompleted);
+                       }
+                       base.InvokeAsync (this.onBeginQueryDelegate, new object [] {
+                        query}, this.onEndQueryDelegate, this.onQueryCompletedDelegate, userState);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/AsyncPatternServer.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/AsyncPatternServer.cs
new file mode 100644 (file)
index 0000000..35846d9
--- /dev/null
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------\r
+// <auto-generated>\r
+//     This code was generated by a tool.\r
+//     Runtime Version:2.0.50727.1433\r
+//\r
+//     Changes to this file may cause incorrect behavior and will be lost if\r
+//     the code is regenerated.\r
+// </auto-generated>\r
+//------------------------------------------------------------------------------\r
+\r
+namespace Proxy.MonoTests.Features.Client\r
+{\r
+    \r
+    \r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    [System.ServiceModel.ServiceContractAttribute(Namespace="http://MonoTests.Features.Contracts", ConfigurationName="Proxy.MonoTests.Features.Client.IAsyncPattern")]\r
+    public interface IAsyncPattern\r
+    {\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IAsyncPattern/AsyncMethod", ReplyAction="http://MonoTests.Features.Contracts/IAsyncPattern/AsyncMethodResponse")]\r
+        int AsyncMethod();\r
+    }\r
+    \r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    public interface IAsyncPatternChannel : Proxy.MonoTests.Features.Client.IAsyncPattern, System.ServiceModel.IClientChannel\r
+    {\r
+    }\r
+    \r
+    [System.Diagnostics.DebuggerStepThroughAttribute()]\r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    public partial class AsyncPatternClient : System.ServiceModel.ClientBase<Proxy.MonoTests.Features.Client.IAsyncPattern>, Proxy.MonoTests.Features.Client.IAsyncPattern\r
+    {\r
+        \r
+        public AsyncPatternClient()\r
+        {\r
+        }\r
+        \r
+        public AsyncPatternClient(string endpointConfigurationName) : \r
+                base(endpointConfigurationName)\r
+        {\r
+        }\r
+        \r
+        public AsyncPatternClient(string endpointConfigurationName, string remoteAddress) : \r
+                base(endpointConfigurationName, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public AsyncPatternClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : \r
+                base(endpointConfigurationName, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public AsyncPatternClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : \r
+                base(binding, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public int AsyncMethod()\r
+        {\r
+            return base.Channel.AsyncMethod();\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/ChangeLog b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/ChangeLog
new file mode 100644 (file)
index 0000000..075e3d1
--- /dev/null
@@ -0,0 +1,18 @@
+2008-04-07  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * added: MessageContractTesterProxy.cs
+       AsyncCallTesterProxy.cs
+       FaultsTesterProxy.cs
+       * fixed: UntypedMessageTesterProxy.cs
+
+2008-04-06  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * Added: UntypedMessageTesterProxy.cs
+
+2008-04-06  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * Added: KnownTypeTesterProxy.cs
+
+2006-04-03  Roei Erez  <roeie@ximian.com>
+       * DataContractTesterProxy.cs
+       PrimitiveTesterProxy.cs
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/DataContractTesterProxy.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/DataContractTesterProxy.cs
new file mode 100644 (file)
index 0000000..3c4aa96
--- /dev/null
@@ -0,0 +1,243 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:2.0.50727.1433
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Proxy.MonoTests.Features.Client
+{
+    [System.Diagnostics.DebuggerStepThroughAttribute()]
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
+    [System.Runtime.Serialization.DataContractAttribute(Name="ComplexPrimitiveClass", Namespace="http://MonoTests.Features.Client")]
+    public partial class ComplexPrimitiveClass : object, System.Runtime.Serialization.IExtensibleDataObject
+    {
+        
+        private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
+        
+        private byte byteMemberField;
+        
+        private double doubleMemberField;
+        
+        private float floatMemberField;
+        
+        private int intMemberField;
+        
+        private long longMemberField;
+        
+        private sbyte sbyteMemberField;
+        
+        private short shortMemberField;
+        
+        private uint uintMemberField;
+        
+        private ulong ulongMemberField;
+        
+        private ushort ushortMemberField;
+        
+        public System.Runtime.Serialization.ExtensionDataObject ExtensionData
+        {
+            get
+            {
+                return this.extensionDataField;
+            }
+            set
+            {
+                this.extensionDataField = value;
+            }
+        }
+        
+        [System.Runtime.Serialization.DataMemberAttribute()]
+        public byte byteMember
+        {
+            get
+            {
+                return this.byteMemberField;
+            }
+            set
+            {
+                this.byteMemberField = value;
+            }
+        }
+        
+        [System.Runtime.Serialization.DataMemberAttribute()]
+        public double doubleMember
+        {
+            get
+            {
+                return this.doubleMemberField;
+            }
+            set
+            {
+                this.doubleMemberField = value;
+            }
+        }
+        
+        [System.Runtime.Serialization.DataMemberAttribute()]
+        public float floatMember
+        {
+            get
+            {
+                return this.floatMemberField;
+            }
+            set
+            {
+                this.floatMemberField = value;
+            }
+        }
+        
+        [System.Runtime.Serialization.DataMemberAttribute()]
+        public int intMember
+        {
+            get
+            {
+                return this.intMemberField;
+            }
+            set
+            {
+                this.intMemberField = value;
+            }
+        }
+        
+        [System.Runtime.Serialization.DataMemberAttribute()]
+        public long longMember
+        {
+            get
+            {
+                return this.longMemberField;
+            }
+            set
+            {
+                this.longMemberField = value;
+            }
+        }
+        
+        [System.Runtime.Serialization.DataMemberAttribute()]
+        public sbyte sbyteMember
+        {
+            get
+            {
+                return this.sbyteMemberField;
+            }
+            set
+            {
+                this.sbyteMemberField = value;
+            }
+        }
+        
+        [System.Runtime.Serialization.DataMemberAttribute()]
+        public short shortMember
+        {
+            get
+            {
+                return this.shortMemberField;
+            }
+            set
+            {
+                this.shortMemberField = value;
+            }
+        }
+        
+        [System.Runtime.Serialization.DataMemberAttribute()]
+        public uint uintMember
+        {
+            get
+            {
+                return this.uintMemberField;
+            }
+            set
+            {
+                this.uintMemberField = value;
+            }
+        }
+        
+        [System.Runtime.Serialization.DataMemberAttribute()]
+        public ulong ulongMember
+        {
+            get
+            {
+                return this.ulongMemberField;
+            }
+            set
+            {
+                this.ulongMemberField = value;
+            }
+        }
+        
+        [System.Runtime.Serialization.DataMemberAttribute()]
+        public ushort ushortMember
+        {
+            get
+            {
+                return this.ushortMemberField;
+            }
+            set
+            {
+                this.ushortMemberField = value;
+            }
+        }
+    }
+}
+
+
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
+[System.ServiceModel.ServiceContractAttribute(Namespace="http://MonoTests.Integrative.Contracts", ConfigurationName="IDataContractTesterContract")]
+public interface IDataContractTesterContract
+{
+    
+    [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Integrative.Contracts/IDataContractTesterContract/Add", ReplyAction="http://MonoTests.Integrative.Contracts/IDataContractTesterContract/AddResponse")]
+       Proxy.MonoTests.Features.Client.ComplexPrimitiveClass Add (Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n1, Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n2);
+    
+    [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Integrative.Contracts/IDataContractTesterContract/AddByRef", ReplyAction="http://MonoTests.Integrative.Contracts/IDataContractTesterContract/AddByRefRespon" +
+        "se")]
+    [return: System.ServiceModel.MessageParameterAttribute(Name="result")]
+       Proxy.MonoTests.Features.Client.ComplexPrimitiveClass AddByRef (Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n1, Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n2);
+}
+
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
+public interface IDataContractTesterContractChannel : IDataContractTesterContract, System.ServiceModel.IClientChannel
+{
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
+public partial class DataContractTesterContractClient : System.ServiceModel.ClientBase<IDataContractTesterContract>, IDataContractTesterContract
+{
+    
+    public DataContractTesterContractClient()
+    {
+    }
+    
+    public DataContractTesterContractClient(string endpointConfigurationName) : 
+            base(endpointConfigurationName)
+    {
+    }
+    
+    public DataContractTesterContractClient(string endpointConfigurationName, string remoteAddress) : 
+            base(endpointConfigurationName, remoteAddress)
+    {
+    }
+    
+    public DataContractTesterContractClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
+            base(endpointConfigurationName, remoteAddress)
+    {
+    }
+    
+    public DataContractTesterContractClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
+            base(binding, remoteAddress)
+    {
+    }
+
+       public Proxy.MonoTests.Features.Client.ComplexPrimitiveClass Add (Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n1, Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n2)
+    {
+        return base.Channel.Add(n1, n2);
+    }
+
+       public Proxy.MonoTests.Features.Client.ComplexPrimitiveClass AddByRef (Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n1, Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n2)
+    {
+        return base.Channel.AddByRef(n1, n2);
+    }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/ExitProcessHelperServer.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/ExitProcessHelperServer.cs
new file mode 100644 (file)
index 0000000..d333d8b
--- /dev/null
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------\r
+// <auto-generated>\r
+//     This code was generated by a tool.\r
+//     Runtime Version:2.0.50727.1433\r
+//\r
+//     Changes to this file may cause incorrect behavior and will be lost if\r
+//     the code is regenerated.\r
+// </auto-generated>\r
+//------------------------------------------------------------------------------\r
+\r
+namespace Proxy.MonoTests.Features.Client\r
+{\r
+    \r
+    \r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    [System.ServiceModel.ServiceContractAttribute(Namespace="http://MonoTests.Features.Contracts", ConfigurationName="Proxy.MonoTests.Features.Client.IExitProcessHelper")]\r
+    public interface IExitProcessHelper\r
+    {\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://MonoTests.Features.Contracts/IExitProcessHelper/ExitProcess")]\r
+        void ExitProcess(int code);\r
+    }\r
+    \r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    public interface IExitProcessHelperChannel : Proxy.MonoTests.Features.Client.IExitProcessHelper, System.ServiceModel.IClientChannel\r
+    {\r
+    }\r
+    \r
+    [System.Diagnostics.DebuggerStepThroughAttribute()]\r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    public partial class ExitProcessHelperClient : System.ServiceModel.ClientBase<Proxy.MonoTests.Features.Client.IExitProcessHelper>, Proxy.MonoTests.Features.Client.IExitProcessHelper\r
+    {\r
+        \r
+        public ExitProcessHelperClient()\r
+        {\r
+        }\r
+        \r
+        public ExitProcessHelperClient(string endpointConfigurationName) : \r
+                base(endpointConfigurationName)\r
+        {\r
+        }\r
+        \r
+        public ExitProcessHelperClient(string endpointConfigurationName, string remoteAddress) : \r
+                base(endpointConfigurationName, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public ExitProcessHelperClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : \r
+                base(endpointConfigurationName, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public ExitProcessHelperClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : \r
+                base(binding, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public void ExitProcess(int code)\r
+        {\r
+            base.Channel.ExitProcess(code);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/FaultsTesterProxy.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/FaultsTesterProxy.cs
new file mode 100644 (file)
index 0000000..a5a7479
--- /dev/null
@@ -0,0 +1,111 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:2.0.50727.1433
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Proxy.MonoTests.Features.Client
+{
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       [System.ServiceModel.ServiceContractAttribute (Namespace = "http://MonoTests.Features.Contracts", ConfigurationName = "IFaultsTesterContract")]
+       public interface IFaultsTesterContract
+       {
+               [System.ServiceModel.OperationContractAttribute (Action = "http://MonoTests.Features.Contracts/IFaultsTesterContract/FaultMethod")]
+               void FaultMethod (string faultText);
+       }
+
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public interface IFaultsTesterContractChannel : IFaultsTesterContract, System.ServiceModel.IClientChannel
+       {
+       }
+
+       [System.Diagnostics.DebuggerStepThroughAttribute ()]
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public partial class FaultsTesterContractClient : System.ServiceModel.ClientBase<IFaultsTesterContract>, IFaultsTesterContract
+       {
+
+               public FaultsTesterContractClient ()
+               {
+               }
+
+               public FaultsTesterContractClient (string endpointConfigurationName) :
+                       base (endpointConfigurationName)
+               {
+               }
+
+               public FaultsTesterContractClient (string endpointConfigurationName, string remoteAddress) :
+                       base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public FaultsTesterContractClient (string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
+                       base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public FaultsTesterContractClient (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
+                       base (binding, remoteAddress)
+               {
+               }
+
+               public void FaultMethod (string faultText)
+               {
+                       base.Channel.FaultMethod (faultText);
+               }
+       }
+
+       //====================
+
+
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       [System.ServiceModel.ServiceContractAttribute (Namespace = "http://MonoTests.Features.Contracts", ConfigurationName = "IFaultsTesterContractIncludeDetails")]
+       public interface IFaultsTesterContractIncludeDetails
+       {
+               [System.ServiceModel.OperationContractAttribute (Action = "http://MonoTests.Features.Contracts/IFaultsTesterContractIncludeDetails/FaultMethod")]
+               void FaultMethod (string faultText);
+       }
+
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public interface IFaultsTesterContractChannelIncludeDetails : IFaultsTesterContractIncludeDetails, System.ServiceModel.IClientChannel
+       {
+       }
+
+       [System.Diagnostics.DebuggerStepThroughAttribute ()]
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public partial class FaultsTesterContractClientIncludeDetails : System.ServiceModel.ClientBase<IFaultsTesterContractIncludeDetails>, IFaultsTesterContractIncludeDetails
+       {
+
+               public FaultsTesterContractClientIncludeDetails ()
+               {
+               }
+
+               public FaultsTesterContractClientIncludeDetails (string endpointConfigurationName) :
+                       base (endpointConfigurationName)
+               {
+               }
+
+               public FaultsTesterContractClientIncludeDetails (string endpointConfigurationName, string remoteAddress) :
+                       base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public FaultsTesterContractClientIncludeDetails (string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
+                       base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public FaultsTesterContractClientIncludeDetails (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
+                       base (binding, remoteAddress)
+               {
+               }
+
+               public void FaultMethod (string faultText)
+               {
+                       base.Channel.FaultMethod (faultText);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/KnownTypeTesterProxy.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/KnownTypeTesterProxy.cs
new file mode 100755 (executable)
index 0000000..9fa2a31
--- /dev/null
@@ -0,0 +1,164 @@
+
+namespace Proxy.MonoTests.Features.Client
+{
+       using System.Runtime.Serialization;
+       using System;
+
+
+       [System.Diagnostics.DebuggerStepThroughAttribute ()]
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.Runtime.Serialization", "3.0.0.0")]
+       [System.Runtime.Serialization.DataContractAttribute (Name = "Point2D", Namespace = "http://MonoTests.Features.Contracts")]
+       [System.SerializableAttribute ()]
+       [System.Runtime.Serialization.KnownTypeAttribute (typeof (AdvPoint2D))]
+       public partial class Point2D : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
+       {
+
+               [System.NonSerializedAttribute ()]
+               private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
+
+               [System.Runtime.Serialization.OptionalFieldAttribute ()]
+               private int XField;
+
+               [System.Runtime.Serialization.OptionalFieldAttribute ()]
+               private int YField;
+
+               [global::System.ComponentModel.BrowsableAttribute (false)]
+               public System.Runtime.Serialization.ExtensionDataObject ExtensionData
+               {
+                       get
+                       {
+                               return this.extensionDataField;
+                       }
+                       set
+                       {
+                               this.extensionDataField = value;
+                       }
+               }
+
+               [System.Runtime.Serialization.DataMemberAttribute ()]
+               public int X
+               {
+                       get
+                       {
+                               return this.XField;
+                       }
+                       set
+                       {
+                               if ((this.XField.Equals (value) != true)) {
+                                       this.XField = value;
+                                       this.RaisePropertyChanged ("X");
+                               }
+                       }
+               }
+
+               [System.Runtime.Serialization.DataMemberAttribute ()]
+               public int Y
+               {
+                       get
+                       {
+                               return this.YField;
+                       }
+                       set
+                       {
+                               if ((this.YField.Equals (value) != true)) {
+                                       this.YField = value;
+                                       this.RaisePropertyChanged ("Y");
+                               }
+                       }
+               }
+
+               public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+               protected void RaisePropertyChanged (string propertyName)
+               {
+                       System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
+                       if ((propertyChanged != null)) {
+                               propertyChanged (this, new System.ComponentModel.PropertyChangedEventArgs (propertyName));
+                       }
+               }
+       }
+
+       [System.Diagnostics.DebuggerStepThroughAttribute ()]
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.Runtime.Serialization", "3.0.0.0")]
+       [System.Runtime.Serialization.DataContractAttribute (Name = "AdvPoint2D", Namespace = "http://MonoTests.Features.Contracts")]
+       [System.SerializableAttribute ()]
+       public partial class AdvPoint2D : Point2D
+       {
+
+               [System.Runtime.Serialization.OptionalFieldAttribute ()]
+               private double ZeroDistanceField;
+
+               [System.Runtime.Serialization.DataMemberAttribute ()]
+               public double ZeroDistance
+               {
+                       get
+                       {
+                               return this.ZeroDistanceField;
+                       }
+                       set
+                       {
+                               if ((this.ZeroDistanceField.Equals (value) != true)) {
+                                       this.ZeroDistanceField = value;
+                                       this.RaisePropertyChanged ("ZeroDistance");
+                               }
+                       }
+               }
+       }
+
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       [System.ServiceModel.ServiceContractAttribute (Namespace = "http://MonoTests.Features.Contracts", ConfigurationName = "IKnownTypeTesterContract")]
+       public interface IKnownTypeTesterContract
+       {
+
+               [System.ServiceModel.OperationContractAttribute (Action = "http://MonoTests.Features.Contracts/IKnownTypeTesterContract/Move", ReplyAction = "http://MonoTests.Features.Contracts/IKnownTypeTesterContract/MoveResponse")]
+               Point2D Move (Point2D point, Point2D delta);
+
+               [System.ServiceModel.OperationContractAttribute (Action = "http://MonoTests.Features.Contracts/IKnownTypeTesterContract/Distance", ReplyAction = "http://MonoTests.Features.Contracts/IKnownTypeTesterContract/DistanceResponse")]
+               double Distance (Point2D point1, Point2D point2);
+       }
+
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public interface IKnownTypeTesterContractChannel : IKnownTypeTesterContract, System.ServiceModel.IClientChannel
+       {
+       }
+
+       [System.Diagnostics.DebuggerStepThroughAttribute ()]
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public partial class KnownTypeTesterContractClient : System.ServiceModel.ClientBase<IKnownTypeTesterContract>, IKnownTypeTesterContract
+       {
+
+               public KnownTypeTesterContractClient ()
+               {
+               }
+
+               public KnownTypeTesterContractClient (string endpointConfigurationName) :
+                       base (endpointConfigurationName)
+               {
+               }
+
+               public KnownTypeTesterContractClient (string endpointConfigurationName, string remoteAddress) :
+                       base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public KnownTypeTesterContractClient (string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
+                       base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public KnownTypeTesterContractClient (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
+                       base (binding, remoteAddress)
+               {
+               }
+
+               public Point2D Move (Point2D point, Point2D delta)
+               {
+                       return base.Channel.Move (point, delta);
+               }
+
+               public double Distance (Point2D point1, Point2D point2)
+               {
+                       return base.Channel.Distance (point1, point2);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/MessageContractTesterProxy.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/MessageContractTesterProxy.cs
new file mode 100644 (file)
index 0000000..c7336fb
--- /dev/null
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Proxy.MonoTests.Features.Client
+{
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       [System.ServiceModel.ServiceContractAttribute (Namespace = "http://MonoTests.Features.Contracts", ConfigurationName = "IMessageContractTesterContract")]
+       public interface IMessageContractTesterContract
+       {
+               [System.ServiceModel.OperationContractAttribute (Action = "http://test/TestMessage_action", ReplyAction = "http://test/TestMessage_action")]
+               TestMessage FormatDate (TestMessage testMessage);
+       }
+
+       [System.Diagnostics.DebuggerStepThroughAttribute ()]
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       [System.ServiceModel.MessageContractAttribute (WrapperName = "TestMessage", WrapperNamespace = "http://MonoTests.Features.Contracts", IsWrapped = true)]
+       public partial class TestMessage
+       {
+
+               [System.ServiceModel.MessageHeaderAttribute (Namespace = "http://MonoTests.Features.Contracts")]
+               public string FormatString;
+
+               [System.ServiceModel.MessageBodyMemberAttribute (Namespace = "http://MonoTests.Features.Contracts", Order = 0)]
+               public DateTime Date;
+
+               [System.ServiceModel.MessageBodyMemberAttribute (Namespace = "http://MonoTests.Features.Contracts", Order = 1)]
+               public string FormattedDate;
+
+               public TestMessage ()
+               {
+               }
+
+               public TestMessage (DateTime Date, string FormatString, string FormattedDate)
+               {
+                       this.Date = Date;
+                       this.FormatString = FormatString;
+                       this.FormattedDate = FormattedDate;
+               }
+       }
+
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public interface IMessageContractTesterContractChannel : IMessageContractTesterContract, System.ServiceModel.IClientChannel
+       {
+       }
+
+       [System.Diagnostics.DebuggerStepThroughAttribute ()]
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public partial class MessageContractTesterContractClient : System.ServiceModel.ClientBase<IMessageContractTesterContract>, IMessageContractTesterContract
+       {
+
+               public MessageContractTesterContractClient ()
+               {
+               }
+
+               public MessageContractTesterContractClient (string endpointConfigurationName) :
+                       base (endpointConfigurationName)
+               {
+               }
+
+               public MessageContractTesterContractClient (string endpointConfigurationName, string remoteAddress) :
+                       base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public MessageContractTesterContractClient (string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
+                       base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public MessageContractTesterContractClient (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
+                       base (binding, remoteAddress)
+               {
+               }
+
+               TestMessage IMessageContractTesterContract.FormatDate (TestMessage testMessage)
+               {
+                       return base.Channel.FormatDate (testMessage);
+               }
+
+               public void Calculate (ref DateTime Date, ref string FormatString, ref string FormattedDate)
+               {
+                       TestMessage inValue = new TestMessage ();
+                       inValue.Date = Date;
+                       inValue.FormatString = FormatString;
+                       inValue.FormattedDate = FormattedDate;
+                       TestMessage retVal = ((IMessageContractTesterContract) (this)).FormatDate (inValue);
+                       Date = retVal.Date;
+                       FormatString = retVal.FormatString;
+                       FormattedDate = retVal.FormattedDate;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/OperationContractServer.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/OperationContractServer.cs
new file mode 100644 (file)
index 0000000..8aab071
--- /dev/null
@@ -0,0 +1,79 @@
+//------------------------------------------------------------------------------\r
+// <auto-generated>\r
+//     This code was generated by a tool.\r
+//     Runtime Version:2.0.50727.1433\r
+//\r
+//     Changes to this file may cause incorrect behavior and will be lost if\r
+//     the code is regenerated.\r
+// </auto-generated>\r
+//------------------------------------------------------------------------------\r
+\r
+namespace Proxy.MonoTests.Features.Client\r
+{\r
+    \r
+    \r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    [System.ServiceModel.ServiceContractAttribute(Namespace="http://MonoTests.Features.Contracts", ConfigurationName="Proxy.MonoTests.Features.Client.IOperationContract")]\r
+    public interface IOperationContract\r
+    {\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IOperationContract/RenamedMethod", ReplyAction="http://MonoTests.Features.Contracts/IOperationContract/RenamedMethodResponse")]\r
+        int RenamedMethod();\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IOperationContract/OrigMethod", ReplyAction="http://MonoTests.Features.Contracts/IOperationContract/OrigMethodResponse")]\r
+        int OrigMethod();\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://MonoTests.Features.Contracts/IOperationContract/Sleep")]\r
+        void Sleep(int mili);\r
+    }\r
+    \r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    public interface IOperationContractChannel : Proxy.MonoTests.Features.Client.IOperationContract, System.ServiceModel.IClientChannel\r
+    {\r
+    }\r
+    \r
+    [System.Diagnostics.DebuggerStepThroughAttribute()]\r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    public partial class OperationContractClient : System.ServiceModel.ClientBase<Proxy.MonoTests.Features.Client.IOperationContract>, Proxy.MonoTests.Features.Client.IOperationContract\r
+    {\r
+        \r
+        public OperationContractClient()\r
+        {\r
+        }\r
+        \r
+        public OperationContractClient(string endpointConfigurationName) : \r
+                base(endpointConfigurationName)\r
+        {\r
+        }\r
+        \r
+        public OperationContractClient(string endpointConfigurationName, string remoteAddress) : \r
+                base(endpointConfigurationName, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public OperationContractClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : \r
+                base(endpointConfigurationName, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public OperationContractClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : \r
+                base(binding, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public int RenamedMethod()\r
+        {\r
+            return base.Channel.RenamedMethod();\r
+        }\r
+        \r
+        public int OrigMethod()\r
+        {\r
+            return base.Channel.OrigMethod();\r
+        }\r
+        \r
+        public void Sleep(int mili)\r
+        {\r
+            base.Channel.Sleep(mili);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/PrimitiveTester.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/PrimitiveTester.cs
new file mode 100644 (file)
index 0000000..cff2eb1
--- /dev/null
@@ -0,0 +1,169 @@
+//------------------------------------------------------------------------------\r
+// <auto-generated>\r
+//     This code was generated by a tool.\r
+//     Runtime Version:2.0.50727.1433\r
+//\r
+//     Changes to this file may cause incorrect behavior and will be lost if\r
+//     the code is regenerated.\r
+// </auto-generated>\r
+//------------------------------------------------------------------------------\r
+\r
+namespace Proxy.MonoTests.Features.Client\r
+{\r
+    \r
+    \r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    [System.ServiceModel.ServiceContractAttribute(Namespace="http://MonoTests.Features.Contracts", ConfigurationName="Proxy.MonoTests.Features.Client.IPrimitiveTesterContract")]\r
+    public interface IPrimitiveTesterContract\r
+    {\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/DoNothing", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/DoNothingResponse")]\r
+        void DoNothing();\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddByte", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddByteResponse")]\r
+        int AddByte(byte n1, byte n2);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddSByte", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddSByteResponse")]\r
+        int AddSByte(sbyte n1, sbyte n2);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddShort", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddShortResponse")]\r
+        int AddShort(short n1, short n2);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddUShort", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddUShortResponse")]\r
+        int AddUShort(ushort n1, ushort n2);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddInt", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddIntResponse")]\r
+        int AddInt(int n1, int n2);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddUInt", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddUIntResponse")]\r
+        uint AddUInt(uint n1, uint n2);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddLong", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddLongResponse")]\r
+        long AddLong(long n1, long n2);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddULong", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddULongResponse")]\r
+        ulong AddULong(ulong n1, ulong n2);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddDouble", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddDoubleResponse")]\r
+        double AddDouble(double n1, double n2);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddFloat", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddFloatResponse")]\r
+        float AddFloat(float n1, float n2);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddByRef", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/AddByRefResponse")]\r
+        [return: System.ServiceModel.MessageParameterAttribute(Name="n3")]\r
+        double AddByRef(out double n4, double n1, double n2);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/NullableInt", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/NullableIntResponse")]\r
+        System.Nullable<int> NullableInt(System.Nullable<int> x);\r
+        \r
+        [System.ServiceModel.OperationContractAttribute(Action="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/NullableChar", ReplyAction="http://MonoTests.Features.Contracts/IPrimitiveTesterContract/NullableCharResponse" +\r
+            "")]\r
+        System.Nullable<char> NullableChar(System.Nullable<char> x);\r
+    }\r
+    \r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    public interface IPrimitiveTesterContractChannel : Proxy.MonoTests.Features.Client.IPrimitiveTesterContract, System.ServiceModel.IClientChannel\r
+    {\r
+    }\r
+    \r
+    [System.Diagnostics.DebuggerStepThroughAttribute()]\r
+    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]\r
+    public partial class PrimitiveTesterContractClient : System.ServiceModel.ClientBase<Proxy.MonoTests.Features.Client.IPrimitiveTesterContract>, Proxy.MonoTests.Features.Client.IPrimitiveTesterContract\r
+    {\r
+        \r
+        public PrimitiveTesterContractClient()\r
+        {\r
+        }\r
+        \r
+        public PrimitiveTesterContractClient(string endpointConfigurationName) : \r
+                base(endpointConfigurationName)\r
+        {\r
+        }\r
+        \r
+        public PrimitiveTesterContractClient(string endpointConfigurationName, string remoteAddress) : \r
+                base(endpointConfigurationName, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public PrimitiveTesterContractClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : \r
+                base(endpointConfigurationName, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public PrimitiveTesterContractClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : \r
+                base(binding, remoteAddress)\r
+        {\r
+        }\r
+        \r
+        public void DoNothing()\r
+        {\r
+            base.Channel.DoNothing();\r
+        }\r
+        \r
+        public int AddByte(byte n1, byte n2)\r
+        {\r
+            return base.Channel.AddByte(n1, n2);\r
+        }\r
+        \r
+        public int AddSByte(sbyte n1, sbyte n2)\r
+        {\r
+            return base.Channel.AddSByte(n1, n2);\r
+        }\r
+        \r
+        public int AddShort(short n1, short n2)\r
+        {\r
+            return base.Channel.AddShort(n1, n2);\r
+        }\r
+        \r
+        public int AddUShort(ushort n1, ushort n2)\r
+        {\r
+            return base.Channel.AddUShort(n1, n2);\r
+        }\r
+        \r
+        public int AddInt(int n1, int n2)\r
+        {\r
+            return base.Channel.AddInt(n1, n2);\r
+        }\r
+        \r
+        public uint AddUInt(uint n1, uint n2)\r
+        {\r
+            return base.Channel.AddUInt(n1, n2);\r
+        }\r
+        \r
+        public long AddLong(long n1, long n2)\r
+        {\r
+            return base.Channel.AddLong(n1, n2);\r
+        }\r
+        \r
+        public ulong AddULong(ulong n1, ulong n2)\r
+        {\r
+            return base.Channel.AddULong(n1, n2);\r
+        }\r
+        \r
+        public double AddDouble(double n1, double n2)\r
+        {\r
+            return base.Channel.AddDouble(n1, n2);\r
+        }\r
+        \r
+        public float AddFloat(float n1, float n2)\r
+        {\r
+            return base.Channel.AddFloat(n1, n2);\r
+        }\r
+        \r
+        public double AddByRef(out double n4, double n1, double n2)\r
+        {\r
+            return base.Channel.AddByRef(out n4, n1, n2);\r
+        }\r
+        \r
+        public System.Nullable<int> NullableInt(System.Nullable<int> x)\r
+        {\r
+            return base.Channel.NullableInt(x);\r
+        }\r
+        \r
+        public System.Nullable<char> NullableChar(System.Nullable<char> x)\r
+        {\r
+            return base.Channel.NullableChar(x);\r
+        }\r
+    }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/UntypedMessageTesterProxy.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Client/UntypedMessageTesterProxy.cs
new file mode 100755 (executable)
index 0000000..5b6f553
--- /dev/null
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Proxy.MonoTests.Features.Client
+{
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       [System.ServiceModel.ServiceContractAttribute (Namespace = "http://MonoTests.Features.Contracts", ConfigurationName = "IUntypedMessageTesterContract")]
+       public interface IUntypedMessageTesterContract
+       {
+               [System.ServiceModel.OperationContractAttribute (Action = "http://localhost/UntypedMessageTester/Message_RequestAction", ReplyAction = "http://localhost/UntypedMessageTester/Message_ReplyAction")]
+               System.ServiceModel.Channels.Message ConcatStrings (System.ServiceModel.Channels.Message request);
+       }
+
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public interface IUntypedMessageTesterContractChannel : IUntypedMessageTesterContract, System.ServiceModel.IClientChannel
+       {
+       }
+
+       [System.Diagnostics.DebuggerStepThroughAttribute ()]
+       [System.CodeDom.Compiler.GeneratedCodeAttribute ("System.ServiceModel", "3.0.0.0")]
+       public partial class UntypedMessageTesterContractClient : System.ServiceModel.ClientBase<IUntypedMessageTesterContract>, IUntypedMessageTesterContract
+       {
+
+               public UntypedMessageTesterContractClient ()
+               {
+               }
+
+               public UntypedMessageTesterContractClient (string endpointConfigurationName)
+                       :
+                               base (endpointConfigurationName)
+               {
+               }
+
+               public UntypedMessageTesterContractClient (string endpointConfigurationName, string remoteAddress)
+                       :
+                               base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public UntypedMessageTesterContractClient (string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
+                       :
+                               base (endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               public UntypedMessageTesterContractClient (System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress)
+                       :
+                               base (binding, remoteAddress)
+               {
+               }
+
+               public System.ServiceModel.Channels.Message ConcatStrings (System.ServiceModel.Channels.Message request)
+               {
+                       return base.Channel.ConcatStrings (request);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/AsyncCallTester.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/AsyncCallTester.cs
new file mode 100644 (file)
index 0000000..339b2ea
--- /dev/null
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel;
+
+namespace MonoTests.Features.Contracts
+{
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
+       public interface IAsyncCallTesterContract
+       {
+               [OperationContract]
+               string Query (string query);
+       }
+
+       [ServiceBehavior (InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
+       public class AsyncCallTester : IAsyncCallTesterContract
+       {
+               public string Query (string query)
+               {
+                       return query + query;
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/AsyncPatternContract.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/AsyncPatternContract.cs
new file mode 100644 (file)
index 0000000..486d2f8
--- /dev/null
@@ -0,0 +1,58 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel;\r
+using System.Threading;\r
+\r
+namespace MonoTests.Features.Contracts\r
+{\r
+       // Define a service contract.\r
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]\r
+       public interface IAsyncPattern\r
+       {\r
+               [OperationContractAttribute (AsyncPattern = true)]\r
+               IAsyncResult BeginAsyncMethod (AsyncCallback callback, object asyncState);\r
+               int EndAsyncMethod (IAsyncResult result);\r
+\r
+               // TODO: Need to investigate asyn methods that have ref/out params that are not necessarily first\r
+               // e.g. how does foo(in, ref, out, in) map to AsyncPattern?\r
+\r
+       }\r
+\r
+       public class AsyncPatternServer : IAsyncPattern\r
+       {\r
+               // Simple async result implementation.\r
+               class CompletedAsyncResult<T> : IAsyncResult\r
+               {\r
+                       T data;\r
+                       object state;\r
+\r
+                       public CompletedAsyncResult (T data, object state) { this.data = data; this.state = state; }\r
+\r
+                       public T Data { get { return data; } }\r
+\r
+                       #region IAsyncResult Members\r
+                       public object AsyncState { get { return (object) state; } }\r
+\r
+                       public WaitHandle AsyncWaitHandle { get { throw new Exception ("The method or operation is not implemented."); } }\r
+\r
+                       public bool CompletedSynchronously { get { return true; } }\r
+\r
+                       public bool IsCompleted { get { return true; } }\r
+                       #endregion\r
+               }\r
+\r
+               public IAsyncResult BeginAsyncMethod (AsyncCallback callback, object asyncState) {\r
+                       IAsyncResult result = new CompletedAsyncResult<int> (3, asyncState);\r
+                       new Thread (new ThreadStart (\r
+                               delegate {\r
+                                       callback (result);\r
+                               })).Start ();\r
+                       return result;\r
+               }\r
+\r
+               public int EndAsyncMethod (IAsyncResult r) {\r
+                       return ((CompletedAsyncResult<int>) r).Data;\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/ChangeLog b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/ChangeLog
new file mode 100644 (file)
index 0000000..923f20a
--- /dev/null
@@ -0,0 +1,19 @@
+2008-04-07  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * added: AsyncCallTester.cs
+       FaultsTester.cs
+       * fixed: MessageContractTester.cs
+
+2008-04-06  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * added UntypedMessageTester.cs
+
+2008-04-06  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * added: KnownTypeTester.cs
+       * removed 3.5 dependencies
+       
+2006-04-03  Roei Erez  <roeie@ximian.com>
+       * DataContractTester.cs
+       MessageContractTester.cs
+       PrimitiveTester
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/DataContractTester.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/DataContractTester.cs
new file mode 100644 (file)
index 0000000..97fc295
--- /dev/null
@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.Runtime.Serialization;
+
+namespace MonoTests.Features.Contracts
+{
+       [ServiceContract (Namespace = "http://MonoTests.Integrative.Contracts")]
+       public interface IDataContractTesterContract
+       {
+               [OperationContract]
+               ComplexPrimitiveClass Add (ComplexPrimitiveClass n1, ComplexPrimitiveClass n2);
+
+               [OperationContract]
+               void AddByRef (ComplexPrimitiveClass n1, ComplexPrimitiveClass n2, out ComplexPrimitiveClass result);
+       }
+
+       public class DataContractTester : IDataContractTesterContract
+       {
+               public ComplexPrimitiveClass Add (ComplexPrimitiveClass n1, ComplexPrimitiveClass n2) {
+                       n1._byte += n2._byte;
+                       n1._sbyte += n2._sbyte;
+                       n1._short += n2._short;
+                       n1._ushort += n2._ushort;
+                       n1._int += n2._int;
+                       n1._uint += n2._uint;
+                       n1._long += n2._long;
+                       n1._ulong += n2._ulong;
+                       n1._double += n2._double;
+                       n1._float += n2._float;
+                       return n1;
+               }
+
+               public void AddByRef (ComplexPrimitiveClass n1, ComplexPrimitiveClass n2, out ComplexPrimitiveClass result) {
+                       result = Add (n1, n2);                  
+               }
+       }
+
+       #region Class Data
+
+       [DataContract (Namespace = "http://MonoTests.Features.Client")]
+       public class ComplexPrimitiveClass
+       {
+               [DataMember(Name="byteMember")]
+               public byte _byte = 1;
+
+               [DataMember (Name = "sbyteMember")]
+               public sbyte _sbyte = 1;
+
+               [DataMember (Name = "shortMember")]
+               public short _short = 1;
+
+               [DataMember (Name = "ushortMember")]
+               public ushort _ushort = 1;
+
+               [DataMember (Name = "intMember")]
+               public int _int = 1;
+
+               [DataMember (Name = "uintMember")]
+               public uint _uint = 1;
+
+               [DataMember (Name = "longMember")]
+               public long _long = 1;
+
+               [DataMember (Name = "ulongMember")]
+               public ulong _ulong = 1;
+
+               [DataMember (Name = "doubleMember")]
+               public double _double = 1;
+
+               [DataMember (Name = "floatMember")]
+               public float _float = 1;
+       }
+
+       #endregion
+
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/DualContract.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/DualContract.cs
new file mode 100644 (file)
index 0000000..c16f3ff
--- /dev/null
@@ -0,0 +1,28 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel;\r
+using System.Threading;\r
+\r
+namespace MonoTests.Features.Contracts\r
+{\r
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]\r
+       public interface IFirstContract\r
+       {\r
+               [OperationContract]\r
+               int FirstMethod ();\r
+       }\r
+\r
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]\r
+       public interface ISecondContract\r
+       {\r
+               [OperationContract]\r
+               int SecondMethod ();\r
+       }\r
+\r
+       public class DualContractServer : IFirstContract, ISecondContract\r
+       {\r
+               public int FirstMethod () { return 1; }\r
+               public int SecondMethod () { return 2; }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/ExitpProcessHelper.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/ExitpProcessHelper.cs
new file mode 100644 (file)
index 0000000..ce18a2c
--- /dev/null
@@ -0,0 +1,23 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel;\r
+using System.Threading;\r
+\r
+namespace MonoTests.Features.Contracts\r
+{\r
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]\r
+       public interface IExitProcessHelper\r
+       {\r
+               [OperationContract(IsOneWay=true)]\r
+               void ExitProcess (int code);\r
+       }\r
+\r
+       public class ExitProcessHelperServer : IExitProcessHelper\r
+       {\r
+               public void ExitProcess (int code) {\r
+                       Environment.Exit (code);\r
+               }\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/FaultsTester.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/FaultsTester.cs
new file mode 100644 (file)
index 0000000..a5102e2
--- /dev/null
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel;
+using System.Web.Services.Description;
+
+namespace MonoTests.Features.Contracts
+{
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
+       public interface IFaultsTesterContract
+       {
+               [OperationContract]
+               void FaultMethod (string faultText);
+       }
+
+       public class FaultsTester : IFaultsTesterContract
+       {
+               public void FaultMethod (string faultText)
+               {
+                       throw new Exception (faultText);
+               }
+       }
+
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
+       public interface IFaultsTesterContractIncludeDetails
+       {
+               [OperationContract]
+               void FaultMethod (string faultText);
+       }
+
+       [ServiceBehavior (IncludeExceptionDetailInFaults = true)]
+       public class FaultsTesterIncludeDetails : IFaultsTesterContractIncludeDetails
+       {
+               public void FaultMethod (string faultText)
+               {
+                       throw new Exception (faultText);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/KnownTypeTester.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/KnownTypeTester.cs
new file mode 100755 (executable)
index 0000000..b8d53c0
--- /dev/null
@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+
+namespace MonoTests.Features.Contracts
+{
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
+       public interface IKnownTypeTesterContract
+       {
+               [OperationContract]
+               Point2D Move (Point2D point, Point2D delta);
+
+               [OperationContract]
+               double Distance (Point2D point1, Point2D point2);
+
+               [OperationContract]
+               BaseContract [] foo ();
+       }
+
+       public class KnownTypeTester : IKnownTypeTesterContract
+       {
+               public Point2D Move (Point2D point, Point2D delta)
+               {
+                       return new AdvPoint2D (point.X + delta.X, point.Y + delta.Y);
+               }
+
+               public double Distance (Point2D point1, Point2D point2)
+               {
+                       return Math.Sqrt (Math.Abs (point1.X - point2.X) +
+                               Math.Abs (point1.Y - point2.Y));
+               }
+
+               public BaseContract [] foo () {
+                       return new BaseContract[] {new DerivedContract ()};
+               }
+
+       }
+
+       [DataContract (Namespace = "http://MonoTests.Features.Contracts")]
+       [KnownType (typeof (AdvPoint2D))]
+       public class Point2D
+       {
+               int x;
+               int y;
+               public Point2D () { }
+
+               public Point2D (int x, int y)
+               {
+                       this.x = x;
+                       this.y = y;
+               }
+
+               [DataMember]
+               public int X
+               {
+                       get { return x; }
+                       set { x = value; }
+               }
+
+               [DataMember]
+               public int Y
+               {
+                       get { return y; }
+                       set { y = value; }
+               }
+       }
+
+       [DataContract (Namespace = "http://MonoTests.Features.Contracts")]
+       public class AdvPoint2D : Point2D
+       {
+               public AdvPoint2D (int x, int y)
+                       : base (x, y)
+               {
+               }
+
+               [DataMember]
+               public double ZeroDistance
+               {
+                       get { return Math.Sqrt (X * X + Y * Y); }
+                       set { }
+               }
+       }
+
+       [DataContract]
+       [KnownType (typeof (DerivedContract))]
+       public class BaseContract
+       {
+               [DataMember]
+               string name;
+       }
+
+       [DataContract]
+       public class DerivedContract : BaseContract
+       {
+               [DataMember]
+               bool blah;
+       }
+
+
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/MessageContractTester.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/MessageContractTester.cs
new file mode 100644 (file)
index 0000000..89e5d1c
--- /dev/null
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.Serialization;
+using System.ServiceModel.Description;
+using System.ServiceModel;
+
+namespace MonoTests.Features.Contracts
+{
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
+       public interface IMessageContractTesterContract
+       {
+               [OperationContract (Action = "http://test/TestMessage_action", ReplyAction = "http://test/TestMessage_action")]
+               TestMessage FormatDate (TestMessage testMessage);
+       }
+
+       [MessageContract]
+       public class TestMessage
+       {
+               private string formatString;
+               private DateTime date;
+               private string formattedDate;
+
+               public TestMessage () 
+               {
+               }
+
+               public TestMessage (DateTime date, string formatString, string formattedDate)
+               {
+                       this.date = date;
+                       this.formatString = formatString;
+                       this.formattedDate = formattedDate;
+               }
+
+               public TestMessage (TestMessage message)
+               {
+                       this.date = message.date;
+                       this.formatString = message.formatString;
+                       this.formattedDate = message.formattedDate;
+               }
+
+               [MessageHeader]
+               public string FormatString
+               {
+                       get { return formatString; }
+                       set { formatString = value; }
+               }
+
+               [MessageBodyMember]
+               public DateTime Date
+               {
+                       get { return date; }
+                       set { date = value; }
+               }
+
+               [MessageBodyMember]
+               public string FormattedDate
+               {
+                       get { return formattedDate; }
+                       set { formattedDate = value; }
+               }
+       }
+
+       public class MessageContractTester : IMessageContractTesterContract
+       {
+               public TestMessage FormatDate (TestMessage testMessage)
+               {
+                       TestMessage r = new TestMessage (testMessage);
+                       r.FormattedDate = r.Date.ToString (r.FormatString);
+                       return r;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/OperationContract.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/OperationContract.cs
new file mode 100644 (file)
index 0000000..aadc6ea
--- /dev/null
@@ -0,0 +1,35 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.ServiceModel;\r
+using System.Threading;\r
+\r
+namespace MonoTests.Features.Contracts\r
+{\r
+       // Define a service contract.\r
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]\r
+       public interface IOperationContract\r
+       {\r
+\r
+               [OperationContract (Name = "RenamedMethod")]\r
+               int OrigMethod ();\r
+\r
+               [OperationContract (Name = "OrigMethod")]\r
+               int RenamedMethod ();\r
+\r
+\r
+               [OperationContract (IsOneWay = true)]\r
+               void Sleep (int mili);\r
+       }\r
+\r
+       public class OperationContractServer : IOperationContract\r
+       {\r
+               public int OrigMethod () { return 1; }\r
+               public int RenamedMethod () { return 2; }\r
+\r
+               public void Sleep(int mili) \r
+               {\r
+                        Thread.Sleep(mili); \r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/OperationContractServer.xml b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/OperationContractServer.xml
new file mode 100644 (file)
index 0000000..54d1bec
--- /dev/null
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8"?><wsdl:definitions name="OperationContractServer" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://MonoTests.Features.Contracts" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"><wsdl:import namespace="http://MonoTests.Features.Contracts" location="http://localhost:9999/OperationContractServer?wsdl=wsdl0"/><wsdl:types/><wsdl:binding name="BasicHttpBinding_IOperationContract" type="i0:IOperationContract"><soap:binding transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="RenamedMethod"><soap:operation soapAction="http://MonoTests.Features.Contracts/IOperationContract/RenamedMethod" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation><wsdl:operation name="OrigMethod"><soap:operation soapAction="http://MonoTests.Features.Contracts/IOperationContract/OrigMethod" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation><wsdl:operation name="AsyncMethod"><soap:operation soapAction="http://MonoTests.Features.Contracts/IOperationContract/AsyncMethod" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation><wsdl:operation name="Sleep"><soap:operation soapAction="http://MonoTests.Features.Contracts/IOperationContract/Sleep" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input></wsdl:operation></wsdl:binding><wsdl:service name="OperationContractServer"><wsdl:port name="BasicHttpBinding_IOperationContract" binding="tns:BasicHttpBinding_IOperationContract"><soap:address location="http://localhost:9999/OperationContractServer"/></wsdl:port></wsdl:service></wsdl:definitions>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/PrimitiveTester.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/PrimitiveTester.cs
new file mode 100644 (file)
index 0000000..b4a33c6
--- /dev/null
@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel;
+
+namespace MonoTests.Features.Contracts
+{
+       // Define a service contract.
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
+       public interface IPrimitiveTesterContract
+       {
+               [OperationContract]
+               void DoNothing ();
+
+               [OperationContract]
+               int AddByte (byte n1, byte n2);
+
+               [OperationContract]
+               int AddSByte (sbyte n1, sbyte n2);
+
+               [OperationContract]
+               int AddShort (short n1, short n2);
+
+               [OperationContract]
+               int AddUShort (ushort n1, ushort n2);
+
+               [OperationContract]
+               int AddInt (int n1, int n2);
+
+               [OperationContract]
+               uint AddUInt (uint n1, uint n2);
+
+               [OperationContract]
+               long AddLong (long n1, long n2);
+
+               [OperationContract]
+               ulong AddULong (ulong n1, ulong n2);
+
+               [OperationContract]
+               double AddDouble (double n1, double n2);
+
+               [OperationContract]
+               float AddFloat (float n1, float n2);
+
+               [OperationContract]
+               char AddChar (char n1, char c2);
+
+               [OperationContract]
+               void AddByRef(double n1, double n2, out double n3, out double n4);
+
+               [OperationContract]
+               int? NullableInt (int? x);
+
+               [OperationContract]
+               float? NullableFloat (float? x);
+
+               [OperationContract]
+               TimeSpan AddTimeSpan (TimeSpan t1, TimeSpan t2);
+
+               [OperationContract]
+               byte [] AddByteArray (byte [] b1, byte [] b2);
+       }
+       
+       public class PrimitiveTester : IPrimitiveTesterContract
+       {
+               public void DoNothing () {
+               }
+
+               public int AddByte (byte n1, byte n2) {
+                       return (byte) n1 + n2;
+               }
+
+               public int AddSByte (sbyte n1, sbyte n2) {
+                       return n1 + n2;
+               }
+
+               public int AddShort (short n1, short n2) {
+                       return n1 + n2;
+               }
+
+               public int AddUShort (ushort n1, ushort n2) {
+                       return n1 + n2;
+               }
+
+               public int AddInt (int n1, int n2) {
+                       return n1 + n2;
+               }
+
+               public uint AddUInt (uint n1, uint n2) {
+                       return n1 + n2;
+               }
+
+               public long AddLong (long n1, long n2) {
+                       return n1 + n2;
+               }
+
+               public ulong AddULong (ulong n1, ulong n2) {
+                       return n1 + n2;
+               }
+
+               public double AddDouble (double n1, double n2) {
+                       return n1 + n2;
+               }
+
+               public float AddFloat (float n1, float n2) {
+                       return n1 + n2;
+               }
+
+               public char AddChar (char n1, char n2) {
+                       return (char)(n1 + n2);
+               }
+
+               public void AddByRef (double n1, double n2, out double n3, out double n4) {
+                       n3 = n4 = n1 + n2;
+               }
+
+               public int? NullableInt(int?x) {
+                       return x==null ? x : x+1;
+               }
+
+               public float? NullableFloat (float? x) {
+                       return x == null ? x : x + 1;
+               }
+
+               public TimeSpan AddTimeSpan (TimeSpan t1, TimeSpan t2) {
+                       return t1.Add (t2);
+               }
+
+               public byte [] AddByteArray (byte [] b1, byte [] b2) {
+                       byte [] ret = new byte [b1.Length];
+                       for (int i = 0; i < b1.Length; i++)
+                               ret [i] = (byte) (b1 [i] + b2 [i]);
+                       return ret;
+               }
+       }       
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/UntypedMessageTester.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Contracts/UntypedMessageTester.cs
new file mode 100755 (executable)
index 0000000..e6a3138
--- /dev/null
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace MonoTests.Features.Contracts
+{
+       [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
+       public interface IUntypedMessageTesterContract
+       {
+               [OperationContract (Action = UntypedMessageTester.RequestAction, ReplyAction = UntypedMessageTester.ReplyAction)]
+               Message ConcatStrings (Message request);
+       }
+
+       public class UntypedMessageTester : IUntypedMessageTesterContract
+       {
+               public const String ReplyAction = "http://localhost/UntypedMessageTester/Message_ReplyAction";
+               public const String RequestAction = "http://localhost/UntypedMessageTester/Message_RequestAction";
+
+               public Message ConcatStrings (Message request)
+               {
+                       string str = string.Empty;
+
+                       string [] inputStrings = request.GetBody<string []> ();
+                       for (int i = 0; i < inputStrings.Length; i++)
+                               str += inputStrings [i];
+
+                       Message response = Message.CreateMessage (request.Version, ReplyAction, str);
+                       return response;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/AsyncCallTest.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/AsyncCallTest.cs
new file mode 100644 (file)
index 0000000..d61a3ea
--- /dev/null
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using Proxy.MonoTests.Features.Client;
+using MonoTests.Features.Contracts;
+using System.Threading;
+
+namespace MonoTests.Features.Serialization
+{
+       [TestFixture]
+       [Category ("NotWorking")] // Can't even build in Mono. Missing public APIs.
+    public class AsyncCallTest : TestFixtureBase<AsyncCallTesterContractClient, AsyncCallTester, MonoTests.Features.Contracts.IAsyncCallTesterContract>
+       {
+               bool client_QueryCompleted;
+               string s = string.Empty;
+        AutoResetEvent ev;
+        Exception err = null;
+
+        public AsyncCallTest()
+        {
+        }
+               [Test]
+               public void TestAsyncCall ()
+               {
+            ev = new AutoResetEvent(false);
+                       client_QueryCompleted = false;
+
+                       ClientProxy.QueryCompleted += new EventHandler<QueryCompletedEventArgs>(Client_QueryCompleted);
+                       ClientProxy.QueryAsync ("heh");
+            ev.WaitOne(2000, true);
+            Assert.IsTrue(client_QueryCompleted, "async call completed");
+            Assert.AreEqual("hehheh", s, "#1");
+            if (err != null) throw err;
+               }
+
+               private void Client_QueryCompleted (object sender, QueryCompletedEventArgs e)
+               {
+                       client_QueryCompleted = true;
+            try
+            {
+                s = e.Result;
+            }
+            catch (Exception _e)
+            {
+                err = _e;
+            }
+            ev.Set();  
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/AsyncPatternTester.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/AsyncPatternTester.cs
new file mode 100644 (file)
index 0000000..265751e
--- /dev/null
@@ -0,0 +1,22 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using Proxy.MonoTests.Features.Client;\r
+using NUnit.Framework;\r
+using System.ServiceModel;\r
+using MonoTests.Features.Contracts;\r
+using System.Threading;\r
+\r
+namespace MonoTests.Features.Serialization\r
+{\r
+       [TestFixture]\r
+       public class AsyncPatternTest : TestFixtureBase<AsyncPatternClient, AsyncPatternServer, MonoTests.Features.Contracts.IAsyncPattern>\r
+       {\r
+\r
+               [Test]\r
+               [Category("NotWorking")]\r
+               public void TestAsync () {\r
+                       Assert.AreEqual (ClientProxy.AsyncMethod (), 3, "Called method with AsyncPattern=true");\r
+               }\r
+       }\r
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/ChangeLog b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/ChangeLog
new file mode 100644 (file)
index 0000000..e3179ba
--- /dev/null
@@ -0,0 +1,21 @@
+2008-05-01  Eyal Alaluf  <eyala@mainsoft.com>
+
+       * PrimitiveTesterTest.cs: Fixed TestLong and TestByRef
+
+2008-04-07  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * added: FaultsTest.cs
+       MessageContractTest.cs
+       AsyncCallTest.cs
+
+2008-04-06  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * added: UntypedMessageTest.cs
+
+2008-04-06  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * added: KnownTypeTest.cs
+
+2006-04-03  Roei Erez  <roeie@ximian.com>
+       * DataContractSerializerTest.cs
+       PrimitiveTesterTest.cs
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/DataContractSerializerTest.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/DataContractSerializerTest.cs
new file mode 100644 (file)
index 0000000..cfa6b4c
--- /dev/null
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel;
+using MonoTests.Features;
+using MonoTests.Features.Contracts;
+using NUnit.Framework;
+
+namespace MonoTests.Features.Serialization
+{
+       [TestFixture]
+    public class DataContractSerializerTest : TestFixtureBase<DataContractTesterContractClient, DataContractTester, MonoTests.Features.Contracts.IDataContractTesterContract>
+       {               
+
+               [Test]
+               public void TestPrimitiveComplexType () {
+                       Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n1 = GetNewDataInstance ();
+                       Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n2 = GetNewDataInstance ();
+                       Proxy.MonoTests.Features.Client.ComplexPrimitiveClass result = ClientProxy.Add (n1, n2);
+                       Assert.IsTrue (result.byteMember == 2);
+                       Assert.IsTrue (result.sbyteMember == 2);
+                       Assert.IsTrue (result.shortMember == 2);
+                       Assert.IsTrue (result.ushortMember == 2);
+                       Assert.IsTrue (result.intMember == 2);
+                       Assert.IsTrue (result.uintMember == 2);
+                       Assert.IsTrue (result.longMember == 2);
+                       Assert.IsTrue (result.ulongMember == 2);
+                       Assert.IsTrue (result.doubleMember == 2);
+                       Assert.IsTrue (result.floatMember == 2);
+               }
+
+               [Test]
+               public void TestPrimitiveComplexTypeByRef () {
+                       Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n1 = GetNewDataInstance ();
+                       Proxy.MonoTests.Features.Client.ComplexPrimitiveClass n2 = GetNewDataInstance ();
+                       Proxy.MonoTests.Features.Client.ComplexPrimitiveClass result = null;
+                       result = ClientProxy.AddByRef (n1, n2);
+                       Assert.IsTrue (result.byteMember == 2);
+                       Assert.IsTrue (result.sbyteMember == 2);
+                       Assert.IsTrue (result.shortMember == 2);
+                       Assert.IsTrue (result.ushortMember == 2);
+                       Assert.IsTrue (result.intMember == 2);
+                       Assert.IsTrue (result.uintMember == 2);
+                       Assert.IsTrue (result.longMember == 2);
+                       Assert.IsTrue (result.ulongMember == 2);
+                       Assert.IsTrue (result.doubleMember == 2);
+                       Assert.IsTrue (result.floatMember == 2);
+               }
+
+               private Proxy.MonoTests.Features.Client.ComplexPrimitiveClass GetNewDataInstance ()
+               {
+                       Proxy.MonoTests.Features.Client.ComplexPrimitiveClass inst = new Proxy.MonoTests.Features.Client.ComplexPrimitiveClass ();
+                       inst.byteMember = 1;
+                       inst.sbyteMember = 1;
+                       inst.intMember = 1;
+                       inst.uintMember = 1;
+                       inst.shortMember = 1;
+                       inst.ushortMember = 1;
+                       inst.longMember = 1;
+                       inst.ulongMember = 1;
+                       inst.doubleMember = 1;
+                       inst.floatMember = 1;
+                       return inst;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/DualContractTester.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/DualContractTester.cs
new file mode 100644 (file)
index 0000000..0d6982f
--- /dev/null
@@ -0,0 +1,30 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using Proxy.MonoTests.Features.Client;\r
+using NUnit.Framework;\r
+using System.ServiceModel;\r
+using MonoTests.Features.Contracts;\r
+using System.Threading;\r
+\r
+namespace MonoTests.Features.Serialization\r
+{\r
+       [TestFixture]\r
+       public class DualContractFirstTest : TestFixtureBase<object, DualContractServer, MonoTests.Features.Contracts.IFirstContract>\r
+       {\r
+               [Test]\r
+               public void TestFirst () {\r
+                       Assert.AreEqual (Client.FirstMethod (), 1, "IFirstContract.FirstMethod");\r
+               }\r
+       }\r
+\r
+       [TestFixture]\r
+       public class DualContractSecondTest : TestFixtureBase<object, DualContractServer, MonoTests.Features.Contracts.ISecondContract>\r
+       {\r
+               [Test]\r
+               public void TestSecond () {\r
+                       Assert.AreEqual (Client.SecondMethod (), 2, "ISecondContract.SecondMethod");\r
+               }\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/ExitProcessHelper.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/ExitProcessHelper.cs
new file mode 100644 (file)
index 0000000..412874d
--- /dev/null
@@ -0,0 +1,15 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using Proxy.MonoTests.Features.Client;\r
+using NUnit.Framework;\r
+using System.ServiceModel;\r
+using MonoTests.Features.Contracts;\r
+\r
+namespace MonoTests.Features.Serialization\r
+{\r
+       [TestFixture]\r
+       public class ExitProcessHelper : TestFixtureBase<Proxy.MonoTests.Features.Client.ExitProcessHelperClient, ExitProcessHelperServer, MonoTests.Features.Contracts.IExitProcessHelper>\r
+       {\r
+       }\r
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/FaultsTest.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/FaultsTest.cs
new file mode 100644 (file)
index 0000000..e64e3fd
--- /dev/null
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Proxy.MonoTests.Features.Client;
+using NUnit.Framework;
+using System.ServiceModel;
+using MonoTests.Features.Contracts;
+
+namespace MonoTests.Features.Serialization
+{
+       [TestFixture]
+    public class FaultsTest : TestFixtureBase<FaultsTesterContractClient, FaultsTester, MonoTests.Features.Contracts.IFaultsTesterContract>
+       {
+               [Test]
+               public void TestFault ()
+               {
+                       try {
+                               Client.FaultMethod ("heh");
+                       }
+                       catch (FaultException e) {
+                               return;
+                       }
+                       Assert.Fail ("No exception was thrown");
+               }
+       }
+
+       [TestFixture]
+    public class FaultsTestIncludeDetails : TestFixtureBase<FaultsTesterContractClientIncludeDetails, MonoTests.Features.Contracts.FaultsTesterIncludeDetails, MonoTests.Features.Contracts.IFaultsTesterContractIncludeDetails>
+       {
+               [Test]
+               public void TestFault ()
+               {
+                       try {
+                               Client.FaultMethod ("heh");
+                       }
+                       catch (FaultException<ExceptionDetail> e) {
+                               Assert.AreEqual ("heh", e.Message);
+                               return;
+                       }
+                       Assert.Fail ("No exception was thrown");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/KnownTypeTest.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/KnownTypeTest.cs
new file mode 100755 (executable)
index 0000000..e51f15b
--- /dev/null
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using MonoTests.Features.Contracts;
+
+namespace MonoTests.Features.Serialization
+{
+       [TestFixture]
+    public class KnownTypeTest : TestFixtureBase<object, MonoTests.Features.Contracts.KnownTypeTester, MonoTests.Features.Contracts.IKnownTypeTesterContract>
+       {
+               [Test]
+               public void TestKnownType ()
+               {
+                       Point2D p1 = new Point2D ();
+                       p1.X = 1;
+                       p1.Y = 1;
+
+                       Point2D p2 = new Point2D ();
+                       p2.X = 2;
+                       p2.Y = 3;
+
+                       Point2D r = Client.Move (p1, p2);
+                       Assert.IsNotNull (r, "#1");
+                       Assert.IsTrue (r is AdvPoint2D, "#2");
+                       Assert.AreEqual (((AdvPoint2D) r).ZeroDistance, 5, "#3");
+
+               }
+
+               [Test]
+               public void TestKnowType2 () {
+                       BaseContract [] x = Client.foo ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/MessageContractTest.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/MessageContractTest.cs
new file mode 100644 (file)
index 0000000..1120852
--- /dev/null
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Proxy.MonoTests.Features.Client;
+using NUnit.Framework;
+
+namespace MonoTests.Features.Serialization
+{
+       [TestFixture]
+       [Category ("NotWorking")] // Serialization failure
+    public class MessageContractTest : TestFixtureBase<MessageContractTesterContractClient, MonoTests.Features.Contracts.MessageContractTester, MonoTests.Features.Contracts.IMessageContractTesterContract>
+       {
+               [Test]
+               public void TestMessageContract ()
+               {
+                       TestMessage msg = new TestMessage ();
+                       msg.Date = new DateTime (2014, 1, 1);
+                       msg.FormatString = "yyyy-MM-dd";
+
+                       TestMessage r = ((IMessageContractTesterContract) Client).FormatDate (msg);
+
+                       Assert.AreEqual ("2014-01-01", r.FormattedDate, "#1");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/OperationContractTester.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/OperationContractTester.cs
new file mode 100644 (file)
index 0000000..9eb4671
--- /dev/null
@@ -0,0 +1,46 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using Proxy.MonoTests.Features.Client;\r
+using NUnit.Framework;\r
+using System.ServiceModel;\r
+using MonoTests.Features.Contracts;\r
+using System.Threading;\r
+\r
+namespace MonoTests.Features.Serialization\r
+{\r
+       [TestFixture]\r
+       public class OperationContractTest : TestFixtureBase<OperationContractClient, OperationContractServer, MonoTests.Features.Contracts.IOperationContract>\r
+       {\r
+               [Test]\r
+               [Category("NotWorking")]\r
+               public void TestName () {\r
+                       Assert.AreEqual(Client.OrigMethod(),2,"Calling OrigMethod should actually call RenamedMethod");\r
+                       Assert.AreEqual(Client.RenamedMethod(),1,"Calling RenamedMethod should actually call OrigMethod");\r
+               }\r
+\r
+               [Test]\r
+               [Category("NotWorking")]\r
+               public void TestOneWay () {\r
+                       int sleepTime = 1 * 1000, failTime = 500; // Good times for inproc, no debugging.\r
+                       if (!Configuration.IsLocal) {\r
+                               sleepTime = 5 * 1000;\r
+                               failTime = 2 * 1000;\r
+                       }\r
+                       DateTime start = DateTime.Now;\r
+                       Client.Sleep (sleepTime);\r
+                       DateTime end = DateTime.Now;\r
+                       TimeSpan diff = end.Subtract (start);\r
+                       TimeSpan max = TimeSpan.FromMilliseconds(failTime);\r
+                       Assert.IsTrue (diff < max, "Sleep({0} milisec) must end in less than {1} seconds",sleepTime,failTime);\r
+                       if (sleepTime > (int) diff.TotalMilliseconds)\r
+                               Thread.Sleep (sleepTime - (int)diff.TotalMilliseconds); // wait for server thread to release itself\r
+               }\r
+\r
+               [Test]\r
+               [Category ("NotWorking")]\r
+               public void TestWsdl () {\r
+                       CheckWsdlImpl ();\r
+               }\r
+       }\r
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/PrimitiveTesterTest.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/PrimitiveTesterTest.cs
new file mode 100644 (file)
index 0000000..532b963
--- /dev/null
@@ -0,0 +1,118 @@
+
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel;
+using MonoTests.Features;
+using MonoTests.Features.Contracts;
+using NUnit.Framework;
+using Proxy.MonoTests.Features.Client;
+
+namespace MonoTests.Features.Serialization
+{
+       [TestFixture]
+    public class PrimitiveTesterTest : TestFixtureBase<PrimitiveTesterContractClient, PrimitiveTester, MonoTests.Features.Contracts.IPrimitiveTesterContract>
+       {
+               [Test]
+               public void TestDoNothing () 
+               {
+                       Client.DoNothing ();
+               }
+
+               [Test]
+               public void TestDouble () {
+                       Assert.IsTrue (Client.AddDouble (1, 1) == 2);
+               }
+
+               [Test]
+               public void TestByte () {
+                       Assert.IsTrue (Client.AddByte (1, 1) == 2);
+               }
+
+               [Test]
+               public void TestSByte () {
+                       Assert.IsTrue (Client.AddSByte (1, 1) == 2);
+               }
+
+               [Test]
+               public void TestShort () {
+                       Assert.IsTrue (Client.AddShort (1, 1) == 2);
+               }
+
+               [Test]
+               public void TestUShort () {
+                       Assert.IsTrue (Client.AddUShort (1, 1) == 2);
+               }
+
+               [Test]
+               public void TestInt () {
+                       Assert.IsTrue (Client.AddInt (1, 1) == 2);
+               }
+
+               [Test]
+               public void TestUInt () {
+                       Assert.IsTrue (Client.AddUInt (1, 1) == 2);
+               }
+
+               [Test]
+               public void TestLong () {
+                       Assert.AreEqual (2, Client.AddLong (1, 1));
+               }
+
+               [Test]
+               public void TestULong () {
+                       Assert.IsTrue (Client.AddULong (1, 1) == 2);
+               }
+
+               [Test]
+               public void TestFloat () {
+                       Assert.IsTrue (Client.AddFloat (1, 1) == 2);
+               }
+
+               [Test]
+               public void TestChar () {
+                       Assert.AreEqual (Client.AddChar ((char) 1, (char) 1), (char) 2);
+               }
+
+               [Test]
+               public void TestByRef () {
+                       double d;
+                       double res = ClientProxy.AddByRef (out d, 1, 1);
+                       Assert.IsTrue(d == res);
+               }
+
+               [Test]
+               public void TestNullableInt() {
+                       int? x1 = Client.NullableInt(3);
+                       Assert.AreEqual(x1,4,"TestNullableInt(3)==4");
+                       int? x2 = Client.NullableInt (null);
+                       Assert.IsNull (x2, "TestNullableInt(null)==null");
+               }
+
+               [Test]
+               public void TestNullableFloat () {
+                       float? x1 = Client.NullableFloat ((float)1.5);
+                       Assert.AreEqual (x1, 2.5, "TestNullableFloat(1.5)==2.5");
+                       float? x2 = Client.NullableFloat (null);
+                       Assert.IsNull (x2, "TestNullableFloat(null)==null");
+               }
+
+               [Test]
+               public void TestTimeSpan () {
+                       TimeSpan t1 = new TimeSpan (12345);
+                       TimeSpan t2 = new TimeSpan (12345);
+                       TimeSpan t3 = Client.AddTimeSpan (t1, t2);
+                       Assert.AreEqual (t3.Ticks, 24690);
+               }
+
+               [Test]
+               public void TestByteArray () {
+                       byte [] b1 = new byte [] { 1, 2, 3, 4, 5 };
+                       byte [] b2 = new byte [] { 6, 7, 8, 9, 10 };
+                       byte [] sum = Client.AddByteArray (b1, b2);
+                       Assert.AreEqual (sum.Length, b1.Length, "Length of return array");
+                       Assert.AreEqual (sum [4], b1 [4] + b2 [4], "fourth element in return array");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/UntypedMessageTest.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/UntypedMessageTest.cs
new file mode 100755 (executable)
index 0000000..f60fd5d
--- /dev/null
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using Proxy.MonoTests.Features.Client;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+
+namespace MonoTests.Features.Serialization
+{
+       [TestFixture]
+       [Category ("NotWorking")] // Message version mismatch. Expected Soap11, Received Soap12
+    public class UntypedMessageTest : TestFixtureBase<UntypedMessageTesterContractClient, MonoTests.Features.Contracts.UntypedMessageTester, MonoTests.Features.Contracts.IUntypedMessageTesterContract>
+       {
+               [Test]
+               public void TestUntypedMessage ()
+               {
+                       String action = "http://localhost/UntypedMessageTester/Message_RequestAction";
+                       using (new OperationContextScope (ClientProxy.InnerChannel)) {
+                               // Call the Sum service operation.
+                               string [] strings = { "a", "b", "c" };
+                               Message request = Message.CreateMessage (OperationContext.Current.OutgoingMessageHeaders.MessageVersion, action, strings);
+                               Message reply = Client.ConcatStrings (request);
+                               string r = reply.GetBody<string> ();
+
+                               Assert.AreEqual (r, "abc", "#1");
+                       }
+
+
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/XmlComparer.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/Features.Serialization/XmlComparer.cs
new file mode 100644 (file)
index 0000000..d9b4b22
--- /dev/null
@@ -0,0 +1,146 @@
+using System;
+using System.Xml;\r
+using System.IO;
+
+namespace MonoTests.stand_alone.WebHarness
+{
+       /// <summary>
+       /// Summary description for XmlComparer.
+       /// </summary>
+       public class XmlComparer
+       {
+               [Flags]
+               public enum Flags {
+                       IgnoreNone=0,
+                       IgnoreAttribOrder=1,
+                       IgnoreNodeOrder=2,
+               }
+               Flags flags;
+               bool ignoreWS = true;
+
+               string lastCompare = "";
+               string _actual = "";
+               string _expected = "";
+
+               public XmlComparer (Flags flags, bool ignoreWS) 
+               {
+                       this.flags = flags;
+                       this.ignoreWS = ignoreWS;
+               }
+
+               public XmlComparer (Flags flags) : this (flags, true)
+               {
+               }
+
+               public XmlComparer () : this (Flags.IgnoreAttribOrder)
+               {
+               }
+
+               public bool AreEqualAttribs (XmlAttributeCollection expected, XmlAttributeCollection actual)
+               {
+                       if (expected.Count != actual.Count)
+                               return false;
+                       for (int i=0; i<expected.Count; i++) {
+                               if ((flags & Flags.IgnoreAttribOrder) != 0) {
+                                       string ln = expected[i].LocalName;
+                                       string ns = expected[i].NamespaceURI;
+                                       string val = expected[i].Value;
+                                       _expected = ns+":"+ln+"="+val;
+                                       XmlAttribute atr2 = actual[ln, ns];
+                                       _actual = atr2 == null ? "<<missing>>" : ns + ":" + ln + "=" + atr2.Value;
+                                       if (atr2 == null || atr2.Value.Trim().ToLower() != val.Trim().ToLower())
+                                               return false;
+                               } else {
+                                       if (expected [i].LocalName != actual [i].LocalName)
+                                               return false;
+                                       if (expected [i].NamespaceURI != actual [i].NamespaceURI)
+                                               return false;
+                                       if (expected [i].Value.Trim().ToLower() != actual [i].Value.Trim().ToLower())
+                                               return false;
+                               }
+                       }
+                       return true;
+               }
+
+               public bool AreEqualNodeList (XmlNodeList expected, XmlNodeList actual)
+               {
+                       if (expected.Count != actual.Count)
+                               return false;
+                       for (int i=0; i<expected.Count; i++) {
+                               if (!AreEqual (expected[i], actual[i]))
+                                       return false;
+                       }
+                       return true;
+               }
+
+               public bool AreEqual (XmlNode expected, XmlNode actual)
+               {
+                       lastCompare = expected.OuterXml + "\n" + actual.OuterXml;
+                       _actual = actual.OuterXml;
+                       _expected = expected.OuterXml;
+                       // skip XmlDeclaration
+                       if ((expected.NodeType == XmlNodeType.XmlDeclaration) &&
+                               (actual.NodeType == XmlNodeType.XmlDeclaration))
+                               return true;
+                       if (expected.NodeType != actual.NodeType)
+                               return false;
+                       if (expected.LocalName != actual.LocalName)
+                               return false;
+                       if (expected.NamespaceURI != actual.NamespaceURI)
+                               return false;
+                       if (expected.Attributes != null && actual.Attributes != null) {
+                               if (!AreEqualAttribs (expected.Attributes, actual.Attributes))
+                                       return false;
+
+                               _actual = actual.OuterXml;
+                               _expected = expected.OuterXml;
+                       }
+                       else //one of nodes has no attrs
+                               if (expected.Attributes != null || actual.Attributes != null)
+                                       return false;//and another has some
+                       if (!expected.HasChildNodes && !actual.HasChildNodes) {
+                               string val1 = expected.Value;
+                               string val2 = actual.Value;
+                               if (ignoreWS) //ignore white spaces
+                               { 
+                                       if (val1 != null)
+                                               val1 = val1.Trim().Replace("\r\n", "\n");
+                                       if (val2 != null)
+                                               val2 = val2.Trim().Replace("\r\n", "\n");
+                               }
+                               return val1 == val2;
+                       }
+                       else {//one of nodes has some children
+                               if (!expected.HasChildNodes || !actual.HasChildNodes)
+                                       return false;//and another has none
+                               return AreEqualNodeList (expected.ChildNodes, actual.ChildNodes);
+                       }
+               }\r
+\r
+               public bool AreEqual (string expected, string actual) \r
+               {\r
+                       XmlDocument eDocument = new XmlDocument();\r
+                       eDocument.LoadXml(expected);\r
+                       XmlNode eNode = eDocument.DocumentElement;\r
+                       XmlDocument aDocument = new XmlDocument ();\r
+                       aDocument.LoadXml (actual);\r
+                       XmlNode aNode = aDocument.DocumentElement;\r
+                       return AreEqual (eNode, aNode);\r
+
+               }
+               public string LastCompare 
+               {
+                       get {return lastCompare;}
+               }
+
+               public string Actual
+               {
+                       get { return _actual; }
+               }
+
+               public string Expected
+               {
+                       get { return _expected; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/FeatureBased/TestFixtureBase.cs b/mcs/class/System.ServiceModel/Test/FeatureBased/TestFixtureBase.cs
new file mode 100644 (file)
index 0000000..42cf8fb
--- /dev/null
@@ -0,0 +1,202 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+using System.Reflection;
+using System.Threading;
+using System.Configuration;
+using System.IO;
+using System.Net;
+using MonoTests.stand_alone.WebHarness;
+using System.ServiceModel.Dispatcher;
+using System.Collections.ObjectModel;
+
+namespace MonoTests.Features
+{
+       public class Configuration
+       {
+               static Configuration() {
+                       onlyServers = Boolean.Parse (ConfigurationManager.AppSettings ["onlyServers"]  ?? "false");
+                       onlyClients = Boolean.Parse (ConfigurationManager.AppSettings ["onlyClients"]  ?? "false");
+                       endpointBase = ConfigurationManager.AppSettings ["endpointBase"] ?? "http://localhost:9999/";
+                       if (!endpointBase.EndsWith ("/"))
+                               endpointBase = endpointBase + '/';
+                       logMessages = Boolean.Parse (ConfigurationManager.AppSettings ["logMessages"] ?? "false");
+               }
+               public static bool onlyServers;
+               public static bool onlyClients;
+               public static string endpointBase;
+               public static bool logMessages;
+               public static bool IsLocal { get { return !onlyServers && !onlyClients; } }
+       }
+
+       class LoggerMessageInspector : IDispatchMessageInspector
+       {
+               #region IDispatchMessageInspector Members
+
+               public object AfterReceiveRequest (ref Message request, IClientChannel channel, InstanceContext instanceContext) {
+                       Console.WriteLine ("****Begin message received by host:");
+                       Console.WriteLine (request);
+                       Console.WriteLine ("****End message received by host:");
+                       return new object ();
+               }
+
+               public void BeforeSendReply (ref Message reply, object correlationState) {
+                       Console.WriteLine ("****Begin message reply from host:");
+                       Console.WriteLine (reply);
+                       Console.WriteLine ("****End message reply from host:");
+               }
+
+               #endregion
+       }
+       class LoggerBehavior : IServiceBehavior
+       {
+
+               #region IServiceBehavior Members
+
+               public void AddBindingParameters (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) {
+
+               }
+
+               public void ApplyDispatchBehavior (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) {
+                       ChannelDispatcher dispatcher = serviceHostBase.ChannelDispatchers [0] as ChannelDispatcher;
+                       dispatcher.Endpoints [0].DispatchRuntime.MessageInspectors.Add (new LoggerMessageInspector ());
+               }
+
+               public void Validate (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) {
+
+               }
+
+               #endregion
+       }
+
+       public abstract class TestFixtureBase<TClient, TServer, IServer> where TClient : new() where TServer: new()
+       {
+               ServiceHost _hostBase;
+
+               protected TestFixtureBase () { }                
+
+               [SetUp]
+               public virtual void Run (){
+                       bool runServer = true;
+                       bool runClient = true;
+                       if (Configuration.onlyClients)
+                               runServer = false;
+                       if (Configuration.onlyServers)
+                               runClient = false;
+                       Run (runServer, runClient);                     
+               }
+
+               public void CheckWsdlImpl () {
+                       string goldWsdl;
+                       try {
+                               Assembly _assembly = Assembly.GetExecutingAssembly ();
+                               StreamReader _stream = new StreamReader (_assembly.GetManifestResourceStream ("MonoTests.System.ServiceModel.Test.FeatureBased.Features.Contracts." + typeof (TServer).Name + ".xml"));
+                               goldWsdl = _stream.ReadToEnd ();
+                       }
+                       catch {
+                               Console.WriteLine ("Couldn't test WSDL of server " + typeof (TServer).Name + " because gold wsdl is not embedded in test !");
+                               return;
+                       }
+                       string currentWsdl = "";
+
+                       HttpWebRequest myReq = (HttpWebRequest) WebRequest.Create (getMexEndpoint () + "?wsdl");
+                       // Obtain a 'Stream' object associated with the response object.
+                       WebResponse response = myReq.GetResponse ();
+                       Stream ReceiveStream = response.GetResponseStream ();
+
+                       Encoding encode = global::System.Text.Encoding.GetEncoding ("utf-8");
+
+                       // Pipe the stream to a higher level stream reader with the required encoding format. 
+                       StreamReader readStream = new StreamReader (ReceiveStream, encode);
+                       Console.WriteLine ("\nResponse stream received");
+                       int maxLen = 10 * 1024;
+                       Char [] read = new Char [maxLen];
+
+                       // Read 256 charcters at a time.    
+                       int count = readStream.Read (read, 0, maxLen);
+                       while (count > 0) {
+                               currentWsdl = currentWsdl + new String (read, 0, count);
+                               count = readStream.Read (read, 0, 256);
+                       }
+                       readStream.Close ();
+                       response.Close ();
+
+                       XmlComparer comparer = new XmlComparer (XmlComparer.Flags.IgnoreAttribOrder, true);
+                       Assert.IsTrue (comparer.AreEqual (goldWsdl, currentWsdl), "Service WSDL does not match gold WSDL");
+
+               }
+
+               protected void Run (bool runServer, bool runClient) {
+
+                       if (runServer) {
+                               _hostBase = InitializeServiceHost ();
+                               _hostBase.Open ();
+                       }
+
+               }
+
+        string getEndpoint()
+        {
+                       return Configuration.endpointBase + typeof(TServer).Name;
+        }
+
+               public string getMexEndpoint () 
+               {
+                       return getEndpoint () + "_wsdl"; // should be getEndpoint() but currently implementation is buggy
+               }
+
+               TClient _client;
+               protected virtual TClient InitializeClient () {
+                       //return new TClient(new BasicHttpBinding(), new EndpointAddress( getEndpoint) );
+                       Type [] paramsTypes = new Type [] { typeof (Binding), typeof (EndpointAddress) };
+                       object [] parameters = new object [] { new BasicHttpBinding (), new EndpointAddress (getEndpoint())};
+
+                       ConstructorInfo info = typeof (TClient).GetConstructor (paramsTypes);
+                       return (TClient) info.Invoke (parameters);
+               }
+
+               public TClient ClientProxy {
+                       get {
+                               if (_client == null)
+                                       _client = InitializeClient ();                  
+                               return _client;
+                       }                       
+               }
+
+               public IServer Client {
+                       get {
+                               ChannelFactory<IServer> factory = new ChannelFactory<IServer> (new BasicHttpBinding (), new EndpointAddress (getEndpoint ()));
+                               return factory.CreateChannel ();
+                       }
+               }
+
+               protected virtual ServiceHost InitializeServiceHost () {
+            ServiceHost host = new ServiceHost(typeof(TServer));
+            host.AddServiceEndpoint(typeof(IServer), new BasicHttpBinding(), getEndpoint());
+                       ServiceMetadataBehavior smb = new ServiceMetadataBehavior ();
+                       smb.HttpGetEnabled = true;
+                       smb.HttpGetUrl = new Uri (getMexEndpoint ());
+                       host.Description.Behaviors.Add (smb);
+                       if (Configuration.logMessages)
+                               host.Description.Behaviors.Add (new LoggerBehavior ());
+            return host;
+               }
+
+
+               protected ServiceHost Host {
+                       get {
+                               return _hostBase;
+                       }
+               }
+
+               [TearDown]
+               protected virtual void Close () {
+                       if (!Configuration.onlyClients && !Configuration.onlyServers &&  Host.State == CommunicationState.Opened)
+                               Host.Close ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/README.txt b/mcs/class/System.ServiceModel/Test/README.txt
new file mode 100644 (file)
index 0000000..8bb30d3
--- /dev/null
@@ -0,0 +1,11 @@
+How to add a new test WCF Client/Server test:\r
+\r
+1. In directory FeatureBased/Features.Contracts add a new contract and implementation class. It is best to copy an existing one and modify it.\r
+2. In directory FeatureBased/Features.Serialization add a new test class. Again copy from a different test class, but remove all members. \r
+   Maintain the inheritance from TestFixtureBase<clientProxy, ServerImplementation, ServerContract>.  However, since you don't have a client\r
+   proxy yet, use 'object' instead.\r
+3. Run the WCFServers executable. This will start the server so it is now running.\r
+4. In command prompt, in directory  Test\FeatureBased\Features.Client run "svcutil.exe <endpointbase>/<serverclassname>_wsdl /n:*,Proxy.MonoTests.Features.Client" e.g.\r
+   svcutil http://localhost:9999/ExitProcessHelperServer_wsdl /n:*,Proxy.MonoTests.Features.Client\r
+5. Include the file in the project\r
+6. In the test class created in step #2, modify the name of the client proxy class to the name of the generated class.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/Resources/ChangeLog b/mcs/class/System.ServiceModel/Test/Resources/ChangeLog
new file mode 100755 (executable)
index 0000000..df5323b
--- /dev/null
@@ -0,0 +1,7 @@
+2006-12-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * test2.pfx : new file.
+
+2006-08-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * test.pfx : new file for serializer test for now.
diff --git a/mcs/class/System.ServiceModel/Test/Resources/test.cer b/mcs/class/System.ServiceModel/Test/Resources/test.cer
new file mode 100644 (file)
index 0000000..497f961
Binary files /dev/null and b/mcs/class/System.ServiceModel/Test/Resources/test.cer differ
diff --git a/mcs/class/System.ServiceModel/Test/Resources/test.pfx b/mcs/class/System.ServiceModel/Test/Resources/test.pfx
new file mode 100644 (file)
index 0000000..fa71db9
Binary files /dev/null and b/mcs/class/System.ServiceModel/Test/Resources/test.pfx differ
diff --git a/mcs/class/System.ServiceModel/Test/Resources/test2.pfx b/mcs/class/System.ServiceModel/Test/Resources/test2.pfx
new file mode 100644 (file)
index 0000000..f7d727a
Binary files /dev/null and b/mcs/class/System.ServiceModel/Test/Resources/test2.pfx differ
diff --git a/mcs/class/System.ServiceModel/Test/SwitchMode/Program.cs b/mcs/class/System.ServiceModel/Test/SwitchMode/Program.cs
new file mode 100644 (file)
index 0000000..2a855ae
--- /dev/null
@@ -0,0 +1,46 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Xml;\r
+using System.Xml.Linq;\r
+\r
+namespace SwitchMode\r
+{\r
+       class Program\r
+       {\r
+               static void Main (string [] args) {\r
+                       string file = args [0];\r
+                       string mode = args [1];\r
+                       XElement config = XElement.Load(file,LoadOptions.PreserveWhitespace);\r
+                       \r
+                       XElement appSettings = config.Element("appSettings");\r
+                       if (appSettings == null) {\r
+                               appSettings = new XElement ("appSettings");\r
+                               config.Add (appSettings);\r
+                       }\r
+                       var results = from el in appSettings.Elements ()\r
+                                                 where el.Attribute ("key").Value == "onlyClients"\r
+                                                 select el;\r
+                       XElement onlyClients;\r
+                       if (results.Count() == 1)\r
+                               onlyClients = results.First ();\r
+                       else if (results.Count() == 0) {\r
+                               onlyClients = new XElement ("add");\r
+                               onlyClients.SetAttributeValue ("key", "onlyClients");\r
+                               appSettings.Add (onlyClients);\r
+                       }\r
+                       else \r
+                               throw new Exception ("Too many onlyClients appSettings clauses");\r
+                       if (mode == "client")\r
+                               onlyClients.SetAttributeValue("value","true");\r
+                       else if (mode == "inproc")\r
+                               onlyClients.SetAttributeValue ("value", "false");\r
+                       else {\r
+                               throw new Exception ("Unrecognized mode: " + mode);\r
+                       }\r
+                       config.Save (file,SaveOptions.DisableFormatting);\r
+                       Console.WriteLine ("Successfully switched to mode : " + mode);\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/Test/SwitchMode/Properties/AssemblyInfo.cs b/mcs/class/System.ServiceModel/Test/SwitchMode/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..38e6074
--- /dev/null
@@ -0,0 +1,36 @@
+using System.Reflection;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+\r
+// General Information about an assembly is controlled through the following \r
+// set of attributes. Change these attribute values to modify the information\r
+// associated with an assembly.\r
+[assembly: AssemblyTitle ("SwitchMode")]\r
+[assembly: AssemblyDescription ("")]\r
+[assembly: AssemblyConfiguration ("")]\r
+[assembly: AssemblyCompany ("MainSoft")]\r
+[assembly: AssemblyProduct ("SwitchMode")]\r
+[assembly: AssemblyCopyright ("Copyright © MainSoft 2008")]\r
+[assembly: AssemblyTrademark ("")]\r
+[assembly: AssemblyCulture ("")]\r
+\r
+// Setting ComVisible to false makes the types in this assembly not visible \r
+// to COM components.  If you need to access a type in this assembly from \r
+// COM, set the ComVisible attribute to true on that type.\r
+[assembly: ComVisible (false)]\r
+\r
+// The following GUID is for the ID of the typelib if this project is exposed to COM\r
+[assembly: Guid ("6a2fc01b-471f-4516-a174-622fea764f4d")]\r
+\r
+// Version information for an assembly consists of the following four values:\r
+//\r
+//      Major Version\r
+//      Minor Version \r
+//      Build Number\r
+//      Revision\r
+//\r
+// You can specify all the values or you can default the Build and Revision Numbers \r
+// by using the '*' as shown below:\r
+// [assembly: AssemblyVersion("1.0.*")]\r
+[assembly: AssemblyVersion ("1.0.0.0")]\r
+[assembly: AssemblyFileVersion ("1.0.0.0")]\r
diff --git a/mcs/class/System.ServiceModel/Test/SwitchMode/SwitchMode.csproj b/mcs/class/System.ServiceModel/Test/SwitchMode/SwitchMode.csproj
new file mode 100644 (file)
index 0000000..e7abacb
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProductVersion>9.0.21022</ProductVersion>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectGuid>{59F7BE17-5E8C-4FA3-BC04-56604E2F00F1}</ProjectGuid>\r
+    <OutputType>Exe</OutputType>\r
+    <AppDesignerFolder>Properties</AppDesignerFolder>\r
+    <RootNamespace>SwitchMode</RootNamespace>\r
+    <AssemblyName>SwitchMode</AssemblyName>\r
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>\r
+    <FileAlignment>512</FileAlignment>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>bin\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="System" />\r
+    <Reference Include="System.Core">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Xml.Linq">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Data.DataSetExtensions">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Data" />\r
+    <Reference Include="System.Xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="Program.cs" />\r
+    <Compile Include="Properties\AssemblyInfo.cs" />\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+       Other similar extension points exist, see Microsoft.Common.targets.\r
+  <Target Name="BeforeBuild">\r
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
+  -->\r
+</Project>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/AddressHeaderTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/AddressHeaderTest.cs
new file mode 100644 (file)
index 0000000..fd6463c
--- /dev/null
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class AddressHeaderTest
+       {
+               [Test]
+               public void WriteAddressHeaderTest ()
+               {
+                       AddressHeader h = AddressHeader.CreateAddressHeader (1);
+
+                       StringWriter sw = new StringWriter ();
+                       XmlWriterSettings s = new XmlWriterSettings ();
+                       s.OmitXmlDeclaration = true;
+                       XmlWriter w = XmlWriter.Create (sw, s);
+                       h.WriteAddressHeader (w);
+
+                       w.Close ();
+
+                       Assert.AreEqual (
+                               @"<int xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">1</int>",
+                               sw.ToString ());
+               }
+
+               [Test]
+               public void CreateAddressHeader ()
+               {
+                       AddressHeader h = AddressHeader.CreateAddressHeader ("foo", "urn:foo", null);
+               }
+
+               [Test]
+               [Category ("NotDotNet")]
+               // It should work, but MS implementation expects body to be
+               // IComparable.
+               public void EqualsTest ()
+               {
+                       AddressHeader h = AddressHeader.CreateAddressHeader (
+                               "foo", "urn:foo", null);
+                       AddressHeader h2 = AddressHeader.CreateAddressHeader (
+                               "foo", "urn:foo", null);
+                       Assert.IsFalse (h.Equals (null), "#1"); // never throw nullref
+                       Assert.IsTrue (h.Equals (h2), "#2");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/AddressingVersionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/AddressingVersionTest.cs
new file mode 100644 (file)
index 0000000..1012a93
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// AddressingVersionTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using NUnit.Framework;
+
+using Element = System.ServiceModel.Channels.TextMessageEncodingBindingElement;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class AddressingVersionTest
+       {
+               [Test]
+               public void Equality ()
+               {
+                       Assert.AreEqual (AddressingVersion.WSAddressing10, 
+                               MessageVersion.Default.Addressing, "#1");
+                       Assert.IsTrue (AddressingVersion.WSAddressing10 == 
+                               MessageVersion.Default.Addressing, "#2");
+                       Assert.IsTrue (Object.ReferenceEquals (
+                               AddressingVersion.WSAddressing10,
+                               MessageVersion.Default.Addressing), "#3");
+               }
+
+               [Test]
+               public void Constants ()
+               {
+                       Assert.AreEqual ("Addressing10 (http://www.w3.org/2005/08/addressing)",
+                               AddressingVersion.WSAddressing10.ToString (), "#1");
+                       Assert.AreEqual ("Addressing200408 (http://schemas.xmlsoap.org/ws/2004/08/addressing)",
+                               AddressingVersion.WSAddressingAugust2004.ToString (), "#2");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/AsymmetricSecurityBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/AsymmetricSecurityBindingElementTest.cs
new file mode 100644 (file)
index 0000000..e9f9cee
--- /dev/null
@@ -0,0 +1,258 @@
+//
+// AsymmetricSecurityBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.Security.Cryptography.X509Certificates;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Threading;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class AsymmetricSecurityBindingElementTest
+       {
+               static X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+               static X509Certificate2 cert2 = new X509Certificate2 ("Test/Resources/test.cer");
+
+               // InitiatorTokenParameters should have asymmetric key.
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")] // this test unnecessarily requires some internal processing order
+               public void ClientInitiatorHasNoKeys1 ()
+               {
+                       ClientInitiatorHasNoKeysCore (false, MessageProtectionOrder.SignBeforeEncrypt);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")] // this test unnecessarily requires some internal processing order
+               public void ClientInitiatorHasNoKeys2 ()
+               {
+                       ClientInitiatorHasNoKeysCore (true, MessageProtectionOrder.SignBeforeEncrypt);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")] // this test unnecessarily requires some internal processing order
+               public void ClientInitiatorHasNoKeys3 ()
+               {
+                       ClientInitiatorHasNoKeysCore (false, MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")] // this test unnecessarily requires some internal processing order
+               public void ClientInitiatorHasNoKeys4 ()
+               {
+                       ClientInitiatorHasNoKeysCore (true, MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature);
+               }
+
+               public void ClientInitiatorHasNoKeysCore (bool deriveKeys, MessageProtectionOrder order)
+               {
+                       AsymmetricSecurityBindingElement sbe =
+                               new AsymmetricSecurityBindingElement ();
+                       sbe.InitiatorTokenParameters =
+                               new UserNameSecurityTokenParameters ();
+                       sbe.RecipientTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       sbe.SetKeyDerivation (deriveKeys);
+                       sbe.MessageProtectionOrder = order;
+                       TransportBindingElement tbe = new HandlerTransportBindingElement (delegate (Message input) {
+                               // funky, but .NET does not raise an error
+                               // until it writes the message to somewhere.
+                               // That is, it won't raise an error if this
+                               // HandlerTransportBindingElement does not
+                               // write the input message to somewhere.
+                               // It is an obvious bug.
+                               input.WriteMessage (XmlWriter.Create (TextWriter.Null));
+                               throw new Exception ();
+                       });
+                       CustomBinding binding = new CustomBinding (sbe, tbe);
+                       EndpointAddress address = new EndpointAddress (
+                               new Uri ("stream:dummy"),
+                               new X509CertificateEndpointIdentity (cert2));
+                       CalcProxy proxy = new CalcProxy (binding, address);
+                       proxy.ClientCredentials.UserName.UserName = "mono";
+                       proxy.Open ();
+                       // Until here the wrong parameters are not checked.
+                       proxy.Sum (1, 2);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               [Category ("NotWorking")]
+               public void ServiceRecipientHasNoKeys ()
+               {
+                       AsymmetricSecurityBindingElement sbe =
+                               new AsymmetricSecurityBindingElement ();
+                       sbe.InitiatorTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       sbe.RecipientTokenParameters =
+                               new UserNameSecurityTokenParameters ();
+                       //sbe.SetKeyDerivation (false);
+                       //sbe.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
+                       CustomBinding binding = new CustomBinding (sbe,
+                               new HttpTransportBindingElement ());
+                       IChannelListener<IReplyChannel> l =
+                               binding.BuildChannelListener<IReplyChannel> (new Uri ("http://localhost:37564"), new BindingParameterCollection ());
+                       try {
+                               l.Open ();
+                       } finally {
+                               if (l.State == CommunicationState.Opened)
+                                       l.Close ();
+                       }
+               }
+
+               Message tmp_request, tmp_reply;
+
+               [Test]
+               [ExpectedException (typeof (MessageSecurityException))]
+               // after having to fix several issues, I forgot what I originally wanted to test here ...
+               [Ignore ("It causes some weird failure and port blocking ...")]
+               public void VerifyX509MessageSecurityAtService ()
+               {
+                       AsymmetricSecurityBindingElement clisbe =
+                               new AsymmetricSecurityBindingElement ();
+                       clisbe.InitiatorTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       clisbe.RecipientTokenParameters =
+                               new X509SecurityTokenParameters ();
+
+                       AsymmetricSecurityBindingElement svcsbe =
+                               new AsymmetricSecurityBindingElement ();
+                       svcsbe.InitiatorTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       svcsbe.RecipientTokenParameters =
+                               new X509SecurityTokenParameters ();
+
+                       CustomBinding b_req = new CustomBinding (clisbe,
+                               new HttpTransportBindingElement ());
+
+                       b_req.ReceiveTimeout = b_req.SendTimeout = TimeSpan.FromSeconds (10);
+
+                       CustomBinding b_res = new CustomBinding (svcsbe, new HttpTransportBindingElement ());
+                       b_res.ReceiveTimeout = b_res.SendTimeout = TimeSpan.FromSeconds (10);
+
+                       EndpointAddress remaddr = new EndpointAddress (
+                               new Uri ("http://localhost:37564"),
+                               new X509CertificateEndpointIdentity (cert2));
+                       CalcProxy proxy = null;
+                       ServiceHost host = new ServiceHost (typeof (CalcService));
+                       host.AddServiceEndpoint (typeof (ICalc), b_res, "http://localhost:37564");
+
+                       ServiceCredentials cred = new ServiceCredentials ();
+                       cred.ServiceCertificate.Certificate = cert;
+                       host.Description.Behaviors.Add (cred);
+                       try {
+                               host.Open ();
+
+                               proxy = new CalcProxy (b_req, remaddr);
+                               proxy.ClientCredentials.ClientCertificate.Certificate = cert;
+
+                               // FIXME: on WinFX, when this Begin method
+                               // is invoked before the listener setup, it
+                               // somehow works, while ours doesn't.
+                               //IAsyncResult result = proxy.BeginSum (1, 2, null, null);
+                               //Assert.AreEqual (3, proxy.EndSum (result));
+                               Assert.AreEqual (3, proxy.Sum (1, 2));
+                       } finally {
+                               if (host.State == CommunicationState.Opened)
+                                       host.Close ();
+                       }
+               }
+
+               [Test]
+               public void SetKeyDerivation ()
+               {
+                       AsymmetricSecurityBindingElement be;
+                       X509SecurityTokenParameters p, p2;
+
+                       be = new AsymmetricSecurityBindingElement ();
+                       p = new X509SecurityTokenParameters ();
+                       p2 = new X509SecurityTokenParameters ();
+                       be.InitiatorTokenParameters = p;
+                       be.RecipientTokenParameters = p2;
+                       be.SetKeyDerivation (false);
+                       Assert.AreEqual (false, p.RequireDerivedKeys, "#1");
+                       Assert.AreEqual (false, p2.RequireDerivedKeys, "#2");
+
+                       be = new AsymmetricSecurityBindingElement ();
+                       p = new X509SecurityTokenParameters ();
+                       p2 = new X509SecurityTokenParameters ();
+                       be.SetKeyDerivation (false); // set in prior - makes no sense
+                       be.InitiatorTokenParameters = p;
+                       be.RecipientTokenParameters = p2;
+                       Assert.AreEqual (true, p.RequireDerivedKeys, "#3");
+                       Assert.AreEqual (true, p2.RequireDerivedKeys, "#4");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")]
+               public void RejectInclusionModeNever ()
+               {
+                       AsymmetricSecurityBindingElement sbe =
+                               new AsymmetricSecurityBindingElement ();
+                       sbe.InitiatorTokenParameters = sbe.RecipientTokenParameters =
+                               new X509SecurityTokenParameters (
+                                       X509KeyIdentifierClauseType.Thumbprint,
+                                       // this leads to the failure.
+                                       SecurityTokenInclusionMode.Never);
+                       ServiceHost host = new ServiceHost (typeof (Foo));
+                       HttpTransportBindingElement hbe =
+                               new HttpTransportBindingElement ();
+                       CustomBinding binding = new CustomBinding (sbe, hbe);
+                       host.AddServiceEndpoint (typeof (IFoo),
+                               binding, new Uri ("http://localhost:37564"));
+                       ServiceCredentials cred = new ServiceCredentials ();
+                       cred.ServiceCertificate.Certificate =
+                               new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+                       cred.ClientCertificate.Authentication.CertificateValidationMode =
+                               X509CertificateValidationMode.None;
+                       host.Description.Behaviors.Add (cred);
+                       try {
+                               host.Open ();
+                       } finally {
+                               if (host.State == CommunicationState.Opened)
+                                       host.Close ();
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/BindingContextTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/BindingContextTest.cs
new file mode 100644 (file)
index 0000000..581ff84
--- /dev/null
@@ -0,0 +1,124 @@
+//
+// BindingContextTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class BindingContextTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void TestCtorBindingNull ()
+               {
+                       new BindingContext (null,
+                               new BindingParameterCollection ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void TestCtorParametersNull ()
+               {
+                       new BindingContext (new CustomBinding (), null);
+               }
+
+               [Test]
+               //[ExpectedException (typeof (ArgumentNullException))]
+               public void TestCtorListenUriBaseAddressNull ()
+               {
+                       new BindingContext (new CustomBinding (),
+                               new BindingParameterCollection (),
+                               null,
+                               "http://localhost:8080",
+                               ListenUriMode.Unique);
+               }
+
+               [Test]
+               //[ExpectedException (typeof (ArgumentNullException))]
+               public void TestCtorListenUriRelativeAddressNull ()
+               {
+                       new BindingContext (new CustomBinding (),
+                               new BindingParameterCollection (),
+                               new Uri ("http://localhost:8080"),
+                               null,
+                               ListenUriMode.Unique);
+               }
+
+               [Test]
+               // Now this test is mostly useless ...
+               public void ConsumeBindingElements ()
+               {
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (
+                                       new TextMessageEncodingBindingElement (),
+                                       new HttpTransportBindingElement ()),
+                               new BindingParameterCollection ());
+
+                       HttpTransportBindingElement be =
+                               new HttpTransportBindingElement ();
+                       be.BuildChannelFactory<IRequestChannel> (ctx);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               [ExpectedException (typeof (ArgumentException))]
+               public void DuplicateMesageEncodingBindingElementError ()
+               {
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (
+                                       new TextMessageEncodingBindingElement (),
+                                       new HttpTransportBindingElement ()),
+                               new BindingParameterCollection ());
+
+                       TextMessageEncodingBindingElement te =
+                               new TextMessageEncodingBindingElement ();
+                       te.BuildChannelFactory<IRequestChannel> (ctx);
+               }
+
+               [Test]
+               public void GetInnerPropertyIsNothingToDoWithParameters ()
+               {
+                       BindingParameterCollection pl =
+                               new BindingParameterCollection ();
+                       pl.Add (new ClientCredentials ());
+                       BindingContext ctx =
+                               new BindingContext (new CustomBinding (), pl);
+                       Assert.IsNull (ctx.GetInnerProperty<ClientCredentials> ());
+
+                       CustomBinding binding = new CustomBinding (new HttpTransportBindingElement ());
+                       ctx = new BindingContext (binding, pl);
+                       Assert.IsNull (ctx.GetInnerProperty<ClientCredentials> ());
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/BindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/BindingElementTest.cs
new file mode 100644 (file)
index 0000000..f1edb31
--- /dev/null
@@ -0,0 +1,206 @@
+//
+// BindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class BindingElementTest
+       {
+               class MyChannelFactory<TChannel>
+                       : ChannelFactoryBase<TChannel>
+               {
+                       public MyChannelFactory ()
+                               : base ()
+                       {
+                       }
+
+                       protected override TChannel OnCreateChannel (EndpointAddress address, Uri via)
+                       {
+                               throw new NotSupportedException ();
+                       }
+
+                       protected override IAsyncResult OnBeginOpen (
+                               TimeSpan timeout, AsyncCallback callback, object state)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override void OnEndOpen (IAsyncResult result)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override void OnOpen (TimeSpan timeout)
+                       {
+                               throw new NotImplementedException ();
+                       }
+               }
+
+               class MyChannelListener<TChannel>
+                       : ChannelListenerBase<TChannel>
+                       where TChannel : class, IChannel
+               {
+                       public MyChannelListener ()
+                               : base ()
+                       {
+                       }
+
+                       public override Uri Uri {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       protected override IAsyncResult OnBeginAcceptChannel (
+                               TimeSpan timeout, AsyncCallback callback, object state)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override TChannel OnAcceptChannel (TimeSpan timeout)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override TChannel OnEndAcceptChannel (IAsyncResult result)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override IAsyncResult OnBeginWaitForChannel (
+                               TimeSpan timeout, AsyncCallback callback, object state)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override bool OnEndWaitForChannel (IAsyncResult result)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override bool OnWaitForChannel (TimeSpan timeout)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override void OnAbort ()
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override IAsyncResult OnBeginClose (
+                               TimeSpan timeout, AsyncCallback callback, object state)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override IAsyncResult OnBeginOpen (
+                               TimeSpan timeout, AsyncCallback callback, object state)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override void OnEndClose (IAsyncResult result)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override void OnEndOpen (IAsyncResult result)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override void OnClose (TimeSpan timeout)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override void OnOpen (TimeSpan timeout)
+                       {
+                       }
+               }
+
+               class MyBindingElement : BindingElement
+               {
+                       public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                               BindingContext ctx)
+                       {
+                               return new MyChannelFactory<TChannel> ();
+                       }
+
+                       public override IChannelListener<TChannel> BuildChannelListener<TChannel> (
+                               BindingContext ctx)
+                       {
+                               return new MyChannelListener<TChannel> ();
+                       }
+
+                       public override bool CanBuildChannelListener<TChannel> (BindingContext ctx)
+                       {
+                               return true;
+                       }
+
+                       public override BindingElement Clone ()
+                       {
+                               return new MyBindingElement ();
+                       }
+
+                       public override T GetProperty<T> (BindingContext context)
+                       {
+                               return null;
+                       }
+               }
+
+               [Test]
+               [Ignore ("It is even not a test yet.")]
+               public void BuildChannelFactory ()
+               {
+                       ServiceHost host = new ServiceHost (typeof (Foo));
+                       host.AddServiceEndpoint (typeof (Foo),
+                               new CustomBinding (new MyBindingElement (),
+                                       new HttpTransportBindingElement ()),
+                               "http://localhost:8080");
+                       host.Open ();
+               }
+
+               [ServiceContract]
+               class Foo
+               {
+                       [OperationContract]
+                       public void Whee ()
+                       {
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/BindingTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/BindingTest.cs
new file mode 100644 (file)
index 0000000..806c2f9
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// BindingTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class BindingTest
+       {
+               class MyBinding : Binding
+               {
+                       public override string Scheme {
+                               get { return "my"; }
+                       }
+
+                       public override BindingElementCollection CreateBindingElements ()
+                       {
+                               return new BindingElementCollection (
+                                       new BindingElement [] { new HttpTransportBindingElement () });
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void BuildChannelFactoryGeneric ()
+               {
+                       // i.e. it should not reuse non-generic version of
+                       // BuildChannelFactory().
+                       new MyBinding ().BuildChannelFactory<IRequestChannel> ((BindingParameterCollection) null);
+               }
+
+               [Test]
+               public void BuildChannelFactoryGeneric2 ()
+               {
+                       new MyBinding ().BuildChannelFactory<IRequestChannel> (
+                               new BindingParameterCollection ());
+               }
+
+               [Test]
+               public void MessageVersionProperty ()
+               {
+                       Assert.AreEqual (MessageVersion.Soap11, new BasicHttpBinding ().MessageVersion, "#1");
+                       Assert.IsNull (new CustomBinding ().MessageVersion, "#2");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/CalcSampleProxy.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/CalcSampleProxy.cs
new file mode 100644 (file)
index 0000000..a004654
--- /dev/null
@@ -0,0 +1,132 @@
+//
+// CalcSampleProxy.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.Security.Cryptography.X509Certificates;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Threading;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [ServiceContract]
+       public interface ICalc
+       {
+               [OperationContract]
+               int Sum (int a, int b);
+
+               [OperationContract (AsyncPattern = true)]
+               IAsyncResult BeginSum (int a, int b, AsyncCallback cb, object state);
+
+               int EndSum (IAsyncResult result);
+       }
+
+       public class CalcProxy : ClientBase<ICalc>, ICalc
+       {
+               public CalcProxy (Binding binding, EndpointAddress address)
+                       : base (binding, address)
+               {
+               }
+
+               public int Sum (int a, int b)
+               {
+                       return Channel.Sum (a, b);
+               }
+
+               public IAsyncResult BeginSum (int a, int b, AsyncCallback cb, object state)
+               {
+                       return Channel.BeginSum (a, b, cb, state);
+               }
+
+               public int EndSum (IAsyncResult result)
+               {
+                       return Channel.EndSum (result);
+               }
+       }
+
+       public class CalcService : ICalc
+       {
+               public int Sum (int a, int b)
+               {
+                       return a + b;
+               }
+
+               public IAsyncResult BeginSum (int a, int b, AsyncCallback cb, object state)
+               {
+                       return new CalcAsyncResult (a, b, cb, state);
+               }
+
+               public int EndSum (IAsyncResult result)
+               {
+                       CalcAsyncResult c = (CalcAsyncResult) result;
+                       return c.A + c.B;
+               }
+       }
+
+       class CalcAsyncResult : IAsyncResult
+       {
+               public int A, B;
+               AsyncCallback callback;
+               object state;
+
+               public CalcAsyncResult (int a, int b, AsyncCallback cb, object state)
+               {
+                       A = a;
+                       B = b;
+                       callback = cb;
+                       this.state = state;
+               }
+
+               public object AsyncState {
+                       get { return state; }
+               }
+
+               public WaitHandle AsyncWaitHandle {
+                       get { return null; }
+               }
+
+               public bool CompletedSynchronously {
+                       get { return true; }
+               }
+
+               public bool IsCompleted {
+                       get { return true; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
new file mode 100644 (file)
index 0000000..792dec2
--- /dev/null
@@ -0,0 +1,560 @@
+2008-04-13  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * BindingTest.cs:
+       consider fixed API in BindingElementCollection class.                   
+
+2008-02-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TcpTransportBindingElementTest.cs : IDuplexChannel is not supported.
+
+2008-02-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * NetNamedPipeTransportBindingElementTest.cs : new test.
+
+2008-02-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EnvelopeVersionTest.cs : updated to work with .NET 3.0 SP1.
+       * TcpTransportBindingElementTest.cs : new test.
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElementTest.cs : test for BuildChannelListener()
+         without listener URIs.
+
+2007-08-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeadersTest.cs : added couple of property settters and
+         AddressingVersion.None.
+
+2007-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MsmqTransportBindingElementTest.cs : modified or removed copied-and-
+         commented lines to fit with msmq binding element.
+
+2007-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MsmqTransportBindingElementTest.cs : new test.
+
+2007-04-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElementTest.cs,
+         AsymmetricSecurityBindingElementTest.cs,
+         HttpTransportBindingElementTest.cs :
+         marked some failing tests (on Orcas) as ignored. Some fixes to
+         make sure that open connection things be closed.
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElementTest.cs : some tests are NotWorking
+         now, as they depend on internal processing order.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageTest.cs : added IsFault().
+
+2007-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElementTest.cs :
+         added tests for GetProperty<ISecurityCapabilities>().
+
+2007-03-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElementTest.cs :
+         fixed inappropriate test name.
+
+2007-03-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElementTest.cs : some more test for ssl parameters.
+
+2007-02-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElementTest.cs : adding [NotWorking]. It happened to
+         raise an expected type of exception at different (and wrong) stage.
+
+2007-01-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElementTest.cs : added notworking
+         RejectInclusionModeNever() case.
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElementTest.cs, CalcSampleProxy.cs : moved
+         sample proxy type to new file.
+       * SecurityBindingElementTest.cs : some tests for
+         SupportingTokenParameters.
+
+2006-12-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InterceptorBindingElement.cs : new utility binding element for
+         testing.
+
+2006-12-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElementTest.cs : added duplicate authenticator test.
+
+2006-12-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElementTest.cs,
+         SymmetricSecurityBindingElementTest.cs,
+         AsymmetricSecurityBindingElementTest.cs :
+         added test for SetKeyDerivation().
+
+2006-12-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElementTest.cs :
+         enable CreateChannelInvalidScheme().
+       * MessageHeaderTest.cs :
+         enable TestIsMessageVersionSupported() and mark IDs.
+
+2006-12-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultConverterTest.cs : new test.
+
+2006-10-13  Ankit Jain  <jankit@novell.com>
+
+       * MessageVersionTest.cs : Add test for MessageVersion.None
+
+2006-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CustomBindingTest.cs : fixed build. It has broken code which
+         recently got reported by improved gmcs.
+
+2006-10-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObjectTest.cs :
+         Some tests on operation at faulted state.
+
+2006-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeadersTest.cs : added some tests for duplicate header items.
+         The resulting tests are odd though.
+
+2006-10-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElementTest.cs :
+         VerifyX509MessageSecurityAtService() is working as a test for async
+         support, but makes little sense as asymmetric security test now.
+
+2006-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElementTest.cs : added more test for
+         listener, though not working yet (e.g. because of async support).
+       * SslStreamSecurityBindingElementTest.cs : new file.
+
+2006-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElementTest.cs : added test for listener
+         whose recipient does not contain symmetric key.
+
+2006-09-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingTest.cs : fixed a test that became ambiguous.
+
+2006-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AsymmetricSecurityBindingElementTest.cs : new file.
+
+2006-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElementTest.cs :
+         added CreateChannelInvalidScheme().
+
+2006-09-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs :
+         added test for making sure to create authenticator and thus reject
+         UserName parameters to become ProtectionTokenParameters.
+
+2006-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs :
+         added some more tests for service DefaultCertificate.
+       * MessageBufferTest.cs, MessageHeadersTest.cs,
+         EmptyFaultExceptionTest.cs, MessageHeaderTest.cs :
+         eliminate console output.
+       * UnknownFaultExceptionTest.cs : removed obsolete file.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs, SecurityBindingElementTest.cs,
+         SecurityAssert.cs : removed extra code for each source. From now on,
+         test for SecurityBindingElement factory methods will go into
+         SecurityBindingElementTest.cs.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityBindingElementTest.cs, SecurityAssert.cs : added copies first.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : added assertion helpers for
+         asymmetric binding elements. Actually am going to move them to another
+         file.
+
+2006-09-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : tiny comment cleanup.
+
+2006-09-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : added test that supplies
+         ChannelProtectionRequirements manually. Added some comments.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : removed some NotWorking.
+       * OneWayBindingElementTest.cs : new test.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElementTest.cs : make sure to close channels
+         so that they don't block other tests.
+       * HandlerTransportBindingElement.cs :
+         be a bit more descriptive on error.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElementTest.cs : enable (async) request test.
+         Added test for creating channel without opening the factory.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageEncoderTest.cs : message version mismatch check.
+
+2006-09-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : added test for missing
+         private key in service certificate.
+       * HandlerTransportBindingElement.cs : fix warning.
+
+2006-09-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HandlerTransportBindingElement.cs : added IOutputChannel impl.
+       * OutputChannelBase.cs : new support file.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactoryTest.cs : moved to Test/S.SM.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactoryTest.cs : don't use IRequestChannel as a contract
+         type. It makes no sense and we reject it as a contract.
+       * HandlerBodyWriter.cs : new helper BodyWriter for tests.
+       * MessageTest.cs : added test for null message version argument.
+       * BindingTest.cs : added MessageVersion property test.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : use OneWayBindingElement
+         to omit reply check and make some tests meaningful.
+
+2006-09-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs :
+         non-x509 service cert test is not working.
+
+2006-09-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeadersTest.cs, MessageHeaderTest.cs, MessageBufferTest.cs :
+         cleaning up NotWorking.
+       * TextMessageEncodingBindingElementTest.cs, CustomBindingTest.cs :
+         moved some irrelevant tests in former file to latter file.
+
+2006-08-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CustomBindingTest.cs, HttpTransportBindingElementTest.cs : added
+         test that assures MessageEncodingBindingElement is not mandatory.
+       * MessageTest.cs : added concept test that shows ToString() somehow
+         allows multi time call.
+       * MessageBufferTest.cs : fix wrong expected exception. Added test
+         that assures it does not allow multi call to CreateBufferedCopy().
+
+2006-08-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : added more tests for
+         different security settings situations.
+
+2006-08-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CustomBindingTest.cs : added EnvelopeVersion.None + security case
+         (which should be rejected).
+       * HandlerTransportBindingElement.cs :
+         removed NotImplementedException in OnClose().
+
+2006-08-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageTest.cs : added some XmlReader inputs with some headers.
+
+2006-08-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingContextTest.cs : added test to assure that binding parameter
+         collection is nothing to do with GetInnerProperty().
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs :
+         some annotations. Added secureconversatin factory method test.
+
+2006-08-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DebugBindingElement.cs : new helper for message interception.
+       * SymmetricSecurityBindingElementTest.cs : cosmetic debug code.
+
+2006-08-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : add OpenChannelFactory().
+         Removed one NotWorking.
+
+2006-08-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : somewhat minor renaming.
+
+2006-08-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : some tests are working now.
+
+2006-08-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : added tests on
+         BuildChannelListener() and reply channels. .NET security binding
+         is still weird that it causes infinite loop, which blocks me from
+         further implementation...
+       * HttpTransportBindingElementTest.cs : replaced sync Request() with
+         async methods and it started working under .NET.
+       * HandlerTransportBindingElement.cs : several refactoring to support
+         listener and reply channel as well.
+
+2006-08-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HandlerTransportBindingElement.cs : added listener support.
+       * ReplyChannelBase.cs : added, for HandlerTransportBindingElement
+         listener support.
+       * SymmetricSecurityBindingElementTest.cs : added some tests for request
+         processing. Like IssuedSecurityTokenProviderTest, still no
+         successful way to create reply...
+
+2006-08-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageBufferTest.cs : removed some NotWorking.
+
+2006-08-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HandlerTransportBindingElement.cs : new utility binding element
+         that supports event hander based transport.
+       * RequestChannelBase.cs :
+         new file. used by above, copied from S.SM.Channels.
+       * SymmetricSecurityBindingElementTest.cs :
+         added tests for those factory methods in SecurityBindingElement
+         that return SymmetricSecurityBindingElement.
+
+2006-07-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * LocalClientSecuritySettingsTest.cs :
+         more cosmetic line: assert IdentityVerifier as not null.
+
+2006-07-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * LocalClientSecuritySettingsTest.cs : new file.
+       * SymmetricSecurityBindingElementTest.cs : added test for
+         default LocalClientSettings values.
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : Test that
+         - SecurityTokenParameters is null by default.
+         - with null SecurityTokenParameters BuildChannelFactory fails.
+
+2006-07-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeadersTest.cs :
+         Added (ignored) WriteHeaderContentsAddressingNone().
+       * MessageTest.cs : added WriteMessagePOX() (EnvelopeVersion.None).
+
+2006-07-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeadersTest.cs : added null serializer argument tests.
+
+2006-07-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeaderTest.cs : added CreateEndpointAddressTypeHeader(). It
+         used to fail since DataContractSerializer..ctor() rejected
+         EndpointAddress.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageBufferTest.cs : Added CreateBufferedCopyConsumesMessage().
+         Some are NotWorking right now.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageBufferTest.cs : Don't use Assert.Equals().
+         Make TestSimpleMessageBuffer() assert that every return value of
+         CreateBufferedCopy() works for WriteMessage().
+
+2006-07-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageBufferTest.cs : build fix.
+
+2006-07-12  Duncan Mak  <duncan@novell.com>
+
+       * MessageBufferTest.cs
+       (TestEmptyMessageBuffer, TestSimpleMessageBuffer):
+       (TestCreateMessageFromClosedBuffer): New tests.
+       
+2006-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElementTest.cs : added connection example, but
+         it's somehow not working.
+
+2006-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultExceptionTest.cs : ignore failing TestGetObjectData().
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SymmetricSecurityBindingElementTest.cs : new test.
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TransactionFlowBindingElementTest.cs : new test.
+
+2006-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageBufferTest.cs, MessageHeadersTest.cs, MessageTest.cs,
+         MessageEncodingBindingElementTest.cs,
+         TextMessageEncodingBindingElementTest.cs :
+         June CTP fixes. MessageFault.DefaultAction vanished.
+         Exception type changes. Duplicate message encoding binding element
+         now causes (different) exception.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageTest.cs :
+         Replaced vanished CreateMessage() with remaining one.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElementTest.cs, CustomBindingTest.cs :
+         Fixed tests based on run-test-ondotnet results.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObjectTest.cs, ChannelFactoryTest.cs :
+         June CTP requires a bunch of extra stuff.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingContextTest.cs :
+         Now listenUri parameters could be null.
+         Split TestCtorListenUriRelativeAddressNull() into two tests, one is
+         for rejecting duplicate message encoding binding element (in June
+         CTP it is rejected now).
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingContextTest.cs, MessageEncoderTest.cs,
+         MessageEncodingBindingElementTest.cs,
+         TextMessageEncodingBindingElementTest.cs :
+         reflect June CTP updates.
+
+2006-06-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageTest.cs : added test that assures null action is allowed.
+
+2006-06-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactoryTest.cs : Test that only interface can be the Type
+         argument in ChannelFactory<T>#.ctor(Type).
+
+2006-06-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageTest.cs : Added CreateSimpleNonPrimitive().
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultExceptionTest.cs : fix tests for beta2. Ignore English-only
+         test.
+
+2006-04-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageEncoderTest.cs : test for text binding with Soap11.
+       * MessageTest.cs : more create/write tests. The serialization part
+         could be shared.
+
+2006-04-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeadersTest.cs : one more removal of NotWorking.
+       * MessageTest.cs : added fault message creation and write test.
+
+2006-03-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeadersTest.cs : removed some NotWorkings.
+       * MessageHeaderTest.cs : uncommented, making several fixes.
+
+2006-03-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TextMessageEncodingBindingElementTest.cs :
+         added trivial CanBuildChannelFactory test.
+
+2006-03-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageTest.cs : test Action header in CreateFromXmlReader().
+
+2006-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageTest.cs : added another CreateMessage(XmlReader,...) test.
+
+2006-03-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageTest.cs : added test for Message.CreateMessage(version,
+         xmlreader,int) and GetReaderAtBodyContents() etc.
+
+2006-03-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageTest.cs : now the test is working, except for
+         UnderstoodHeaders.
+       * MessageHeadersTest.cs : added GetReaderAtHeader() tests and so on.
+
+2006-03-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageTest.cs MessageEncoderTest.cs : new tests.
+       * MessageHeadersTest.cs : some tests are working now. Added some more
+         tests.
+
+2006-03-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultExceptionTest.cs :
+         Don't test English-specific exception message.
+         Removed AreEqual() .Don't hide actual cause of assertion failure.
+
+2006-03-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageEncodingBindingElement.cs : with Feb. CTP we can define our
+         own MessageEncodingBindingElement, so added more tests for such
+         custom binding element.
+
+2006-03-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AddressHeaderTest.cs : marked EqualsTest() which got to not work
+         in Feb. CTP.
+       * ChannelFactoryTest.cs : null type argument ctor() does not
+         exist anymore.
+
+2006-03-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeadersTest.cs
+         AddressingVersionTest.cs
+         FaultExceptionTest.cs : updated tests to work fine with Feb. CTP.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObjectTest.cs : some State tests.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObjectTest.cs : some simple Open/Close tests.
+
+2005-10-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CommunicationObjectTest.cs : new file (testing run-test).
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/CommunicationObjectTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/CommunicationObjectTest.cs
new file mode 100644 (file)
index 0000000..f528106
--- /dev/null
@@ -0,0 +1,180 @@
+//
+// CommunicationObjectTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       class ExtCommObj : CommunicationObject
+       {
+               public new bool Aborted, Opened, Closed;
+
+               public ExtCommObj () : base ()
+               {
+               }
+
+               protected override TimeSpan DefaultCloseTimeout {
+                       get { return TimeSpan.Zero; }
+               }
+               protected override TimeSpan DefaultOpenTimeout {
+                       get { return TimeSpan.Zero; }
+               }
+
+               public new bool IsDisposed {
+                       get { return base.IsDisposed; }
+               }
+
+               public void XFault ()
+               {
+                       Fault ();
+               }
+
+               protected override void OnAbort ()
+               {
+                       if (Aborted)
+                               throw new Exception ("Already aborted");
+                       Aborted = true;
+               }
+
+               protected override IAsyncResult OnBeginClose (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override IAsyncResult OnBeginOpen (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       if (Closed)
+                               throw new Exception ("Already closed");
+                       Closed = true;
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       if (Opened)
+                               throw new Exception ("Already opened");
+                       Opened = true;
+               }
+       }
+
+       [TestFixture]
+       public class CommunicationObjectTest
+       {
+               [Test]
+               public void OpenClose ()
+               {
+                       ExtCommObj obj = new ExtCommObj ();
+                       Assert.AreEqual (CommunicationState.Created, obj.State, "#1");
+                       obj.Open ();
+                       Assert.AreEqual (CommunicationState.Opened, obj.State, "#2");
+                       Assert.IsTrue (obj.Opened, "#2-2");
+                       obj.Close ();
+                       Assert.AreEqual (CommunicationState.Closed, obj.State, "#3");
+                       Assert.IsTrue (obj.Closed, "#3-2");
+                       Assert.AreEqual (true, obj.IsDisposed, "#4");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void OpenOpenFails ()
+               {
+                       ExtCommObj obj = new ExtCommObj ();
+                       obj.Open ();
+                       obj.Open ();
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void CloseAtInitialState ()
+               {
+                       ExtCommObj obj = new ExtCommObj ();
+                       obj.Close (); // Aborted() is called.
+                       Assert.IsTrue (obj.Aborted);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ObjectDisposedException))]
+               public void OpenClosedItemFails ()
+               {
+                       ExtCommObj obj = new ExtCommObj ();
+                       obj.Open ();
+                       obj.Close ();
+                       obj.Open ();
+               }
+
+               [Test]
+               public void Fault ()
+               {
+                       ExtCommObj obj = new ExtCommObj ();
+                       obj.XFault ();
+
+                       obj = new ExtCommObj ();
+                       obj.Open ();
+                       obj.XFault ();
+                       Assert.AreEqual (CommunicationState.Faulted, obj.State);
+                       Assert.AreEqual (false, obj.IsDisposed);
+               }
+
+               [Test]
+               [ExpectedException (typeof (CommunicationObjectFaultedException))]
+               public void OpenFaulted ()
+               {
+                       ExtCommObj obj = new ExtCommObj ();
+                       obj.XFault ();
+                       obj.Open ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (CommunicationObjectFaultedException))]
+               public void CloseFaulted ()
+               {
+                       ExtCommObj obj = new ExtCommObj ();
+                       obj.Open ();
+                       obj.XFault ();
+                       obj.Close ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/CustomBindingTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/CustomBindingTest.cs
new file mode 100644 (file)
index 0000000..a3948a3
--- /dev/null
@@ -0,0 +1,276 @@
+//
+// CustomBindingTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.IdentityModel.Tokens;
+using System.Runtime.Serialization;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Text;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class CustomBindingTest
+       {
+               [Test]
+               public void DefaultCtor ()
+               {
+                       CustomBinding cb = new CustomBinding ();
+                       
+                       Assert.AreEqual (0, cb.Elements.Count, "#1");
+                       Assert.AreEqual ("CustomBinding", cb.Name, "#3");
+                       Assert.AreEqual ("http://tempuri.org/", cb.Namespace, "#4");
+                       Assert.AreEqual (TimeSpan.FromMinutes (1), cb.OpenTimeout, "#5");
+                       Assert.AreEqual (TimeSpan.FromMinutes (1), cb.CloseTimeout, "#6");
+                       Assert.AreEqual (TimeSpan.FromMinutes (1), cb.SendTimeout, "#7");
+                       Assert.AreEqual (TimeSpan.FromMinutes (10), cb.ReceiveTimeout, "#8");
+                       Assert.AreEqual (0, cb.CreateBindingElements ().Count, "#9");
+               }
+
+               class MyBinding : Binding
+               {
+                       public override string Scheme { get { return "hoge"; } }
+
+                       public override BindingElementCollection CreateBindingElements ()
+                       {
+                               throw new ApplicationException ("HEHE");
+                       }
+               }
+
+               [Test]
+               public void CtorFromAnotherBinding ()
+               {
+                       CustomBinding cb =
+                               new CustomBinding (new WSHttpBinding ());
+                       // Its properties become mostly copy of the original one
+                       Assert.AreEqual (4, cb.Elements.Count, "#1");
+                       Assert.AreEqual ("http", cb.Scheme, "#2");
+                       Assert.AreEqual ("WSHttpBinding", cb.Name, "#3");
+                       Assert.AreEqual ("http://tempuri.org/", cb.Namespace, "#4");
+
+                       Assert.AreEqual (4, cb.CreateBindingElements ().Count, "#9");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ApplicationException))]
+               public void CtorFromAnotherBindingCallsCreateBindingElement ()
+               {
+                       new CustomBinding (new MyBinding ());
+               }
+
+               Message reqmsg, resmsg;
+
+               [Test]
+               public void CustomTransportDoesNotRequireMessageEncoding ()
+               {
+                       ReplyHandler replier = delegate (Message msg) {
+                               resmsg = msg;
+                       };
+
+                       RequestReceiver receiver = delegate () {
+                               return reqmsg;
+                       };
+
+                       RequestSender sender = delegate (Message msg) {
+                               reqmsg = msg;
+
+                               CustomBinding br = new CustomBinding (
+                                       new HandlerTransportBindingElement (replier, receiver));
+                               IChannelListener<IReplyChannel> l =
+                                       br.BuildChannelListener<IReplyChannel> (
+                                               new BindingParameterCollection ());
+                               l.Open ();
+                               IReplyChannel rch = l.AcceptChannel ();
+                               rch.Open ();
+                               Message res = Message.CreateMessage (MessageVersion.Default, "urn:succeeded");
+                               rch.ReceiveRequest ().Reply (res);
+                               rch.Close ();
+                               l.Close ();
+
+                               return resmsg;
+                       };
+
+                       CustomBinding bs = new CustomBinding (
+                               new HandlerTransportBindingElement (sender));
+
+                       IChannelFactory<IRequestChannel> f =
+                               bs.BuildChannelFactory<IRequestChannel> (
+                                       new BindingParameterCollection ());
+                       f.Open ();
+                       IRequestChannel ch = f.CreateChannel (new EndpointAddress ("urn:dummy"));
+                       ch.Open ();
+                       Message result = ch.Request (Message.CreateMessage (MessageVersion.Default, "urn:request"));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               //  Envelope Version 'EnvelopeNone (http://schemas.microsoft.com/ws/2005/05/envelope/none)'
+               // does not support adding Message Headers.
+               public void MessageSecurityPOX ()
+               {
+                       SymmetricSecurityBindingElement sbe =
+                               new SymmetricSecurityBindingElement ();
+                       sbe.ProtectionTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       RequestSender sender = delegate (Message input) {
+                               MessageBuffer buf = input.CreateBufferedCopy (0x10000);
+                               using (XmlWriter w = XmlWriter.Create (Console.Error)) {
+                                       buf.CreateMessage ().WriteMessage (w);
+                               }
+                               return buf.CreateMessage ();
+                       };
+
+                       CustomBinding binding = new CustomBinding (
+                               sbe,
+                               new TextMessageEncodingBindingElement (
+                                       MessageVersion.None, Encoding.UTF8),
+                               new HandlerTransportBindingElement (sender));
+
+                       EndpointAddress address = new EndpointAddress (
+                               new Uri ("http://localhost:8080"),
+                               new X509CertificateEndpointIdentity (new X509Certificate2 ("Test/Resources/test.pfx", "mono")));
+
+                       ChannelFactory<IRequestChannel> cf =
+                               new ChannelFactory<IRequestChannel> (binding, address);
+                       IRequestChannel ch = cf.CreateChannel ();
+/*
+                       // neither of Endpoint, Contract nor its Operation seems
+                       // to have applicable behaviors (except for
+                       // ClientCredentials)
+                       Assert.AreEqual (1, cf.Endpoint.Behaviors.Count, "EndpointBehavior");
+                       Assert.AreEqual (0, cf.Endpoint.Contract.Behaviors.Count, "ContractBehavior");
+                       Assert.AreEqual (1, cf.Endpoint.Contract.Operations.Count, "Operations");
+                       OperationDescription od = cf.Endpoint.Contract.Operations [0];
+                       Assert.AreEqual (0, od.Behaviors.Count, "OperationBehavior");
+*/
+
+                       ch.Open ();
+                       try {
+                               ch.Request (Message.CreateMessage (MessageVersion.None, "urn:myaction"));
+                       } finally {
+                               ch.Close ();
+                       }
+               }
+
+               [Test]
+               [Ignore ("it's underway")]
+               [Category ("NotWorking")]
+               public void MessageSecurityManualProtection ()
+               {
+                       SymmetricSecurityBindingElement sbe =
+                               new SymmetricSecurityBindingElement ();
+                       sbe.ProtectionTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       RequestSender sender = delegate (Message input) {
+                               MessageBuffer buf = input.CreateBufferedCopy (0x10000);
+                               using (XmlWriter w = XmlWriter.Create (Console.Error)) {
+                                       buf.CreateMessage ().WriteMessage (w);
+                               }
+                               return buf.CreateMessage ();
+                       };
+
+                       CustomBinding binding = new CustomBinding (
+                               sbe,
+                               new TextMessageEncodingBindingElement (),
+                               new HandlerTransportBindingElement (sender));
+
+                       EndpointAddress address = new EndpointAddress (
+                               new Uri ("http://localhost:8080"),
+                               new X509CertificateEndpointIdentity (new X509Certificate2 ("Test/Resources/test.pfx", "mono")));
+
+                       ChannelProtectionRequirements reqs =
+                               new ChannelProtectionRequirements ();
+                       reqs.OutgoingSignatureParts.AddParts (
+                               new MessagePartSpecification (new XmlQualifiedName ("SampleValue", "urn:foo")), "urn:myaction");
+                       BindingParameterCollection parameters =
+                               new BindingParameterCollection ();
+                       parameters.Add (reqs);
+/*
+                       SymmetricSecurityBindingElement innersbe =
+                               new SymmetricSecurityBindingElement ();
+                       innersbe.ProtectionTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       sbe.ProtectionTokenParameters =
+                               new SecureConversationSecurityTokenParameters (
+                                       innersbe, false, reqs);
+*/
+
+                       IChannelFactory<IRequestChannel> cf =
+                               binding.BuildChannelFactory<IRequestChannel> (parameters);
+                       cf.Open ();
+                       IRequestChannel ch = cf.CreateChannel (address);
+
+                       ch.Open ();
+                       try {
+                               ch.Request (Message.CreateMessage (MessageVersion.None, "urn:myaction", new SampleValue ()));
+                       } finally {
+                               ch.Close ();
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               [Category ("NotWorking")]
+               public void BuildChannelListenerNoTransport ()
+               {
+                       CustomBinding cb = new CustomBinding (
+                               new TextMessageEncodingBindingElement (),
+                               new CompositeDuplexBindingElement ());
+                       BindingContext ctx = new BindingContext (
+                               cb, new BindingParameterCollection ());
+                       new TextMessageEncodingBindingElement ().BuildChannelListener<IReplyChannel> (ctx);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               [Category ("NotWorking")]
+               public void BuildChannelListenerWithDuplicateElement ()
+               {
+                       CustomBinding cb = new CustomBinding (
+                               new TextMessageEncodingBindingElement (),
+                               new HttpTransportBindingElement ());
+                       BindingContext ctx = new BindingContext (
+                               cb, new BindingParameterCollection (),
+                               new Uri ("http://localhost:8080"), String.Empty, ListenUriMode.Unique);
+                       new TextMessageEncodingBindingElement ().BuildChannelListener<IReplyChannel> (ctx);
+               }
+       }
+
+       [DataContract (Namespace = "urn:foo")]
+       class SampleValue
+       {
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/DebugBindingElement.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/DebugBindingElement.cs
new file mode 100644 (file)
index 0000000..99f5d1c
--- /dev/null
@@ -0,0 +1,174 @@
+//
+// DebugBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Xml;
+using NUnit.Framework;
+
+
+// This binding element class is for testing some bindings to intercept
+// messages.
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       class DebugBindingElement : BindingElement
+       {
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       return new DebugChannelFactory<TChannel> (context.BuildInnerChannelFactory<TChannel> ());
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return new DebugBindingElement ();
+               }
+
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       return context.GetInnerProperty<T> ();
+               }
+       }
+
+       class DebugChannelFactory<TChannel> : ChannelFactoryBase<TChannel>
+       {
+               IChannelFactory<TChannel> inner;
+
+               public DebugChannelFactory (IChannelFactory<TChannel> inner)
+               {
+                       this.inner = inner;
+               }
+
+               public override T GetProperty<T> ()
+               {
+                       return inner.GetProperty<T> ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       inner.Open (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               protected override TChannel OnCreateChannel (EndpointAddress ep, Uri via)
+               {
+                       if (typeof (TChannel) == typeof (IRequestChannel))
+                               return (TChannel) (object) new DebugRequestChannel (this, (IRequestChannel) (object) inner.CreateChannel (ep, via));
+                       throw new Exception ("huh?");
+               }
+       }
+
+       class DebugRequestChannel : RequestChannelBase
+       {
+               ChannelFactoryBase source;
+               IRequestChannel inner;
+
+               public DebugRequestChannel (ChannelFactoryBase source, IRequestChannel inner)
+                        : base (source)
+               {
+                       this.source = source;
+                       this.inner = inner;
+               }
+
+               public override EndpointAddress RemoteAddress {
+                       get { return inner.RemoteAddress; }
+               }
+
+               public override Uri Via {
+                       get { return inner.Via; }
+               }
+
+               protected override void OnAbort ()
+               {
+                       inner.Abort ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       inner.Open (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       inner.Close (timeout);
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override Message Request (Message req, TimeSpan timeout)
+               {
+XmlWriterSettings settings = new XmlWriterSettings ();
+settings.Indent = true;
+MessageBuffer buf = req.CreateBufferedCopy (0x10000);
+using (XmlWriter w = XmlWriter.Create (Console.Error, settings)) {
+buf.CreateMessage ().WriteMessage (w);
+}
+Console.Error.WriteLine ("******************** Debug Request() ********************");
+Console.Error.Flush ();
+                       return inner.Request (buf.CreateMessage (), timeout);
+               }
+
+               public override IAsyncResult BeginRequest (Message req, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override Message EndRequest (IAsyncResult result)
+               {
+                       throw new NotSupportedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/EmptyFaultExceptionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/EmptyFaultExceptionTest.cs
new file mode 100644 (file)
index 0000000..591af18
--- /dev/null
@@ -0,0 +1,52 @@
+#if USE_DEPRECATED
+// EmptyFaultException does not exist anymore
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Text;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class EmptyFaultExceptionTest
+       {
+               [Test]
+               public void TestDefaults ()
+               {
+                       EmptyFaultException e = new EmptyFaultException ();
+                       Assert.AreEqual (MessageFault.DefaultAction, e.Action);
+                       Assert.IsTrue (e.Code.IsSenderFault);
+                       Assert.IsNull (e.Code.SubCode);
+                       Assert.AreEqual ("Unspecified ServiceModel Fault.", e.Reason.GetMatchingTranslation ().Text);
+               }
+
+               [Test]
+               [Ignore ("bad English-oriented test")]
+               public void TestToString ()
+               {
+                       EmptyFaultException e = new EmptyFaultException ();
+                       Assert.AreEqual (
+                               String.Format ("{0}: {1} (Fault Detail is equal to null).", e.GetType (), e.Message),
+                               e.ToString ());
+               }
+
+               bool AreEqual (MessageFault a, MessageFault b)
+               {
+                       return a.Actor == b.Actor && a.Code == b.Code && a.HasDetail == b.HasDetail && a.Node == b.Node && a.Reason == b.Reason;
+               }
+
+               [Test]
+               public void TestCreateMessageFault ()
+               {
+                       EmptyFaultException e = new EmptyFaultException ();
+                       Assert.IsTrue (
+                               AreEqual (MessageFault.CreateFault (e.Code, e.Reason), e.CreateMessageFault ()));
+               }
+       }
+}
+#endif
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/EnvelopeVersionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/EnvelopeVersionTest.cs
new file mode 100644 (file)
index 0000000..f36b5cb
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// MessageVersionTest.cs
+//
+// Author:
+//     Duncan Mak <duncan@ximian.com>
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Text;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class EnvelopeVersionTest
+       {
+               [Test]
+               public void GetUltimateDestinationActorValuesTest ()
+               {
+                       // SOAP 1.1
+                       Assert.AreEqual (2, EnvelopeVersion.Soap11.GetUltimateDestinationActorValues ().Length, "#1");
+                       Assert.AreEqual (String.Empty, EnvelopeVersion.Soap11.GetUltimateDestinationActorValues () [0], "#2");
+                       Assert.AreEqual ("http://schemas.xmlsoap.org/soap/actor/next", EnvelopeVersion.Soap11.GetUltimateDestinationActorValues () [1], "#3");
+
+                       // SOAP 1.2
+                       Assert.AreEqual (3, EnvelopeVersion.Soap12.GetUltimateDestinationActorValues ().Length, "#4");
+                       Assert.AreEqual (String.Empty,
+                           EnvelopeVersion.Soap12.GetUltimateDestinationActorValues () [0], "#5");
+                       Assert.AreEqual ("http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver",
+                                        EnvelopeVersion.Soap12.GetUltimateDestinationActorValues () [1], "#6");
+                       Assert.AreEqual ("http://www.w3.org/2003/05/soap-envelope/role/next",
+                                        EnvelopeVersion.Soap12.GetUltimateDestinationActorValues () [2], "#7");
+               }
+
+               [Test]
+               public void Equality ()
+               {
+                       Assert.AreEqual (EnvelopeVersion.Soap12, MessageVersion.Default.Envelope, "#1");
+                       Assert.IsTrue (EnvelopeVersion.Soap12 == MessageVersion.Default.Envelope, "#2");
+                       Assert.IsTrue (Object.ReferenceEquals (EnvelopeVersion.Soap12, MessageVersion.Default.Envelope), "#3");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultConverterTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultConverterTest.cs
new file mode 100644 (file)
index 0000000..60587df
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// FaultConverterTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class FaultConverterTest
+       {
+               static readonly FaultConverter s11 = FaultConverter.GetDefaultFaultConverter (MessageVersion.Soap11WSAddressing10);
+               static readonly FaultConverter s12 = FaultConverter.GetDefaultFaultConverter (MessageVersion.Default);
+
+               XmlWriterSettings GetWriterSettings ()
+               {
+                       XmlWriterSettings s = new XmlWriterSettings ();
+                       s.OmitXmlDeclaration = true;
+                       return s;
+               }
+
+               [Test]
+               public void TryCreateExceptionDefault ()
+               {
+                       Message msg;
+                       Assert.IsFalse (s12.TryCreateFaultMessage (new Exception ("error happened"), out msg), "#1-1");
+
+                       Assert.IsFalse (s12.TryCreateFaultMessage (new FaultException ("fault happened", FaultCode.CreateSenderFaultCode (new FaultCode ("IAmBroken"))), out msg), "#1-2");
+
+                       Assert.IsFalse (s12.TryCreateFaultMessage (new FaultException<string> ("fault happened."), out msg), "#1-3");
+
+                       Assert.IsFalse (s11.TryCreateFaultMessage (new Exception ("error happened"), out msg), "#2-1");
+
+                       Assert.IsFalse (s11.TryCreateFaultMessage (new FaultException ("fault happened", FaultCode.CreateSenderFaultCode (new FaultCode ("IAmBroken"))), out msg), "#2-2");
+
+                       Assert.IsFalse (s11.TryCreateFaultMessage (new FaultException<string> ("fault happened."), out msg), "#2-3");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultExceptionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/FaultExceptionTest.cs
new file mode 100644 (file)
index 0000000..6a36bb0
--- /dev/null
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Text;
+using System.Xml;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+        [TestFixture]
+        public class FaultExceptionTest
+        {
+               [Test]
+               public void TestDefaults ()
+               {
+                       FaultException<int> e = new FaultException<int> (0);
+                       Assert.AreEqual (0, e.Detail, "#1");
+                       Assert.IsNull (e.Action, "#2");
+               }
+
+               [Test]
+               public void TestMessage ()
+               {
+                       FaultException<int> e = new FaultException<int> (0);
+                       Assert.AreEqual (e.Message, e.Reason.GetMatchingTranslation ().Text);
+               }
+               [Test]
+               public void TestCode ()
+               {
+                       // default Code is a SenderFault with a null SubCode
+                       FaultException<int> e = new FaultException<int> (0);
+                       Assert.IsTrue (e.Code.IsSenderFault);
+                       Assert.IsNull (e.Code.SubCode);
+               }
+
+               [Test]
+               public void TestAction ()
+               {
+                       FaultException<int> e = new FaultException<int> (0);
+                       Assert.IsNull (e.Action);
+               }
+
+               static void AreMessageFaultEqual (MessageFault a, MessageFault b, string label)
+               {
+                       Assert.AreEqual (a.Actor, b.Actor, label + ".Actor");
+                       Assert.AreEqual (a.Code, b.Code, label + ".Code");
+                       Assert.AreEqual (a.HasDetail, b.HasDetail, label + ".HasDetail");
+                       Assert.AreEqual (a.Node, b.Node, label + ".Node");
+                       Assert.AreEqual (a.Reason, b.Reason, label + ".Reason");
+               }
+
+               [Test]
+               public void TestCreateMessageFault ()
+               {
+                       FaultException<int> e = new FaultException<int> (0);                            Assert.IsFalse (
+                               (object) MessageFault.CreateFault (e.Code, e.Reason, e.Detail)
+                               == e.CreateMessageFault (), "#1");
+                       AreMessageFaultEqual (
+                               MessageFault.CreateFault (e.Code, e.Reason, e.Detail), 
+                               e.CreateMessageFault (), "#2");
+               }
+
+               [Test]
+               [Ignore ("this test is old")]
+               public void TestGetObjectData ()
+               {
+                       FaultException<int> e = new FaultException<int> (0);
+
+                       if (true) {
+                               XmlWriterSettings s = new XmlWriterSettings ();
+                               s.Indent = true;
+                               s.ConformanceLevel = ConformanceLevel.Fragment;
+                               XmlWriter w = XmlWriter.Create (TextWriter.Null, s);
+                               XmlObjectSerializer formatter = new DataContractSerializer (typeof (int));
+                               formatter.WriteObject (w, e);
+                               w.Close ();
+                       }
+               }
+
+               [Test]
+               [Ignore ("This test premises English.")]
+               public void TestToString ()
+               {
+                       FaultException<int> e = new FaultException<int> (0);                    
+                       Assert.AreEqual (
+                               String.Format ("{0}: {1} (Fault Detail is equal to {2}).", e.GetType (), e.Message, e.Detail),
+                               e.ToString ());
+               }
+        }
+}
+
+
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/HandlerBodyWriter.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/HandlerBodyWriter.cs
new file mode 100644 (file)
index 0000000..0e986fb
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// HandlerBodyWriter.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Xml;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       public delegate void BodyContentsWriter (XmlDictionaryWriter writer);
+
+       public class HandlerBodyWriter : BodyWriter
+       {
+               BodyContentsWriter handler;
+
+               public HandlerBodyWriter (BodyContentsWriter handler)
+                       : base (true)
+               {
+                       this.handler = handler;
+               }
+
+               protected override void OnWriteBodyContents (XmlDictionaryWriter writer)
+               {
+                       handler (writer);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/HandlerTransportBindingElement.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/HandlerTransportBindingElement.cs
new file mode 100644 (file)
index 0000000..58814ba
--- /dev/null
@@ -0,0 +1,649 @@
+//
+// HandlerTransportBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.Threading;
+using System.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       public delegate Message RequestSender (Message input);
+       public delegate Message RequestReceiver ();
+       public delegate void ReplyHandler (Message input);
+
+       public class HandlerTransportBindingElement : TransportBindingElement
+       {
+               RequestSender sender;
+
+               ReplyHandler reply_handler;
+               RequestReceiver receiver;
+
+               public HandlerTransportBindingElement (RequestSender sender)
+               {
+                       this.sender = sender;
+               }
+
+               public HandlerTransportBindingElement (ReplyHandler handler, RequestReceiver receiver)
+               {
+                       this.reply_handler = handler;
+                       this.receiver = receiver;
+               }
+
+               public RequestSender RequestSender {
+                       get { return sender; }
+               }
+
+               public ReplyHandler ReplyHandler {
+                       get { return reply_handler; }
+               }
+
+               public RequestReceiver RequestReceiver {
+                       get { return receiver; }
+               }
+
+               public override string Scheme {
+                       get { return "stream"; }
+               }
+
+               public override BindingElement Clone ()
+               {
+                       if (sender != null)
+                               return new HandlerTransportBindingElement (sender);
+                       else
+                               return new HandlerTransportBindingElement (reply_handler, receiver);
+               }
+
+               public override bool CanBuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       return typeof (TChannel) == typeof (IRequestChannel) ||
+                               typeof (TChannel) == typeof (IRequestChannel);
+               }
+
+               public override bool CanBuildChannelListener<TChannel> (BindingContext context)
+               {
+                       return typeof (TChannel) == typeof (IReplyChannel) ||
+                               typeof (TChannel) == typeof (IInputChannel);
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       return new HandlerTransportChannelFactory<TChannel> (this);
+               }
+
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (BindingContext context)
+               {
+                       // FIXME: pass uri
+                       return new HandlerTransportChannelListener<TChannel> (this, new Uri ("stream:dummy"));
+               }
+       }
+
+       public class HandlerTransportChannelFactory<TChannel> : ChannelFactoryBase<TChannel>
+       {
+               HandlerTransportBindingElement source;
+
+               public HandlerTransportChannelFactory (HandlerTransportBindingElement source)
+               {
+                       this.source = source;
+               }
+
+               public HandlerTransportBindingElement Source {
+                       get { return source; }
+               }
+
+               protected override TChannel OnCreateChannel (EndpointAddress address, Uri via)
+               {
+                       if (typeof (TChannel) == typeof (IRequestChannel))
+                               return (TChannel) (object) new HandlerTransportRequestChannel ((HandlerTransportChannelFactory<IRequestChannel>) (object) this, address, via);
+                       if (typeof (TChannel) == typeof (IOutputChannel))
+                               return (TChannel) (object) new HandlerTransportOutputChannel ((HandlerTransportChannelFactory<IOutputChannel>) (object) this, address, via);
+
+                       throw new NotSupportedException (String.Format ("Channel '{0}' is not supported.", typeof (TChannel)));
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       // do nothing
+               }
+       }
+
+       public class HandlerTransportOutputChannel : OutputChannelBase
+       {
+               HandlerTransportChannelFactory<IOutputChannel> source;
+               EndpointAddress address;
+               Uri via;
+
+               public HandlerTransportOutputChannel (HandlerTransportChannelFactory<IOutputChannel> source, EndpointAddress address, Uri via)
+                       : base (source)
+               {
+                       this.source = source;
+                       this.address = address;
+                       this.via = via;
+               }
+
+               public override EndpointAddress RemoteAddress {
+                       get { return address; }
+               }
+
+               public override Uri Via {
+                       get { return via; }
+               }
+
+               public override void Send (Message input, TimeSpan timeout)
+               {
+                       source.Source.RequestSender (input);
+               }
+
+               class OutputAsyncResult : IAsyncResult
+               {
+                       Message message;
+                       object state;
+                       bool completed = true;
+
+                       public OutputAsyncResult (Message message, object state)
+                       {
+                               this.message = message;
+                               this.state = state;
+                       }
+
+                       public Message Message {
+                               get { return message; }
+                       }
+
+                       public object AsyncState {
+                               get { return state; }
+                       }
+
+                       public WaitHandle AsyncWaitHandle {
+                               get { return null; }
+                       }
+
+                       public bool CompletedSynchronously {
+                               get { return true; }
+                       }
+
+                       public bool IsCompleted {
+                               get { return completed; }
+                               internal set { completed = value; }
+                       }
+               }
+
+               public override IAsyncResult BeginSend (Message input, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       // FIXME: timeout is not considered here.
+                       return new OutputAsyncResult (input, state);
+               }
+
+               public override void EndSend (IAsyncResult result)
+               {
+                       source.Source.RequestSender (((OutputAsyncResult) result).Message);
+               }
+
+
+               protected override void OnAbort ()
+               {
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       // throw new NotImplementedException ("OnOpen");
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("OnBeginOpen");
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("OnEndOpen");
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       // throw new NotImplementedException ("OnClose");
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("OnBeginClose");
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("OnEndClose");
+               }
+       }
+
+       public class HandlerTransportRequestChannel : RequestChannelBase
+       {
+               HandlerTransportChannelFactory<IRequestChannel> source;
+               EndpointAddress address;
+               Uri via;
+
+               public HandlerTransportRequestChannel (HandlerTransportChannelFactory<IRequestChannel> source, EndpointAddress address, Uri via)
+                       : base (source)
+               {
+                       this.source = source;
+                       this.address = address;
+                       this.via = via;
+               }
+
+               public override EndpointAddress RemoteAddress {
+                       get { return address; }
+               }
+
+               public override Uri Via {
+                       get { return via; }
+               }
+
+               public override Message Request (Message input, TimeSpan timeout)
+               {
+                       return source.Source.RequestSender (input);
+               }
+
+               class RequestAsyncResult : IAsyncResult
+               {
+                       Message message;
+                       object state;
+                       bool completed = true;
+
+                       public RequestAsyncResult (Message message, object state)
+                       {
+                               this.message = message;
+                               this.state = state;
+                       }
+
+                       public Message Message {
+                               get { return message; }
+                       }
+
+                       public object AsyncState {
+                               get { return state; }
+                       }
+
+                       public WaitHandle AsyncWaitHandle {
+                               get { return null; }
+                       }
+
+                       public bool CompletedSynchronously {
+                               get { return true; }
+                       }
+
+                       public bool IsCompleted {
+                               get { return completed; }
+                               internal set { completed = value; }
+                       }
+               }
+
+               public override IAsyncResult BeginRequest (Message input, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       // FIXME: timeout is not considered here.
+                       return new RequestAsyncResult (input, state);
+               }
+
+               public override Message EndRequest (IAsyncResult result)
+               {
+                       return source.Source.RequestSender (((RequestAsyncResult) result).Message);
+               }
+
+
+               protected override void OnAbort ()
+               {
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       // throw new NotImplementedException ("OnOpen");
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("OnBeginOpen");
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("OnEndOpen");
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       // throw new NotImplementedException ("OnClose");
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("OnBeginClose");
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("OnEndClose");
+               }
+       }
+
+       public class HandlerTransportChannelListener<TChannel>
+               : ChannelListenerBase<TChannel>
+               where TChannel : class, IChannel
+       {
+               HandlerTransportBindingElement source;
+               Uri uri;
+
+               public HandlerTransportChannelListener (HandlerTransportBindingElement source, Uri uri)
+               {
+                       this.source = source;
+                       this.uri = uri;
+               }
+
+               public HandlerTransportBindingElement Source {
+                       get { return source; }
+               }
+
+
+               public override Uri Uri {
+                       get { return uri; }
+               }
+
+               protected override TChannel OnAcceptChannel (TimeSpan timeout)
+               {
+                       if (typeof (TChannel) == typeof (IReplyChannel))
+                               return (TChannel) (object) new HandlerTransportReplyChannel ((HandlerTransportChannelListener<IReplyChannel>) (object) this);
+
+                       throw new NotSupportedException ();
+               }
+
+               protected override IAsyncResult OnBeginAcceptChannel (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("OnBeginAcceptChannel");
+               }
+
+               protected override TChannel OnEndAcceptChannel (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("EndAcceptChannel");
+               }
+
+               protected override bool OnWaitForChannel (TimeSpan timeout)
+               {
+                       return true;
+               }
+
+               protected override IAsyncResult OnBeginWaitForChannel (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("OnBeginWaitForChannel");
+               }
+
+               protected override bool OnEndWaitForChannel (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("EndWaitForChannel");
+               }
+
+
+               protected override void OnAbort ()
+               {
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       // throw new NotImplementedException ("OnOpen");
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("OnBeginOpen");
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("EndOpen");
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       //throw new NotImplementedException ("Close");
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("OnBeginClose");
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("OnEndClose");
+               }
+       }
+
+       public class HandlerTransportReplyChannel : ReplyChannelBase
+       {
+               EndpointAddress address;
+               HandlerTransportChannelListener<IReplyChannel> source;
+
+               public HandlerTransportReplyChannel (HandlerTransportChannelListener<IReplyChannel> source)
+                       : base (source)
+               {
+                       this.source = source;
+                       address = new EndpointAddress (source.Uri);
+               }
+
+               public HandlerTransportChannelListener<IReplyChannel> Source {
+                       get { return source; }
+               }
+
+               public override EndpointAddress LocalAddress {
+                       get { return address; }
+               }
+
+               class ReceiveRequestAsyncResult : IAsyncResult
+               {
+                       object state;
+                       bool completed = true;
+
+                       public ReceiveRequestAsyncResult (object state)
+                       {
+                               this.state = state;
+                       }
+
+                       public object AsyncState {
+                               get { return state; }
+                       }
+
+                       public WaitHandle AsyncWaitHandle {
+                               get { return null; }
+                       }
+
+                       public bool CompletedSynchronously {
+                               get { return true; }
+                       }
+
+                       public bool IsCompleted {
+                               get { return completed; }
+                               internal set { completed = value; }
+                       }
+               }
+
+               public override RequestContext ReceiveRequest (TimeSpan timeout)
+               {
+                       RequestContext ret;
+                       if (!TryReceiveRequest (timeout, out ret))
+                               throw new Exception ();
+                       return ret;
+               }
+
+               public override IAsyncResult BeginReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return new ReceiveRequestAsyncResult (state);
+               }
+
+               public override RequestContext EndReceiveRequest (IAsyncResult result)
+               {
+                       //ReceiveRequestAsyncResult r =
+                       //      (ReceiveRequestAsyncResult) result;
+                       return new HandlerRequestContext (this);
+               }
+
+               public override bool TryReceiveRequest (TimeSpan timeout, out RequestContext ret)
+               {
+                       ret = new HandlerRequestContext (this);
+                       return true;
+               }
+
+               public override IAsyncResult BeginTryReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       // hack, hack
+                       return new ReceiveRequestAsyncResult (state);
+               }
+
+               public override bool EndTryReceiveRequest (IAsyncResult result, out RequestContext ret)
+               {
+                       // hack, hack
+                       //ReceiveRequestAsyncResult r =
+                       //      (ReceiveRequestAsyncResult) result;
+                       return TryReceiveRequest (TimeSpan.FromSeconds (5), out ret);
+               }
+
+               public override bool WaitForRequest (TimeSpan timeout)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override IAsyncResult BeginWaitForRequest (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("BeginWaitForRequest");
+               }
+
+               public override bool EndWaitForRequest (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("EndWaitForRequest");
+               }
+
+
+               protected override void OnAbort ()
+               {
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       // throw new NotImplementedException ("OnOpen");
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("OnBeginOpen");
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("EndOpen");
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       //throw new NotImplementedException ("Close");
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("OnBeginClose");
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("OnEndClose");
+               }
+       }
+
+       public class HandlerRequestContext : RequestContext
+       {
+               HandlerTransportReplyChannel source;
+               Message request_message;
+
+               public HandlerRequestContext (HandlerTransportReplyChannel source)
+               {
+                       this.source = source;
+                       if (source.Source.Source.RequestReceiver != null)
+                               request_message = source.Source.Source.RequestReceiver ();
+               }
+
+
+               public override void Abort ()
+               {
+               }
+
+               public override void Close ()
+               {
+               }
+
+               public override void Close (TimeSpan timeout)
+               {
+               }
+
+               public override Message RequestMessage {
+                       get { return request_message; }
+               }
+
+               public override void Reply (Message msg)
+               {
+                       source.Source.Source.ReplyHandler (msg);
+               }
+
+               public override void Reply (Message msg, TimeSpan timeout)
+               {
+                       source.Source.Source.ReplyHandler (msg);
+               }
+
+               public override IAsyncResult BeginReply (Message msg, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("BeginReply");
+               }
+
+               public override IAsyncResult BeginReply (Message msg, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ("BeginReply");
+               }
+
+               public override void EndReply (IAsyncResult result)
+               {
+                       throw new NotImplementedException ("EndReply");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/HttpTransportBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/HttpTransportBindingElementTest.cs
new file mode 100644 (file)
index 0000000..3a9b445
--- /dev/null
@@ -0,0 +1,307 @@
+//
+// HttpTransportBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Threading;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class HttpTransportBindingElementTest
+       {
+               static BindingParameterCollection empty_params =
+                       new BindingParameterCollection ();
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       HttpTransportBindingElement be =
+                               new HttpTransportBindingElement ();
+                       Assert.AreEqual (false, be.AllowCookies, "#1");
+                       Assert.AreEqual (AuthenticationSchemes.Anonymous,
+                               be.AuthenticationScheme, "#2");
+                       Assert.AreEqual (false, be.BypassProxyOnLocal, "#3");
+                       Assert.AreEqual (default (HostNameComparisonMode),
+                               be.HostNameComparisonMode, "#4");
+                       Assert.AreEqual (0x10000, be.MaxBufferSize, "#6");
+                       Assert.IsNull (be.ProxyAddress, "#7");
+                       Assert.AreEqual (AuthenticationSchemes.Anonymous,
+                               be.ProxyAuthenticationScheme, "#8");
+                       Assert.AreEqual (String.Empty, be.Realm, "#9");
+                       Assert.AreEqual ("http", be.Scheme, "#10");
+                       Assert.AreEqual (default (TransferMode),
+                               be.TransferMode, "#11");
+                       Assert.AreEqual (false,
+                               be.UnsafeConnectionNtlmAuthentication, "#12");
+                       Assert.AreEqual (true, be.UseDefaultWebProxy, "#13");
+               }
+
+               [Test]
+               public void CanBuildChannelFactory ()
+               {
+                       HttpTransportBindingElement be =
+                               new HttpTransportBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (), empty_params);
+                       Assert.IsTrue (be.CanBuildChannelFactory<IRequestChannel> (ctx), "#1");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IInputChannel> (ctx), "#2");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IReplyChannel> (ctx), "#3");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IOutputChannel> (ctx), "#4");
+                       // seems like it does not support session channels by itself ?
+                       Assert.IsFalse (be.CanBuildChannelFactory<IRequestSessionChannel> (ctx), "#5");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IInputSessionChannel> (ctx), "#6");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IReplySessionChannel> (ctx), "#7");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IOutputSessionChannel> (ctx), "#8");
+
+                       // IServiceChannel is not supported
+                       Assert.IsFalse (be.CanBuildChannelListener<IServiceChannel> (ctx), "#9");
+               }
+
+               [Test]
+               public void CanBuildChannelListener ()
+               {
+                       HttpTransportBindingElement be =
+                               new HttpTransportBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (), empty_params);
+                       Assert.IsTrue (be.CanBuildChannelListener<IReplyChannel> (ctx), "#1");
+                       Assert.IsFalse (be.CanBuildChannelListener<IOutputChannel> (ctx), "#2");
+                       Assert.IsFalse (be.CanBuildChannelListener<IRequestChannel> (ctx), "#3");
+                       Assert.IsFalse (be.CanBuildChannelListener<IInputChannel> (ctx), "#4");
+                       // seems like it does not support session channels by itself ?
+                       Assert.IsFalse (be.CanBuildChannelListener<IReplySessionChannel> (ctx), "#5");
+                       Assert.IsFalse (be.CanBuildChannelListener<IOutputSessionChannel> (ctx), "#6");
+                       Assert.IsFalse (be.CanBuildChannelListener<IRequestSessionChannel> (ctx), "#7");
+                       Assert.IsFalse (be.CanBuildChannelListener<IInputSessionChannel> (ctx), "#8");
+
+                       // IServiceChannel is not supported
+                       Assert.IsFalse (be.CanBuildChannelListener<IServiceChannel> (ctx), "#9");
+               }
+
+               [Test]
+               public void BuildChannelFactory ()
+               {
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (
+                                       new HttpTransportBindingElement ()),
+                               empty_params);
+                       // returns HttpChannelFactory
+                       IChannelFactory<IRequestChannel> f =
+                               ctx.BuildInnerChannelFactory<IRequestChannel> ();
+                       f.Open (); // required
+                       IChannel c = f.CreateChannel (new EndpointAddress (
+                               "http://www.mono-project.com"));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateChannelWithoutOpen ()
+               {
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (
+                                       new HttpTransportBindingElement ()),
+                               empty_params);
+                       // returns HttpChannelFactory
+                       IChannelFactory<IRequestChannel> f =
+                               ctx.BuildInnerChannelFactory<IRequestChannel> ();
+                       IChannel c = f.CreateChannel (new EndpointAddress (
+                               "http://www.mono-project.com"));
+               }
+
+               [Test]
+               public void BuildChannelFactoryTwoHttp ()
+               {
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (
+                                       new HttpTransportBindingElement (),
+                                       new HttpTransportBindingElement ()),
+                               empty_params);
+                       ctx.BuildInnerChannelFactory<IRequestChannel> ();
+               }
+
+               [Test]
+               public void BuildChannelFactoryHttpThenMessage ()
+               {
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (
+                                       new HttpTransportBindingElement (),
+                                       new BinaryMessageEncodingBindingElement ()),
+                               empty_params);
+                       IChannelFactory<IRequestChannel> cf =
+                               ctx.BuildInnerChannelFactory<IRequestChannel> ();
+                       cf.Open ();
+               }
+
+               [Test]
+               // with July CTP it still works ...
+               public void BuildChannelFactoryHttpNoMessage ()
+               {
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (
+                                       new HttpTransportBindingElement ()),
+                               empty_params);
+                       IChannelFactory<IRequestChannel> cf =
+                               ctx.BuildInnerChannelFactory<IRequestChannel> ();
+                       cf.Open ();
+               }
+
+               [Test]
+               public void BuildChannelFactoryIgnoresRemaining ()
+               {
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (
+                                       new HttpTransportBindingElement (),
+                                       new InvalidBindingElement ()),
+                               empty_params);
+                       ctx.BuildInnerChannelFactory<IRequestChannel> ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateChannelInvalidScheme ()
+               {
+                       IChannelFactory<IRequestChannel> f = new BasicHttpBinding ().BuildChannelFactory<IRequestChannel> (new BindingParameterCollection ());
+                       f.Open ();
+                       f.CreateChannel (new EndpointAddress ("stream:dummy"));
+               }
+
+               [Test]
+               public void BuildChannelListenerWithoutListenUri ()
+               {
+                       new BasicHttpBinding ().BuildChannelListener<IReplyChannel> (new BindingParameterCollection ());
+               }
+
+               #region connection test
+
+               string svcret;
+
+               [Test]
+               [Ignore ("It somehow fails...")]
+               // It is almost identical to http-low-level-binding
+               public void LowLevelHttpConnection ()
+               {
+                       HttpTransportBindingElement lel =
+                               new HttpTransportBindingElement ();
+
+                       // Service
+                       BindingContext lbc = new BindingContext (
+                               new CustomBinding (),
+                               new BindingParameterCollection (),
+                               new Uri ("http://localhost:37564"),
+                               String.Empty, ListenUriMode.Explicit);
+                       listener = lel.BuildChannelListener<IReplyChannel> (lbc);
+
+                       try {
+
+                       listener.Open ();
+
+                       svcret = "";
+
+                       Thread svc = new Thread (delegate () {
+                               try {
+                                       svcret = LowLevelHttpConnection_SetupService ();
+                               } catch (Exception ex) {
+                                       svcret = ex.ToString ();
+                               }
+                       });
+                       svc.Start ();
+
+                       // Client code goes here.
+
+                       HttpTransportBindingElement el =
+                               new HttpTransportBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (),
+                               new BindingParameterCollection ());
+                       IChannelFactory<IRequestChannel> factory =
+                               el.BuildChannelFactory<IRequestChannel> (ctx);
+
+                       factory.Open ();
+
+                       IRequestChannel request = factory.CreateChannel (
+                               new EndpointAddress ("http://localhost:37564"));
+
+                       request.Open ();
+
+                       try {
+                       try {
+                               Message reqmsg = Message.CreateMessage (
+                                       MessageVersion.Default, "Echo");
+                               // sync version does not work here.
+                               Message msg = request.Request (reqmsg, TimeSpan.FromSeconds (5));
+
+                               using (XmlWriter w = XmlWriter.Create (TextWriter.Null)) {
+                                       msg.WriteMessage (w);
+                               }
+
+                               if (svcret != null)
+                                       Assert.Fail (svcret.Length > 0 ? svcret : "service code did not finish until this test expected.");
+                       } finally {
+                               if (request.State == CommunicationState.Opened)
+                                       request.Close ();
+                       }
+                       } finally {
+                               if (factory.State == CommunicationState.Opened)
+                                       factory.Close ();
+                       }
+                       } finally {
+                               if (listener.State == CommunicationState.Opened)
+                                       listener.Close ();
+                       }
+               }
+
+               IChannelListener<IReplyChannel> listener;
+
+               string LowLevelHttpConnection_SetupService ()
+               {
+                       IReplyChannel reply = listener.AcceptChannel ();
+                       reply.Open ();
+                       if (!reply.WaitForRequest (TimeSpan.FromSeconds (10)))
+                               return "No request reached here.";
+
+                       svcret = "Receiving request ...";
+                       RequestContext ctx = reply.ReceiveRequest ();
+                       if (ctx == null)
+                               return "No request context returned.";
+
+                       svcret = "Starting reply ...";
+                       ctx.Reply (Message.CreateMessage (MessageVersion.Default, "Ack"));
+                       return null; // OK
+               }
+
+               #endregion
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/InterceptorBindingElement.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/InterceptorBindingElement.cs
new file mode 100644 (file)
index 0000000..c000bd0
--- /dev/null
@@ -0,0 +1,515 @@
+//
+// InterceptorBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.Security.Principal;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Security.Cryptography.Xml;
+using System.Threading;
+using NUnit.Framework;
+
+using MonoTests.System.ServiceModel.Channels;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       public delegate void InterceptorRequestContextHandler (MessageBuffer src);
+
+       class InterceptorBindingElement : BindingElement
+       {
+               InterceptorRequestContextHandler handler;
+
+               public InterceptorBindingElement (InterceptorRequestContextHandler handler)
+               {
+                       this.handler = handler;
+               }
+
+               public InterceptorRequestContextHandler Handler {
+                       get { return handler; }
+               }
+
+               public override bool CanBuildChannelListener<TChannel> (BindingContext context)
+               {
+                       return true;
+               }
+
+               public override bool CanBuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       return true;
+               }
+
+               public override IChannelListener<TChannel> BuildChannelListener<TChannel> (BindingContext context)
+               {
+                       return new InterceptorChannelListener<TChannel> (this, context);
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (BindingContext context)
+               {
+                       return new InterceptorChannelFactory<TChannel> (this, context);
+               }
+
+               public override T GetProperty<T> (BindingContext ctx)
+               {
+                       return ctx.GetInnerProperty<T> ();
+               }
+
+               public override BindingElement Clone ()
+               {
+                       return this;
+               }
+       }
+
+       abstract class DefaultTimeoutCommunicationObject : CommunicationObject
+       {
+               IDefaultCommunicationTimeouts timeouts;
+               public DefaultTimeoutCommunicationObject (IDefaultCommunicationTimeouts timeouts)
+               {
+                       this.timeouts = timeouts;
+               }
+
+               protected override TimeSpan DefaultOpenTimeout {
+                       get { return timeouts.OpenTimeout; }
+               }
+               protected override TimeSpan DefaultCloseTimeout {
+                       get { return timeouts.CloseTimeout; }
+               }
+       }
+
+       class InterceptorChannelFactory<TChannel> : ChannelFactoryBase<TChannel>
+       {
+               InterceptorBindingElement element;
+               IChannelFactory<TChannel> inner;
+
+               public InterceptorChannelFactory (InterceptorBindingElement element, BindingContext context)
+                       : base (null)
+               {
+                       this.element = element;
+                       inner = context.BuildInnerChannelFactory<TChannel> ();
+               }
+
+               public InterceptorBindingElement Element {
+                       get { return element; }
+               }
+
+               public override T GetProperty<T> ()
+               {
+                       return inner.GetProperty<T> ();
+               }
+
+               protected override TChannel OnCreateChannel (EndpointAddress address, Uri uri)
+               {
+                       if (typeof (TChannel) == typeof (IRequestChannel))
+                               return (TChannel) (object) new InterceptorRequestChannel (
+                                       (InterceptorChannelFactory<IRequestChannel>) (object) this,
+                                       (IRequestChannel) (object) inner.CreateChannel (address, uri));
+                       throw new NotImplementedException ();
+               }
+
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       inner.Open (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginOpen (timeout, callback, state);
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       inner.EndOpen (result);
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       inner.Close (timeout);
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginClose (timeout, callback, state);
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       inner.EndClose (result);
+               }
+
+               protected override void OnAbort ()
+               {
+                       inner.Abort ();
+               }
+       }
+
+       class InterceptorChannelListener<TChannel> : ChannelListenerBase<TChannel> where TChannel : class, IChannel
+       {
+               InterceptorBindingElement element;
+               IChannelListener<TChannel> inner;
+
+               public InterceptorChannelListener (InterceptorBindingElement element, BindingContext context)
+               {
+                       this.element = element;
+                       inner = context.BuildInnerChannelListener<TChannel> ();
+               }
+
+               public InterceptorBindingElement Element {
+                       get { return element; }
+               }
+
+               public override Uri Uri {
+                       get { return inner.Uri; }
+               }
+
+               protected override TChannel OnAcceptChannel (TimeSpan timeout)
+               {
+                       if (typeof (TChannel) == typeof (IReplyChannel))
+                               return (TChannel) (object) new InterceptorReplyChannel (
+                                       (InterceptorChannelListener<IReplyChannel>) (object) this,
+                                       (IReplyChannel) (object) inner.AcceptChannel (timeout));
+                       throw new NotImplementedException ();
+               }
+
+               protected override IAsyncResult OnBeginAcceptChannel (
+                       TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginAcceptChannel (timeout, callback, state);
+               }
+
+               protected override TChannel OnEndAcceptChannel (IAsyncResult result)
+               {
+                       if (typeof (TChannel) == typeof (IReplyChannel))
+                               return (TChannel) (object) new InterceptorReplyChannel (
+                                       (InterceptorChannelListener<IReplyChannel>) (object) this,
+                                       (IReplyChannel) (object) inner.EndAcceptChannel (result));
+                       throw new NotImplementedException ();
+               }
+
+
+               protected override bool OnWaitForChannel (TimeSpan timeout)
+               {
+                       return inner.WaitForChannel (timeout);
+               }
+
+               protected override IAsyncResult OnBeginWaitForChannel (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginWaitForChannel (timeout, callback, state);
+               }
+
+               protected override bool OnEndWaitForChannel (IAsyncResult result)
+               {
+                       return inner.EndWaitForChannel (result);
+               }
+
+
+               protected override void OnAbort ()
+               {
+                       inner.Abort ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       inner.Open (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginOpen (timeout, callback, state);
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       inner.EndOpen (result);
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       inner.Close (timeout);
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginClose (timeout, callback, state);
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       inner.EndClose (result);
+               }
+       }
+
+       class InterceptorRequestChannel : ChannelBase, IRequestChannel
+       {
+               InterceptorChannelFactory<IRequestChannel> source;
+               IRequestChannel inner;
+
+               public InterceptorRequestChannel (InterceptorChannelFactory<IRequestChannel> source, IRequestChannel inner)
+                       : base (source)
+               {
+                       this.source = source;
+                       this.inner = inner;
+               }
+
+               public EndpointAddress RemoteAddress {
+                       get { return inner.RemoteAddress; }
+               }
+
+               public Uri Via {
+                       get { return inner.Via; }
+               }
+
+               public Message Request (Message message)
+               {
+                       return inner.Request (message);
+               }
+               public Message Request (Message message, TimeSpan timeout)
+               {
+                       return inner.Request (message, timeout);
+               }
+               public IAsyncResult BeginRequest (Message message, AsyncCallback callback, object state)
+               {
+                       return inner.BeginRequest (message, callback, state);
+               }
+               public IAsyncResult BeginRequest (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginRequest (message, timeout, callback, state);
+               }
+               public Message EndRequest (IAsyncResult result)
+               {
+                       return inner.EndRequest (result);
+               }
+
+
+               protected override void OnAbort ()
+               {
+                       inner.Abort ();
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       inner.Open (timeout);
+               }
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginOpen (timeout, callback, state);
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       inner.EndOpen (result);
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       inner.Close (timeout);
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginClose (timeout, callback, state);
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       inner.EndClose (result);
+               }
+       }
+
+       class InterceptorReplyChannel : ReplyChannelBase
+       {
+               InterceptorChannelListener<IReplyChannel> source;
+               IReplyChannel inner;
+
+               public InterceptorReplyChannel (InterceptorChannelListener<IReplyChannel> source, IReplyChannel inner)
+                       : base (source)
+               {
+                       this.source = source;
+                       this.inner = inner;
+               }
+
+               public override EndpointAddress LocalAddress {
+                       get { return inner.LocalAddress; }
+               }
+
+               RequestContext Inspect (RequestContext src)
+               {
+                       CopyRequestContext ret = new CopyRequestContext (src);
+                       source.Element.Handler (ret.Buffer);
+                       return ret;
+               }
+
+               public override RequestContext ReceiveRequest ()
+               {
+                       return Inspect (inner.ReceiveRequest ());
+               }
+
+               public override RequestContext ReceiveRequest (TimeSpan timeout)
+               {
+                       return Inspect (inner.ReceiveRequest (timeout));
+               }
+
+               public override IAsyncResult BeginReceiveRequest (AsyncCallback callback, object state)
+               {
+                       return inner.BeginReceiveRequest (callback, state);
+               }
+
+               public override IAsyncResult BeginReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginReceiveRequest (timeout, callback, state);
+               }
+
+               public override RequestContext EndReceiveRequest (IAsyncResult result)
+               {
+                       return Inspect (inner.EndReceiveRequest (result));
+               }
+
+               public override bool TryReceiveRequest (TimeSpan timeout, out RequestContext context)
+               {
+                       if (inner.TryReceiveRequest (timeout, out context)) {
+                               context = Inspect (context);
+                               return true;
+                       }
+                       context = null;
+                       return false;
+               }
+
+               public override IAsyncResult BeginTryReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginTryReceiveRequest (timeout, callback, state);
+               }
+
+               public override bool EndTryReceiveRequest (IAsyncResult result, out RequestContext context)
+               {
+                       if (inner.EndTryReceiveRequest (result, out context)) {
+                               context = Inspect (context);
+                               return true;
+                       }
+                       context = null;
+                       return false;
+               }
+
+               public override bool WaitForRequest (TimeSpan timeout)
+               {
+                       return inner.WaitForRequest (timeout);
+               }
+
+               public override IAsyncResult BeginWaitForRequest (TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return inner.BeginWaitForRequest (timeout, callback, state);
+               }
+
+               public override bool EndWaitForRequest (IAsyncResult result)
+               {
+                       return inner.EndWaitForRequest (result);
+               }
+
+               protected override void OnAbort ()
+               {
+                       inner.Abort ();
+               }
+
+               protected override void OnClose (TimeSpan timeout)
+               {
+                       inner.Close (timeout);
+               }
+
+               protected override void OnOpen (TimeSpan timeout)
+               {
+                       inner.Open (timeout);
+               }
+       }
+
+       class CopyRequestContext : RequestContext
+       {
+               RequestContext src;
+               MessageBuffer buffer;
+               Message copy_msg;
+
+               public CopyRequestContext (RequestContext src)
+               {
+                       this.src = src;
+                       buffer = src.RequestMessage.CreateBufferedCopy (0x10000);
+                       copy_msg = buffer.CreateMessage ();
+               }
+
+               public MessageBuffer Buffer {
+                       get { return buffer; }
+               }
+
+               public override void Abort ()
+               {
+                       src.Abort ();
+               }
+
+               public override void Close ()
+               {
+                       src.Close ();
+               }
+
+               public override void Close (TimeSpan timeout)
+               {
+                       src.Close (timeout);
+               }
+
+               public override IAsyncResult BeginReply (Message message, AsyncCallback callback, object state)
+               {
+                       return src.BeginReply (message, callback, state);
+               }
+
+               public override IAsyncResult BeginReply (Message message, TimeSpan timeout, AsyncCallback callback, object state)
+               {
+                       return src.BeginReply (message, timeout, callback, state);
+               }
+
+               public override void EndReply (IAsyncResult result)
+               {
+                       src.EndReply (result);
+               }
+
+               public override void Reply (Message message)
+               {
+                       src.Reply (message);
+               }
+
+               public override void Reply (Message message, TimeSpan timeout)
+               {
+                       src.Reply (message, timeout);
+               }
+
+               public override Message RequestMessage {
+                       get { return copy_msg; }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/InvalidBindingElement.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/InvalidBindingElement.cs
new file mode 100644 (file)
index 0000000..62eda44
--- /dev/null
@@ -0,0 +1,62 @@
+//
+// InvalidBindingElement.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using NUnit.Framework;
+
+
+// This binding element class is for testing some bindings to check
+// invocation relationship.
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       public class InvalidBindingElement : BindingElement
+       {
+               public override BindingElement Clone ()
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
+                       BindingContext context)
+               {
+                       throw new NotSupportedException ();
+               }
+
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       return null;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/LocalClientSecuritySettingsTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/LocalClientSecuritySettingsTest.cs
new file mode 100644 (file)
index 0000000..0ca2d81
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// LocalClientSecuritySettingsTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class LocalClientSecuritySettingsTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       LocalClientSecuritySettings lc = new LocalClientSecuritySettings ();
+                       Assert.IsNotNull (lc, "#1");
+                       Assert.AreEqual (true, lc.CacheCookies, "#2");
+                       Assert.AreEqual (60, lc.CookieRenewalThresholdPercentage, "#3");
+                       Assert.AreEqual (true, lc.DetectReplays, "#4");
+                       Assert.AreEqual (TimeSpan.FromMinutes (5), lc.MaxClockSkew, "#5");
+                       Assert.AreEqual (TimeSpan.MaxValue, lc.MaxCookieCachingTime, "#6");
+                       Assert.AreEqual (true, lc.ReconnectTransportOnFailure, "#7");
+                       Assert.AreEqual (900000, lc.ReplayCacheSize, "#8");
+                       Assert.AreEqual (TimeSpan.FromMinutes (5), lc.ReplayWindow, "#9");
+                       Assert.AreEqual (TimeSpan.FromHours (10), lc.SessionKeyRenewalInterval, "#10");
+                       Assert.AreEqual (TimeSpan.FromMinutes (5), lc.SessionKeyRolloverInterval, "#11");
+                       Assert.AreEqual (TimeSpan.FromMinutes (5), lc.TimestampValidityDuration, "#12");
+                       // FIXME: IdentityVerifier
+                       Assert.IsNotNull (lc.IdentityVerifier, "#13");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageBufferTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageBufferTest.cs
new file mode 100644 (file)
index 0000000..7bf87c6
--- /dev/null
@@ -0,0 +1,196 @@
+using System;
+using System.IO;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+using System.Text;
+using System.Xml;
+using System.Xml.XPath;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class MessageBufferTest
+       {
+               [Test]
+               public void TestCreateNavigator ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "http://tempuri.org/");
+                       MessageBuffer mb = m.CreateBufferedCopy (1024);
+
+                       XPathNavigator nav = mb.CreateNavigator ();
+
+                       Assert.IsTrue (nav is SeekableXPathNavigator);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void TestCreateBufferedCopyTwice ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "action", 1);
+                       m.CreateBufferedCopy (64);
+                       m.CreateBufferedCopy (64);
+               }
+
+               [Test]
+               public void TestCreateMessage ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "action", 1);
+                       Message m2 = Message.CreateMessage (MessageVersion.Default, "action", 1);
+                       MessageBuffer mb = m.CreateBufferedCopy (64);
+
+                       Message n = mb.CreateMessage ();
+                       Assert.AreEqual (m2.ToString (), n.ToString (), "#2");
+               }
+
+               [Test, ExpectedException (typeof (ArgumentNullException))]
+               public void TestWriteMessageNull ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "action", 1);
+                       MessageBuffer mb = m.CreateBufferedCopy (64);
+
+                       mb.WriteMessage (null);
+               }
+               
+               [Test]
+               public void WriteMessageWithDictionaryWriter ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "action", 1);
+
+                       StringBuilder sb = new StringBuilder ();
+                       XmlWriter w = XmlWriter.Create (sb);
+                       XmlDictionaryWriter dw = XmlDictionaryWriter.CreateDictionaryWriter (w);                        
+                       m.WriteMessage (dw);
+                       dw.Close ();
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void TestWriteMessage ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "action", 1);
+                       Message n = Message.CreateMessage (MessageVersion.Default, "action", 1);
+                       Assert.AreEqual (m.ToString (), n.ToString ());
+
+                       // Write out a message using a Binary XmlDictionaryWriter
+                       MemoryStream ms = new MemoryStream ();
+                       XmlDictionaryWriter w = XmlDictionaryWriter.CreateBinaryWriter (ms);
+                       m.WriteMessage (w);
+                       w.Close ();
+                       ms.Close ();
+                       byte [] expected = ms.GetBuffer ();
+                       StringBuilder sb = new StringBuilder ();
+                       sb.AppendLine ("expected: " + expected.Length);
+
+                       for (int i = 0; i < 24; i++) {
+                               byte b = expected [i];
+                               sb.Append (String.Format ("{0:X02} ", b));
+                       }
+                       string exp = sb.ToString ();
+
+                       // Write out an equivalent MessageBuffer
+                       MessageBuffer mb = n.CreateBufferedCopy (1024);
+                       sb = new StringBuilder ();
+                       ms = new MemoryStream ();
+                       mb.WriteMessage (ms);
+                       ms.Close ();
+                       byte [] actual = ms.GetBuffer ();
+                       sb.AppendLine ("actual: " + actual.Length);
+                       for (int i = 0; i < 24; i++) {
+                               byte b = actual [i];
+                               sb.Append (String.Format ("{0:X02} ", b));
+                       }
+                       string act = sb.ToString ();
+
+//                     Console.WriteLine (exp + "\n" + act);
+
+                       // So the lengths of the buffer are the same....
+                       Assert.AreEqual (expected.Length, actual.Length);
+
+                       // TODO: 
+                       // There are three possible XmlDictionaryWriters:
+                       // Binary, Dictionary, Mtom
+                       // 
+                       // It doesn't have a MIME type header, so it's definitely not Mtom.
+                       // Dictionary outputs text, so it's not that either.
+                       // It's got to be the Binary one.
+                       //
+                       // But the content differs, why? 
+
+                       // FIXME: we don't have AreNotEqual
+                       // Assert.AreNotEqual (expected, actual);
+               }
+               
+               [Test]
+               public void TestEmptyMessageBuffer ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, String.Empty);
+                       MessageBuffer b = m.CreateBufferedCopy (0);
+
+                       Assert.IsTrue (m.IsEmpty, "#1");
+                       Assert.AreEqual (0, b.BufferSize, "#2");
+                       Assert.AreEqual ("application/soap+msbin1", b.MessageContentType, "#3");
+               }
+
+               [Test]
+               public void TestSimpleMessageBuffer ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, 
+                                                          String.Empty,
+                                                          new MyBodyWriter ());
+                       MessageBuffer b = m.CreateBufferedCopy (Int32.MaxValue);
+
+                       Assert.IsFalse (m.IsEmpty, "#1");
+                       Assert.AreEqual (0, b.BufferSize, "#2");
+                       Assert.AreEqual ("application/soap+msbin1", b.MessageContentType, "#3");
+                       // BodyWriter must not be used twice.
+                       using (XmlWriter w = XmlWriter.Create (TextWriter.Null)) {
+                               b.CreateMessage ().WriteMessage (w);
+                       }
+                       using (XmlWriter w = XmlWriter.Create (TextWriter.Null)) {
+                               b.CreateMessage ().WriteMessage (w);
+                       }
+               }
+
+               [Test, ExpectedException (typeof (ObjectDisposedException))]
+               public void TestCreateMessageFromClosedBuffer ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, String.Empty);
+                       MessageBuffer b = m.CreateBufferedCopy (0);
+
+                       b.Close ();
+                       b.CreateMessage ();
+               }
+
+               [Test, ExpectedException (typeof (InvalidOperationException))]
+               public void CreateBufferedCopyConsumesMessage ()
+               {
+                       Message msg = Message.CreateMessage (
+                               MessageVersion.Default, "foo", new MyBodyWriter ());
+                       MessageBuffer buf = msg.CreateBufferedCopy (1);
+                       // This WriteMessage() complains that the Message
+                       // is already consumed.
+                       using (XmlWriter w = XmlWriter.Create (TextWriter.Null)) {
+                               msg.WriteMessage (w);
+                       }
+               }
+       }
+
+       internal class MyBodyWriter : BodyWriter
+       {
+               bool done;
+
+               internal MyBodyWriter ()
+                       : base (false)
+               {
+               }
+
+               protected override void OnWriteBodyContents (XmlDictionaryWriter writer)
+               {
+                       if (done)
+                               Assert.Fail ("Allow two or more write.");
+                       done = true;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageEncoderTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageEncoderTest.cs
new file mode 100644 (file)
index 0000000..dc7756e
--- /dev/null
@@ -0,0 +1,112 @@
+//
+// MessageEncoderTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using NUnit.Framework;
+
+using TextElement = System.ServiceModel.Channels.TextMessageEncodingBindingElement;
+using BinaryElement = System.ServiceModel.Channels.BinaryMessageEncodingBindingElement;
+using MtomElement = System.ServiceModel.Channels.MtomMessageEncodingBindingElement;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class MessageEncoderTest
+       {
+               class MyEncodingBindingElement : MessageEncodingBindingElement
+               {
+                       public override BindingElement Clone ()
+                       {
+                               throw new Exception ();
+                       }
+
+                       public override T GetProperty<T> (BindingContext ctx)
+                       {
+                               throw new Exception ();
+                       }
+
+                       public override MessageEncoderFactory CreateMessageEncoderFactory ()
+                       {
+                               throw new Exception ();
+                       }
+
+                       public override MessageVersion MessageVersion {
+                               get { throw new Exception (); }
+                               set { throw new Exception (); }
+                       }
+               }
+
+               [Test]
+               public void Properties ()
+               {
+                       MessageEncoder t = new TextElement ().CreateMessageEncoderFactory ().Encoder;
+                       MessageEncoder b = new BinaryElement ().CreateMessageEncoderFactory ().Encoder;
+                       MessageEncoder m = new MtomElement ().CreateMessageEncoderFactory ().Encoder;
+
+                       // TextMessageEncodingBindingElement.WriteEncoding
+                       // default value is UTF8.
+                       ServiceAssert.AssertMessageEncoder (
+                               // Those curly double quotations are smelly, very implementation specific.
+                               "application/soap+xml; charset=utf-8", "application/soap+xml",
+                               MessageVersion.Default, t, "Text");
+                       ServiceAssert.AssertMessageEncoder (
+                               "application/soap+msbin1", "application/soap+msbin1",
+                               MessageVersion.Default, b, "Binary");
+                       ServiceAssert.AssertMessageEncoder (
+                               "multipart/related; type=\"application/xop+xml\"", "multipart/related",
+                               MessageVersion.Default, m, "Mtom");
+
+                       MessageEncoder t2 = new TextElement (
+                               MessageVersion.Soap11WSAddressing10,
+                               Encoding.UTF8)
+                               .CreateMessageEncoderFactory ().Encoder;
+
+                       ServiceAssert.AssertMessageEncoder (
+                               // Those curly double quotations are smelly, very implementation specific.
+                               "text/xml; charset=utf-8", "text/xml",
+                               MessageVersion.Soap11WSAddressing10, t2, "Text2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ProtocolException))]
+               public void MessageVersionMismatch ()
+               {
+                       Message msg = Message.CreateMessage (
+                               // ... while BasicHttpBinding expects Soap11.
+                               MessageVersion.Soap11WSAddressing10,
+                               "http://tempuri.org/IFoo/Echo", "TEST");
+                       MessageEncoderFactory f = new TextMessageEncodingBindingElement (MessageVersion.Soap11, Encoding.UTF8).CreateMessageEncoderFactory ();
+                       f.Encoder.WriteMessage (msg, new MemoryStream ());
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageEncodingBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageEncodingBindingElementTest.cs
new file mode 100644 (file)
index 0000000..6c6140a
--- /dev/null
@@ -0,0 +1,121 @@
+//
+// TextMessageEncodingBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using NUnit.Framework;
+
+using Element = System.ServiceModel.Channels.TextMessageEncodingBindingElement;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class MessageEncodingBindingElementTest
+       {
+               class MyEncodingBindingElement : MessageEncodingBindingElement
+               {
+                       public override BindingElement Clone ()
+                       {
+                               throw new Exception ();
+                       }
+
+                       public override T GetProperty<T> (BindingContext ctx)
+                       {
+                               throw new Exception ();
+                       }
+
+                       public override MessageEncoderFactory CreateMessageEncoderFactory ()
+                       {
+                               throw new Exception ();
+                       }
+
+                       public override MessageVersion MessageVersion {
+                               get { throw new Exception (); }
+                               set { throw new Exception (); }
+                       }
+               }
+
+               [Test]
+               public void BuildChannelFactory1 ()
+               {
+                       MessageEncodingBindingElement be =
+                               new TextMessageEncodingBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (
+                                       new HttpTransportBindingElement ()),
+                               new BindingParameterCollection ());
+                       // hmm, it returns HttpChannelFactory, not sure
+                       // if TextMessageEncodingBindingElement is considered.
+                       be.BuildChannelFactory<IRequestChannel> (ctx);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void BuildChannelFactoryFail1 ()
+               {
+                       MessageEncodingBindingElement be =
+                               new TextMessageEncodingBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               // no transport -> fail
+                               new CustomBinding (),
+                               new BindingParameterCollection ());
+                       be.BuildChannelFactory<IRequestChannel> (ctx);
+               }
+
+               [Test]
+               public void BuildChannelFactory2 ()
+               {
+                       MessageEncodingBindingElement be =
+                               new MyEncodingBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (
+                                       new HttpTransportBindingElement ()),
+                               new BindingParameterCollection ());
+                       // hmm, it returns HttpChannelFactory, not sure
+                       // if TextMessageEncodingBindingElement is considered.
+                       be.BuildChannelFactory<IRequestChannel> (ctx);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void BuildChannelFactoryFail2 ()
+               {
+                       MessageEncodingBindingElement be =
+                               new MyEncodingBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               // no transport -> fail
+                               new CustomBinding (
+                                       new TextMessageEncodingBindingElement ()),
+                               new BindingParameterCollection ());
+                       be.BuildChannelFactory<IRequestChannel> (ctx);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageHeaderTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageHeaderTest.cs
new file mode 100644 (file)
index 0000000..7b3e8bf
--- /dev/null
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Text;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class MessageHeaderTest
+       {
+               [Test]
+               public void TestDefaultValues ()
+               {
+                       MessageHeader h = MessageHeader.CreateHeader ("foo", "bar", 1);
+                       Assert.AreEqual (String.Empty, h.Actor);
+                       Assert.IsFalse (h.MustUnderstand);
+                       Assert.IsFalse (h.Relay);
+               }
+
+               [Test]
+               public void TestIsMessageVersionSupported ()
+               {
+                       MessageHeader h;
+
+                       // by default, both versions are supported.
+                       h = MessageHeader.CreateHeader ("foo", "bar", 1);
+                       Assert.IsTrue (h.IsMessageVersionSupported (MessageVersion.Soap11WSAddressing10), "#1");
+                       Assert.IsTrue (h.IsMessageVersionSupported (MessageVersion.Soap12WSAddressing10), "#2");
+
+                       // SOAP 1.1 is not supported if Actor == Soap12.NextDestinationActorValue
+                       h = MessageHeader.CreateHeader ("foo", "bar", 1, false, MessageVersion.Soap12WSAddressing10.Envelope.NextDestinationActorValue);
+                       Assert.IsFalse (h.IsMessageVersionSupported (MessageVersion.Soap11WSAddressing10), "#3");
+                       Assert.IsTrue (h.IsMessageVersionSupported (MessageVersion.Soap12WSAddressing10), "#4");
+
+                       // SOAP 1.1 is not supported if Actor == Soap12's UltimateDestinationActor
+                       h = MessageHeader.CreateHeader ("foo", "bar", 1, false, MessageVersion.Soap12WSAddressing10.Envelope.GetUltimateDestinationActorValues () [1]);
+                       Assert.IsFalse (h.IsMessageVersionSupported (MessageVersion.Soap11WSAddressing10), "#5");
+                       Assert.IsTrue (h.IsMessageVersionSupported (MessageVersion.Soap12WSAddressing10), "#6");
+
+                       // SOAP 1.2 is not supported if Actor == Soap11.NextDestinationActorValue
+                       h = MessageHeader.CreateHeader ("foo", "bar", 1, false, MessageVersion.Soap11WSAddressing10.Envelope.NextDestinationActorValue);
+                       Assert.IsTrue (h.IsMessageVersionSupported (MessageVersion.Soap11WSAddressing10), "#7");
+                       Assert.IsFalse (h.IsMessageVersionSupported (MessageVersion.Soap12WSAddressing10), "#8");
+               }
+
+               [Test]
+               public void TestToString ()
+               {
+                       MessageHeader h = MessageHeader.CreateHeader ("foo", "bar", 1);
+                       StringBuilder sb = new StringBuilder ();
+                       XmlWriterSettings settings = new XmlWriterSettings ();
+                       settings.OmitXmlDeclaration = true;
+                       settings.Indent = true;
+
+                       XmlWriter w = XmlWriter.Create (sb, settings);
+
+                       h.WriteHeader (w, MessageVersion.Soap12WSAddressing10);
+                       w.Close ();
+                       
+                       // ToString is the same as WriteHeader (minus the XML declaration)
+                       Assert.AreEqual (sb.ToString (), h.ToString ());
+               }
+
+               [Test]
+               public void TestWriteStartHeader ()
+               {
+                       int value = 1;
+
+                       MessageHeader h = MessageHeader.CreateHeader ("foo", "bar", value);                        
+
+                       StringBuilder sb = new StringBuilder ();                                            
+                       XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter (
+                               XmlWriter.Create (sb));                     
+                       h.WriteStartHeader (w, MessageVersion.Soap12WSAddressing10);
+                       w.Close ();
+                       string actual = sb.ToString ();
+                       
+                       sb = new StringBuilder ();
+                       XmlWriter w2 = XmlWriter.Create (sb);
+                       w2.WriteStartElement (h.Name, h.Namespace);
+                       w2.Close ();
+                       string expected = sb.ToString ();
+
+                       // WriteStartHeader == WriteStartElement (msg.Name, msg.Namespace)
+                       Assert.AreEqual (expected, actual);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void TestWriteHeaderContent ()
+               {
+                       int value = 1;
+
+                       MessageHeader h = MessageHeader.CreateHeader ("foo", "bar", value);
+                       XmlObjectSerializer f = new DataContractSerializer (typeof (int));
+
+                       StringBuilder sb = new StringBuilder ();
+                       XmlWriterSettings settings = new XmlWriterSettings ();
+                       settings.ConformanceLevel = ConformanceLevel.Auto;                        
+                       XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter (
+                               XmlWriter.Create (sb, settings));
+
+                       w.WriteStartElement ("dummy-root");
+                       h.WriteHeaderContents (w, MessageVersion.Soap12WSAddressing10);
+                       w.WriteEndElement ();
+                       w.Flush ();
+                       string actual = sb.ToString ();
+
+                       f.WriteObject (w, value);
+                       string expected = sb.ToString ();
+
+                       // the output of WriteHeaderContent is the same as XmlSerializer.Serialize
+                       Assert.AreEqual (expected, actual);
+               }
+
+               [Test]
+               public void TestWriteHeaderAttributes ()
+               {
+                       MessageHeader h = MessageHeader.CreateHeader ("foo", "bar", 1, 
+                               true, "some actor", true);
+                       StringBuilder sb = new StringBuilder ();                
+                       XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (sb));
+                      
+                       h.WriteStartHeader (w, MessageVersion.Soap12WSAddressing10);
+                       w.WriteEndElement ();
+                       w.Close ();
+               }
+
+               [Test]
+               public void TestGenericConstructor ()
+               {
+                       MessageHeader<int> h = new MessageHeader<int> ();
+
+                       Assert.AreEqual (null, h.Actor);
+                       Assert.AreEqual (default (int), h.Content);
+                       Assert.IsFalse (h.MustUnderstand);
+                       Assert.IsFalse (h.Relay);
+               }
+
+               [Test]
+               public void CreateEndpointAddressTypeHeader ()
+               {
+                       MessageHeader.CreateHeader (
+                               "ReplyTo",
+                               "http://www.w3.org/2005/08/addressing",
+                               new EndpointAddress ("http://localhost:8080"));
+                       MessageHeader.CreateHeader (
+                               "ReplyTo",
+                               "http://www.w3.org/2005/08/addressing",
+                               new EndpointAddress ("http://localhost:8080"),
+                               new DataContractSerializer (typeof (EndpointAddress)));
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageHeadersTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageHeadersTest.cs
new file mode 100644 (file)
index 0000000..d9e9101
--- /dev/null
@@ -0,0 +1,393 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Text;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class MessageHeadersTest
+       {
+               string wsa1 = "http://www.w3.org/2005/08/addressing";
+
+               [Test] // it is somehow allowed ...
+               public void AddDuplicate ()
+               {
+                       MessageHeaders headers = new MessageHeaders (MessageVersion.Default);
+                       headers.Add (MessageHeader.CreateHeader ("Action", wsa1, "urn:foo"));
+                       headers.Add (MessageHeader.CreateHeader ("Action", wsa1, "urn:bar"));
+               }
+
+               [Test]
+               public void AddDuplicate2 ()
+               {
+                       MessageHeaders headers = new MessageHeaders (MessageVersion.Default);
+                       headers.Add (MessageHeader.CreateHeader ("Action", wsa1, "urn:foo", true, "whoa"));
+                       headers.Add (MessageHeader.CreateHeader ("Action", wsa1, "urn:bar", true, "whee"));
+               }
+
+               [Test]
+               public void TestConstructor ()
+               {
+                       MessageHeaders headers = new MessageHeaders (MessageVersion.Soap12WSAddressing10);
+                       Assert.AreEqual (0, headers.Count);
+
+                       headers = new MessageHeaders (MessageVersion.Default);
+                       Assert.AreEqual (0, headers.Count);
+               }
+
+               [Test]
+               public void TestFindHeader ()
+               {
+                       // <a:Action mU="true">test</a:Action>
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+                       Assert.AreEqual (1, m.Headers.Count, "#0");
+
+                       // <MyHeader xmlns="bar">1</MyHeader>
+                       m.Headers.Add (MessageHeader.CreateHeader ("MyHeader", "bar", 1));
+                       // <MyHeader xmlns="baz" role="john">1</MyHeader>
+                       m.Headers.Add (MessageHeader.CreateHeader ("MyHeader", "baz", 1, false, "john"));
+
+                       MessageHeaders headers = m.Headers;
+                       // The first header is at 0
+                       Assert.AreEqual (0, headers.FindHeader ("Action",
+                                                               "http://www.w3.org/2005/08/addressing"), "#1");
+
+                       // The return value of FindHeader maps to its places in the headers
+                       Assert.AreEqual (1, headers.FindHeader ("MyHeader", "bar"), "#2");
+
+                       // If a header has actor (role) specified, then it must be provided
+                       Assert.AreEqual (-1, headers.FindHeader ("MyHeader", "baz"), "#3");
+                       Assert.AreEqual (2, headers.FindHeader ("MyHeader", "baz", "john"), "#4");
+               }
+
+               [Test]
+               public void TestFindHeaderWithMultipleIdenticalHeaders ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+                       m.Headers.Add (MessageHeader.CreateHeader (
+                               "Action", "http://schemas.xmlsoap.org/ws/2004/08/addressing", 1));
+
+                       MessageHeaders headers = m.Headers;
+
+                       headers.FindHeader ("Action", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
+               }
+
+               [Test]
+               public void TestGetHeader ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+                       MessageHeaders headers = m.Headers;
+
+                       Assert.AreEqual ("test", headers.GetHeader<string> (0));
+               }
+
+               [Test, ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void TestGetHeaderOutOfRange ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+                       MessageHeaders headers = m.Headers;
+
+                       Assert.AreEqual ("test", headers.GetHeader<int> (1));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void GetHeaderNullSerializer ()
+               {
+                       MessageHeaders headers = new MessageHeaders (MessageVersion.Default);
+                       string ns = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
+                       headers.Add (MessageHeader.CreateHeader ("Action", ns, "urn:foo"));
+                       headers.GetHeader<string> (0, null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void GetHeaderNullSerializer2 ()
+               {
+                       MessageHeaders headers = new MessageHeaders (MessageVersion.Default);
+                       string ns = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
+                       headers.Add (MessageHeader.CreateHeader ("Action", ns, "urn:foo"));
+                       headers.GetHeader<string> ("Action", ns, (XmlObjectSerializer) null);
+               }
+
+               [Test, ExpectedException (typeof (MessageHeaderException))]
+               public void TestGetHeaderNonexistent ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+                       MessageHeaders headers = m.Headers;
+
+                       headers.GetHeader<string>("name", "namespace");
+               }
+
+               [Test]
+               public void TestInsert ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+
+                       m.Headers.Add (MessageHeader.CreateHeader ("FirstHeader", "ns", "first"));
+                       Assert.AreEqual (1, m.Headers.FindHeader ("FirstHeader", "ns"));
+
+                       m.Headers.Insert (1, MessageHeader.CreateHeader ("InsertedHeader", "ns", "insert"));
+                       
+                       Assert.AreEqual (1, m.Headers.FindHeader ("InsertedHeader", "ns"));
+                       Assert.AreEqual (2, m.Headers.FindHeader ("FirstHeader", "ns"));
+               }
+
+               [Test]
+               public void TestWriteStartHeaderSimple ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+                       MessageHeader h = MessageHeader.CreateHeader ("FirstHeader", "ns", "first");
+                       m.Headers.Add (h);
+
+                       StringBuilder sb = new StringBuilder ();
+                       XmlWriterSettings s = new XmlWriterSettings ();
+                       s.ConformanceLevel = ConformanceLevel.Fragment;
+                       XmlWriter w = XmlWriter.Create (sb, s);
+                       XmlDictionaryWriter dw = XmlDictionaryWriter.CreateDictionaryWriter (w);
+                       m.Headers.WriteStartHeader (1, dw);
+                       dw.Close ();
+                       w.Close ();
+                       string actual = sb.ToString ();
+
+                       sb = new StringBuilder ();
+                       w = XmlWriter.Create (sb, s);
+                       dw = XmlDictionaryWriter.CreateDictionaryWriter (w);                    
+                       h.WriteStartHeader (dw, MessageVersion.Soap12WSAddressing10);
+                       dw.Close ();
+                       w.Close ();
+                       string expected = sb.ToString (); 
+
+                       
+                       Assert.AreEqual (expected, actual);
+               }
+
+               [Test]
+               public void TestWriteStartHeaderWithActor ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+                       MessageHeader h = MessageHeader.CreateHeader ("FirstHeader", "ns", "first", true, "actor");
+                       m.Headers.Add (h);
+
+                       StringBuilder sb = new StringBuilder ();
+                       XmlWriterSettings s = new XmlWriterSettings ();
+                       s.ConformanceLevel = ConformanceLevel.Fragment;
+                       XmlWriter w = XmlWriter.Create (sb, s);
+                       XmlDictionaryWriter dw = XmlDictionaryWriter.CreateDictionaryWriter (w);
+                       m.Headers.WriteStartHeader (1, dw);
+                       dw.Close ();
+                       w.Close ();
+                       string actual = sb.ToString ();
+
+                       sb = new StringBuilder ();
+                       w = XmlWriter.Create (sb, s);
+                       dw = XmlDictionaryWriter.CreateDictionaryWriter (w);
+                       h.WriteStartHeader (dw, MessageVersion.Soap12WSAddressing10);
+                       dw.Close ();
+                       w.Close ();
+                       string expected = sb.ToString ();
+
+                       Assert.AreEqual (expected, actual);
+               }
+
+               [Test]
+               public void TestWriteHeaderContents ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+
+                       m.Headers.Add (MessageHeader.CreateHeader ("FirstHeader", "ns", "first"));
+                       Assert.AreEqual (1, m.Headers.FindHeader ("FirstHeader", "ns"));
+
+                       m.Headers.Add (MessageHeader.CreateHeader ("SecondHeader", "ns", 2));
+
+                       StringBuilder sb = new StringBuilder ();
+                       // Even if XmlWriter is allowed to write fragment,
+                       // DataContractSerializer never allows it to write
+                       // content in contentOnly mode.
+                       XmlWriterSettings settings = new XmlWriterSettings ();
+                       settings.OmitXmlDeclaration = true;
+                       //settings.ConformanceLevel = ConformanceLevel.Fragment;
+                       XmlWriter w = XmlWriter.Create (sb, settings);
+                       w.WriteStartElement ("root");
+                       w.WriteStartElement ("HEADER1");
+                       m.Headers.WriteHeaderContents (1, w);
+                       w.WriteEndElement ();
+                       w.WriteStartElement ("HEADER2");
+                       m.Headers.WriteHeaderContents (2, w);
+                       w.WriteEndElement ();
+                       w.WriteEndElement ();
+                       w.Close ();
+                       
+                       Assert.AreEqual ("<root><HEADER1>first</HEADER1><HEADER2>2</HEADER2></root>", sb.ToString ());
+               }
+
+               [Test]
+               [Ignore ("I believe that with AddressingVersion.None it should not output any mustUnderstand addressing headers.")]
+               public void WriteHeaderContentsAddressingNone ()
+               {
+                       // This Action header is IMO extraneous.
+                       string xml = "<?xml version=\"1.0\" encoding=\"utf-16\"?><s:Envelope xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\"><s:Header><Action s:mustUnderstand=\"1\" xmlns=\"http://schemas.microsoft.com/ws/2005/08/addressing/none\">Echo</Action></s:Header><s:Body xmlns=\"http://tempuri.org/\"><Echo xmlns=\"http://tempuri.org/\" /></s:Body></s:Envelope>";
+                       Message m = Message.CreateMessage (MessageVersion.Soap12, "Echo", (object) null);
+                       StringWriter sw = new StringWriter ();
+                       using (XmlWriter w = XmlWriter.Create (sw)) {
+                               m.WriteMessage (w);
+                       }
+                       Assert.AreEqual (xml, sw.ToString ());
+               }
+
+               [Test]
+               public void TestAction ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+                       m.Headers.Add (MessageHeader.CreateHeader ("FirstHeader", "ns", "first"));
+                       Assert.AreEqual ("test", m.Headers.Action, "#1");
+
+                       MessageHeaders headers = new MessageHeaders (MessageVersion.Default, 1);
+                       Assert.AreEqual (null, headers.Action, "#2");
+                       headers.Add (MessageHeader.CreateHeader ("Action", "http://www.w3.org/2005/08/addressing", "test"));
+
+                       MessageHeaderInfo info = headers [0];
+                       Assert.AreEqual ("Action", info.Name, "#2-1");
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing", info.Namespace, "#2-2");
+                       Assert.AreEqual (false, info.MustUnderstand, "#2-3");
+                       Assert.AreEqual (String.Empty, info.Actor, "#2-4");
+
+                       Assert.AreEqual ("test", headers.Action, "#3");
+                       headers.Clear ();
+                       Assert.AreEqual (null, headers.Action, "#4");
+               }
+
+               [Test]
+               public void MessageCreateAddsAction ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+                       MessageHeaderInfo info = m.Headers [0];
+                       Assert.AreEqual ("Action", info.Name, "#1");
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing", info.Namespace, "#2");
+                       Assert.AreEqual (true, info.MustUnderstand, "#3");
+                       Assert.AreEqual (String.Empty, info.Actor, "#4");
+               }
+
+               [Test]
+               public void GetReaderAtHeader ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "test", 1);
+                       XmlDictionaryReader r = m.Headers.GetReaderAtHeader (0);
+
+                       XmlDictionaryReader r2 = m.Headers.GetReaderAtHeader (0);
+                       using (XmlWriter x = XmlWriter.Create (TextWriter.Null)) {
+                               r2.MoveToContent ();
+                               while (!r2.EOF)
+                                       x.WriteNode (r2, false);
+                       }
+
+                       /*
+                       // Seems like there is some attribute order differences 
+                       // in XmlDictionaryReader or XmlWriter, so don't compare
+                       // XML in raw strings.
+
+                       StringWriter sw = new StringWriter ();
+                       XmlWriterSettings settings = new XmlWriterSettings ();
+                       settings.OmitXmlDeclaration = true;
+                       settings.ConformanceLevel = ConformanceLevel.Fragment;
+                       XmlWriter w = XmlWriter.Create (sw, settings);
+                       Assert.AreEqual (ReadState.Interactive, r.ReadState, "#1-1");
+                       Assert.AreEqual (XmlNodeType.Element, r.NodeType, "#1-2");
+                       while (!r.EOF)
+                               w.WriteNode (r, false);
+                       w.Flush ();
+                       Assert.AreEqual ("<Action a:mustUnderstand=\"1\" xmlns=\"http://www.w3.org/2005/08/addressing\" xmlns:a=\"http://www.w3.org/2003/05/soap-envelope\">test</Action>", sw.ToString (), "#2");
+                       */
+                       Assert.AreEqual (ReadState.Interactive, r.ReadState, "#1-1");
+                       Assert.AreEqual (XmlNodeType.Element, r.NodeType, "#1-2");
+                       Assert.AreEqual ("Action", r.LocalName, "#1-3");
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing", r.NamespaceURI, "#1-4");
+                       Assert.AreEqual ("1", r.GetAttribute ("mustUnderstand", "http://www.w3.org/2003/05/soap-envelope"), "#1-5");
+                       Assert.AreEqual ("test", r.ReadElementContentAsString (), "#1-6");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void GetReaderAtHeaderOutOfRange ()
+               {
+                       MessageHeaders h = new MessageHeaders (MessageVersion.Default, 1);
+                       h.GetReaderAtHeader (0);
+               }
+
+               // I doubt things wrt this work fine on WinFX; sometimes it
+               // does *not* raise an error, while sometimes it does. And it
+               // is basically consistent on every run against the same
+               // *_test.dll binary. Huh.
+               [Test]
+               [ExpectedException (typeof (MessageHeaderException))] // multiple headers: "Action"
+               [Category ("NotWorking")]
+               public void CopyHeadersFrom ()
+               {
+                       Message msg = Message.CreateMessage (MessageVersion.Default, "urn:myaction");
+                       Message msg2 = Message.CreateMessage (MessageVersion.Default, "urn:myaction2");
+                       msg2.Headers.CopyHeadersFrom (msg);
+                       Assert.AreEqual ("urn:myaction2", msg2.Headers.Action);
+               }
+
+               [Test]
+               public void AddressingNoneAndAction ()
+               {
+                       MessageHeaders h = new MessageHeaders (MessageVersion.Soap12);
+                       h.Action = "urn:foo";
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddressingNoneAndFrom ()
+               {
+                       MessageHeaders h = new MessageHeaders (MessageVersion.Soap12);
+                       h.From = new EndpointAddress ("http://localhost:8080");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddressingNoneAndFaultTo ()
+               {
+                       MessageHeaders h = new MessageHeaders (MessageVersion.Soap12);
+                       h.FaultTo = new EndpointAddress ("http://localhost:8080");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddressingNoneAndMessageId ()
+               {
+                       MessageHeaders h = new MessageHeaders (MessageVersion.Soap12);
+                       h.MessageId = new UniqueId (Guid.NewGuid ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddressingNoneAndRelatesTo ()
+               {
+                       MessageHeaders h = new MessageHeaders (MessageVersion.Soap12);
+                       h.RelatesTo = new UniqueId (Guid.NewGuid ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddressingNoneAndReplyTo ()
+               {
+                       MessageHeaders h = new MessageHeaders (MessageVersion.Soap12);
+                       h.ReplyTo = new EndpointAddress ("http://localhost:8080");
+               }
+
+               [Test]
+               public void AddressingNoneAndTo ()
+               {
+                       MessageHeaders h = new MessageHeaders (MessageVersion.Soap12);
+                       h.To = new Uri ("http://localhost:8080");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageTest.cs
new file mode 100644 (file)
index 0000000..880f70e
--- /dev/null
@@ -0,0 +1,323 @@
+//
+// MessageTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Globalization;
+using System.IO;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class MessageTest
+       {
+               public static string GetSerializedMessage (Message msg)
+               {
+                       StringWriter sw = new StringWriter ();
+                       XmlWriterSettings settings = new XmlWriterSettings ();
+                       settings.OmitXmlDeclaration = true;
+                       using (XmlWriter xw = XmlWriter.Create (sw, settings)) {
+                               msg.WriteMessage (xw);
+                       }
+                       return sw.ToString ();
+               }
+
+               [Test]
+               public void CreateNullAction ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       using (XmlWriter w = XmlWriter.Create (sw)) {
+                               Message.CreateMessage (MessageVersion.Default, (string) null).WriteMessage (w);
+                       }
+                       Assert.IsTrue (sw.ToString ().IndexOf ("Action") < 0);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CreateNullVersion ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       Message.CreateMessage (null, "http://tempuri.org/MyAction");
+               }
+
+               [Test]
+               public void CreateSimpleAndWrite ()
+               {
+                       string xml = @"<s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://www.w3.org/2003/05/soap-envelope""><s:Header><a:Action s:mustUnderstand=""1"">Ack</a:Action></s:Header><s:Body /></s:Envelope>";
+
+                       Message msg = Message.CreateMessage (
+                               MessageVersion.Default, "Ack");
+                       // It should be XML comparison, not string comparison
+                       Assert.AreEqual (xml, GetSerializedMessage (msg));
+               }
+
+               [Test]
+               public void CreateSimpleNonPrimitive ()
+               {
+                       string xml = @"<s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://www.w3.org/2003/05/soap-envelope""><s:Header><a:Action s:mustUnderstand=""1"">Sample1</a:Action></s:Header><s:Body><MessageTest.Sample1 xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.datacontract.org/2004/07/MonoTests.System.ServiceModel.Channels""><Member1>member1</Member1><Member2><Member>sample2 member</Member></Member2></MessageTest.Sample1></s:Body></s:Envelope>";
+
+                       Message msg = Message.CreateMessage (
+                               MessageVersion.Default, "Sample1", new Sample1 ());
+                       // It should be XML comparison, not string comparison
+                       Assert.AreEqual (xml, GetSerializedMessage (msg));
+               }
+
+               [DataContract]
+               class Sample1
+               {
+                       [DataMember]
+                       public string Member1 = "member1";
+
+                       [DataMember]
+                       public Sample2 Member2 = new Sample2 ();
+               }
+
+               [DataContract]
+               class Sample2
+               {
+                       [DataMember]
+                       public string Member = "sample2 member";
+               }
+
+               [Test]
+               public void CreateSimpleSoap11WSA1_0 ()
+               {
+                       string xml = @"<s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/""><s:Header><a:Action s:mustUnderstand=""1"">http://tempuri.org/IFoo/Echo</a:Action></s:Header><s:Body><string xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">hoge</string></s:Body></s:Envelope>";
+
+                       Message msg = Message.CreateMessage (
+                               MessageVersion.Soap11WSAddressing10,
+                               "http://tempuri.org/IFoo/Echo",
+                               "hoge");
+                       // It should be XML comparison, not string comparison
+                       Assert.AreEqual (xml, GetSerializedMessage (msg));
+               }
+
+               [Test]
+               public void CreateFaultMessageAndWrite ()
+               {
+                       string xml = @"<s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://www.w3.org/2003/05/soap-envelope""><s:Header><a:Action s:mustUnderstand=""1"">http://www.w3.org/2005/08/addressing/fault</a:Action></s:Header><s:Body><s:Fault><s:Code><s:Value xmlns:a=""urn:me"">a:me</s:Value></s:Code><s:Reason><s:Text xml:lang="""">am so lazy</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>";
+
+                       FaultCode fc = new FaultCode ("me", "urn:me");
+                       FaultReasonText ft = new FaultReasonText ("am so lazy", CultureInfo.InvariantCulture);
+                       Message msg = Message.CreateMessage (
+                               MessageVersion.Default,
+                               MessageFault.CreateFault (fc, new FaultReason (ft)),
+                               "http://www.w3.org/2005/08/addressing/fault");
+                       // It should be XML comparison, not string comparison
+                       Assert.AreEqual (xml, GetSerializedMessage (msg));
+               }
+
+               [Test]
+               public void CreateAndWriteBodyObject ()
+               {
+                       string xml = @"<s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://www.w3.org/2003/05/soap-envelope""><s:Header><a:Action s:mustUnderstand=""1"">Ack</a:Action></s:Header><s:Body><string xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">TEST</string></s:Body></s:Envelope>";
+
+                       Message msg = Message.CreateMessage (
+                               MessageVersion.Default, "Ack", "TEST");
+                       // It should be XML comparison, not string comparison
+                       Assert.AreEqual (xml, GetSerializedMessage (msg));
+               }
+
+               // From XmlReader
+
+               [Test]
+               public void CreateFromXmlReader ()
+               {
+                       string xml = @"<s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://www.w3.org/2003/05/soap-envelope""><s:Header><a:Action s:mustUnderstand=""1"">Ack</a:Action><TestHeaderItem>test</TestHeaderItem></s:Header><s:Body></s:Body></s:Envelope>";
+
+                       XmlReader r = XmlReader.Create (new StringReader (xml));
+                       Message msg = Message.CreateMessage (r, 10000, MessageVersion.Default);
+                       Assert.AreEqual (MessageVersion.Default, msg.Version, "#2");
+                       Assert.AreEqual (2, msg.Headers.Count, "#4");
+                       Assert.AreEqual ("Ack", msg.Headers.Action, "#3");
+                       Assert.IsNull (msg.Headers.FaultTo, "#5");
+                       Assert.IsNull (msg.Headers.From, "#6");
+                       Assert.IsNull (msg.Headers.MessageId, "#7");
+                       Assert.IsTrue (msg.IsEmpty, "#8");
+
+                       MessageHeaderInfo hi = msg.Headers [0];
+                       Assert.AreEqual ("Action", hi.Name, "#h1-1");
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing", hi.Namespace, "#h1-2");
+                       Assert.AreEqual (String.Empty, hi.Actor, "#h1-3");
+                       Assert.IsTrue (hi.MustUnderstand, "#h1-4");
+                       Assert.IsFalse (hi.Relay, "#h1-5");
+                       Assert.IsFalse (hi.IsReferenceParameter, "#h1-6");
+
+                       int count = 0;
+
+                       /* FIXME: test UnderstoodHeaders later
+                       foreach (MessageHeaderInfo i in msg.Headers.UnderstoodHeaders) {
+                               count++;
+                               Assert.AreEqual ("", i.Actor, "#9");
+                               Assert.IsFalse (i.IsReferenceParameter, "#10");
+                               Assert.IsTrue (i.MustUnderstand, "#11");
+                               Assert.AreEqual ("Action", i.Name, "#12");
+                               Assert.AreEqual ("http://www.w3.org/2005/08/addressing", i.Namespace, "#13");
+                               Assert.AreEqual (false, i.Relay, "#14");
+                       }
+                       Assert.AreEqual (1, count, "#15"); // allow only once
+                       */
+
+                       // MS implementation closes XmlReader regardless of
+                       // its initial state, which isn't good.
+                       //Assert.AreEqual (ReadState.Closed, r.ReadState, "#1");
+
+                       r = XmlReader.Create (new StringReader (xml));
+                       r.MoveToContent ();
+                       msg = Message.CreateMessage (r, 10000, MessageVersion.Default);
+                       // ditto
+                       // Assert.AreEqual (ReadState.Closed, r.ReadState, "#1-2");
+
+                       string xml2 = @"<Wrap><s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://www.w3.org/2003/05/soap-envelope""><s:Header><a:Action s:mustUnderstand=""1"">Ack</a:Action></s:Header><s:Body /></s:Envelope></Wrap>";
+
+                       r = XmlReader.Create (new StringReader (xml2));
+                       r.MoveToContent ();
+                       r.Read (); // s:Envelope
+                       msg = Message.CreateMessage (r, 10000, MessageVersion.Default);
+                       // ditto
+                       // Assert.AreEqual (ReadState.Closed, r.ReadState, "#1-3");
+               }
+
+               [Test]
+               public void CreateFromXmlReader2 ()
+               {
+                       string xml = @"<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/""><s:Body><string xmlns=""http://schemas.microsoft.com/2003/10/Serialization/"">hoge</string></s:Body></s:Envelope>";
+                       XmlReader r = XmlReader.Create (new StringReader (xml));
+                       Message msg = Message.CreateMessage (r, 10000, MessageVersion.Soap11WSAddressing10);
+                       Assert.AreEqual (0, msg.Headers.Count, "#1");
+                       Assert.IsNull (msg.Headers.Action, "#2");
+                       Assert.IsFalse (msg.IsEmpty, "#3");
+                       Assert.AreEqual ("hoge", msg.GetBody<string> (), "#4");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void GetReaderAtBodyContentsEmptyError ()
+               {
+                       string xml = @"<s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://www.w3.org/2003/05/soap-envelope""><s:Header></s:Header><s:Body></s:Body></s:Envelope>";
+
+                       XmlReader r = XmlReader.Create (new StringReader (xml));
+                       Message msg = Message.CreateMessage (r, 10000, MessageVersion.Default);
+                       msg.GetReaderAtBodyContents ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void GetReaderAtBodyContentsTwice ()
+               {
+                       string xml = @"<s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://www.w3.org/2003/05/soap-envelope""><s:Header></s:Header><s:Body>TEST</s:Body></s:Envelope>";
+
+                       XmlReader r = XmlReader.Create (new StringReader (xml));
+                       Message msg = Message.CreateMessage (r, 10000, MessageVersion.Default);
+                       msg.GetReaderAtBodyContents ();
+                       msg.GetReaderAtBodyContents ();
+               }
+
+               [Test]
+               public void GetReaderAtBodyContentsAfterSourceClosed ()
+               {
+                       string xml = @"<s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://www.w3.org/2003/05/soap-envelope""><s:Header></s:Header><s:Body>TEST</s:Body></s:Envelope>";
+
+                       Message msg;
+                       using (XmlReader r = XmlReader.Create (new StringReader (xml))) {
+                               msg = Message.CreateMessage (r, 10000, MessageVersion.Default);
+                       }
+                       // The reader is already closed by nature of using statement.
+                       XmlDictionaryReader r2 = msg.GetReaderAtBodyContents ();
+                       Assert.AreEqual (ReadState.Closed, r2.ReadState);
+               }
+
+               [Test]
+               public void WriteMessagePOX ()
+               {
+                       string xml = "<?xml version=\"1.0\" encoding=\"utf-16\"?><z:anyType i:nil=\"true\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:z=\"http://schemas.microsoft.com/2003/10/Serialization/\" />";
+                       Message m = Message.CreateMessage (MessageVersion.None, "Blah", (object) null);
+                       StringWriter sw = new StringWriter ();
+                       using (XmlWriter w = XmlWriter.Create (sw)) {
+                               m.WriteMessage (w);
+                       }
+                       Assert.AreEqual (xml, sw.ToString ());
+               }
+
+               [Test]
+               public void ReadHeaders1 ()
+               {
+                       string xml = "<s:Envelope xmlns:s='http://www.w3.org/2003/05/soap-envelope'><s:Header><custom1 /><custom2>bah</custom2></s:Header><s:Body/></s:Envelope>";
+                       using (XmlReader r = XmlReader.Create (new StringReader (xml))) {
+                               Message m = Message.CreateMessage (r, 1000, MessageVersion.Default);
+                               Assert.AreEqual (2, m.Headers.Count, "#1");
+                               Assert.AreEqual (String.Empty, m.Headers.GetHeader<string> (0), "#2");
+                               Assert.AreEqual ("bah", m.Headers.GetHeader<string> (1), "#3");
+                               // 0, 1, then 0
+                               Assert.AreEqual (String.Empty, m.Headers.GetHeader<string> (0), "#2");
+                       }
+               }
+
+               [Test]
+               public void ReadHeaders2 ()
+               {
+                       string xml = "<s:Envelope xmlns:s='http://www.w3.org/2003/05/soap-envelope'><s:Header><u:Timestamp xmlns:u='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'><u:Created>blah</u:Created><u:Expires>bleh</u:Expires></u:Timestamp></s:Header><s:Body/></s:Envelope>";
+                       using (XmlReader r = XmlReader.Create (new StringReader (xml))) {
+                               Message m = Message.CreateMessage (r, 1000, MessageVersion.Default);
+                               Assert.AreEqual (1, m.Headers.Count, "#1");
+                       }
+               }
+
+               [Test]
+               public void ReadHeadersMustUnderstand ()
+               {
+                       // it includes mustUnderstand, but is ignored at
+                       // this stage.
+                       string xml = "<s:Envelope xmlns:s='http://www.w3.org/2003/05/soap-envelope'><s:Header><blah s:mustUnderstand='true'>foo</blah></s:Header><s:Body/></s:Envelope>";
+                       using (XmlReader r = XmlReader.Create (new StringReader (xml))) {
+                               Message m = Message.CreateMessage (r, 1000, MessageVersion.Default);
+                               Assert.AreEqual (1, m.Headers.Count, "#1");
+                       }
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ToStringSomehowDoesNotConsumeMessage ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "action", 1);
+                       Assert.AreEqual (m.ToString (), m.ToString ());
+               }
+
+               [Test]
+               public void IsFault ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "action", 1);
+                       Assert.IsFalse (m.IsFault, "#1");
+                       m = Message.CreateMessage (MessageVersion.Default, new FaultCode ("ActionNotSupported", "urn:myfault"), "I dunno", "urn:myaction");
+                       Assert.IsTrue (m.IsFault, "#2");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageVersionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageVersionTest.cs
new file mode 100644 (file)
index 0000000..31bb0e6
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// MessageVersionTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using NUnit.Framework;
+
+using Element = System.ServiceModel.Channels.TextMessageEncodingBindingElement;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class MessageVersionTest
+       {
+               [Test]
+               public void Equality ()
+               {
+                       MessageVersion v = MessageVersion.CreateVersion (
+                               EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10);
+                       Assert.AreEqual (MessageVersion.Default, v, "#1");
+
+                       v = MessageVersion.CreateVersion (
+                               EnvelopeVersion.Soap11, AddressingVersion.WSAddressing10);
+                       Assert.AreEqual (MessageVersion.Soap11WSAddressing10, v, "#2");
+
+                       v = MessageVersion.CreateVersion (
+                               EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10);
+                       Assert.AreEqual (MessageVersion.Soap12WSAddressing10, v, "#3");
+                       
+                       v = MessageVersion.CreateVersion (
+                               EnvelopeVersion.None, AddressingVersion.None);
+                       Assert.AreEqual (MessageVersion.None, v, "#4");
+
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MsmqTransportBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/MsmqTransportBindingElementTest.cs
new file mode 100644 (file)
index 0000000..cbd1e05
--- /dev/null
@@ -0,0 +1,183 @@
+//
+// MsmqTransportBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Threading;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class MsmqTransportBindingElementTest
+       {
+               static BindingParameterCollection empty_params =
+                       new BindingParameterCollection ();
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       MsmqTransportBindingElement be =
+                               new MsmqTransportBindingElement ();
+                       Assert.AreEqual (8, be.MaxPoolSize, "#1");
+                       Assert.AreEqual (0x80000, be.MaxBufferPoolSize, "#2");
+                       Assert.AreEqual (QueueTransferProtocol.Native, be.QueueTransferProtocol, "#2");
+                       Assert.AreEqual ("net.msmq", be.Scheme, "#3");
+
+                       Assert.IsNull (be.CustomDeadLetterQueue, "#5");
+                       Assert.AreEqual (DeadLetterQueue.System, be.DeadLetterQueue, "#6");
+                       Assert.IsTrue (be.Durable, "#7");
+                       Assert.IsTrue (be.ExactlyOnce, "#8");
+                       Assert.AreEqual (0x10000, be.MaxReceivedMessageSize, "#9");
+                       Assert.AreEqual (2, be.MaxRetryCycles, "#10");
+                       Assert.AreEqual (ReceiveErrorHandling.Fault, be.ReceiveErrorHandling, "#11");
+                       Assert.AreEqual (5, be.ReceiveRetryCount, "#12");
+                       // hmm, it is documented as 10 minutes but ...
+                       Assert.AreEqual (TimeSpan.FromMinutes (30), be.RetryCycleDelay, "#13");
+                       Assert.AreEqual (TimeSpan.FromDays (1), be.TimeToLive, "#15");
+                       Assert.IsFalse (be.UseMsmqTracing, "#16");
+                       Assert.IsFalse (be.UseSourceJournal, "#17");
+               }
+
+               [Test]
+               public void CanBuildChannelFactory ()
+               {
+                       MsmqTransportBindingElement be =
+                               new MsmqTransportBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (), empty_params);
+                       Assert.IsFalse (be.CanBuildChannelFactory<IRequestChannel> (ctx), "#1");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IInputChannel> (ctx), "#2");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IReplyChannel> (ctx), "#3");
+                       Assert.IsTrue (be.CanBuildChannelFactory<IOutputChannel> (ctx), "#4");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IRequestSessionChannel> (ctx), "#5");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IInputSessionChannel> (ctx), "#6");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IReplySessionChannel> (ctx), "#7");
+                       Assert.IsTrue (be.CanBuildChannelFactory<IOutputSessionChannel> (ctx), "#8");
+
+                       // IServiceChannel is not supported
+                       Assert.IsFalse (be.CanBuildChannelListener<IServiceChannel> (ctx), "#9");
+               }
+
+               [Test]
+               public void CanBuildChannelListener ()
+               {
+                       MsmqTransportBindingElement be =
+                               new MsmqTransportBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (), empty_params);
+                       Assert.IsFalse (be.CanBuildChannelListener<IReplyChannel> (ctx), "#1");
+                       Assert.IsFalse (be.CanBuildChannelListener<IOutputChannel> (ctx), "#2");
+                       Assert.IsFalse (be.CanBuildChannelListener<IRequestChannel> (ctx), "#3");
+                       Assert.IsTrue (be.CanBuildChannelListener<IInputChannel> (ctx), "#4");
+                       Assert.IsFalse (be.CanBuildChannelListener<IReplySessionChannel> (ctx), "#5");
+                       Assert.IsFalse (be.CanBuildChannelListener<IOutputSessionChannel> (ctx), "#6");
+                       Assert.IsFalse (be.CanBuildChannelListener<IRequestSessionChannel> (ctx), "#7");
+                       Assert.IsTrue (be.CanBuildChannelListener<IInputSessionChannel> (ctx), "#8");
+
+                       // IServiceChannel is not supported
+                       Assert.IsFalse (be.CanBuildChannelListener<IServiceChannel> (ctx), "#9");
+               }
+
+               [Test]
+               public void BuildChannelFactory ()
+               {
+                       MsmqTransportBindingElement be =
+                               new MsmqTransportBindingElement ();
+                       // Without settings them, it borks when MSMQ setup
+                       // does not support AD integration.
+                       be.MsmqTransportSecurity.MsmqAuthenticationMode =
+                               MsmqAuthenticationMode.None;
+                       be.MsmqTransportSecurity.MsmqProtectionLevel =
+                               ProtectionLevel.None;
+
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (be),
+                               empty_params);
+                       // returns MsmqChannelFactory
+                       IChannelFactory<IOutputChannel> f =
+                               ctx.BuildInnerChannelFactory<IOutputChannel> ();
+                       f.Open (); // required
+                       IChannel c = f.CreateChannel (new EndpointAddress (
+                               "net.msmq://nosuchqueueexists"));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateChannelWithoutOpen ()
+               {
+                       MsmqTransportBindingElement be =
+                               new MsmqTransportBindingElement ();
+                       // Without settings them, it borks when MSMQ setup
+                       // does not support AD integration.
+                       be.MsmqTransportSecurity.MsmqAuthenticationMode =
+                               MsmqAuthenticationMode.None;
+                       be.MsmqTransportSecurity.MsmqProtectionLevel =
+                               ProtectionLevel.None;
+
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (be),
+                               empty_params);
+                       // returns MsmqChannelFactory
+                       IChannelFactory<IOutputChannel> f =
+                               ctx.BuildInnerChannelFactory<IOutputChannel> ();
+
+                       IChannel c = f.CreateChannel (new EndpointAddress (
+                               "net.msmq://nosuchqueueexists"));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateChannelInvalidScheme ()
+               {
+                       MsmqTransportBindingElement be =
+                               new MsmqTransportBindingElement ();
+                       // Without settings them, it borks when MSMQ setup
+                       // does not support AD integration.
+                       be.MsmqTransportSecurity.MsmqAuthenticationMode =
+                               MsmqAuthenticationMode.None;
+                       be.MsmqTransportSecurity.MsmqProtectionLevel =
+                               ProtectionLevel.None;
+
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (be),
+                               empty_params);
+                       // returns MsmqChannelFactory
+                       IChannelFactory<IOutputChannel> f =
+                               ctx.BuildInnerChannelFactory<IOutputChannel> ();
+                       f.Open ();
+                       f.CreateChannel (new EndpointAddress ("stream:dummy"));
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/NamedPipeTransportBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/NamedPipeTransportBindingElementTest.cs
new file mode 100644 (file)
index 0000000..6f89473
--- /dev/null
@@ -0,0 +1,120 @@
+//
+// NamedPipeTransportBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2008 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Threading;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class NamedPipeTransportBindingElementTest
+       {
+               static BindingParameterCollection empty_params =
+                       new BindingParameterCollection ();
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       NamedPipeTransportBindingElement be =
+                               new NamedPipeTransportBindingElement ();
+                       Assert.AreEqual (TimeSpan.FromSeconds (5), be.ChannelInitializationTimeout, "#1");
+                       Assert.AreEqual (0x2000, be.ConnectionBufferSize, "#2");
+                       Assert.AreEqual (HostNameComparisonMode.StrongWildcard, be.HostNameComparisonMode, "#3");
+                       Assert.AreEqual (0x10000, be.MaxBufferSize, "#4");
+                       Assert.AreEqual (TimeSpan.FromMilliseconds (200), be.MaxOutputDelay, "#5");
+                       Assert.AreEqual (1, be.MaxPendingAccepts, "#6");
+                       Assert.AreEqual (10, be.MaxPendingConnections, "#7");
+                       Assert.AreEqual (TransferMode.Buffered, be.TransferMode, "#8");
+
+                       Assert.AreEqual ("net.pipe", be.Scheme, "#11");
+                       NamedPipeConnectionPoolSettings pool = be.ConnectionPoolSettings;
+                       Assert.IsNotNull (pool, "#13");
+                       Assert.AreEqual ("default", pool.GroupName, "#14");
+                       Assert.AreEqual (TimeSpan.FromSeconds (120), pool.IdleTimeout, "#15");
+                       Assert.AreEqual (10, pool.MaxOutboundConnectionsPerEndpoint, "#17");
+               }
+
+               [Test]
+               public void CanBuildChannelFactory ()
+               {
+                       NamedPipeTransportBindingElement be =
+                               new NamedPipeTransportBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (), empty_params);
+                       Assert.IsFalse (be.CanBuildChannelFactory<IRequestChannel> (ctx), "#1");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IInputChannel> (ctx), "#2");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IReplyChannel> (ctx), "#3");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IOutputChannel> (ctx), "#4");
+
+                       Assert.IsFalse (be.CanBuildChannelFactory<IRequestSessionChannel> (ctx), "#5");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IInputSessionChannel> (ctx), "#6");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IReplySessionChannel> (ctx), "#7");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IOutputSessionChannel> (ctx), "#8");
+
+                       // IServiceChannel is not supported
+                       Assert.IsFalse (be.CanBuildChannelFactory<IServiceChannel> (ctx), "#9");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IClientChannel> (ctx), "#10");
+
+                       Assert.IsTrue (be.CanBuildChannelFactory<IDuplexSessionChannel> (ctx), "#11");
+                       Assert.IsTrue (be.CanBuildChannelFactory<IDuplexSessionChannel> (ctx), "#12");
+               }
+
+               [Test]
+               public void CanBuildChannelListener ()
+               {
+                       NamedPipeTransportBindingElement be =
+                               new NamedPipeTransportBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (), empty_params);
+                       Assert.IsFalse (be.CanBuildChannelListener<IReplyChannel> (ctx), "#1");
+                       Assert.IsFalse (be.CanBuildChannelListener<IOutputChannel> (ctx), "#2");
+                       Assert.IsFalse (be.CanBuildChannelListener<IRequestChannel> (ctx), "#3");
+                       Assert.IsFalse (be.CanBuildChannelListener<IInputChannel> (ctx), "#4");
+
+                       Assert.IsFalse (be.CanBuildChannelListener<IReplySessionChannel> (ctx), "#5");
+                       Assert.IsFalse (be.CanBuildChannelListener<IOutputSessionChannel> (ctx), "#6");
+                       Assert.IsFalse (be.CanBuildChannelListener<IRequestSessionChannel> (ctx), "#7");
+                       Assert.IsFalse (be.CanBuildChannelListener<IInputSessionChannel> (ctx), "#8");
+
+                       // IServiceChannel is not supported
+                       Assert.IsFalse (be.CanBuildChannelListener<IServiceChannel> (ctx), "#9");
+                       Assert.IsFalse (be.CanBuildChannelListener<IClientChannel> (ctx), "#10");
+
+                       Assert.IsFalse (be.CanBuildChannelListener<IDuplexChannel> (ctx), "#11");
+                       Assert.IsTrue (be.CanBuildChannelListener<IDuplexSessionChannel> (ctx), "#12");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/OneWayBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/OneWayBindingElementTest.cs
new file mode 100644 (file)
index 0000000..444b4a3
--- /dev/null
@@ -0,0 +1,90 @@
+//
+// OneWayBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class OneWayBindingElementTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void BuildRequestChannelFactory ()
+               {
+                       OneWayBindingElement be =
+                               new OneWayBindingElement ();
+                       CustomBinding binding = new CustomBinding (
+                               new HandlerTransportBindingElement (null));
+                       BindingContext ctx = new BindingContext (
+                               binding, new BindingParameterCollection ());
+                       be.BuildChannelFactory<IRequestChannel> (ctx);
+               }
+
+               [Test]
+               public void BuildOutputChannelFactory ()
+               {
+                       OneWayBindingElement be =
+                               new OneWayBindingElement ();
+                       CustomBinding binding = new CustomBinding (
+                               new HandlerTransportBindingElement (null));
+                       BindingContext ctx = new BindingContext (
+                               binding, new BindingParameterCollection ());
+                       be.BuildChannelFactory<IOutputChannel> (ctx);
+               }
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void BuildReplyChannelListener ()
+               {
+                       OneWayBindingElement be =
+                               new OneWayBindingElement ();
+                       CustomBinding binding = new CustomBinding (
+                               new HandlerTransportBindingElement (null));
+                       BindingContext ctx = new BindingContext (
+                               binding, new BindingParameterCollection ());
+                       be.BuildChannelListener<IReplyChannel> (ctx);
+               }
+
+               [Test]
+               public void BuildInputChannelListener ()
+               {
+                       OneWayBindingElement be =
+                               new OneWayBindingElement ();
+                       CustomBinding binding = new CustomBinding (
+                               new HandlerTransportBindingElement (null));
+                       BindingContext ctx = new BindingContext (
+                               binding, new BindingParameterCollection ());
+                       be.BuildChannelListener<IInputChannel> (ctx);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/OutputChannelBase.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/OutputChannelBase.cs
new file mode 100644 (file)
index 0000000..bf06276
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// OutputChannelBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       public abstract class OutputChannelBase : ChannelBase, IOutputChannel
+       {
+               ChannelFactoryBase channel_factory;
+
+               public OutputChannelBase (ChannelFactoryBase factory)
+                       : base (factory)
+               {
+                       this.channel_factory = factory;
+               }
+
+               protected override TimeSpan DefaultCloseTimeout {
+                       get { return TimeSpan.FromSeconds (5); }
+               }
+
+               protected override TimeSpan DefaultOpenTimeout {
+                       get { return TimeSpan.FromSeconds (5); }
+               }
+
+               public abstract EndpointAddress RemoteAddress { get; }
+
+               public abstract Uri Via { get; }
+
+               // Send
+
+               public void Send (Message message)
+               {
+                       Send (message, DefaultSendTimeout);
+               }
+
+               public abstract void Send (Message message, TimeSpan timeout);
+
+               public IAsyncResult BeginSend (Message message, AsyncCallback callback, object state)
+               {
+                       return BeginSend (message, DefaultSendTimeout, callback, state);
+               }
+
+               public abstract IAsyncResult BeginSend (Message message, TimeSpan timeout, AsyncCallback callback, object state);
+
+               public abstract void EndSend (IAsyncResult result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/ReplyChannelBase.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/ReplyChannelBase.cs
new file mode 100644 (file)
index 0000000..3970d45
--- /dev/null
@@ -0,0 +1,127 @@
+//
+// ReplyChannelBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       public abstract class ReplyChannelBase : ChannelBase, IReplyChannel
+       {
+               ChannelListenerBase channel_listener;
+
+               public ReplyChannelBase (ChannelListenerBase listener)
+                       : base (listener)
+               {
+                       this.channel_listener = listener;
+               }
+
+               protected override TimeSpan DefaultCloseTimeout {
+                       get { return TimeSpan.FromSeconds (5); }
+               }
+
+               protected override TimeSpan DefaultOpenTimeout {
+                       get { return TimeSpan.FromSeconds (5); }
+               }
+
+               public abstract EndpointAddress LocalAddress { get; }
+
+               public virtual bool TryReceiveRequest ()
+               {
+                       RequestContext dummy;
+                       return TryReceiveRequest (DefaultReceiveTimeout, out dummy);
+               }
+
+               public abstract bool TryReceiveRequest (TimeSpan timeout, out RequestContext context);
+
+               public abstract IAsyncResult BeginTryReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state);
+
+               public virtual bool EndTryReceiveRequest (IAsyncResult result)
+               {
+                       RequestContext dummy;
+                       return EndTryReceiveRequest (result, out dummy);
+               }
+
+               public abstract bool EndTryReceiveRequest (IAsyncResult result, out RequestContext context);
+
+               public virtual bool WaitForRequest ()
+               {
+                       return WaitForRequest (DefaultReceiveTimeout);
+               }
+
+               public abstract bool WaitForRequest (TimeSpan timeout);
+
+               public abstract IAsyncResult BeginWaitForRequest (TimeSpan timeout, AsyncCallback callback, object state);
+
+               public abstract bool EndWaitForRequest (IAsyncResult result);
+
+               public virtual RequestContext ReceiveRequest ()
+               {
+                       return ReceiveRequest (DefaultReceiveTimeout);
+               }
+
+               public abstract RequestContext ReceiveRequest (TimeSpan timeout);
+
+               public virtual IAsyncResult BeginReceiveRequest (AsyncCallback callback, object state)
+               {
+                       return BeginReceiveRequest (DefaultReceiveTimeout, callback, state);
+               }
+
+               public abstract IAsyncResult BeginReceiveRequest (TimeSpan timeout, AsyncCallback callback, object state);
+
+               public abstract RequestContext EndReceiveRequest (IAsyncResult result);
+
+               protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndOpen (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override IAsyncResult OnBeginClose (TimeSpan timeout,
+                       AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void OnEndClose (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/RequestChannelBase.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/RequestChannelBase.cs
new file mode 100644 (file)
index 0000000..9572d31
--- /dev/null
@@ -0,0 +1,80 @@
+//
+// RequestChannelBase.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       public abstract class RequestChannelBase : ChannelBase, IRequestChannel
+       {
+               ChannelFactoryBase channel_factory;
+
+               public RequestChannelBase (ChannelFactoryBase factory)
+                       : base (factory)
+               {
+                       this.channel_factory = factory;
+               }
+
+               protected override TimeSpan DefaultCloseTimeout {
+                       get { return TimeSpan.FromSeconds (5); }
+               }
+
+               protected override TimeSpan DefaultOpenTimeout {
+                       get { return TimeSpan.FromSeconds (5); }
+               }
+
+               public abstract EndpointAddress RemoteAddress { get; }
+
+               public abstract Uri Via { get; }
+
+               // Request
+
+               public Message Request (Message message)
+               {
+                       return Request (message, DefaultSendTimeout);
+               }
+
+               public abstract Message Request (Message message, TimeSpan timeout);
+
+               public IAsyncResult BeginRequest (Message message, AsyncCallback callback, object state)
+               {
+                       return BeginRequest (message, DefaultSendTimeout, callback, state);
+               }
+
+               public abstract IAsyncResult BeginRequest (Message message, TimeSpan timeout, AsyncCallback callback, object state);
+
+               public abstract Message EndRequest (IAsyncResult result);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SecurityAssert.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SecurityAssert.cs
new file mode 100644 (file)
index 0000000..463cb78
--- /dev/null
@@ -0,0 +1,266 @@
+//
+// SecurityAssert.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.Security.Cryptography.X509Certificates;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       public static class SecurityAssert
+       {
+               public static void AssertLocalClientSecuritySettings (
+                       bool cacheCookies,
+                       int renewalThresholdPercentage,
+                       bool detectReplays,
+                       LocalClientSecuritySettings lc, string label)
+               {
+                       Assert.IsNotNull (lc, label + " IsNotNull");
+                       Assert.AreEqual (cacheCookies, lc.CacheCookies, label + ".CacheCookies");
+                       Assert.AreEqual (renewalThresholdPercentage, lc.CookieRenewalThresholdPercentage, label + ".CookieRenewalThresholdPercentage");
+                       Assert.AreEqual (detectReplays, lc.DetectReplays, label + ".DetectReplays");
+               }
+
+               public static void AssertSecurityTokenParameters (
+                       SecurityTokenInclusionMode protectionTokenInclusionMode,
+                       SecurityTokenReferenceStyle protectionTokenReferenceStyle,
+                       bool protectionTokenRequireDerivedKeys,
+                       SecurityTokenParameters tp, string label)
+               {
+                       Assert.IsNotNull (tp, label + " IsNotNull");
+                       Assert.AreEqual (protectionTokenInclusionMode,
+                               tp.InclusionMode, label + ".InclusionMode");
+                       Assert.AreEqual (protectionTokenReferenceStyle,
+                               tp.ReferenceStyle, label + ".ReferenceStyle");
+                       Assert.AreEqual (protectionTokenRequireDerivedKeys,
+                               tp.RequireDerivedKeys, label + ".RequireDerivedKeys");
+               }
+
+               public static void AssertSupportingTokenParameters (
+                       int endorsing, int signed, int signedEncrypted, int signedEndorsing,
+                       SupportingTokenParameters tp, string label)
+               {
+                       Assert.IsNotNull (tp, label + " IsNotNull");
+                       Assert.AreEqual (endorsing, tp.Endorsing.Count, label + ".Endoring.Count");
+                       Assert.AreEqual (signed, tp.Signed.Count, label + ".Signed.Count");
+                       Assert.AreEqual (signedEncrypted, tp.SignedEncrypted.Count, label + ".SignedEncrypted.Count");
+                       Assert.AreEqual (signedEndorsing, tp.SignedEndorsing.Count, label + ".SignedEndorsing.Count");
+               }
+
+               public static void AssertSecurityBindingElement (
+                       SecurityAlgorithmSuite algorithm,
+                       bool includeTimestamp,
+                       SecurityKeyEntropyMode keyEntropyMode,
+                       MessageSecurityVersion messageSecurityVersion,
+                       SecurityHeaderLayout securityHeaderLayout,
+                       // EndpointSupportingTokenParameters
+                       int endorsing, int signed, int signedEncrypted, int signedEndorsing,
+                       // LocalClientSettings
+                       bool cacheCookies,
+                       int renewalThresholdPercentage,
+                       bool detectReplays,
+                       SecurityBindingElement be, string label)
+               {
+                       Assert.AreEqual (algorithm, be.DefaultAlgorithmSuite, label + ".DefaultAlgorithmSuite");
+                       Assert.AreEqual (includeTimestamp, be.IncludeTimestamp, label + ".KeyEntropyMode");
+                       Assert.AreEqual (keyEntropyMode,
+                               be.KeyEntropyMode, label + "#3");
+
+                       Assert.AreEqual (messageSecurityVersion,
+                               be.MessageSecurityVersion, label + ".MessageSecurityVersion");
+                       Assert.AreEqual (securityHeaderLayout,
+                               be.SecurityHeaderLayout, label + ".SecurityHeaderLayout");
+
+                       // FIXME: they should be extracted step by step...
+
+                       // EndpointSupportingTokenParameters
+                       SupportingTokenParameters tp = be.EndpointSupportingTokenParameters;
+                       AssertSupportingTokenParameters (
+                               endorsing, signed, signedEncrypted, signedEndorsing,
+                               tp, label + ".Endpoint");
+
+                       // OptionalEndpointSupportingTokenParameters
+                       tp = be.OptionalEndpointSupportingTokenParameters;
+                       Assert.IsNotNull (tp, label + "#3-0");
+                       Assert.AreEqual (0, tp.Endorsing.Count, label + "#3-1");
+                       Assert.AreEqual (0, tp.Signed.Count, label + "#3-2");
+                       Assert.AreEqual (0, tp.SignedEncrypted.Count, label + "#3-3");
+                       Assert.AreEqual (0, tp.SignedEndorsing.Count, label + "#3-4");
+
+                       // OperationSupportingTokenParameters
+                       IDictionary<string,SupportingTokenParameters> oper = be.OperationSupportingTokenParameters;
+                       Assert.IsNotNull (oper, label + "#4-1");
+                       Assert.AreEqual (0, oper.Count, label + "#4-2");
+
+                       // OptionalOperationSupportingTokenParameters
+                       oper = be.OptionalOperationSupportingTokenParameters;
+                       Assert.IsNotNull (oper, label + "#5-1");
+                       Assert.AreEqual (0, oper.Count, label + "#5-2");
+
+                       // LocalClientSettings
+                       LocalClientSecuritySettings lc =
+                               be.LocalClientSettings;
+                       AssertLocalClientSecuritySettings (
+                               cacheCookies,
+                               renewalThresholdPercentage,
+                               detectReplays,
+                               lc, "");
+                       // FIXME: IdentityVerifier
+                       Assert.AreEqual (TimeSpan.FromMinutes (5), lc.MaxClockSkew, label + "#7-5");
+                       Assert.AreEqual (TimeSpan.MaxValue, lc.MaxCookieCachingTime, label + "#7-6");
+                       Assert.AreEqual (true, lc.ReconnectTransportOnFailure, label + "#7-7");
+                       Assert.AreEqual (900000, lc.ReplayCacheSize, label + "#7-8");
+                       Assert.AreEqual (TimeSpan.FromMinutes (5), lc.ReplayWindow, label + "#7-9");
+                       Assert.AreEqual (TimeSpan.FromHours (10), lc.SessionKeyRenewalInterval, label + "#7-10");
+                       Assert.AreEqual (TimeSpan.FromMinutes (5), lc.SessionKeyRolloverInterval, label + "#7-11");
+                       Assert.AreEqual (TimeSpan.FromMinutes (5), lc.TimestampValidityDuration, label + "#7-12");
+
+                       // FIXME: LocalServiceSettings
+               }
+
+               public static void AssertSymmetricSecurityBindingElement (
+                       SecurityAlgorithmSuite algorithm,
+                       bool includeTimestamp,
+                       SecurityKeyEntropyMode keyEntropyMode,
+                       MessageProtectionOrder messageProtectionOrder,
+                       MessageSecurityVersion messageSecurityVersion,
+                       bool requireSignatureConfirmation,
+                       SecurityHeaderLayout securityHeaderLayout,
+                       // EndpointSupportingTokenParameters
+                       int endorsing, int signed, int signedEncrypted, int signedEndorsing,
+                       // ProtectionTokenParameters
+                       bool hasProtectionTokenParameters,
+                       SecurityTokenInclusionMode protectionTokenInclusionMode,
+                       SecurityTokenReferenceStyle protectionTokenReferenceStyle,
+                       bool protectionTokenRequireDerivedKeys,
+                       // LocalClientSettings
+                       bool cacheCookies,
+                       int renewalThresholdPercentage,
+                       bool detectReplays,
+                       SymmetricSecurityBindingElement be, string label)
+               {
+                       AssertSecurityBindingElement (
+                               algorithm,
+                               includeTimestamp,
+                               keyEntropyMode,
+                               messageSecurityVersion,
+                               securityHeaderLayout,
+                               // EndpointSupportingTokenParameters
+                               endorsing, signed, signedEncrypted, signedEndorsing,
+                               // LocalClientSettings
+                               cacheCookies,
+                               renewalThresholdPercentage,
+                               detectReplays,
+                               be, label);
+
+                       Assert.AreEqual (messageProtectionOrder, be.MessageProtectionOrder, label + ".MessageProtectionOrder");
+                       Assert.AreEqual (requireSignatureConfirmation, be.RequireSignatureConfirmation, label + ".RequireSignatureConfirmation");
+
+                       if (!hasProtectionTokenParameters)
+                               Assert.IsNull (be.ProtectionTokenParameters, label + ".ProtectionTokenParameters (null)");
+                       else
+                               AssertSecurityTokenParameters (
+                                       protectionTokenInclusionMode,
+                                       protectionTokenReferenceStyle,
+                                       protectionTokenRequireDerivedKeys,
+                                       be.ProtectionTokenParameters, label + ".ProtectionTokenParameters");
+               }
+
+               public static void AssertAsymmetricSecurityBindingElement (
+                       SecurityAlgorithmSuite algorithm,
+                       bool includeTimestamp,
+                       SecurityKeyEntropyMode keyEntropyMode,
+                       MessageProtectionOrder messageProtectionOrder,
+                       MessageSecurityVersion messageSecurityVersion,
+                       bool requireSignatureConfirmation,
+                       SecurityHeaderLayout securityHeaderLayout,
+                       // EndpointSupportingTokenParameters
+                       int endorsing, int signed, int signedEncrypted, int signedEndorsing,
+                       // InitiatorTokenParameters
+                       bool hasInitiatorTokenParameters,
+                       SecurityTokenInclusionMode initiatorTokenInclusionMode,
+                       SecurityTokenReferenceStyle initiatorTokenReferenceStyle,
+                       bool initiatorTokenRequireDerivedKeys,
+                       // RecipientTokenParameters
+                       bool hasRecipientTokenParameters,
+                       SecurityTokenInclusionMode recipientTokenInclusionMode,
+                       SecurityTokenReferenceStyle recipientTokenReferenceStyle,
+                       bool recipientTokenRequireDerivedKeys,
+                       // LocalClientSettings
+                       bool cacheCookies,
+                       int renewalThresholdPercentage,
+                       bool detectReplays,
+                       AsymmetricSecurityBindingElement be, string label)
+               {
+                       AssertSecurityBindingElement (
+                               algorithm,
+                               includeTimestamp,
+                               keyEntropyMode,
+                               messageSecurityVersion,
+                               securityHeaderLayout,
+                               // EndpointSupportingTokenParameters
+                               endorsing, signed, signedEncrypted, signedEndorsing,
+                               // LocalClientSettings
+                               cacheCookies,
+                               renewalThresholdPercentage,
+                               detectReplays,
+                               be, label);
+
+                       Assert.AreEqual (messageProtectionOrder, be.MessageProtectionOrder, label + ".MessageProtectionOrder");
+                       Assert.AreEqual (requireSignatureConfirmation, be.RequireSignatureConfirmation, label + ".RequireSignatureConfirmation");
+
+                       if (!hasInitiatorTokenParameters)
+                               Assert.IsNull (be.InitiatorTokenParameters, label + ".InitiatorTokenParameters (null)");
+                       else
+                               AssertSecurityTokenParameters (
+                                       initiatorTokenInclusionMode,
+                                       initiatorTokenReferenceStyle,
+                                       initiatorTokenRequireDerivedKeys,
+                                       be.InitiatorTokenParameters, label + ".InitiatorTokenParameters");
+                       if (!hasRecipientTokenParameters)
+                               Assert.IsNull (be.RecipientTokenParameters, label + ".RecipientTokenParameters (null)");
+                       else
+                               AssertSecurityTokenParameters (
+                                       recipientTokenInclusionMode,
+                                       recipientTokenReferenceStyle,
+                                       recipientTokenRequireDerivedKeys,
+                                       be.RecipientTokenParameters, label + ".RecipientTokenParameters");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SecurityBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SecurityBindingElementTest.cs
new file mode 100644 (file)
index 0000000..9a47651
--- /dev/null
@@ -0,0 +1,634 @@
+//
+// SecurityBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.Security.Cryptography.X509Certificates;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class SecurityBindingElementTest
+       {
+               #region Factory methods
+
+               [Test]
+               public void CreateAnonymousForCertificateBindingElement ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               SecurityBindingElement.CreateAnonymousForCertificateBindingElement ();
+
+                       SecurityAssert.AssertSymmetricSecurityBindingElement (
+                               SecurityAlgorithmSuite.Default,
+                               true, // IncludeTimestamp
+                               SecurityKeyEntropyMode.CombinedEntropy,
+                               MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature,
+                               MessageSecurityVersion.Default,
+                               true, // RequireSignatureConfirmation
+                               SecurityHeaderLayout.Strict,
+                               // EndpointSupportingTokenParameters: endorsing, signed, signedEncrypted, signedEndorsing (by count)
+                               0, 0, 0, 0,
+                               // ProtectionTokenParameters
+                               true, SecurityTokenInclusionMode.Never, SecurityTokenReferenceStyle.Internal, true,
+                               // LocalClientSettings
+                               true, 60, true,
+
+                               be, "");
+
+                       // test ProtectionTokenParameters
+                       X509SecurityTokenParameters tp =
+                               be.ProtectionTokenParameters
+                               as X509SecurityTokenParameters;
+                       Assert.IsNotNull (tp, "#2-1");
+                       SecurityAssert.AssertSecurityTokenParameters (
+                               SecurityTokenInclusionMode.Never,
+                               SecurityTokenReferenceStyle.Internal, 
+                               true, tp, "Protection");
+                       Assert.AreEqual (X509KeyIdentifierClauseType.Thumbprint, tp.X509ReferenceStyle, "#2-2");
+               }
+
+               [Test]
+               public void CreateIssuedTokenBindingElement1 ()
+               {
+                       IssuedSecurityTokenParameters tp =
+                               new IssuedSecurityTokenParameters ();
+                       SymmetricSecurityBindingElement be =
+                               SecurityBindingElement.CreateIssuedTokenBindingElement (tp);
+
+                       SecurityAssert.AssertSymmetricSecurityBindingElement (
+                               SecurityAlgorithmSuite.Default,
+                               true, // IncludeTimestamp
+                               SecurityKeyEntropyMode.CombinedEntropy,
+                               MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature,
+                               MessageSecurityVersion.Default,
+                               false, // RequireSignatureConfirmation
+                               SecurityHeaderLayout.Strict,
+                               // EndpointSupportingTokenParameters: endorsing, signed, signedEncrypted, signedEndorsing (by count)
+                               0, 0, 0, 0,
+                               // ProtectionTokenParameters
+                               true, SecurityTokenInclusionMode.AlwaysToRecipient, SecurityTokenReferenceStyle.Internal, true,
+                               // LocalClientSettings
+                               true, 60, true,
+
+                               be, "");
+
+                       // test ProtectionTokenParameters
+                       Assert.AreEqual (tp, be.ProtectionTokenParameters, "#2-1");
+                       SecurityAssert.AssertSecurityTokenParameters (
+                               SecurityTokenInclusionMode.AlwaysToRecipient,
+                               SecurityTokenReferenceStyle.Internal, 
+                               true, tp, "Protection");
+               }
+
+               [Test]
+               public void CreateIssuedTokenForCertificateBindingElement1 ()
+               {
+                       IssuedSecurityTokenParameters tp =
+                               new IssuedSecurityTokenParameters ();
+                       SymmetricSecurityBindingElement be =
+                               SecurityBindingElement.CreateIssuedTokenForCertificateBindingElement (tp);
+
+                       SecurityAssert.AssertSymmetricSecurityBindingElement (
+                               SecurityAlgorithmSuite.Default,
+                               true, // IncludeTimestamp
+                               SecurityKeyEntropyMode.CombinedEntropy,
+                               MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature,
+                               MessageSecurityVersion.Default,
+                               true, // RequireSignatureConfirmation
+                               SecurityHeaderLayout.Strict,
+                               // EndpointSupportingTokenParameters: endorsing, signed, signedEncrypted, signedEndorsing (by count)
+                               1, 0, 0, 0,
+                               // ProtectionTokenParameters
+                               true, SecurityTokenInclusionMode.Never, SecurityTokenReferenceStyle.Internal, true,
+                               // LocalClientSettings
+                               true, 60, true,
+
+                               be, "");
+
+                       // test ProtectionTokenParameters
+                       X509SecurityTokenParameters ptp =
+                               be.ProtectionTokenParameters
+                               as X509SecurityTokenParameters;
+                       Assert.IsNotNull (ptp, "#2-1");
+                       SecurityAssert.AssertSecurityTokenParameters (
+                               SecurityTokenInclusionMode.Never,
+                               SecurityTokenReferenceStyle.Internal, 
+                               true, ptp, "Protection");
+                       Assert.AreEqual (X509KeyIdentifierClauseType.Thumbprint, ptp.X509ReferenceStyle, "#2-2");
+
+                       Assert.AreEqual (tp, be.EndpointSupportingTokenParameters.Endorsing [0], "EndpointParams.Endorsing[0]");
+               }
+
+               [Test]
+               public void CreateIssuedTokenForSslBindingElement1 ()
+               {
+                       IssuedSecurityTokenParameters tp =
+                               new IssuedSecurityTokenParameters ();
+                       SymmetricSecurityBindingElement be =
+                               SecurityBindingElement.CreateIssuedTokenForSslBindingElement (tp);
+
+                       SecurityAssert.AssertSymmetricSecurityBindingElement (
+                               SecurityAlgorithmSuite.Default,
+                               true, // IncludeTimestamp
+                               SecurityKeyEntropyMode.CombinedEntropy,
+                               MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature,
+                               MessageSecurityVersion.Default,
+                               true, // RequireSignatureConfirmation
+                               SecurityHeaderLayout.Strict,
+                               // EndpointSupportingTokenParameters: endorsing, signed, signedEncrypted, signedEndorsing (by count)
+                               1, 0, 0, 0,
+                               // ProtectionTokenParameters
+                               true, SecurityTokenInclusionMode.AlwaysToRecipient, SecurityTokenReferenceStyle.Internal, true,
+                               // LocalClientSettings
+                               true, 60, true,
+
+                               be, "");
+
+                       Assert.AreEqual (tp, be.EndpointSupportingTokenParameters.Endorsing [0], "EndpointParams.Endorsing[0]");
+
+                       // FIXME: test ProtectionTokenParameters
+               }
+
+               [Test]
+               public void CreateKerberosBindingElement ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               SecurityBindingElement.CreateKerberosBindingElement ();
+
+                       SecurityAssert.AssertSymmetricSecurityBindingElement (
+                               SecurityAlgorithmSuite.Basic128,
+                               true, // IncludeTimestamp
+                               SecurityKeyEntropyMode.CombinedEntropy,
+                               MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature,
+                               MessageSecurityVersion.Default,
+                               false, // RequireSignatureConfirmation
+                               SecurityHeaderLayout.Strict,
+                               // EndpointSupportingTokenParameters: endorsing, signed, signedEncrypted, signedEndorsing (by count)
+                               0, 0, 0, 0,
+                               // ProtectionTokenParameters
+                               true, SecurityTokenInclusionMode.Once, SecurityTokenReferenceStyle.Internal, true,
+                               // LocalClientSettings
+                               true, 60, true,
+
+                               be, "");
+
+                       // FIXME: test ProtectionTokenParameters
+               }
+
+               [Test]
+               public void CreateSslNegotiationBindingElement ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               SecurityBindingElement.CreateSslNegotiationBindingElement (true, true);
+
+                       SecurityAssert.AssertSymmetricSecurityBindingElement (
+                               SecurityAlgorithmSuite.Default,
+                               true, // IncludeTimestamp
+                               SecurityKeyEntropyMode.CombinedEntropy,
+                               MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature,
+                               MessageSecurityVersion.Default,
+                               false, // RequireSignatureConfirmation
+                               SecurityHeaderLayout.Strict,
+                               // EndpointSupportingTokenParameters: endorsing, signed, signedEncrypted, signedEndorsing (by count)
+                               0, 0, 0, 0,
+                               // ProtectionTokenParameters
+                               true, SecurityTokenInclusionMode.AlwaysToRecipient, SecurityTokenReferenceStyle.Internal, true,
+                               // LocalClientSettings
+                               true, 60, true,
+
+                               be, "");
+
+                       // FIXME: also try different constructor arguments
+
+                       // test ProtectionTokenParameters
+                       Assert.AreEqual (typeof (SslSecurityTokenParameters), be.ProtectionTokenParameters.GetType (), "#1");
+                       SslSecurityTokenParameters sp = be.ProtectionTokenParameters as SslSecurityTokenParameters;
+                       Assert.AreEqual (true, sp.RequireCancellation, "#2");
+                       Assert.AreEqual (true, sp.RequireClientCertificate, "#3");
+               }
+
+               [Test]
+               public void CreateSspiNegotiationBindingElement ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               SecurityBindingElement.CreateSspiNegotiationBindingElement ();
+
+                       SecurityAssert.AssertSymmetricSecurityBindingElement (
+                               SecurityAlgorithmSuite.Default,
+                               true, // IncludeTimestamp
+                               SecurityKeyEntropyMode.CombinedEntropy,
+                               MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature,
+                               MessageSecurityVersion.Default,
+                               false, // RequireSignatureConfirmation
+                               SecurityHeaderLayout.Strict,
+                               // EndpointSupportingTokenParameters: endorsing, signed, signedEncrypted, signedEndorsing (by count)
+                               0, 0, 0, 0,
+                               // ProtectionTokenParameters
+                               true, SecurityTokenInclusionMode.AlwaysToRecipient, SecurityTokenReferenceStyle.Internal, true,
+                               // LocalClientSettings
+                               true, 60, true,
+
+                               be, "");
+
+                       // FIXME: Try boolean argument as well.
+
+                       // FIXME: test ProtectionTokenParameters
+               }
+
+               [Test]
+               public void CreateUserNameForCertificateBindingElement ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               SecurityBindingElement.CreateUserNameForCertificateBindingElement ();
+
+                       SecurityAssert.AssertSymmetricSecurityBindingElement (
+                               SecurityAlgorithmSuite.Default,
+                               true, // IncludeTimestamp
+                               SecurityKeyEntropyMode.CombinedEntropy,
+                               MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature,
+                               MessageSecurityVersion.Default,
+                               false, // RequireSignatureConfirmation
+                               SecurityHeaderLayout.Strict,
+                               // EndpointSupportingTokenParameters: endorsing, signed, signedEncrypted, signedEndorsing (by count)
+                               0, 0, 1, 0,
+                               // ProtectionTokenParameters
+                               true, SecurityTokenInclusionMode.Never, SecurityTokenReferenceStyle.Internal, true,
+                               // LocalClientSettings
+                               true, 60, true,
+
+                               be, "");
+
+                       UserNameSecurityTokenParameters up =
+                               be.EndpointSupportingTokenParameters.SignedEncrypted [0] as UserNameSecurityTokenParameters;
+                       // FIXME: test it
+
+                       // FIXME: test ProtectionTokenParameters
+               }
+
+               [Test]
+               public void CreateUserNameForSslBindingElement ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               SecurityBindingElement.CreateUserNameForSslBindingElement ();
+
+                       SecurityAssert.AssertSymmetricSecurityBindingElement (
+                               SecurityAlgorithmSuite.Default,
+                               true, // IncludeTimestamp
+                               SecurityKeyEntropyMode.CombinedEntropy,
+                               MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature,
+                               MessageSecurityVersion.Default,
+                               false, // RequireSignatureConfirmation
+                               SecurityHeaderLayout.Strict,
+                               // EndpointSupportingTokenParameters: endorsing, signed, signedEncrypted, signedEndorsing (by count)
+                               0, 0, 1, 0,
+                               // ProtectionTokenParameters
+                               true, SecurityTokenInclusionMode.AlwaysToRecipient, SecurityTokenReferenceStyle.Internal, true,
+                               // LocalClientSettings
+                               true, 60, true,
+
+                               be, "");
+
+                       UserNameSecurityTokenParameters up =
+                               be.EndpointSupportingTokenParameters.SignedEncrypted [0] as UserNameSecurityTokenParameters;
+                       // FIXME: test it
+
+                       // FIXME: test ProtectionTokenParameters
+               }
+
+               // non-symmetric return value by definition, but still
+               // returns symmetric binding elements.
+
+               [Test]
+               public void CreateSecureConversationBindingElement ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               SecurityBindingElement.CreateSecureConversationBindingElement (new SymmetricSecurityBindingElement ())
+                               as SymmetricSecurityBindingElement;
+
+                       SecurityAssert.AssertSymmetricSecurityBindingElement (
+                               SecurityAlgorithmSuite.Default,
+                               true, // IncludeTimestamp
+                               SecurityKeyEntropyMode.CombinedEntropy,
+                               MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature,
+                               MessageSecurityVersion.Default,
+                               false, // RequireSignatureConfirmation
+                               SecurityHeaderLayout.Strict,
+                               // EndpointSupportingTokenParameters: endorsing, signed, signedEncrypted, signedEndorsing (by count)
+                               0, 0, 0, 0,
+                               // ProtectionTokenParameters
+                               true, SecurityTokenInclusionMode.AlwaysToRecipient, SecurityTokenReferenceStyle.Internal, true,
+                               // LocalClientSettings
+                               true, 60, true,
+
+                               be, "");
+
+                       // test ProtectionTokenParameters
+                       SecureConversationSecurityTokenParameters tp =
+                               be.ProtectionTokenParameters as SecureConversationSecurityTokenParameters;
+                       Assert.IsNotNull (tp, "#2-1");
+
+                       SecurityAssert.AssertSecurityTokenParameters (
+                               SecurityTokenInclusionMode.AlwaysToRecipient,
+                               SecurityTokenReferenceStyle.Internal,
+                               true, tp, "Protection");
+               }
+
+               #endregion
+
+               [Test]
+               public void SetKeyDerivation ()
+               {
+                       SetKeyDerivationCorrect (new TransportSecurityBindingElement (), "transport");
+                       SetKeyDerivationIncorrect (new TransportSecurityBindingElement (), "transport");
+                       SetKeyDerivationCorrect (new SymmetricSecurityBindingElement (), "symmetric");
+                       SetKeyDerivationIncorrect (new SymmetricSecurityBindingElement (), "symmetric");
+                       SetKeyDerivationCorrect (new AsymmetricSecurityBindingElement (), "asymmetric");
+                       SetKeyDerivationIncorrect (new AsymmetricSecurityBindingElement (), "asymmetric");
+               }
+
+               void SetKeyDerivationCorrect (SecurityBindingElement be, string label)
+               {
+                       X509SecurityTokenParameters p, p2;
+                       p = new X509SecurityTokenParameters ();
+                       p2 = new X509SecurityTokenParameters ();
+                       Assert.AreEqual (true, p.RequireDerivedKeys, label + "#1");
+                       Assert.AreEqual (true, p2.RequireDerivedKeys, label + "#2");
+                       be.EndpointSupportingTokenParameters.Endorsing.Add (p);
+                       be.EndpointSupportingTokenParameters.Endorsing.Add (p2);
+                       be.SetKeyDerivation (false);
+                       Assert.AreEqual (false, p.RequireDerivedKeys, label + "#3");
+                       Assert.AreEqual (false, p2.RequireDerivedKeys, label + "#4");
+               }
+
+               void SetKeyDerivationIncorrect (SecurityBindingElement be, string label)
+               {
+                       X509SecurityTokenParameters p, p2;
+                       p = new X509SecurityTokenParameters ();
+                       p2 = new X509SecurityTokenParameters ();
+                       // setting in prior - makes no sense
+                       be.SetKeyDerivation (false);
+                       be.EndpointSupportingTokenParameters.Endorsing.Add (p);
+                       be.EndpointSupportingTokenParameters.Endorsing.Add (p2);
+                       Assert.AreEqual (true, p.RequireDerivedKeys, label + "#5");
+                       Assert.AreEqual (true, p2.RequireDerivedKeys, label + "#6");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               [Category ("NotWorking")]
+               public void CheckDuplicateAuthenticatorTypesClient ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               new SymmetricSecurityBindingElement ();
+                       be.ProtectionTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       be.EndpointSupportingTokenParameters.Endorsing.Add (
+                               new X509SecurityTokenParameters ());
+                       // This causes multiple supporting token authenticator
+                       // of the same type.
+                       be.OptionalEndpointSupportingTokenParameters.Endorsing.Add (
+                               new X509SecurityTokenParameters ());
+                       Binding b = new CustomBinding (be, new HttpTransportBindingElement ());
+                       ClientCredentials cred = new ClientCredentials ();
+                       cred.ClientCertificate.Certificate =
+                               new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+                       IChannelFactory<IReplyChannel> ch = b.BuildChannelFactory<IReplyChannel> (new Uri ("http://localhost:37564"), cred);
+                       try {
+                               ch.Open ();
+                       } finally {
+                               if (ch.State == CommunicationState.Closed)
+                                       ch.Close ();
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               [Category ("NotWorking")]
+               public void CheckDuplicateAuthenticatorTypesService ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               new SymmetricSecurityBindingElement ();
+                       be.ProtectionTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       be.EndpointSupportingTokenParameters.Endorsing.Add (
+                               new X509SecurityTokenParameters ());
+                       // This causes multiple supporting token authenticator
+                       // of the same type.
+                       be.OptionalEndpointSupportingTokenParameters.Endorsing.Add (
+                               new X509SecurityTokenParameters ());
+                       Binding b = new CustomBinding (be, new HttpTransportBindingElement ());
+                       ServiceCredentials cred = new ServiceCredentials ();
+                       cred.ServiceCertificate.Certificate =
+                               new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+                       IChannelListener<IReplyChannel> ch = b.BuildChannelListener<IReplyChannel> (new Uri ("http://localhost:37564"), cred);
+                       try {
+                               ch.Open ();
+                       } finally {
+                               if (ch.State == CommunicationState.Closed)
+                                       ch.Close ();
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")]
+               public void NonEndorsibleParameterInEndorsingSupport ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               new SymmetricSecurityBindingElement ();
+                       be.ProtectionTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       be.EndpointSupportingTokenParameters.Endorsing.Add (
+                               new UserNameSecurityTokenParameters ());
+                       Binding b = new CustomBinding (be, new HttpTransportBindingElement ());
+                       X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+                       EndpointAddress ea = new EndpointAddress (new Uri ("http://localhost:37564"), new X509CertificateEndpointIdentity (cert));
+                       CalcProxy client = new CalcProxy (b, ea);
+                       client.ClientCredentials.UserName.UserName = "rupert";
+                       client.Sum (1, 2);
+               }
+
+               void AssertSecurityCapabilities (
+                       ProtectionLevel request, ProtectionLevel response,
+                       bool supportsClientAuth, bool supportsClientWinId,
+                       bool supportsServerAuth, ISecurityCapabilities c,
+                       string label)
+               {
+                       Assert.AreEqual (request, c.SupportedRequestProtectionLevel, label + ".request");
+                       Assert.AreEqual (response, c.SupportedResponseProtectionLevel, label + ".response");
+                       Assert.AreEqual (supportsClientAuth, c.SupportsClientAuthentication, label + ".client-auth");
+                       Assert.AreEqual (supportsClientWinId, c.SupportsClientWindowsIdentity, label + ".client-identity");
+                       Assert.AreEqual (supportsServerAuth, c.SupportsServerAuthentication, label + ".server-auth");
+               }
+
+               ISecurityCapabilities GetSecurityCapabilities (SecurityBindingElement be)
+               {
+                       BindingContext bc = new BindingContext (
+                               new CustomBinding (),
+                               new BindingParameterCollection ());
+                       return be.GetProperty<ISecurityCapabilities> (bc);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void GetPropertyNullBindingContext1 ()
+               {
+                       new SymmetricSecurityBindingElement ()
+                               .GetProperty<ISecurityCapabilities> (null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void GetPropertyNullBindingContext2 ()
+               {
+                       new AsymmetricSecurityBindingElement ()
+                               .GetProperty<ISecurityCapabilities> (null);
+               }
+
+               [Test]
+               public void GetPropertySecurityCapabilities ()
+               {
+                       ISecurityCapabilities c;
+                       RsaSecurityTokenParameters rsa =
+                               new RsaSecurityTokenParameters ();
+                       UserNameSecurityTokenParameters user =
+                               new UserNameSecurityTokenParameters ();
+                       X509SecurityTokenParameters x509 =
+                               new X509SecurityTokenParameters ();
+                       SecureConversationSecurityTokenParameters sc1 =
+                               new SecureConversationSecurityTokenParameters ();
+                       sc1.BootstrapSecurityBindingElement =
+                               new SymmetricSecurityBindingElement (); // empty
+                       SecureConversationSecurityTokenParameters sc2 =
+                               new SecureConversationSecurityTokenParameters ();
+                       sc2.BootstrapSecurityBindingElement =
+                               new SymmetricSecurityBindingElement (x509);
+                       SecureConversationSecurityTokenParameters sc3 =
+                               new SecureConversationSecurityTokenParameters ();
+                       sc3.BootstrapSecurityBindingElement =
+                               new AsymmetricSecurityBindingElement (null, x509);
+                       SecureConversationSecurityTokenParameters sc4 =
+                               new SecureConversationSecurityTokenParameters ();
+                       sc4.BootstrapSecurityBindingElement =
+                               new AsymmetricSecurityBindingElement (x509, null);
+
+                       // no parameters
+                       c = GetSecurityCapabilities (
+                               new SymmetricSecurityBindingElement ());
+                       AssertSecurityCapabilities (
+                               ProtectionLevel.EncryptAndSign,
+                               ProtectionLevel.EncryptAndSign,
+                               false, false, false, c, "#1");
+
+                       // x509 parameters for both
+                       c = GetSecurityCapabilities (
+                               new SymmetricSecurityBindingElement (x509));
+                       AssertSecurityCapabilities (
+                               ProtectionLevel.EncryptAndSign,
+                               ProtectionLevel.EncryptAndSign,
+                               true, true, true, c, "#2");
+
+                       // no initiator parameters
+                       c = GetSecurityCapabilities (
+                               new AsymmetricSecurityBindingElement (x509, null));
+                       AssertSecurityCapabilities (
+                               ProtectionLevel.EncryptAndSign,
+                               ProtectionLevel.EncryptAndSign,
+                               false, false, true, c, "#3");
+
+                       // no recipient parameters
+                       c = GetSecurityCapabilities (
+                               new AsymmetricSecurityBindingElement (null, x509));
+                       AssertSecurityCapabilities (
+                               ProtectionLevel.EncryptAndSign,
+                               ProtectionLevel.EncryptAndSign,
+                               true, true, false, c, "#4");
+
+                       // initiator does not support identity
+                       c = GetSecurityCapabilities (
+                               new AsymmetricSecurityBindingElement (x509, rsa));
+                       AssertSecurityCapabilities (
+                               ProtectionLevel.EncryptAndSign,
+                               ProtectionLevel.EncryptAndSign,
+                               true, false, true, c, "#5");
+
+                       // recipient does not support server auth
+                       c = GetSecurityCapabilities (
+                               new AsymmetricSecurityBindingElement (user, x509));
+                       AssertSecurityCapabilities (
+                               ProtectionLevel.EncryptAndSign,
+                               ProtectionLevel.EncryptAndSign,
+                               true, true, false, c, "#6");
+
+                       // secureconv with no symm. bootstrap params
+                       c = GetSecurityCapabilities (
+                               new SymmetricSecurityBindingElement (sc1));
+                       AssertSecurityCapabilities (
+                               ProtectionLevel.EncryptAndSign,
+                               ProtectionLevel.EncryptAndSign,
+                               false, false, false, c, "#7");
+
+                       // secureconv with x509 symm. bootstrap params
+                       c = GetSecurityCapabilities (
+                               new SymmetricSecurityBindingElement (sc2));
+                       AssertSecurityCapabilities (
+                               ProtectionLevel.EncryptAndSign,
+                               ProtectionLevel.EncryptAndSign,
+                               true, true, true, c, "#8");
+
+                       // secureconv with x509 initiator bootstrap params
+                       c = GetSecurityCapabilities (
+                               new SymmetricSecurityBindingElement (sc3));
+                       AssertSecurityCapabilities (
+                               ProtectionLevel.EncryptAndSign,
+                               ProtectionLevel.EncryptAndSign,
+                               true, true, false, c, "#9");
+
+                       // secureconv with x509 recipient bootstrap params
+                       c = GetSecurityCapabilities (
+                               new SymmetricSecurityBindingElement (sc4));
+                       AssertSecurityCapabilities (
+                               ProtectionLevel.EncryptAndSign,
+                               ProtectionLevel.EncryptAndSign,
+                               false, false, true, c, "#10");
+
+                       // FIXME: find out such cases that returns other ProtectionLevel values.
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SslStreamSecurityBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SslStreamSecurityBindingElementTest.cs
new file mode 100644 (file)
index 0000000..01f273e
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// SslStreamSecurityBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.Text;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class SslStreamSecurityBindingElementTest : BindingElementTest
+       {
+               [Test]
+               [Category ("NotWorking")]
+               public void DefaultValues ()
+               {
+                       SslStreamSecurityBindingElement bel =
+                               new SslStreamSecurityBindingElement ();
+                       Assert.IsNotNull (bel.IdentityVerifier, "#1");
+                       Assert.AreEqual (false, bel.RequireClientCertificate, "#2");
+                       Assert.AreEqual ("<msf:SslTransportSecurity xmlns:msf=\"http://schemas.microsoft.com/ws/2006/05/framing/policy\" />", bel.GetTransportTokenAssertion ().OuterXml, "#3");
+               }
+
+               StreamSecurityUpgradeProvider CreateClientProvider (params object [] parameters)
+               {
+                       SslStreamSecurityBindingElement bel =
+                               new SslStreamSecurityBindingElement ();
+                       BindingParameterCollection pl =
+                               new BindingParameterCollection ();
+                       foreach (object o in parameters)
+                               pl.Add (o);
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (new HttpTransportBindingElement ()), pl);
+                       return bel.BuildClientStreamUpgradeProvider (ctx)
+                               as StreamSecurityUpgradeProvider;
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")]
+               public void ClientProviderCreateAcceptorBeforeOpen ()
+               {
+                       StreamSecurityUpgradeProvider p = CreateClientProvider ();
+                       p.CreateUpgradeAcceptor ();
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ClientAcceptUpgradeWithoutServiceCertificate ()
+               {
+                       StreamSecurityUpgradeProvider p = CreateClientProvider ();
+                       Assert.IsNotNull (p, "#1");
+                       Assert.IsNull (p.Identity, "#2"); // not yet, before Open().
+                       p.Open ();
+                       StreamUpgradeAcceptor a = p.CreateUpgradeAcceptor ();
+                       try {
+                               Stream s = a.AcceptUpgrade (new MemoryStream (new byte [] {1, 2, 3, 4, 5}));
+                               Assert.Fail ("It should somehow raise an error."); // on Winfx it is unwise ArgumentNullException
+                       } catch (Exception) {
+                       } finally {
+                               p.Close ();
+                       }
+               }
+
+               [Test]
+               [Ignore ("find out how to fill serverCertificate")]
+               public void ClientAcceptUpgrade ()
+               {
+                       ServiceCredentials cred = new ServiceCredentials ();
+                       X509Certificate2 cert = 
+                               new X509Certificate2 ("Test/Resources/test.cer");
+                       cred.ServiceCertificate.Certificate = cert;
+                       X509CertificateEndpointIdentity ident =
+                               new X509CertificateEndpointIdentity (cert);
+                       StreamSecurityUpgradeProvider p = CreateClientProvider (cred, ident);
+                       p.Open ();
+                       try {
+                               StreamSecurityUpgradeAcceptor a =
+                                       p.CreateUpgradeAcceptor ()
+                                       as StreamSecurityUpgradeAcceptor;
+                               Assert.IsNotNull (a, "#1");
+                               SecurityMessageProperty prop =
+                                       a.GetRemoteSecurity ();
+                               Assert.IsNull (prop, "#2"); // hmm
+                               Stream s = a.AcceptUpgrade (new MemoryStream (new byte [] {1, 2, 3, 4, 5}));
+                       } finally {
+                               p.Close ();
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SymmetricSecurityBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/SymmetricSecurityBindingElementTest.cs
new file mode 100644 (file)
index 0000000..5792d72
--- /dev/null
@@ -0,0 +1,664 @@
+//
+// SymmetricSecurityBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.Security.Cryptography.X509Certificates;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class SymmetricSecurityBindingElementTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               new SymmetricSecurityBindingElement ();
+
+                       SecurityAssert.AssertSymmetricSecurityBindingElement (
+                               SecurityAlgorithmSuite.Default,
+                               true, // IncludeTimestamp
+                               SecurityKeyEntropyMode.CombinedEntropy,
+                               MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature,
+                               MessageSecurityVersion.Default,
+                               false, // RequireSignatureConfirmation
+                               SecurityHeaderLayout.Strict,
+                               // EndpointSupportingTokenParameters: endorsing, signed, signedEncrypted, signedEndorsing (by count)
+                               0, 0, 0, 0,
+                               // ProtectionTokenParameters
+                               false,
+                               default (SecurityTokenInclusionMode),
+                               default (SecurityTokenReferenceStyle),
+                               default (bool),
+                               // LocalClientSettings
+                               true, 60, true,
+
+                               be, "");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void BuildChannelWithoutProtectionTokenParameters ()
+               {
+                       CustomBinding b = new CustomBinding (
+                               new SymmetricSecurityBindingElement (),
+                               new TextMessageEncodingBindingElement (),
+                               new HttpTransportBindingElement ());
+                       b.BuildChannelFactory<IRequestChannel> (new BindingParameterCollection ());
+               }
+
+               CustomBinding CreateBinding ()
+               {
+                       RequestSender handler = delegate (Message input) {
+                               throw new Exception ();
+                       };
+                       return CreateBinding (handler);
+               }
+
+               CustomBinding CreateBinding (RequestSender sender)
+               {
+                       return CreateBinding (sender, new X509SecurityTokenParameters ());
+               }
+
+               CustomBinding CreateBinding (RequestSender sender, bool isOneWay)
+               {
+                       return CreateBinding (sender, new X509SecurityTokenParameters (), isOneWay);
+               }
+
+               CustomBinding CreateBinding (SecurityTokenParameters protectionTokenParameters)
+               {
+                       RequestSender handler = delegate (Message input) {
+                               throw new Exception ();
+                       };
+                       return CreateBinding (handler, protectionTokenParameters);
+               }
+
+               CustomBinding CreateBinding (RequestSender sender,
+                       SecurityTokenParameters protectionTokenParameters)
+               {
+                       return CreateBinding (sender, protectionTokenParameters, false);
+               }
+
+               CustomBinding CreateBinding (RequestSender sender,
+                       SecurityTokenParameters protectionTokenParameters,
+                       bool isOneWay)
+               {
+                       SymmetricSecurityBindingElement sbe =
+                               new SymmetricSecurityBindingElement ();
+                       sbe.ProtectionTokenParameters = protectionTokenParameters;
+                       List<BindingElement> l = new List<BindingElement> ();
+                       l.Add (sbe);
+                       l.Add (new TextMessageEncodingBindingElement ());
+                       if (isOneWay)
+                               l.Add (new OneWayBindingElement ());
+                       l.Add (new HandlerTransportBindingElement (sender));
+                       CustomBinding b = new CustomBinding (l);
+                       return b;
+               }
+
+               CustomBinding CreateBinding (ReplyHandler replier, RequestReceiver receiver)
+               {
+                       SymmetricSecurityBindingElement sbe =
+                               new SymmetricSecurityBindingElement ();
+                       sbe.ProtectionTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       CustomBinding b = new CustomBinding (
+                               sbe,
+                               new TextMessageEncodingBindingElement (),
+                               new HandlerTransportBindingElement (replier, receiver));
+                       return b;
+               }
+
+               EndpointAddress CreateX509EndpointAddress (string uri)
+               {
+                       EndpointIdentity identity =
+                               new X509CertificateEndpointIdentity (new X509Certificate2 ("Test/Resources/test.pfx", "mono"));
+                       return new EndpointAddress (new Uri (uri), identity);
+               }
+
+               IChannelListener<IReplyChannel> CreateListener (ReplyHandler handler, RequestReceiver receiver)
+               {
+                       CustomBinding rb = CreateBinding (handler, receiver);
+                       BindingParameterCollection bpl =
+                               new BindingParameterCollection ();
+                       ServiceCredentials cred = new ServiceCredentials ();
+                       cred.ServiceCertificate.Certificate =
+                               new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+                       IServiceBehavior sb = cred;
+                       sb.AddBindingParameters (null, null, null, bpl);
+                       IChannelListener<IReplyChannel> listener = rb.BuildChannelListener<IReplyChannel> (bpl);
+                       return listener;
+               }
+
+               [Test]
+               public void OpenChannelFactory ()
+               {
+                       CustomBinding b = CreateBinding ();
+
+                       IChannelFactory<IRequestChannel> f =
+                               b.BuildChannelFactory<IRequestChannel> (new BindingParameterCollection ());
+                       f.Open ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void BuildChannelWithoutOpen ()
+               {
+                       CustomBinding b = CreateBinding ();
+
+                       IChannelFactory<IRequestChannel> f =
+                               b.BuildChannelFactory<IRequestChannel> (new BindingParameterCollection ());
+                       f.CreateChannel (CreateX509EndpointAddress ("stream:dummy"));
+               }
+
+               [Test]
+               public void OpenRequestNonAuthenticatable ()
+               {
+                       SymmetricSecurityBindingElement sbe = 
+                               new SymmetricSecurityBindingElement ();
+                       sbe.ProtectionTokenParameters =
+                               new UserNameSecurityTokenParameters ();
+                       Binding binding = new CustomBinding (sbe, new HandlerTransportBindingElement (null));
+                       BindingParameterCollection pl =
+                               new BindingParameterCollection ();
+                       ClientCredentials cred = new ClientCredentials ();
+                       cred.UserName.UserName = "mono";
+                       pl.Add (cred);
+                       IChannelFactory<IRequestChannel> f =
+                               binding.BuildChannelFactory<IRequestChannel> (pl);
+                       f.Open ();
+                       IRequestChannel ch = f.CreateChannel (new EndpointAddress ("stream:dummy"));
+                       try {
+                               ch.Open ();
+                               Assert.Fail ("NotSupportedException is expected.");
+                       } catch (NotSupportedException) {
+                       }
+               }
+
+               // The service certificate is not provided for target
+               // 'stream:dummy'. Specify a service certificate in 
+               // ClientCredentials.
+               [Test]
+               public void OpenRequestWithoutServiceCertificate ()
+               {
+                       CustomBinding b = CreateBinding ();
+
+                       IChannelFactory<IRequestChannel> f =
+                               b.BuildChannelFactory<IRequestChannel> (new BindingParameterCollection ());
+                       f.Open ();
+                       // This EndpointAddress does not contain X509 identity
+                       IRequestChannel ch = f.CreateChannel (new EndpointAddress ("stream:dummy"));
+                       try {
+                               ch.Open ();
+                               Assert.Fail ("expected InvalidOperationException here.");
+                       } catch (InvalidOperationException) {
+                       }
+               }
+
+               IChannelFactory<IRequestChannel> CreateDefaultServiceCertFactory ()
+               {
+                       CustomBinding b = CreateBinding (delegate (Message req) {
+                               return null;
+                               });
+                       ClientCredentials cred = new ClientCredentials ();
+                       cred.ServiceCertificate.DefaultCertificate = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+                       BindingParameterCollection parameters =
+                               new BindingParameterCollection ();
+                       parameters.Add (cred);
+                       ChannelProtectionRequirements cp =
+                               new ChannelProtectionRequirements ();
+                       cp.IncomingSignatureParts.AddParts (
+                               new MessagePartSpecification (true),
+                               "http://tempuri.org/MyAction");
+                       cp.IncomingEncryptionParts.AddParts (
+                               new MessagePartSpecification (true),
+                               "http://tempuri.org/MyAction");
+                       parameters.Add (cp);
+
+                       return b.BuildChannelFactory<IRequestChannel> (parameters);
+               }
+
+               [Test]
+               public void OpenRequestWithDefaultServiceCertificate ()
+               {
+                       IChannelFactory<IRequestChannel> f =
+                               CreateDefaultServiceCertFactory ();
+                       f.Open ();
+                       // This EndpointAddress does not contain X509 identity
+                       IRequestChannel ch = f.CreateChannel (new EndpointAddress ("stream:dummy"));
+                       ch.Open ();
+                       // stop here.
+               }
+
+               [Test]
+               [ExpectedException (typeof (MessageSecurityException))]
+               [Category ("NotWorking")]
+               // from WinFX:
+               // MessageSecurityException : Identity check failed for outgoing
+               // message. The expected DNS identity of the remote endpoint was
+               // '' but the remote endpoint provided DNS claim 'Poupou's-
+               // Software-Factory'. If this is a legitimate remote endpoint,
+               // you can fix the problem by explicitly specifying DNS identity
+               // 'Poupou's-Software-Factory' as the Identity property of
+               // EndpointAddress when creating channel proxy.
+               public void RequestWithDefaultServiceCertificateWithoutDns ()
+               {
+                       IChannelFactory<IRequestChannel> f =
+                               CreateDefaultServiceCertFactory ();
+                       f.Open ();
+                       // This EndpointAddress does not contain X509 identity
+                       IRequestChannel ch = f.CreateChannel (new EndpointAddress ("stream:dummy"));
+                       ch.Open ();
+                       // -> MessageSecurityException (IdentityVerifier complains DNS claim)
+                       ch.Request (Message.CreateMessage (MessageVersion.Default, "http://tempuri.org/MyAction"));
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void RequestWithDefaultServiceCertificateWithDns ()
+               {
+                       IChannelFactory<IRequestChannel> f =
+                               CreateDefaultServiceCertFactory ();
+                       f.Open ();
+                       // This EndpointAddress does not contain X509 identity
+                       IRequestChannel ch = f.CreateChannel (new EndpointAddress (new Uri ("stream:dummy"), new DnsEndpointIdentity ("Poupou's-Software-Factory")));
+                       ch.Open ();
+                       // -> MessageSecurityException (IdentityVerifier complains DNS claim)
+                       ch.Request (Message.CreateMessage (MessageVersion.Default, "http://tempuri.org/MyAction"));
+               }
+
+               [Test]
+               [Category ("NotWorking")] // it depends on Kerberos
+               public void OpenRequestWithoutServiceCertificateForNonX509 ()
+               {
+                       CustomBinding b = CreateBinding (new MyOwnSecurityTokenParameters ());
+
+                       IChannelFactory<IRequestChannel> f =
+                               b.BuildChannelFactory<IRequestChannel> (new BindingParameterCollection ());
+                       f.Open ();
+                       // This EndpointAddress does not contain X509 identity
+                       IRequestChannel ch = f.CreateChannel (new EndpointAddress ("stream:dummy"));
+                       ch.Open ();
+               }
+
+               [Test]
+               public void SendRequestWithoutOpen ()
+               {
+                       CustomBinding b = CreateBinding ();
+
+                       IChannelFactory<IRequestChannel> f =
+                               b.BuildChannelFactory<IRequestChannel> (new BindingParameterCollection ());
+                       f.Open ();
+                       IRequestChannel ch = f.CreateChannel (CreateX509EndpointAddress ("stream:dummy"));
+                       try {
+                               ch.Request (Message.CreateMessage (MessageVersion.Default, "myAction"));
+                               Assert.Fail ("expected InvalidOperationException here.");
+                       } catch (InvalidOperationException) {
+                       }
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void SendRequestWithoutSignatureMessagePart ()
+               {
+                       CustomBinding b = CreateBinding ();
+
+                       // without ChannelProtectionRequirements it won't be
+                       // signed and/or encrypted.
+                       IChannelFactory<IRequestChannel> f =
+                               b.BuildChannelFactory<IRequestChannel> (new BindingParameterCollection ());
+                       f.Open ();
+                       IRequestChannel ch = f.CreateChannel (CreateX509EndpointAddress ("stream:dummy"));
+
+                       ch.Open ();
+                       // MessageSecurityException : No signature message parts
+                       // were specified for messages with the 'myAction' 
+                       // action.
+                       try {
+                               ch.Request (Message.CreateMessage (b.MessageVersion, "myAction"));
+                               Assert.Fail ("MessageSecurityException is expected here.");
+                       } catch (MessageSecurityException) {
+                       }
+               }
+
+
+               [Test]
+               [ExpectedException (typeof (Exception))]
+               [Category ("NotWorking")]
+               public void SendRequestWithSignatureMessagePart ()
+               {
+                       CustomBinding b = CreateBinding ();
+                       ChannelProtectionRequirements cp =
+                               new ChannelProtectionRequirements ();
+                       cp.IncomingSignatureParts.AddParts (new MessagePartSpecification (true), "myAction");
+                       cp.IncomingEncryptionParts.AddParts (new MessagePartSpecification (true), "myAction");
+                       BindingParameterCollection parameters =
+                               new BindingParameterCollection ();
+                       parameters.Add (cp);
+
+                       IChannelFactory<IRequestChannel> f =
+                               b.BuildChannelFactory<IRequestChannel> (parameters);
+                       f.Open ();
+                       IRequestChannel ch = f.CreateChannel (CreateX509EndpointAddress ("stream:dummy"));
+
+                       ch.Open ();
+                       ch.Request (Message.CreateMessage (b.MessageVersion, "myAction"));
+               }
+
+               [Test]
+               [Category ("NotWorking")] // it requires OneWay
+               public void RequestBasedOnContract1 ()
+               {
+                       CustomBinding b = CreateBinding (delegate (Message input) {
+                               return null;
+                       }, true);
+
+                       IFoo foo = ChannelFactory<IFoo>.CreateChannel (b, CreateX509EndpointAddress ("stream:dummy"));
+                       foo.Bar (Message.CreateMessage (b.MessageVersion, "http://tempuri.org/IFoo/Bar"));
+               }
+
+               [Test]
+               public void RequestBasedOnContract2 ()
+               {
+                       CustomBinding b = CreateBinding (delegate (Message input) {
+                               return null;
+                       }, true);
+
+                       IFoo foo = ChannelFactory<IFoo>.CreateChannel (b, CreateX509EndpointAddress ("stream:dummy"));
+                       foo.Baz ("TEST");
+               }
+
+               [Test]
+               // it still does not produce secure message ...
+               [Category ("NotWorking")]
+               public void RequestBasedOnContract3 ()
+               {
+                       CustomBinding b = CreateBinding (delegate (Message input) {
+                               // seems like security message property is not attached to the request.
+                               foreach (object o in input.Properties.Values)
+                                       if (o is SecurityMessageProperty)
+                                               Assert.Fail ("there should be a SecurityMessageProperty.");
+                               return null;
+                       }, true);
+
+                       IFoo foo = ChannelFactory<IFoo>.CreateChannel (b, CreateX509EndpointAddress ("stream:dummy"));
+                       foo.Bleh ("TEST");
+               }
+
+               // from WCF (beta2):
+               // "MessageSecurityException : Security processor was unable
+               // to find a security header in the message. This might be
+               // because the message is an unsecured fault or because there
+               // is a binding mismatch between the communicating parties.
+               // This can occur if the service is configured for security
+               // and the client is not using security."
+               [Test]
+               [ExpectedException (typeof (MessageSecurityException))]
+               [Category ("NotWorking")]
+               public void RequestUnsecuredReply ()
+               {
+                       CustomBinding b = CreateBinding (delegate (Message input) {
+                               return input;
+                       });
+
+                       IFoo foo = ChannelFactory<IFoo>.CreateChannel (b, CreateX509EndpointAddress ("stream:dummy"));
+                       foo.Bar (Message.CreateMessage (b.MessageVersion, "http://tempuri.org/IFoo/Bar"));
+               }
+
+               [ServiceContract]
+               interface IFoo
+               {
+                       [OperationContract (IsOneWay = true)]
+                       void Bar (Message msg);
+
+                       [OperationContract (IsOneWay = true)]
+                       void Baz (string src);
+
+                       [OperationContract (ProtectionLevel = ProtectionLevel.Sign, IsOneWay = true)]
+                       void Bleh (string src);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void BuildListenerWithoutProtectionTokenParameters ()
+               {
+                       CustomBinding b = new CustomBinding (
+                               new SymmetricSecurityBindingElement (),
+                               new TextMessageEncodingBindingElement (),
+                               new HttpTransportBindingElement ());
+                       b.BuildChannelListener<IReplyChannel> (new BindingParameterCollection ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void OpenListenerWithoutServiceCertificate ()
+               {
+                       CustomBinding rb = CreateBinding ();
+                       IChannelListener<IReplyChannel> listener = rb.BuildChannelListener<IReplyChannel> (new BindingParameterCollection ());
+                       listener.Open ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void OpenListenerNoPrivateKeyInServiceCertificate ()
+               {
+                       CustomBinding rb = CreateBinding ();
+                       BindingParameterCollection bpl =
+                               new BindingParameterCollection ();
+                       ServiceCredentials cred = new ServiceCredentials ();
+                       cred.ServiceCertificate.Certificate =
+                               new X509Certificate2 ("Test/Resources/test.cer");
+                       IServiceBehavior sb = cred;
+                       sb.AddBindingParameters (null, null, null, bpl);
+                       IChannelListener<IReplyChannel> listener = rb.BuildChannelListener<IReplyChannel> (bpl);
+                       listener.Open ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AcceptChannelWithoutOpenListener ()
+               {
+                       IChannelListener<IReplyChannel> listener = CreateListener (null, null);
+                       listener.AcceptChannel ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")]
+               public void ReceiveRequestWithoutOpenChannel ()
+               {
+                       IChannelListener<IReplyChannel> listener = CreateListener (null, null);
+                       listener.Open ();
+                       IReplyChannel reply = listener.AcceptChannel ();
+                       reply.ReceiveRequest ();
+               }
+
+               [Test]
+               [Ignore ("It's not working")]
+               [ExpectedException (typeof (ApplicationException))]
+               public void ReceiveRequest ()
+               {
+                       // Seems like this method is invoked to send a reply
+                       // with related to "already created" SOAP fault.
+                       //
+                       // It is still not understandable that this delegate
+                       // is invoked as an infinite loop ...
+                       ReplyHandler handler = delegate (Message input) {
+Console.Error.WriteLine ("Processing a reply.");
+                               // a:InvalidSecurity
+                               // An error occurred when verifying security for the message.
+                               Assert.IsTrue (input.IsFault);
+                               throw new ApplicationException ();
+                       };
+                       Message msg = Message.CreateMessage (MessageVersion.Default, "myAction");
+                       RequestReceiver receiver = delegate () {
+                               return msg;
+                       };
+                       IChannelListener<IReplyChannel> listener = CreateListener (handler, receiver);
+                       listener.Open ();
+                       IReplyChannel reply = listener.AcceptChannel ();
+                       reply.Open ();
+                       RequestContext ctx = reply.EndReceiveRequest (reply.BeginReceiveRequest (null, null));
+               }
+
+               // Without SecurityBindingElement it works.
+               // With it, it causes kind of infinite loop around 
+               // RequestContext.get_RequestMessage() which somehow blocks
+               // finishing HandlerTransportRequestChannel.Request() (and
+               // it continues until the timeout).
+               [Test]
+               [Ignore ("It's not working")]
+               [Category ("NotWorking")]
+               public void FullRequest ()
+               {
+                       EndpointIdentity identity =
+                               new X509CertificateEndpointIdentity (new X509Certificate2 ("Test/Resources/test.pfx", "mono"));
+                       EndpointAddress address =
+                               new EndpointAddress (new Uri ("stream:dummy"), identity);
+
+                       Message mreq = Message.CreateMessage (MessageVersion.Default, "myAction");
+                       Message mreply = null;
+
+XmlWriterSettings settings = new XmlWriterSettings ();
+settings.Indent = true;
+
+                       // listener setup
+                       ReplyHandler replyHandler = delegate (Message rinput) {
+                               mreply = rinput;
+                       };
+                       RequestReceiver receiver = delegate () {
+                               return mreq;
+                       };
+                       IChannelListener<IReplyChannel> listener = CreateListener (replyHandler, receiver);
+                       listener.Open ();
+                       IReplyChannel reply = listener.AcceptChannel ();
+                       reply.Open ();
+
+                       RequestSender reqHandler = delegate (Message input) {
+                               try {
+                                       // sync version somehow causes an infinite loop (!?)
+                                       RequestContext ctx = reply.EndReceiveRequest (reply.BeginReceiveRequest (TimeSpan.FromSeconds (5), null, null));
+//                                     RequestContext ctx = reply.ReceiveRequest (TimeSpan.FromSeconds (5));
+                                       Console.Error.WriteLine ("Acquired RequestContext.");
+                                       ctx.Reply (input);
+                               } catch (Exception ex) {
+                                       Console.Error.WriteLine ("ERROR during processing a request in FullRequest()");
+                                       Console.Error.WriteLine (ex);
+                                       Console.Error.Flush ();
+                                       throw;
+                               }
+                               return mreply;
+                       };
+                       CustomBinding b = CreateBinding (reqHandler);
+
+                       IRequestChannel ch = ChannelFactory<IRequestChannel>.CreateChannel (b, address);
+
+                       ch.Open ();
+                       Console.Error.WriteLine ("**** starting a request  ****");
+                       IAsyncResult async = ch.BeginRequest (mreq, null, null);
+                       Console.Error.WriteLine ("**** request started. ****");
+                       Message res = ch.EndRequest (async);
+               }
+
+               [Test]
+               public void SetKeyDerivation ()
+               {
+                       SymmetricSecurityBindingElement be;
+                       X509SecurityTokenParameters p;
+
+                       be = new SymmetricSecurityBindingElement ();
+                       p = new X509SecurityTokenParameters ();
+                       be.ProtectionTokenParameters = p;
+                       be.SetKeyDerivation (false);
+                       Assert.AreEqual (false, p.RequireDerivedKeys, "#1");
+
+                       be = new SymmetricSecurityBindingElement ();
+                       p = new X509SecurityTokenParameters ();
+                       be.SetKeyDerivation (false); // set in prior - makes no sense
+                       be.ProtectionTokenParameters = p;
+                       Assert.AreEqual (true, p.RequireDerivedKeys, "#2");
+               }
+       }
+
+       class MyOwnSecurityTokenParameters : SecurityTokenParameters
+       {
+               public MyOwnSecurityTokenParameters ()
+               {
+               }
+
+               protected MyOwnSecurityTokenParameters (MyOwnSecurityTokenParameters source)
+               {
+               }
+
+               protected override bool HasAsymmetricKey {
+                       get { return false; }
+               }
+
+               protected override bool SupportsClientAuthentication {
+                       get { return true; }
+               }
+
+               protected override bool SupportsClientWindowsIdentity {
+                       get { return false; }
+               }
+
+               protected override bool SupportsServerAuthentication {
+                       get { return true; }
+               }
+
+               protected override SecurityTokenParameters CloneCore ()
+               {
+                       return new MyOwnSecurityTokenParameters (this);
+               }
+
+               protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+               {
+                       // If there were another token type that supports protection
+                       // and does not require X509, it should be used instead ...
+                       requirement.TokenType = SecurityTokenTypes.Kerberos;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/TcpTransportBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/TcpTransportBindingElementTest.cs
new file mode 100644 (file)
index 0000000..a036a72
--- /dev/null
@@ -0,0 +1,124 @@
+//
+// TcpTransportBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2008 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Threading;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class TcpTransportBindingElementTest
+       {
+               static BindingParameterCollection empty_params =
+                       new BindingParameterCollection ();
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       TcpTransportBindingElement be =
+                               new TcpTransportBindingElement ();
+                       Assert.AreEqual (TimeSpan.FromSeconds (5), be.ChannelInitializationTimeout, "#1");
+                       Assert.AreEqual (0x2000, be.ConnectionBufferSize, "#2");
+                       Assert.AreEqual (HostNameComparisonMode.StrongWildcard, be.HostNameComparisonMode, "#3");
+                       Assert.AreEqual (0x10000, be.MaxBufferSize, "#4");
+                       Assert.AreEqual (TimeSpan.FromMilliseconds (200), be.MaxOutputDelay, "#5");
+                       Assert.AreEqual (1, be.MaxPendingAccepts, "#6");
+                       Assert.AreEqual (10, be.MaxPendingConnections, "#7");
+                       Assert.AreEqual (TransferMode.Buffered, be.TransferMode, "#8");
+
+                       Assert.AreEqual (10, be.ListenBacklog, "#9");
+                       Assert.IsFalse (be.PortSharingEnabled, "#10");
+                       Assert.AreEqual ("net.tcp", be.Scheme, "#11");
+                       Assert.IsFalse (be.TeredoEnabled, "#12");
+                       TcpConnectionPoolSettings pool = be.ConnectionPoolSettings;
+                       Assert.IsNotNull (pool, "#13");
+                       Assert.AreEqual ("default", pool.GroupName, "#14");
+                       Assert.AreEqual (TimeSpan.FromSeconds (120), pool.IdleTimeout, "#15");
+                       Assert.AreEqual (TimeSpan.FromSeconds (300), pool.LeaseTimeout, "#16");
+                       Assert.AreEqual (10, pool.MaxOutboundConnectionsPerEndpoint, "#17");
+               }
+
+               [Test]
+               public void CanBuildChannelFactory ()
+               {
+                       TcpTransportBindingElement be =
+                               new TcpTransportBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (), empty_params);
+                       Assert.IsFalse (be.CanBuildChannelFactory<IRequestChannel> (ctx), "#1");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IInputChannel> (ctx), "#2");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IReplyChannel> (ctx), "#3");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IOutputChannel> (ctx), "#4");
+
+                       Assert.IsFalse (be.CanBuildChannelFactory<IRequestSessionChannel> (ctx), "#5");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IInputSessionChannel> (ctx), "#6");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IReplySessionChannel> (ctx), "#7");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IOutputSessionChannel> (ctx), "#8");
+
+                       // IServiceChannel is not supported
+                       Assert.IsFalse (be.CanBuildChannelFactory<IServiceChannel> (ctx), "#9");
+                       Assert.IsFalse (be.CanBuildChannelFactory<IClientChannel> (ctx), "#10");
+
+                       Assert.IsFalse (be.CanBuildChannelFactory<IDuplexChannel> (ctx), "#11");
+                       Assert.IsTrue (be.CanBuildChannelFactory<IDuplexSessionChannel> (ctx), "#12");
+               }
+
+               [Test]
+               public void CanBuildChannelListener ()
+               {
+                       TcpTransportBindingElement be =
+                               new TcpTransportBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (), empty_params);
+                       Assert.IsFalse (be.CanBuildChannelListener<IReplyChannel> (ctx), "#1");
+                       Assert.IsFalse (be.CanBuildChannelListener<IOutputChannel> (ctx), "#2");
+                       Assert.IsFalse (be.CanBuildChannelListener<IRequestChannel> (ctx), "#3");
+                       Assert.IsFalse (be.CanBuildChannelListener<IInputChannel> (ctx), "#4");
+
+                       Assert.IsFalse (be.CanBuildChannelListener<IReplySessionChannel> (ctx), "#5");
+                       Assert.IsFalse (be.CanBuildChannelListener<IOutputSessionChannel> (ctx), "#6");
+                       Assert.IsFalse (be.CanBuildChannelListener<IRequestSessionChannel> (ctx), "#7");
+                       Assert.IsFalse (be.CanBuildChannelListener<IInputSessionChannel> (ctx), "#8");
+
+                       // IServiceChannel is not supported
+                       Assert.IsFalse (be.CanBuildChannelListener<IServiceChannel> (ctx), "#9");
+                       Assert.IsFalse (be.CanBuildChannelListener<IClientChannel> (ctx), "#10");
+
+                       Assert.IsFalse (be.CanBuildChannelListener<IDuplexChannel> (ctx), "#11");
+                       Assert.IsTrue (be.CanBuildChannelListener<IDuplexSessionChannel> (ctx), "#12");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/TextMessageEncodingBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/TextMessageEncodingBindingElementTest.cs
new file mode 100644 (file)
index 0000000..521a005
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// TextMessageEncodingBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Text;
+using NUnit.Framework;
+
+using Element = System.ServiceModel.Channels.TextMessageEncodingBindingElement;
+
+namespace MonoTests.System.ServiceModel.Channels
+{
+       [TestFixture]
+       public class TextMessageEncodingBindingElementTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       Element el = new Element ();
+                       Assert.AreEqual (64, el.MaxReadPoolSize, "#1");
+                       Assert.AreEqual (16, el.MaxWritePoolSize, "#2");
+                       Assert.AreEqual (MessageVersion.Default, el.MessageVersion, "#3");
+                       // FIXME: test ReaderQuotas
+
+                       Assert.AreEqual (Encoding.UTF8, el.WriteEncoding, "#4");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void BuildChannelListenerNullArg ()
+               {
+                       new Element ().BuildChannelListener<IReplyChannel> (null);
+               }
+
+               [Test]
+               public void CanBuildChannelFactory ()
+               {
+                       CustomBinding cb = new CustomBinding (
+                               new HttpTransportBindingElement ());
+                       BindingContext ctx = new BindingContext (
+                               cb, new BindingParameterCollection ());
+                       Element el = new Element ();
+                       Assert.IsTrue (el.CanBuildChannelFactory<IRequestChannel> (ctx), "#1");
+                       Assert.IsFalse (el.CanBuildChannelFactory<IRequestSessionChannel> (ctx), "#2");
+               }
+
+               [Test]
+               public void BuildChannelFactory ()
+               {
+                       CustomBinding cb = new CustomBinding (
+                               new HttpTransportBindingElement ());
+                       BindingContext ctx = new BindingContext (
+                               cb, new BindingParameterCollection ());
+                       Element el = new Element ();
+                       IChannelFactory<IRequestChannel> cf =
+                               el.BuildChannelFactory<IRequestChannel> (ctx);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void BuildChannelListenerEmptyCustomBinding ()
+               {
+                       CustomBinding cb = new CustomBinding ();
+                       BindingContext ctx = new BindingContext (
+                               cb, new BindingParameterCollection ());
+                       new Element ().BuildChannelListener<IReplyChannel> (ctx);
+               }
+
+               [Test]
+               public void BuildChannelListenerWithTransport ()
+               {
+                       CustomBinding cb = new CustomBinding (
+                               new HttpTransportBindingElement ());
+                       BindingContext ctx = new BindingContext (
+                               cb, new BindingParameterCollection (),
+                               new Uri ("http://localhost:8080"), String.Empty, ListenUriMode.Unique);
+                       new Element ().BuildChannelListener<IReplyChannel> (ctx);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/TransactionFlowBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/TransactionFlowBindingElementTest.cs
new file mode 100644 (file)
index 0000000..38aa43f
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// TransactionFlowBindingElementTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class TransactionFlowBindingElementTest
+       {
+               [Test]
+               //[Ignore ("Mono never supports OleTx, thus it won't work forever.")]
+               public void DefaultValues ()
+               {
+                       TransactionFlowBindingElement be =
+                               new TransactionFlowBindingElement ();
+                       Assert.AreEqual (TransactionProtocol.Default,
+                                        be.TransactionProtocol, "#1");
+               }
+
+               public void CanBuildChannelFactory ()
+               {
+                       TransactionFlowBindingElement be =
+                               new TransactionFlowBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (),
+                               new BindingParameterCollection ());
+                       Assert.IsTrue (be.CanBuildChannelFactory<IRequestChannel> (ctx), "#1");
+                       Assert.IsTrue (be.CanBuildChannelFactory<IOutputChannel> (ctx), "#2");
+                       Assert.IsTrue (be.CanBuildChannelFactory<IRequestSessionChannel> (ctx), "#3");
+                       Assert.IsTrue (be.CanBuildChannelFactory<IOutputSessionChannel> (ctx), "#4");
+               }
+
+               public void CanBuildChannelListener ()
+               {
+                       TransactionFlowBindingElement be =
+                               new TransactionFlowBindingElement ();
+                       BindingContext ctx = new BindingContext (
+                               new CustomBinding (),
+                               new BindingParameterCollection ());
+                       Assert.IsTrue (be.CanBuildChannelListener<IReplyChannel> (ctx), "#1");
+                       Assert.IsTrue (be.CanBuildChannelListener<IInputChannel> (ctx), "#2");
+                       Assert.IsTrue (be.CanBuildChannelListener<IRequestSessionChannel> (ctx), "#3");
+                       Assert.IsTrue (be.CanBuildChannelListener<IOutputSessionChannel> (ctx), "#4");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/AddressHeaderCollectionElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/AddressHeaderCollectionElementTest.cs
new file mode 100644 (file)
index 0000000..9ea1c49
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// AddressHeaderCollectionElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Channels;
+using System.Configuration;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class AddressHeaderCollectionElementTest
+       {
+               [Test]
+               public void ReadConfiguration () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/client.endpoint").GetSectionGroup ("system.serviceModel");
+                       AddressHeaderCollection col = config.Client.Endpoints [0].Headers.Headers;
+
+                       Assert.AreEqual (2, col.Count, "count");
+
+                       AddressHeader header = col [0];
+                       Assert.AreEqual ("Header1", header.Name, "name");
+                       Assert.AreEqual ("", header.Namespace, "name");
+
+                       header = col [1];
+                       Assert.AreEqual ("Header2", header.Name, "name");
+                       Assert.AreEqual ("uri:my.custom.manespace", header.Namespace, "name");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/BasicHttpBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/BasicHttpBindingElementTest.cs
new file mode 100644 (file)
index 0000000..5a1279f
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// BasicHttpBindingElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.ServiceModel;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class BasicHttpBindingElementTest
+       {
+               class Poker : BasicHttpBindingElement
+               {
+                       public Type GetBindingElementType () {
+                               return BindingElementType;
+                       }
+               }
+
+               [Test]
+               public void BindingElementType () {
+                       Poker poker = new Poker ();
+                       Assert.AreEqual (typeof (BasicHttpBinding), poker.GetBindingElementType (), "BindingElementType");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/BehaviorsSectionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/BehaviorsSectionTest.cs
new file mode 100644 (file)
index 0000000..802cc86
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// BehaviorsSectionTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.Configuration;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class BehaviorsSectionTest
+       {
+               class Poker : BehaviorsSection
+               {
+                       public ConfigurationPropertyCollection GetProperties () {
+                               return Properties;
+                       }
+
+                       [ConfigurationProperty ("myProperty")]
+                       string MyProperty {
+                               get { return "myProperty"; }
+                               set { }
+                       }
+               }
+
+               [Test]
+               public void Properties () {
+
+                       Poker p1 = new Poker ();
+                       Poker p2 = new Poker ();
+
+                       Assert.AreEqual (false, p1.GetProperties ().Contains ("myProperty"), "Contains myProperty");
+                       Assert.AreEqual (false, p1.GetProperties () == p2.GetProperties (), "#");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/BindingsSectionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/BindingsSectionTest.cs
new file mode 100644 (file)
index 0000000..147e388
--- /dev/null
@@ -0,0 +1,61 @@
+//
+// BindingsSectionTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Channels;
+using System.Configuration;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class BindingsSectionTest
+       {
+
+               [Test]
+               [Category("NotWorking")]
+               public void UserConfiguration () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/userBinding").GetSectionGroup ("system.serviceModel");
+
+                       BindingsSection section = config.Bindings;
+
+                       BindingCollectionElement collectionElement = section ["userBinding"];
+                       Assert.AreEqual (typeof (UserBindingCollectionElement), collectionElement.GetType (), "type");
+
+                       StandardBindingElementCollection<UserBindingElement> userBindings = ((UserBindingCollectionElement) collectionElement).Bindings;
+
+                       Assert.AreEqual (2, userBindings.Count, "Count");
+
+                       Assert.AreEqual ("UserBinding_1", userBindings [0].Name, "Name_1");
+                       Assert.AreEqual ("UserBinding_2", userBindings [1].Name, "Name_2");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ChangeLog b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ChangeLog
new file mode 100644 (file)
index 0000000..50648be
--- /dev/null
@@ -0,0 +1,52 @@
+2008-04-03  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * StandardBindingElementCollectionTest.cs: fixed test
+
+2008-04-01  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceElementTest.cs: new test
+
+2008-03-26  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceModelSectionGroupTest.cs: add #if NET_3_5
+       * CustomBindingElementTest.cs: new test
+
+2008-03-26  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * MetadataElementTest.cs: new test
+
+2008-03-04  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ServiceModelConfigurationElementCollectionTest.cs: Created file.
+       * ChannelEndpointElementTest.cs: Created file.
+
+2008-02-19  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * MexBindingElementTest.cs: new test
+
+2008-02-19  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * StandardBindingCollectionElementTest.cs: add test
+
+2008-02-17  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * BasicHttpBindingElementTest.cs:
+       * NetNamedPipeBindingElementTest.cs:
+       * NetPeerTcpBindingElementTest.cs:
+       * NetTcpBindingElementTest.cs:
+       * ServiceModelSectionGroupTest.cs:
+       * StandardBindingCollectionElementTest.cs:
+       new tests.
+       
+2008-02-17  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * StandardBindingElementCollectionTest.cs new test.
+       
+2006-06-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelSectionGroupTest.cs : commented out Endpoints().
+         It does not work fine on .NET too.
+
+2006-06-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelSectionGroupTest.cs : new test.
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ChannelEndpointElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ChannelEndpointElementTest.cs
new file mode 100644 (file)
index 0000000..df67273
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// ChannelEndpointElementTest.cs
+//
+// Author:
+//     Eyal Alaluf <eyala@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.Configuration;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class ChannelEndpointElementTest
+       {
+               [Test]
+               public void TestEmptyProps ()
+               {
+                       ChannelEndpointElement empty = new ChannelEndpointElement ();
+                       Assert.AreEqual ("", empty.Name, "#01");
+                       Assert.AreEqual (null, empty.Contract, "#02");
+                       Assert.AreEqual (null, empty.Binding, "#03");
+                       Assert.AreEqual (null, empty.Address, "#04");
+                       Assert.AreEqual ("", empty.BindingConfiguration, "#05");
+                       Assert.AreEqual ("", empty.BehaviorConfiguration, "#06");
+                       Assert.IsNotNull (empty.Headers, "#07");
+                       Assert.IsNotNull (empty.Identity, "#08");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/CustomBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/CustomBindingElementTest.cs
new file mode 100644 (file)
index 0000000..ec23e6c
--- /dev/null
@@ -0,0 +1,405 @@
+//
+// AddressHeaderCollectionElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.Configuration;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Channels;
+using System.Net;
+using System.ServiceModel;
+using System.Net.Security;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class CustomBindingElementTest
+       {
+               CustomBindingCollectionElement OpenConfig () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/customBinding").GetSectionGroup ("system.serviceModel");
+                       Assert.AreEqual (7, config.Bindings.CustomBinding.Bindings.Count, "CustomBinding count");
+                       return config.Bindings.CustomBinding;
+               }
+
+               T GetElement<T> (int index) where T : BindingElementExtensionElement {
+                       CustomBindingElement binding = OpenConfig ().Bindings [index];
+                       T element = (T) binding [typeof (T)];
+                       Assert.IsNotNull (element, typeof (T).Name + " is not exist in collection.");
+                       return element;
+               }
+
+               [Test]
+               public void CustomBindingElement () {
+                       CustomBindingElement binding = OpenConfig ().Bindings [0];
+
+                       Assert.AreEqual ("CustomBinding_1", binding.Name, "Name");
+                       Assert.AreEqual (new TimeSpan (0, 2, 0), binding.CloseTimeout, "CloseTimeout");
+                       Assert.AreEqual (new TimeSpan (0, 2, 0), binding.OpenTimeout, "OpenTimeout");
+                       Assert.AreEqual (new TimeSpan (0, 20, 0), binding.ReceiveTimeout, "ReceiveTimeout");
+                       Assert.AreEqual (new TimeSpan (0, 2, 0), binding.SendTimeout, "SendTimeout");
+
+               }
+
+               [Test]
+               public void BinaryMessageEncodingElement () {
+
+                       BinaryMessageEncodingElement binaryMessageEncoding = GetElement<BinaryMessageEncodingElement> (0);
+
+                       Assert.AreEqual (typeof (BinaryMessageEncodingBindingElement), binaryMessageEncoding.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("binaryMessageEncoding", binaryMessageEncoding.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (128, binaryMessageEncoding.MaxReadPoolSize, "MaxReadPoolSize");
+                       Assert.AreEqual (1024, binaryMessageEncoding.MaxSessionSize, "MaxSessionSize");
+                       Assert.AreEqual (32, binaryMessageEncoding.MaxWritePoolSize, "MaxWritePoolSize");
+                       Assert.AreEqual (1024, binaryMessageEncoding.ReaderQuotas.MaxArrayLength, "ReaderQuotas.MaxArrayLength");
+                       Assert.AreEqual (1024, binaryMessageEncoding.ReaderQuotas.MaxBytesPerRead, "ReaderQuotas.MaxBytesPerRead");
+                       Assert.AreEqual (1024, binaryMessageEncoding.ReaderQuotas.MaxDepth, "ReaderQuotas.MaxDepth");
+                       Assert.AreEqual (1024, binaryMessageEncoding.ReaderQuotas.MaxNameTableCharCount, "ReaderQuotas.MaxNameTableCharCount");
+                       Assert.AreEqual (1024, binaryMessageEncoding.ReaderQuotas.MaxStringContentLength, "ReaderQuotas.MaxStringContentLength");
+               }
+
+               [Test]
+               public void CompositeDuplexElement () {
+                       CompositeDuplexElement element = GetElement<CompositeDuplexElement> (0);
+
+                       Assert.AreEqual (typeof (CompositeDuplexBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("compositeDuplex", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual ("http://client.base.address", element.ClientBaseAddress.OriginalString, "ClientBaseAddress");
+               }
+
+               [Test]
+               public void OneWayElement () {
+                       OneWayElement element = GetElement<OneWayElement> (0);
+
+                       Assert.AreEqual (typeof (OneWayBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("oneWay", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (5, element.MaxAcceptedChannels, "MaxAcceptedChannels");
+                       Assert.AreEqual (true, element.PacketRoutable, "PacketRoutable");
+
+                       Assert.AreEqual (new TimeSpan (0, 1, 0), element.ChannelPoolSettings.IdleTimeout, "ChannelPoolSettings.IdleTimeout");
+                       Assert.AreEqual (new TimeSpan (0, 12, 0), element.ChannelPoolSettings.LeaseTimeout, "ChannelPoolSettings.LeaseTimeout");
+                       Assert.AreEqual (5, element.ChannelPoolSettings.MaxOutboundChannelsPerEndpoint, "ChannelPoolSettings.MxOutboundChannelsPerEndpoint");
+               }
+
+               [Test]
+               public void HttpTransportElement () {
+                       HttpTransportElement element = GetElement<HttpTransportElement> (0);
+
+                       Assert.AreEqual (typeof (HttpTransportBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("httpTransport", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
+                       Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
+                       Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
+                       Assert.AreEqual (true, element.AllowCookies, "AllowCookies");
+                       Assert.AreEqual (AuthenticationSchemes.None, element.AuthenticationScheme, "AuthenticationScheme");
+                       Assert.AreEqual (true, element.BypassProxyOnLocal, "BypassProxyOnLocal");
+                       Assert.AreEqual (HostNameComparisonMode.Exact, element.HostNameComparisonMode, "HostNameComparisonMode");
+                       Assert.AreEqual (false, element.KeepAliveEnabled, "KeepAliveEnabled");
+                       Assert.AreEqual (32768, element.MaxBufferSize, "MaxBufferSize");
+                       Assert.AreEqual ("http://proxy.address", element.ProxyAddress.OriginalString, "ProxyAddress");
+                       Assert.AreEqual (AuthenticationSchemes.None, element.ProxyAuthenticationScheme, "ProxyAuthenticationScheme");
+                       Assert.AreEqual ("Realm", element.Realm, "Realm");
+                       Assert.AreEqual (TransferMode.Streamed, element.TransferMode, "TransferMode");
+                       Assert.AreEqual (true, element.UnsafeConnectionNtlmAuthentication, "UnsafeConnectionNtlmAuthentication");
+                       Assert.AreEqual (false, element.UseDefaultWebProxy, "UseDefaultWebProxy");
+               }
+
+               [Test]
+               public void HttpsTransportElement () {
+                       HttpsTransportElement element = GetElement<HttpsTransportElement> (1);
+
+                       Assert.AreEqual (typeof (HttpsTransportBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("httpsTransport", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
+                       Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
+                       Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
+                       Assert.AreEqual (true, element.AllowCookies, "AllowCookies");
+                       Assert.AreEqual (AuthenticationSchemes.None, element.AuthenticationScheme, "AuthenticationScheme");
+                       Assert.AreEqual (true, element.BypassProxyOnLocal, "BypassProxyOnLocal");
+                       Assert.AreEqual (HostNameComparisonMode.Exact, element.HostNameComparisonMode, "HostNameComparisonMode");
+                       Assert.AreEqual (true, element.KeepAliveEnabled, "KeepAliveEnabled");
+                       Assert.AreEqual (32768, element.MaxBufferSize, "MaxBufferSize");
+                       Assert.AreEqual ("https://proxy.address", element.ProxyAddress.OriginalString, "ProxyAddress");
+                       Assert.AreEqual (AuthenticationSchemes.None, element.ProxyAuthenticationScheme, "ProxyAuthenticationScheme");
+                       Assert.AreEqual ("Realm", element.Realm, "Realm");
+                       Assert.AreEqual (TransferMode.Streamed, element.TransferMode, "TransferMode");
+                       Assert.AreEqual (true, element.UnsafeConnectionNtlmAuthentication, "UnsafeConnectionNtlmAuthentication");
+                       Assert.AreEqual (false, element.UseDefaultWebProxy, "UseDefaultWebProxy");
+               }
+
+               [Test]
+               public void PnrpPeerResolverElement () {
+                       PnrpPeerResolverElement element = GetElement<PnrpPeerResolverElement> (0);
+
+                       Assert.AreEqual (typeof (PnrpPeerResolverBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("pnrpPeerResolver", element.ConfigurationElementName, "ConfigurationElementName");
+               }
+
+               [Test]
+               public void PrivacyNoticeElement () {
+                       PrivacyNoticeElement element = GetElement<PrivacyNoticeElement> (0);
+
+                       Assert.AreEqual (typeof (PrivacyNoticeBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("privacyNoticeAt", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual ("http://url", element.Url.OriginalString, "Url");
+                       Assert.AreEqual (5, element.Version, "Version");
+               }
+
+               [Test]
+               public void ReliableSessionElement () {
+                       ReliableSessionElement element = GetElement<ReliableSessionElement> (0);
+
+                       Assert.AreEqual (typeof (ReliableSessionBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("reliableSession", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (TimeSpan.Parse ("00:00:00.4000000"), element.AcknowledgementInterval, "AcknowledgementInterval");
+                       Assert.AreEqual (false, element.FlowControlEnabled, "FlowControlEnabled");
+                       Assert.AreEqual (new TimeSpan (0, 15, 0), element.InactivityTimeout, "InactivityTimeout");
+                       Assert.AreEqual (8, element.MaxPendingChannels, "MaxPendingChannels");
+                       Assert.AreEqual (16, element.MaxRetryCount, "MaxRetryCount");
+                       Assert.AreEqual (16, element.MaxTransferWindowSize, "MaxTransferWindowSize");
+                       Assert.AreEqual (false, element.Ordered, "Ordered");
+                       Assert.AreEqual (ReliableMessagingVersion.WSReliableMessaging11, element.ReliableMessagingVersion, "ReliableMessagingVersion");
+               }
+
+               [Test]
+               public void SecurityElement () {
+                       SecurityElement element = GetElement<SecurityElement> (0);
+
+                       Assert.AreEqual (typeof (SecurityBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("security", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       // TODO
+               }
+
+               [Test]
+               public void SslStreamSecurityElement () {
+                       SslStreamSecurityElement element = GetElement<SslStreamSecurityElement> (0);
+
+                       Assert.AreEqual (typeof (SslStreamSecurityBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("sslStreamSecurity", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.RequireClientCertificate, "RequireClientCertificate");
+               }
+
+               [Test]
+               public void TransactionFlowElement () {
+                       TransactionFlowElement element = GetElement<TransactionFlowElement> (0);
+
+                       Assert.AreEqual (typeof (TransactionFlowBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("transactionFlow", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (TransactionProtocol.WSAtomicTransactionOctober2004, element.TransactionProtocol, "TransactionProtocol");
+               }
+
+               [Test]
+               public void UseManagedPresentationElement () {
+                       UseManagedPresentationElement element = GetElement<UseManagedPresentationElement> (0);
+
+                       Assert.AreEqual (typeof (UseManagedPresentationBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("useManagedPresentation", element.ConfigurationElementName, "ConfigurationElementName");
+               }
+
+               [Test]
+               public void WindowsStreamSecurityElement () {
+                       WindowsStreamSecurityElement element = GetElement<WindowsStreamSecurityElement> (1);
+
+                       Assert.AreEqual (typeof (WindowsStreamSecurityBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("windowsStreamSecurity", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (ProtectionLevel.None, element.ProtectionLevel, "ProtectionLevel");
+               }
+
+               [Test]
+               public void TextMessageEncodingElement () {
+                       TextMessageEncodingElement element = GetElement<TextMessageEncodingElement> (1);
+
+                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("textMessageEncoding", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (128, element.MaxReadPoolSize, "MaxReadPoolSize");
+                       Assert.AreEqual (Encoding.UTF32, element.WriteEncoding, "WriteEncoding");
+                       Assert.AreEqual (MessageVersion.Soap11WSAddressingAugust2004, element.MessageVersion, "MessageVersion");
+                       Assert.AreEqual (32, element.MaxWritePoolSize, "MaxWritePoolSize");
+                       Assert.AreEqual (128, element.ReaderQuotas.MaxArrayLength, "ReaderQuotas.MaxArrayLength");
+                       Assert.AreEqual (128, element.ReaderQuotas.MaxBytesPerRead, "ReaderQuotas.MaxBytesPerRead");
+                       Assert.AreEqual (128, element.ReaderQuotas.MaxDepth, "ReaderQuotas.MaxDepth");
+                       Assert.AreEqual (128, element.ReaderQuotas.MaxNameTableCharCount, "ReaderQuotas.MaxNameTableCharCount");
+                       Assert.AreEqual (128, element.ReaderQuotas.MaxStringContentLength, "ReaderQuotas.MaxStringContentLength");
+               }
+
+               [Test]
+               public void MtomMessageEncodingElement () {
+                       MtomMessageEncodingElement element = GetElement<MtomMessageEncodingElement> (2);
+
+                       Assert.AreEqual (typeof (MtomMessageEncodingBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("mtomMessageEncoding", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (128, element.MaxReadPoolSize, "MaxReadPoolSize");
+                       Assert.AreEqual (32, element.MaxWritePoolSize, "MaxWritePoolSize");
+                       Assert.AreEqual (32768, element.MaxBufferSize, "MaxBufferSize");
+                       Assert.AreEqual (Encoding.UTF32, element.WriteEncoding, "WriteEncoding");
+                       Assert.AreEqual (MessageVersion.Soap11WSAddressingAugust2004, element.MessageVersion, "MessageVersion");
+                       Assert.AreEqual (256, element.ReaderQuotas.MaxArrayLength, "ReaderQuotas.MaxArrayLength");
+                       Assert.AreEqual (256, element.ReaderQuotas.MaxBytesPerRead, "ReaderQuotas.MaxBytesPerRead");
+                       Assert.AreEqual (256, element.ReaderQuotas.MaxDepth, "ReaderQuotas.MaxDepth");
+                       Assert.AreEqual (256, element.ReaderQuotas.MaxNameTableCharCount, "ReaderQuotas.MaxNameTableCharCount");
+                       Assert.AreEqual (256, element.ReaderQuotas.MaxStringContentLength, "ReaderQuotas.MaxStringContentLength");
+               }
+
+               [Test]
+               public void MsmqIntegrationElement () {
+                       MsmqIntegrationElement element = GetElement<MsmqIntegrationElement> (2);
+
+                       Assert.AreEqual (typeof (global::System.ServiceModel.MsmqIntegration.MsmqIntegrationBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("msmqIntegration", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
+                       Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
+                       Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
+                       Assert.AreEqual ("http://CustomDeadLetterQueue", element.CustomDeadLetterQueue.OriginalString, "CustomDeadLetterQueue");
+                       Assert.AreEqual (DeadLetterQueue.Custom, element.DeadLetterQueue, "DeadLetterQueue");
+                       Assert.AreEqual (false, element.Durable, "Durable");
+                       Assert.AreEqual (false, element.ExactlyOnce, "ExactlyOnce");
+                       Assert.AreEqual (3, element.MaxRetryCycles, "MaxRetryCycles");
+                       Assert.AreEqual (ReceiveErrorHandling.Drop, element.ReceiveErrorHandling, "ReceiveErrorHandling");
+                       Assert.AreEqual (10, element.ReceiveRetryCount, "ReceiveRetryCount");
+                       Assert.AreEqual (new TimeSpan (0, 15, 0), element.RetryCycleDelay, "RetryCycleDelay");
+                       Assert.AreEqual (TimeSpan.Parse ("1.12:00:00"), element.TimeToLive, "TimeToLive");
+                       Assert.AreEqual (true, element.UseSourceJournal, "UseSourceJournal");
+                       Assert.AreEqual (true, element.UseMsmqTracing, "UseMsmqTracing");
+                       Assert.AreEqual (global::System.ServiceModel.MsmqIntegration.MsmqMessageSerializationFormat.Binary, element.SerializationFormat, "SerializationFormat");
+                       Assert.AreEqual (MsmqAuthenticationMode.Certificate, element.MsmqTransportSecurity.MsmqAuthenticationMode, "MsmqTransportSecurity.MsmqAuthenticationMode");
+                       Assert.AreEqual (MsmqEncryptionAlgorithm.Aes, element.MsmqTransportSecurity.MsmqEncryptionAlgorithm, "MsmqTransportSecurity.MsmqEncryptionAlgorithm");
+                       Assert.AreEqual (ProtectionLevel.EncryptAndSign, element.MsmqTransportSecurity.MsmqProtectionLevel, "MsmqTransportSecurity.MsmqProtectionLevel");
+                       Assert.AreEqual (MsmqSecureHashAlgorithm.Sha256, element.MsmqTransportSecurity.MsmqSecureHashAlgorithm, "MsmqTransportSecurity.MsmqSecureHashAlgorithm");
+               }
+
+               [Test]
+               public void MsmqTransportElement () {
+                       MsmqTransportElement element = GetElement<MsmqTransportElement> (3);
+
+                       Assert.AreEqual (typeof (MsmqTransportBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("msmqTransport", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
+                       Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
+                       Assert.AreEqual (262144, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
+                       Assert.AreEqual ("http://CustomDeadLetterQueue", element.CustomDeadLetterQueue.OriginalString, "CustomDeadLetterQueue");
+                       Assert.AreEqual (DeadLetterQueue.Custom, element.DeadLetterQueue, "DeadLetterQueue");
+                       Assert.AreEqual (false, element.Durable, "Durable");
+                       Assert.AreEqual (false, element.ExactlyOnce, "ExactlyOnce");
+                       Assert.AreEqual (3, element.MaxRetryCycles, "MaxRetryCycles");
+                       Assert.AreEqual (ReceiveErrorHandling.Drop, element.ReceiveErrorHandling, "ReceiveErrorHandling");
+                       Assert.AreEqual (9, element.ReceiveRetryCount, "ReceiveRetryCount");
+                       Assert.AreEqual (new TimeSpan (0, 15, 0), element.RetryCycleDelay, "RetryCycleDelay");
+                       Assert.AreEqual (TimeSpan.Parse ("1.12:00:00"), element.TimeToLive, "TimeToLive");
+                       Assert.AreEqual (true, element.UseSourceJournal, "UseSourceJournal");
+                       Assert.AreEqual (true, element.UseMsmqTracing, "UseMsmqTracing");
+                       Assert.AreEqual (MsmqAuthenticationMode.Certificate, element.MsmqTransportSecurity.MsmqAuthenticationMode, "MsmqTransportSecurity.MsmqAuthenticationMode");
+                       Assert.AreEqual (MsmqEncryptionAlgorithm.Aes, element.MsmqTransportSecurity.MsmqEncryptionAlgorithm, "MsmqTransportSecurity.MsmqEncryptionAlgorithm");
+                       Assert.AreEqual (ProtectionLevel.EncryptAndSign, element.MsmqTransportSecurity.MsmqProtectionLevel, "MsmqTransportSecurity.MsmqProtectionLevel");
+                       Assert.AreEqual (MsmqSecureHashAlgorithm.Sha256, element.MsmqTransportSecurity.MsmqSecureHashAlgorithm, "MsmqTransportSecurity.MsmqSecureHashAlgorithm");
+               }
+
+               [Test]
+               public void NamedPipeTransportElement () {
+                       NamedPipeTransportElement element = GetElement<NamedPipeTransportElement> (4);
+
+                       Assert.AreEqual (typeof (NamedPipeTransportBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("namedPipeTransport", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
+                       Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
+                       Assert.AreEqual (32768, element.MaxBufferSize, "MaxBufferSize");
+                       Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
+                       Assert.AreEqual (4096, element.ConnectionBufferSize, "ConnectionBufferSize");
+                       Assert.AreEqual (HostNameComparisonMode.Exact, element.HostNameComparisonMode, "HostNameComparisonMode");
+                       Assert.AreEqual (new TimeSpan (0, 0, 20), element.ChannelInitializationTimeout, "ChannelInitializationTimeout");
+                       Assert.AreEqual (5, element.MaxPendingConnections, "MaxPendingConnections");
+                       Assert.AreEqual (TimeSpan.Parse ("00:00:01.2000000"), element.MaxOutputDelay, "MaxOutputDelay");
+                       Assert.AreEqual (3, element.MaxPendingAccepts, "MaxPendingAccepts");
+                       Assert.AreEqual (TransferMode.Streamed, element.TransferMode, "MaxPendingAccepts");
+
+                       Assert.AreEqual ("GroupName", element.ConnectionPoolSettings.GroupName, "ConnectionPoolSettings.GroupName");
+                       Assert.AreEqual (new TimeSpan (0, 6, 0), element.ConnectionPoolSettings.IdleTimeout, "ConnectionPoolSettings.IdleTimeout");
+                       Assert.AreEqual (20, element.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint, "ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint");
+               }
+
+               [Test]
+               public void TcpTransportElement () {
+                       TcpTransportElement element = GetElement<TcpTransportElement> (5);
+
+                       Assert.AreEqual (typeof (TcpTransportBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("tcpTransport", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.ManualAddressing, "ManualAddressing");
+                       Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
+                       Assert.AreEqual (32768, element.MaxBufferSize, "MaxBufferSize");
+                       Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
+                       Assert.AreEqual (4096, element.ConnectionBufferSize, "ConnectionBufferSize");
+                       Assert.AreEqual (HostNameComparisonMode.Exact, element.HostNameComparisonMode, "HostNameComparisonMode");
+                       Assert.AreEqual (new TimeSpan (0, 0, 15), element.ChannelInitializationTimeout, "ChannelInitializationTimeout");
+                       Assert.AreEqual (20, element.MaxPendingConnections, "MaxPendingConnections");
+                       Assert.AreEqual (TimeSpan.Parse ("00:00:01.2000000"), element.MaxOutputDelay, "MaxOutputDelay");
+                       Assert.AreEqual (3, element.MaxPendingAccepts, "MaxPendingAccepts");
+                       Assert.AreEqual (TransferMode.Streamed, element.TransferMode, "MaxPendingAccepts");
+                       Assert.AreEqual (20, element.ListenBacklog, "ListenBacklog");
+                       Assert.AreEqual (true, element.PortSharingEnabled, "PortSharingEnabled");
+                       Assert.AreEqual (true, element.TeredoEnabled, "TeredoEnabled");
+
+                       Assert.AreEqual ("GroupName", element.ConnectionPoolSettings.GroupName, "ConnectionPoolSettings.GroupName");
+                       Assert.AreEqual (new TimeSpan (0, 15, 0), element.ConnectionPoolSettings.LeaseTimeout, "ConnectionPoolSettings.LeaseTimeout");
+                       Assert.AreEqual (new TimeSpan (0, 2, 30), element.ConnectionPoolSettings.IdleTimeout, "ConnectionPoolSettings.IdleTimeout");
+                       Assert.AreEqual (30, element.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint, "ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint");
+               }
+
+               [Test]
+               public void PeerTransportElement () {
+                       PeerTransportElement element = GetElement<PeerTransportElement> (6);
+
+                       Assert.AreEqual (typeof (PeerTransportBindingElement), element.BindingElementType, "BindingElementType");
+                       Assert.AreEqual ("peerTransport", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (262144, element.MaxBufferPoolSize, "MaxBufferPoolSize");
+                       Assert.AreEqual (32768, element.MaxReceivedMessageSize, "MaxReceivedMessageSize");
+                       Assert.AreEqual (IPAddress.Parse ("192.168.0.1"), element.ListenIPAddress, "ListenIPAddress");
+                       Assert.AreEqual (88, element.Port, "Port");
+
+                       Assert.AreEqual (SecurityMode.Message, element.Security.Mode, "Security.Mode");
+                       Assert.AreEqual (PeerTransportCredentialType.Certificate, element.Security.Transport.CredentialType, "Security.Transport.CredentialType");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/EndpointBehaviorElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/EndpointBehaviorElementTest.cs
new file mode 100644 (file)
index 0000000..350a84f
--- /dev/null
@@ -0,0 +1,262 @@
+//
+// EndpointBehaviorElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.Configuration;
+using System.ServiceModel.Description;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel.Security;
+using System.Security.Principal;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class EndpointBehaviorElementTest
+       {
+               EndpointBehaviorElement OpenConfig () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/endpointBehaviors").GetSectionGroup ("system.serviceModel");
+                       return config.Behaviors.EndpointBehaviors [0];
+               }
+
+               [Test]
+               public void CallbackDebugElement () {
+                       EndpointBehaviorElement behavior = OpenConfig ();
+                       CallbackDebugElement callbackDebug = (CallbackDebugElement) behavior [typeof (CallbackDebugElement)];
+
+                       if (callbackDebug == null)
+                               Assert.Fail ("CallbackDebugElement is not exist in collection.");
+
+                       Assert.AreEqual (typeof (CallbackDebugBehavior), callbackDebug.BehaviorType, "RoleProviderName");
+                       Assert.AreEqual ("callbackDebug", callbackDebug.ConfigurationElementName, "RoleProviderName");
+                       Assert.AreEqual (true, callbackDebug.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
+               }
+
+               [Test]
+               public void CallbackDebugElement_defaults () {
+                       CallbackDebugElement element = new CallbackDebugElement ();
+
+                       Assert.AreEqual (typeof (CallbackDebugBehavior), element.BehaviorType, "element");
+                       Assert.AreEqual ("callbackDebug", element.ConfigurationElementName, "ConfigurationElementName");
+                       Assert.AreEqual (false, element.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
+               }
+
+               [Test]
+               public void CallbackTimeoutsElement () {
+                       EndpointBehaviorElement behavior = OpenConfig ();
+                       CallbackTimeoutsElement element = (CallbackTimeoutsElement) behavior [typeof (CallbackTimeoutsElement)];
+
+                       if (element == null)
+                               Assert.Fail ("CallbackTimeoutsElement is not exist in collection.");
+
+                       Assert.AreEqual ("System.ServiceModel.Description.CallbackTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
+                       Assert.AreEqual ("callbackTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
+                       Assert.AreEqual (new TimeSpan (0, 2, 30), element.TransactionTimeout, "TransactionTimeout");
+               }
+
+               [Test]
+               public void CallbackTimeoutsElement_defaults () {
+                       CallbackTimeoutsElement element = new CallbackTimeoutsElement ();
+
+                       Assert.AreEqual ("System.ServiceModel.Description.CallbackTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
+                       Assert.AreEqual ("callbackTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
+                       Assert.AreEqual (new TimeSpan (0, 0, 0), element.TransactionTimeout, "TransactionTimeout");
+               }
+
+               [Test]
+               public void ClientViaElement () {
+                       EndpointBehaviorElement behavior = OpenConfig ();
+                       ClientViaElement element = (ClientViaElement) behavior [typeof (ClientViaElement)];
+
+                       if (element == null)
+                               Assert.Fail ("ClientViaElement is not exist in collection.");
+
+                       Assert.AreEqual (typeof (ClientViaBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("clientVia", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual ("http://via.uri", element.ViaUri.OriginalString, "ViaUri");
+               }
+
+               [Test]
+               public void ClientViaElement_defaults () {
+                       ClientViaElement element = new ClientViaElement ();
+
+                       Assert.AreEqual (typeof (ClientViaBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("clientVia", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (null, element.ViaUri, "ViaUri");
+               }
+
+               [Test]
+               public void DataContractSerializerElement () {
+                       EndpointBehaviorElement behavior = OpenConfig ();
+                       DataContractSerializerElement element = (DataContractSerializerElement) behavior [typeof (DataContractSerializerElement)];
+
+                       if (element == null)
+                               Assert.Fail ("DataContractSerializerElement is not exist in collection.");
+
+                       Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
+                       Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
+                       Assert.AreEqual (32768, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
+               }
+
+               [Test]
+               public void DataContractSerializerElement_defaults () {
+                       DataContractSerializerElement element = new DataContractSerializerElement ();
+
+                       Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
+                       Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (false, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
+                       Assert.AreEqual (65536, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
+               }
+
+               [Test]
+               public void SynchronousReceiveElement () {
+                       EndpointBehaviorElement behavior = OpenConfig ();
+                       SynchronousReceiveElement element = (SynchronousReceiveElement) behavior [typeof (SynchronousReceiveElement)];
+
+                       if (element == null)
+                               Assert.Fail ("SynchronousReceiveElement is not exist in collection.");
+
+                       Assert.AreEqual (typeof (SynchronousReceiveBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("synchronousReceive", element.ConfigurationElementName, "ConfigurationElementName");
+               }
+
+               [Test]
+               public void SynchronousReceiveElement_defaults () {
+                       SynchronousReceiveElement element = new SynchronousReceiveElement ();
+
+                       Assert.AreEqual (typeof (SynchronousReceiveBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("synchronousReceive", element.ConfigurationElementName, "ConfigurationElementName");
+               }
+
+               [Test]
+               public void TransactedBatchingElement () {
+                       EndpointBehaviorElement behavior = OpenConfig ();
+                       TransactedBatchingElement element = (TransactedBatchingElement) behavior [typeof (TransactedBatchingElement)];
+
+                       if (element == null)
+                               Assert.Fail ("TransactedBatchingElement is not exist in collection.");
+
+                       Assert.AreEqual (typeof (TransactedBatchingBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("transactedBatching", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (16, element.MaxBatchSize, "MaxBatchSize");
+               }
+
+               [Test]
+               public void TransactedBatchingElement_defaults () {
+                       TransactedBatchingElement element = new TransactedBatchingElement ();
+
+                       Assert.AreEqual (typeof (TransactedBatchingBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("transactedBatching", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (0, element.MaxBatchSize, "MaxBatchSize");
+               }
+
+               [Test]
+               public void ClientCredentialsElement () {
+                       EndpointBehaviorElement behavior = OpenConfig ();
+                       ClientCredentialsElement element = (ClientCredentialsElement) behavior [typeof (ClientCredentialsElement)];
+
+                       if (element == null)
+                               Assert.Fail ("ClientCredentialsElement is not exist in collection.");
+
+                       Assert.AreEqual (typeof (ClientCredentials), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("clientCredentials", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (false, element.SupportInteractive, "SupportInteractive");
+                       Assert.AreEqual ("ClientCredentialType", element.Type, "Type");
+
+                       Assert.AreEqual ("findValue", element.ClientCertificate.FindValue, "ClientCertificate.FindValue");
+                       Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.StoreLocation, "ClientCertificate.StoreLocation");
+                       Assert.AreEqual (StoreName.Root, element.ClientCertificate.StoreName, "ClientCertificate.StoreName");
+                       Assert.AreEqual (X509FindType.FindByExtension, element.ClientCertificate.X509FindType, "ClientCertificate.X509FindType");
+
+                       Assert.AreEqual ("findValue", element.ServiceCertificate.DefaultCertificate.FindValue, "ServiceCertificate.DefaultCertificate.FindValue");
+                       Assert.AreEqual (StoreLocation.LocalMachine, element.ServiceCertificate.DefaultCertificate.StoreLocation, "ServiceCertificate.DefaultCertificate.StoreLocation");
+                       Assert.AreEqual (StoreName.Root, element.ServiceCertificate.DefaultCertificate.StoreName, "ServiceCertificate.DefaultCertificate.StoreName");
+                       Assert.AreEqual (X509FindType.FindByExtension, element.ServiceCertificate.DefaultCertificate.X509FindType, "ServiceCertificate.DefaultCertificate.X509FindType");
+
+                       Assert.AreEqual ("CustomCertificateValidatorType", element.ServiceCertificate.Authentication.CustomCertificateValidatorType, "ServiceCertificate.Authentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509CertificateValidationMode.None, element.ServiceCertificate.Authentication.CertificateValidationMode, "ServiceCertificate.Authentication.CertificateValidationMode");
+                       Assert.AreEqual (X509RevocationMode.Offline, element.ServiceCertificate.Authentication.RevocationMode, "ServiceCertificate.Authentication.RevocationMode");
+                       Assert.AreEqual (StoreLocation.LocalMachine, element.ServiceCertificate.Authentication.TrustedStoreLocation, "ServiceCertificate.Authentication.TrustedStoreLocation");
+
+                       Assert.AreEqual (false, element.Windows.AllowNtlm, "Windows.AllowNtlm");
+                       Assert.AreEqual (TokenImpersonationLevel.None, element.Windows.AllowedImpersonationLevel, "Windows.AllowedImpersonationLevel");
+
+                       Assert.AreEqual (false, element.IssuedToken.CacheIssuedTokens, "IssuedToken.CacheIssuedTokens");
+                       Assert.AreEqual (SecurityKeyEntropyMode.ClientEntropy, element.IssuedToken.DefaultKeyEntropyMode, "IssuedToken.DefaultKeyEntropyMode");
+                       Assert.AreEqual (30, element.IssuedToken.IssuedTokenRenewalThresholdPercentage, "IssuedToken.IssuedTokenRenewalThresholdPercentage");
+
+                       Assert.AreEqual (TokenImpersonationLevel.None, element.HttpDigest.ImpersonationLevel, "HttpDigest.ImpersonationLevel");
+               }
+
+               [Test]
+               public void ClientCredentialsElement_defaults () {
+                       ClientCredentialsElement element = new ClientCredentialsElement ();
+
+                       Assert.AreEqual (typeof (ClientCredentials), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("clientCredentials", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.SupportInteractive, "SupportInteractive");
+                       Assert.AreEqual (String.Empty, element.Type, "Type");
+
+                       Assert.AreEqual (String.Empty, element.ClientCertificate.FindValue, "ClientCertificate.FindValue");
+                       Assert.AreEqual (StoreLocation.CurrentUser, element.ClientCertificate.StoreLocation, "ClientCertificate.StoreLocation");
+                       Assert.AreEqual (StoreName.My, element.ClientCertificate.StoreName, "ClientCertificate.StoreName");
+                       Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ClientCertificate.X509FindType, "ClientCertificate.X509FindType");
+
+                       Assert.AreEqual (String.Empty, element.ServiceCertificate.DefaultCertificate.FindValue, "ServiceCertificate.DefaultCertificate.FindValue");
+                       Assert.AreEqual (StoreLocation.CurrentUser, element.ServiceCertificate.DefaultCertificate.StoreLocation, "ServiceCertificate.DefaultCertificate.StoreLocation");
+                       Assert.AreEqual (StoreName.My, element.ServiceCertificate.DefaultCertificate.StoreName, "ServiceCertificate.DefaultCertificate.StoreName");
+                       Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ServiceCertificate.DefaultCertificate.X509FindType, "ServiceCertificate.DefaultCertificate.X509FindType");
+
+                       Assert.AreEqual (String.Empty, element.ServiceCertificate.Authentication.CustomCertificateValidatorType, "ServiceCertificate.Authentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.ServiceCertificate.Authentication.CertificateValidationMode, "ServiceCertificate.Authentication.CertificateValidationMode");
+                       Assert.AreEqual (X509RevocationMode.Online, element.ServiceCertificate.Authentication.RevocationMode, "ServiceCertificate.Authentication.RevocationMode");
+                       Assert.AreEqual (StoreLocation.CurrentUser, element.ServiceCertificate.Authentication.TrustedStoreLocation, "ServiceCertificate.Authentication.TrustedStoreLocation");
+
+                       Assert.AreEqual (true, element.Windows.AllowNtlm, "Windows.AllowNtlm");
+                       Assert.AreEqual (TokenImpersonationLevel.Identification, element.Windows.AllowedImpersonationLevel, "Windows.AllowedImpersonationLevel");
+
+                       Assert.AreEqual (true, element.IssuedToken.CacheIssuedTokens, "IssuedToken.CacheIssuedTokens");
+                       Assert.AreEqual (SecurityKeyEntropyMode.CombinedEntropy, element.IssuedToken.DefaultKeyEntropyMode, "IssuedToken.DefaultKeyEntropyMode");
+                       Assert.AreEqual (60, element.IssuedToken.IssuedTokenRenewalThresholdPercentage, "IssuedToken.IssuedTokenRenewalThresholdPercentage");
+
+                       Assert.AreEqual (TokenImpersonationLevel.Identification, element.HttpDigest.ImpersonationLevel, "HttpDigest.ImpersonationLevel");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ExtensionsSectionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ExtensionsSectionTest.cs
new file mode 100644 (file)
index 0000000..ea84154
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// ExtensionsSectionTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel.Configuration;
+using System.Configuration;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class ExtensionsSectionTest
+       {
+               class Poker : ExtensionsSection
+               {
+                       public ConfigurationPropertyCollection GetProperties () {
+                               return Properties;
+                       }
+
+                       [ConfigurationProperty ("myProperty")]
+                       string MyProperty {
+                               get { return "myProperty"; }
+                               set { }
+                       }
+               }
+
+               [Test]
+               public void Properties () {
+
+                       Poker p1 = new Poker ();
+                       Poker p2 = new Poker ();
+
+                       Assert.AreEqual (false, p1.GetProperties ().Contains ("myProperty"), "Contains myProperty");
+                       Assert.AreEqual (false, p1.GetProperties () == p2.GetProperties (), "#");
+               }
+
+               [Test]
+               public void BindingExtensions () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/extensions").GetSectionGroup ("system.serviceModel");
+
+                       Assert.AreEqual (typeof (BasicHttpBindingCollectionElement).AssemblyQualifiedName, config.Extensions.BindingExtensions ["basicHttpBinding"].Type, "baseHttpBinding");
+                       Assert.AreEqual (typeof (NetTcpBindingCollectionElement).AssemblyQualifiedName, config.Extensions.BindingExtensions ["netTcpBinding"].Type, "baseHttpBinding");
+                       Assert.AreEqual (typeof (CustomBindingCollectionElement).AssemblyQualifiedName, config.Extensions.BindingExtensions ["customBinding"].Type, "baseHttpBinding");
+                       Assert.AreEqual ("MyBindingCollectionElement", config.Extensions.BindingExtensions ["bindingExtensions1"].Type, "MyBindingCollectionElement");
+                       Assert.AreEqual ("AnotherBindingCollectionElement", config.Extensions.BindingExtensions ["bindingExtensions2"].Type, "AnotherBindingCollectionElement");
+               }
+
+               [Test]
+               public void BehaviorExtensions () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/extensions").GetSectionGroup ("system.serviceModel");
+
+                       Assert.AreEqual (typeof (ServiceAuthorizationElement).AssemblyQualifiedName, config.Extensions.BehaviorExtensions ["serviceAuthorization"].Type, "serviceAuthorization");
+                       Assert.AreEqual ("MyBehaviorElement", config.Extensions.BehaviorExtensions ["behaviorExtensions1"].Type, "MyBehaviorElement");
+                       Assert.AreEqual ("AnotherBehaviorElement", config.Extensions.BehaviorExtensions ["behaviorExtensions2"].Type, "AnotherBehaviorElement");
+               }
+
+               [Test]
+               public void BindingElementExtensions () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/extensions").GetSectionGroup ("system.serviceModel");
+
+                       Assert.AreEqual (typeof (BinaryMessageEncodingElement).AssemblyQualifiedName, config.Extensions.BindingElementExtensions ["binaryMessageEncoding"].Type, "binaryMessageEncoding");
+                       Assert.AreEqual ("MyBindingElementElement", config.Extensions.BindingElementExtensions ["bindingElementExtensions1"].Type, "MyBindingElementElement");
+                       Assert.AreEqual ("AnotherBindingElementElement", config.Extensions.BindingElementExtensions ["bindingElementExtensions2"].Type, "AnotherBindingElementElement");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/MetadataElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/MetadataElementTest.cs
new file mode 100644 (file)
index 0000000..28a446c
--- /dev/null
@@ -0,0 +1,134 @@
+//
+// MetadataElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.Configuration;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class MetadataElementTest
+       {
+               ServiceModelSectionGroup OpenConfig (string name) {
+                       return (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/" + name).GetSectionGroup ("system.serviceModel");
+               }
+
+               [Test]
+               public void PolicyImporters () {
+                       ServiceModelSectionGroup config = OpenConfig ("client.metadata");
+                       PolicyImporterElementCollection col = config.Client.Metadata.PolicyImporters;
+
+                       Assert.AreEqual (2, col.Count, "Count");
+
+                       PolicyImporterElement item = col ["PolicyImporterType1"];
+                       if (item == null)
+                               Assert.Fail ("PolicyImporterType1 not exists");
+
+                       Assert.AreEqual ("PolicyImporterType1", item.Type, "PolicyImporterType1.Type");
+
+                       item = col ["PolicyImporterType2"];
+                       if (item == null)
+                               Assert.Fail ("PolicyImporterType2 not exists");
+
+                       Assert.AreEqual ("PolicyImporterType2", item.Type, "PolicyImporterType2.Type");
+               }
+
+               [Test]
+               public void WsdlImporters () {
+                       ServiceModelSectionGroup config = OpenConfig ("client.metadata");
+                       WsdlImporterElementCollection col = config.Client.Metadata.WsdlImporters;
+
+                       Assert.AreEqual (2, col.Count, "Count");
+
+                       WsdlImporterElement item = col ["WSDLImporter1"];
+                       if (item == null)
+                               Assert.Fail ("WSDLImporter1 not exists");
+
+                       Assert.AreEqual ("WSDLImporter1", item.Type, "WSDLImporter1.Type");
+
+                       item = col ["WSDLImporter2"];
+                       if (item == null)
+                               Assert.Fail ("WSDLImporter2 not exists");
+
+                       Assert.AreEqual ("WSDLImporter2", item.Type, "WSDLImporter2.Type");
+               }
+
+               [Test]
+               public void PolicyImporters_DefaultConfiguration () {
+                       ServiceModelSectionGroup config = OpenConfig ("empty");
+                       PolicyImporterElementCollection col = config.Client.Metadata.PolicyImporters;
+
+                       Type [] types = new Type [] {
+                               typeof(CompositeDuplexBindingElementImporter),
+                               typeof(MessageEncodingBindingElementImporter),
+                               typeof(OneWayBindingElementImporter),
+                               typeof(PrivacyNoticeBindingElementImporter),
+                               typeof(ReliableSessionBindingElementImporter),
+                               typeof(SecurityBindingElementImporter),
+                               typeof(TransactionFlowBindingElementImporter),
+                               typeof(TransportBindingElementImporter),
+                               typeof(UseManagedPresentationBindingElementImporter)
+                       };
+                       foreach (Type type in types) {
+                               PolicyImporterElement item = col [type.AssemblyQualifiedName];
+                               if (item == null)
+                                       Assert.Fail (type.Name + " not exists");
+
+                               Assert.AreEqual (type.AssemblyQualifiedName, item.Type, type.Name);
+                       }
+               }
+
+               [Test]
+               public void WsdlImporters_DefaultConfiguration () {
+                       ServiceModelSectionGroup config = OpenConfig ("empty");
+                       WsdlImporterElementCollection col = config.Client.Metadata.WsdlImporters;
+
+                       Type [] types = new Type [] { 
+                               typeof(MessageEncodingBindingElementImporter),
+                               typeof(StandardBindingImporter),
+                               typeof(TransportBindingElementImporter),
+                               typeof(DataContractSerializerMessageContractImporter),
+                               typeof(XmlSerializerMessageContractImporter)
+                       };
+                       foreach (Type type in types) {
+                               WsdlImporterElement item = col [type.AssemblyQualifiedName];
+                               if (item == null)
+                                       Assert.Fail (type.Name + " not exists");
+
+                               Assert.AreEqual (type.AssemblyQualifiedName, item.Type, type.Name);
+                       }
+               }
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/MexBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/MexBindingElementTest.cs
new file mode 100644 (file)
index 0000000..92b47f2
--- /dev/null
@@ -0,0 +1,58 @@
+//
+// MexBindingElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class MexBindingElementTest
+       {
+               class Poker<TStandardBinding> : MexBindingElement<TStandardBinding> where TStandardBinding : Binding
+               {
+                       public Poker (string name)
+                               : base (name) {
+                       }
+
+                       public Type GetBindingElementType () {
+                               return BindingElementType;
+                       }
+               }
+
+               [Test]
+               public void BindingElementType () {
+                       Poker<CustomBinding> poker = new Poker<CustomBinding> ("kuku");
+                       Assert.AreEqual (typeof (CustomBinding), poker.GetBindingElementType (), "BindingElementType");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/NetNamedPipeBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/NetNamedPipeBindingElementTest.cs
new file mode 100644 (file)
index 0000000..653c344
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// NetNamedPipeBindingElement.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.ServiceModel;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class NetNamedPipeBindingElementTest
+       {
+               class Poker : NetNamedPipeBindingElement
+               {
+                       public Type GetBindingElementType () {
+                               return BindingElementType;
+                       }
+               }
+
+               [Test]
+               public void BindingElementType () {
+                       Poker poker = new Poker ();
+                       Assert.AreEqual (typeof (NetNamedPipeBinding), poker.GetBindingElementType (), "BindingElementType");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/NetPeerTcpBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/NetPeerTcpBindingElementTest.cs
new file mode 100644 (file)
index 0000000..466a943
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// NetPeerTcpBindingElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.ServiceModel;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class NetPeerTcpBindingElementTest
+       {
+               class Poker : NetPeerTcpBindingElement
+               {
+                       public Type GetBindingElementType () {
+                               return BindingElementType;
+                       }
+               }
+
+               [Test]
+               public void BindingElementType () {
+                       Poker poker = new Poker ();
+                       Assert.AreEqual (typeof (NetPeerTcpBinding), poker.GetBindingElementType (), "BindingElementType");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/NetTcpBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/NetTcpBindingElementTest.cs
new file mode 100644 (file)
index 0000000..e059369
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// NetTcpBindingElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.ServiceModel;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class NetTcpBindingElementTest
+       {
+               class Poker : NetTcpBindingElement
+               {
+                       public Type GetBindingElementType () {
+                               return BindingElementType;
+                       }
+               }
+
+               [Test]
+               public void BindingElementType () {
+                       Poker poker = new Poker ();
+                       Assert.AreEqual (typeof (NetTcpBinding), poker.GetBindingElementType (), "BindingElementType");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceBehaviorElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceBehaviorElementTest.cs
new file mode 100644 (file)
index 0000000..44f5666
--- /dev/null
@@ -0,0 +1,389 @@
+//
+// ServiceBehaviorElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Description;
+using System.Configuration;
+using System.ServiceModel;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel.Security;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class ServiceBehaviorElementTest
+       {
+               ServiceBehaviorElement OpenConfig () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/serviceBehaviors").GetSectionGroup ("system.serviceModel");
+                       return config.Behaviors.ServiceBehaviors [0];
+               }
+
+               [Test]
+               public void ServiceAuthorizationElement () {
+                       ServiceBehaviorElement behavior = OpenConfig ();
+                       ServiceAuthorizationElement serviceAuthorization = (ServiceAuthorizationElement) behavior [typeof (ServiceAuthorizationElement)];
+
+                       if (serviceAuthorization == null)
+                               Assert.Fail ("ServiceAuthorizationElement is not exist in collection.");
+
+                       Assert.AreEqual (typeof (ServiceAuthorizationBehavior), serviceAuthorization.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceAuthorization", serviceAuthorization.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual ("RoleProvider", serviceAuthorization.RoleProviderName, "RoleProviderName");
+                       Assert.AreEqual (PrincipalPermissionMode.UseAspNetRoles, serviceAuthorization.PrincipalPermissionMode, "PrincipalPermissionMode");
+                       Assert.AreEqual (true, serviceAuthorization.ImpersonateCallerForAllOperations, "ImpersonateCallerForAllOperations");
+                       Assert.AreEqual ("SerAuthManagType", serviceAuthorization.ServiceAuthorizationManagerType, "ServiceAuthorizationManagerType");
+
+                       Assert.AreEqual (2, serviceAuthorization.AuthorizationPolicies.Count, "AuthorizationPolicies.Count");
+                       Assert.AreEqual ("PolicyType1", serviceAuthorization.AuthorizationPolicies [0].PolicyType, "AuthorizationPolicies[0].PolicyType");
+                       Assert.AreEqual ("PolicyType2", serviceAuthorization.AuthorizationPolicies [1].PolicyType, "AuthorizationPolicies[1].PolicyType");
+               }
+
+               [Test]
+               public void ServiceAuthorizationElement_default () {
+                       ServiceAuthorizationElement serviceAuthorization = new ServiceAuthorizationElement ();
+
+                       Assert.AreEqual (typeof (ServiceAuthorizationBehavior), serviceAuthorization.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceAuthorization", serviceAuthorization.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (String.Empty, serviceAuthorization.RoleProviderName, "RoleProviderName");
+                       Assert.AreEqual (PrincipalPermissionMode.UseWindowsGroups, serviceAuthorization.PrincipalPermissionMode, "PrincipalPermissionMode");
+                       Assert.AreEqual (false, serviceAuthorization.ImpersonateCallerForAllOperations, "ImpersonateCallerForAllOperations");
+                       Assert.AreEqual (String.Empty, serviceAuthorization.ServiceAuthorizationManagerType, "ServiceAuthorizationManagerType");
+
+                       Assert.AreEqual (0, serviceAuthorization.AuthorizationPolicies.Count, "AuthorizationPolicies.Count");
+               }
+
+               [Test]
+               public void DataContractSerializerElement () {
+                       ServiceBehaviorElement behavior = OpenConfig ();
+                       DataContractSerializerElement element = (DataContractSerializerElement) behavior [typeof (DataContractSerializerElement)];
+
+                       if (element == null)
+                               Assert.Fail ("DataContractSerializerElement is not exist in collection.");
+
+                       Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
+                       Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
+                       Assert.AreEqual (32768, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
+               }
+
+               [Test]
+               public void DataContractSerializerElement_defaults () {
+                       DataContractSerializerElement element = new DataContractSerializerElement ();
+
+                       Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
+                       Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (false, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
+                       Assert.AreEqual (65536, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
+               }
+
+               [Test]
+               public void ServiceDebugElement () {
+                       ServiceBehaviorElement behavior = OpenConfig ();
+                       ServiceDebugElement element = (ServiceDebugElement) behavior [typeof (ServiceDebugElement)];
+
+                       if (element == null)
+                               Assert.Fail ("ServiceDebugElement is not exist in collection.");
+
+                       Assert.AreEqual (typeof (ServiceDebugBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceDebug", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (false, element.HttpHelpPageEnabled, "HttpHelpPageEnabled");
+                       Assert.AreEqual ("http://help.page.url", element.HttpHelpPageUrl.OriginalString, "HttpHelpPageUrl");
+                       Assert.AreEqual (false, element.HttpsHelpPageEnabled, "HttpsHelpPageEnabled");
+                       Assert.AreEqual ("https://help.page.url", element.HttpsHelpPageUrl.OriginalString, "HttpsHelpPageUrl");
+                       Assert.AreEqual (true, element.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
+               }
+
+               [Test]
+               public void ServiceDebugElement_defaults () {
+                       ServiceDebugElement element = new ServiceDebugElement ();
+
+                       Assert.AreEqual (typeof (ServiceDebugBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceDebug", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.HttpHelpPageEnabled, "HttpHelpPageEnabled");
+                       Assert.AreEqual (null, element.HttpHelpPageUrl, "HttpHelpPageUrl");
+                       Assert.AreEqual (true, element.HttpsHelpPageEnabled, "HttpsHelpPageEnabled");
+                       Assert.AreEqual (null, element.HttpsHelpPageUrl, "HttpsHelpPageUrl");
+                       Assert.AreEqual (false, element.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
+               }
+
+               [Test]
+               public void ServiceMetadataPublishingElement () {
+                       ServiceBehaviorElement behavior = OpenConfig ();
+                       ServiceMetadataPublishingElement element = (ServiceMetadataPublishingElement) behavior [typeof (ServiceMetadataPublishingElement)];
+
+                       if (element == null)
+                               Assert.Fail ("ServiceMetadataPublishingElement is not exist in collection.");
+
+                       Assert.AreEqual (typeof (ServiceMetadataBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceMetadata", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (true, element.HttpGetEnabled, "HttpGetEnabled");
+                       Assert.AreEqual ("http://get.url", element.HttpGetUrl.OriginalString, "HttpGetUrl");
+                       Assert.AreEqual (true, element.HttpsGetEnabled, "HttpsGetEnabled");
+                       Assert.AreEqual ("https://get.url", element.HttpsGetUrl.OriginalString, "HttpsHelpPageUrl");
+                       Assert.AreEqual ("http://external.metadata.location", element.ExternalMetadataLocation.OriginalString, "ExternalMetadataLocation");
+                       Assert.AreEqual (PolicyVersion.Policy12, element.PolicyVersion, "PolicyVersion");
+               }
+
+               [Test]
+               public void ServiceMetadataPublishingElement_defaults () {
+                       ServiceMetadataPublishingElement element = new ServiceMetadataPublishingElement ();
+
+                       Assert.AreEqual (typeof (ServiceMetadataBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceMetadata", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (false, element.HttpGetEnabled, "HttpGetEnabled");
+                       Assert.AreEqual (null, element.HttpGetUrl, "HttpGetUrl");
+                       Assert.AreEqual (false, element.HttpsGetEnabled, "HttpsGetEnabled");
+                       Assert.AreEqual (null, element.HttpsGetUrl, "HttpsGetUrl");
+                       Assert.AreEqual (null, element.ExternalMetadataLocation, "ExternalMetadataLocation");
+                       Assert.AreEqual (PolicyVersion.Default, element.PolicyVersion, "PolicyVersion");
+               }
+
+               [Test]
+               public void ServiceSecurityAuditElement () {
+                       ServiceBehaviorElement behavior = OpenConfig ();
+                       ServiceSecurityAuditElement element = (ServiceSecurityAuditElement) behavior [typeof (ServiceSecurityAuditElement)];
+
+                       if (element == null)
+                               Assert.Fail ("ServiceSecurityAuditElement is not exist in collection.");
+
+                       Assert.AreEqual (typeof (ServiceSecurityAuditBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceSecurityAudit", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (AuditLogLocation.Application, element.AuditLogLocation, "AuditLogLocation");
+                       Assert.AreEqual (false, element.SuppressAuditFailure, "SuppressAuditFailure");
+                       Assert.AreEqual (AuditLevel.Success, element.ServiceAuthorizationAuditLevel, "ServiceAuthorizationAuditLevel");
+                       Assert.AreEqual (AuditLevel.Success, element.MessageAuthenticationAuditLevel, "MessageAuthenticationAuditLevel");
+               }
+
+               [Test]
+               public void ServiceSecurityAuditElement_defaults () {
+                       ServiceSecurityAuditElement element = new ServiceSecurityAuditElement ();
+
+                       Assert.AreEqual (typeof (ServiceSecurityAuditBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceSecurityAudit", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (AuditLogLocation.Default, element.AuditLogLocation, "AuditLogLocation");
+                       Assert.AreEqual (true, element.SuppressAuditFailure, "SuppressAuditFailure");
+                       Assert.AreEqual (AuditLevel.None, element.ServiceAuthorizationAuditLevel, "ServiceAuthorizationAuditLevel");
+                       Assert.AreEqual (AuditLevel.None, element.MessageAuthenticationAuditLevel, "MessageAuthenticationAuditLevel");
+               }
+
+               [Test]
+               public void ServiceThrottlingElement () {
+                       ServiceBehaviorElement behavior = OpenConfig ();
+                       ServiceThrottlingElement element = (ServiceThrottlingElement) behavior [typeof (ServiceThrottlingElement)];
+
+                       if (element == null)
+                               Assert.Fail ("ServiceThrottlingElement is not exist in collection.");
+
+                       Assert.AreEqual (typeof (ServiceThrottlingBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceThrottling", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (32, element.MaxConcurrentCalls, "MaxConcurrentCalls");
+                       Assert.AreEqual (20, element.MaxConcurrentSessions, "MaxConcurrentSessions");
+                       Assert.AreEqual (14, element.MaxConcurrentInstances, "MaxConcurrentInstances");
+               }
+
+               [Test]
+               public void ServiceThrottlingElement_defaults () {
+                       ServiceThrottlingElement element = new ServiceThrottlingElement ();
+
+                       Assert.AreEqual (typeof (ServiceThrottlingBehavior), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceThrottling", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (16, element.MaxConcurrentCalls, "MaxConcurrentCalls");
+                       Assert.AreEqual (10, element.MaxConcurrentSessions, "MaxConcurrentSessions");
+                       Assert.AreEqual (26, element.MaxConcurrentInstances, "MaxConcurrentInstances");
+               }
+
+               [Test]
+               public void ServiceTimeoutsElement () {
+                       ServiceBehaviorElement behavior = OpenConfig ();
+                       ServiceTimeoutsElement element = (ServiceTimeoutsElement) behavior [typeof (ServiceTimeoutsElement)];
+
+                       if (element == null)
+                               Assert.Fail ("ServiceTimeoutsElement is not exist in collection.");
+
+                       Assert.AreEqual ("System.ServiceModel.Description.ServiceTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
+                       Assert.AreEqual ("serviceTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (new TimeSpan (0, 3, 0), element.TransactionTimeout, "TransactionTimeout");
+               }
+
+               [Test]
+               public void ServiceTimeoutsElement_defaults () {
+                       ServiceTimeoutsElement element = new ServiceTimeoutsElement ();
+
+                       Assert.AreEqual ("System.ServiceModel.Description.ServiceTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
+                       Assert.AreEqual ("serviceTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (new TimeSpan (0, 0, 0), element.TransactionTimeout, "TransactionTimeout");
+               }
+
+               [Test]
+               public void ServiceCredentialsElement () {
+                       ServiceBehaviorElement behavior = OpenConfig ();
+                       ServiceCredentialsElement element = (ServiceCredentialsElement) behavior [typeof (ServiceCredentialsElement)];
+
+                       if (element == null)
+                               Assert.Fail ("ServiceCredentialsElement is not exist in collection.");
+
+                       Assert.AreEqual (typeof (ServiceCredentials), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceCredentials", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual ("ServiceCredentialsType", element.Type, "Type");
+
+                       Assert.AreEqual ("FindValue", element.ClientCertificate.Certificate.FindValue, "ClientCertificate.Certificate.FindValue");
+                       Assert.AreEqual (StoreLocation.CurrentUser, element.ClientCertificate.Certificate.StoreLocation, "ClientCertificate.Certificate.StoreLocation");
+                       Assert.AreEqual (StoreName.Root, element.ClientCertificate.Certificate.StoreName, "ClientCertificate.Certificate.StoreName");
+                       Assert.AreEqual (X509FindType.FindByIssuerName, element.ClientCertificate.Certificate.X509FindType, "ClientCertificate.Certificate.X509FindType");
+
+                       Assert.AreEqual ("CustomCertificateValidationType", element.ClientCertificate.Authentication.CustomCertificateValidatorType, "ClientCertificate.Authentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.ClientCertificate.Authentication.CertificateValidationMode, "ClientCertificate.Authentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509RevocationMode.Offline, element.ClientCertificate.Authentication.RevocationMode, "ClientCertificate.Authentication.RevocationMode");
+                       Assert.AreEqual (StoreLocation.CurrentUser, element.ClientCertificate.Authentication.TrustedStoreLocation, "ClientCertificate.Authentication.TrustedStoreLocation");
+                       Assert.AreEqual (false, element.ClientCertificate.Authentication.IncludeWindowsGroups, "ClientCertificate.Authentication.IncludeWindowsGroups");
+                       Assert.AreEqual (true, element.ClientCertificate.Authentication.MapClientCertificateToWindowsAccount, "ClientCertificate.Authentication.MapClientCertificateToWindowsAccount");
+
+                       Assert.AreEqual ("FindValue", element.ServiceCertificate.FindValue, "ServiceCertificate.FindValue");
+                       Assert.AreEqual (StoreLocation.CurrentUser, element.ServiceCertificate.StoreLocation, "ServiceCertificate.StoreLocation");
+                       Assert.AreEqual (StoreName.Root, element.ServiceCertificate.StoreName, "ServiceCertificate.StoreName");
+                       Assert.AreEqual (X509FindType.FindByIssuerName, element.ServiceCertificate.X509FindType, "ServiceCertificate.X509FindType");
+
+                       Assert.AreEqual (UserNamePasswordValidationMode.MembershipProvider, element.UserNameAuthentication.UserNamePasswordValidationMode, "UserNameAuthentication.UserNamePasswordValidationMode");
+                       Assert.AreEqual (false, element.UserNameAuthentication.IncludeWindowsGroups, "UserNameAuthentication.IncludeWindowsGroups");
+                       Assert.AreEqual ("MembershipProviderName", element.UserNameAuthentication.MembershipProviderName, "UserNameAuthentication.MembershipProviderName");
+                       Assert.AreEqual ("CustomUserNamePasswordValidatorType", element.UserNameAuthentication.CustomUserNamePasswordValidatorType, "UserNameAuthentication.customUserNamePasswordValidatorType");
+                       Assert.AreEqual (true, element.UserNameAuthentication.CacheLogonTokens, "UserNameAuthentication.CacheLogonTokens");
+                       Assert.AreEqual (252, element.UserNameAuthentication.MaxCachedLogonTokens, "UserNameAuthentication.MaxCachedLogonTokens");
+                       Assert.AreEqual (new TimeSpan (0, 30, 0), element.UserNameAuthentication.CachedLogonTokenLifetime, "UserNameAuthentication.CachedLogonTokenLifetime");
+
+                       Assert.AreEqual ("FindValue", element.Peer.Certificate.FindValue, "Peer.Certificate.FindValue");
+                       Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.Certificate.StoreLocation, "Peer.Certificate.StoreLocation");
+                       Assert.AreEqual (StoreName.Root, element.Peer.Certificate.StoreName, "Peer.Certificate.StoreName");
+                       Assert.AreEqual (X509FindType.FindByIssuerName, element.Peer.Certificate.X509FindType, "Peer.Certificate.X509FindType");
+
+                       Assert.AreEqual ("CustomCertificateValidatorType", element.Peer.PeerAuthentication.CustomCertificateValidatorType, "Peer.Authentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509CertificateValidationMode.Custom, element.Peer.PeerAuthentication.CertificateValidationMode, "Peer.Authentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509RevocationMode.Offline, element.Peer.PeerAuthentication.RevocationMode, "Peer.Authentication.RevocationMode");
+                       Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.PeerAuthentication.TrustedStoreLocation, "Peer.Authentication.TrustedStoreLocation");
+
+                       Assert.AreEqual ("CustomCertificateValidatorType", element.Peer.MessageSenderAuthentication.CustomCertificateValidatorType, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509CertificateValidationMode.None, element.Peer.MessageSenderAuthentication.CertificateValidationMode, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509RevocationMode.Offline, element.Peer.MessageSenderAuthentication.RevocationMode, "Peer.MessageSenderAuthentication.RevocationMode");
+                       Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.MessageSenderAuthentication.TrustedStoreLocation, "Peer.MessageSenderAuthentication.TrustedStoreLocation");
+
+                       Assert.AreEqual ("CustomCertificateValidatorType", element.IssuedTokenAuthentication.CustomCertificateValidatorType, "IssuedTokenAuthentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.IssuedTokenAuthentication.CertificateValidationMode, "IssuedTokenAuthentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509RevocationMode.Offline, element.IssuedTokenAuthentication.RevocationMode, "IssuedTokenAuthentication.RevocationMode");
+                       Assert.AreEqual (StoreLocation.CurrentUser, element.IssuedTokenAuthentication.TrustedStoreLocation, "IssuedTokenAuthentication.TrustedStoreLocation");
+                       Assert.AreEqual ("SalmSerializerType", element.IssuedTokenAuthentication.SamlSerializerType, "IssuedTokenAuthentication.SamlSerializerType");
+                       Assert.AreEqual (true, element.IssuedTokenAuthentication.AllowUntrustedRsaIssuers, "IssuedTokenAuthentication.AllowUntrustedRsaIssuers");
+
+                       Assert.AreEqual ("FindValue", element.IssuedTokenAuthentication.KnownCertificates [0].FindValue, "IssuedTokenAuthentication.KnownCertificates[0].FindValue");
+                       Assert.AreEqual (StoreLocation.CurrentUser, element.IssuedTokenAuthentication.KnownCertificates [0].StoreLocation, "IssuedTokenAuthentication.KnownCertificates[0].StoreLocation");
+                       Assert.AreEqual (StoreName.Root, element.IssuedTokenAuthentication.KnownCertificates [0].StoreName, "IssuedTokenAuthentication.KnownCertificates[0].StoreName");
+                       Assert.AreEqual (X509FindType.FindByIssuerName, element.IssuedTokenAuthentication.KnownCertificates [0].X509FindType, "IssuedTokenAuthentication.KnownCertificates[0].X509FindType");
+
+                       Assert.AreEqual ("SecurityStateEncoderType", element.SecureConversationAuthentication.SecurityStateEncoderType, "SecureConversationAuthentication.SecurityStateEncoderType");
+               }
+
+               [Test]
+               public void ServiceCredentialsElement_defaults () {
+                       ServiceCredentialsElement element = new ServiceCredentialsElement ();
+
+                       Assert.AreEqual (typeof (ServiceCredentials), element.BehaviorType, "BehaviorType");
+                       Assert.AreEqual ("serviceCredentials", element.ConfigurationElementName, "ConfigurationElementName");
+
+                       Assert.AreEqual (String.Empty, element.Type, "Type");
+
+                       Assert.AreEqual (String.Empty, element.ClientCertificate.Certificate.FindValue, "ClientCertificate.Certificate.FindValue");
+                       Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.Certificate.StoreLocation, "ClientCertificate.Certificate.StoreLocation");
+                       Assert.AreEqual (StoreName.My, element.ClientCertificate.Certificate.StoreName, "ClientCertificate.Certificate.StoreName");
+                       Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ClientCertificate.Certificate.X509FindType, "ClientCertificate.Certificate.X509FindType");
+
+                       Assert.AreEqual (String.Empty, element.ClientCertificate.Authentication.CustomCertificateValidatorType, "ClientCertificate.Authentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.ClientCertificate.Authentication.CertificateValidationMode, "ClientCertificate.Authentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509RevocationMode.Online, element.ClientCertificate.Authentication.RevocationMode, "ClientCertificate.Authentication.RevocationMode");
+                       Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.Authentication.TrustedStoreLocation, "ClientCertificate.Authentication.TrustedStoreLocation");
+                       Assert.AreEqual (true, element.ClientCertificate.Authentication.IncludeWindowsGroups, "ClientCertificate.Authentication.IncludeWindowsGroups");
+                       Assert.AreEqual (false, element.ClientCertificate.Authentication.MapClientCertificateToWindowsAccount, "ClientCertificate.Authentication.MapClientCertificateToWindowsAccount");
+
+                       Assert.AreEqual (String.Empty, element.ServiceCertificate.FindValue, "ServiceCertificate.FindValue");
+                       Assert.AreEqual (StoreLocation.LocalMachine, element.ServiceCertificate.StoreLocation, "ServiceCertificate.StoreLocation");
+                       Assert.AreEqual (StoreName.My, element.ServiceCertificate.StoreName, "ServiceCertificate.StoreName");
+                       Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ServiceCertificate.X509FindType, "ServiceCertificate.X509FindType");
+
+                       Assert.AreEqual (UserNamePasswordValidationMode.Windows, element.UserNameAuthentication.UserNamePasswordValidationMode, "UserNameAuthentication.UserNamePasswordValidationMode");
+                       Assert.AreEqual (true, element.UserNameAuthentication.IncludeWindowsGroups, "UserNameAuthentication.IncludeWindowsGroups");
+                       Assert.AreEqual (String.Empty, element.UserNameAuthentication.MembershipProviderName, "UserNameAuthentication.MembershipProviderName");
+                       Assert.AreEqual (String.Empty, element.UserNameAuthentication.CustomUserNamePasswordValidatorType, "UserNameAuthentication.customUserNamePasswordValidatorType");
+                       Assert.AreEqual (false, element.UserNameAuthentication.CacheLogonTokens, "UserNameAuthentication.CacheLogonTokens");
+                       Assert.AreEqual (128, element.UserNameAuthentication.MaxCachedLogonTokens, "UserNameAuthentication.MaxCachedLogonTokens");
+                       Assert.AreEqual (new TimeSpan (0, 15, 0), element.UserNameAuthentication.CachedLogonTokenLifetime, "UserNameAuthentication.CachedLogonTokenLifetime");
+
+                       Assert.AreEqual (String.Empty, element.Peer.Certificate.FindValue, "Peer.Certificate.FindValue");
+                       Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.Certificate.StoreLocation, "Peer.Certificate.StoreLocation");
+                       Assert.AreEqual (StoreName.My, element.Peer.Certificate.StoreName, "Peer.Certificate.StoreName");
+                       Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.Peer.Certificate.X509FindType, "Peer.Certificate.X509FindType");
+
+                       Assert.AreEqual (String.Empty, element.Peer.PeerAuthentication.CustomCertificateValidatorType, "Peer.Authentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.Peer.PeerAuthentication.CertificateValidationMode, "Peer.Authentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509RevocationMode.Online, element.Peer.PeerAuthentication.RevocationMode, "Peer.Authentication.RevocationMode");
+                       Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.PeerAuthentication.TrustedStoreLocation, "Peer.Authentication.TrustedStoreLocation");
+
+                       Assert.AreEqual (String.Empty, element.Peer.MessageSenderAuthentication.CustomCertificateValidatorType, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.Peer.MessageSenderAuthentication.CertificateValidationMode, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509RevocationMode.Online, element.Peer.MessageSenderAuthentication.RevocationMode, "Peer.MessageSenderAuthentication.RevocationMode");
+                       Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.MessageSenderAuthentication.TrustedStoreLocation, "Peer.MessageSenderAuthentication.TrustedStoreLocation");
+
+                       Assert.AreEqual (String.Empty, element.IssuedTokenAuthentication.CustomCertificateValidatorType, "IssuedTokenAuthentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.IssuedTokenAuthentication.CertificateValidationMode, "IssuedTokenAuthentication.CustomCertificateValidatorType");
+                       Assert.AreEqual (X509RevocationMode.Online, element.IssuedTokenAuthentication.RevocationMode, "IssuedTokenAuthentication.RevocationMode");
+                       Assert.AreEqual (StoreLocation.LocalMachine, element.IssuedTokenAuthentication.TrustedStoreLocation, "IssuedTokenAuthentication.TrustedStoreLocation");
+                       Assert.AreEqual (String.Empty, element.IssuedTokenAuthentication.SamlSerializerType, "IssuedTokenAuthentication.SamlSerializerType");
+                       Assert.AreEqual (false, element.IssuedTokenAuthentication.AllowUntrustedRsaIssuers, "IssuedTokenAuthentication.AllowUntrustedRsaIssuers");
+
+                       Assert.AreEqual (0, element.IssuedTokenAuthentication.KnownCertificates.Count, "IssuedTokenAuthentication.KnownCertificates.Count");
+
+                       Assert.AreEqual (String.Empty, element.SecureConversationAuthentication.SecurityStateEncoderType, "SecureConversationAuthentication.SecurityStateEncoderType");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceElementTest.cs
new file mode 100644 (file)
index 0000000..1d4fe97
--- /dev/null
@@ -0,0 +1,86 @@
+//
+// ServiceElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.Configuration;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class ServiceElementTest
+       {
+               [Test]
+               public void ReadConfiguration () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/service").GetSectionGroup ("system.serviceModel");
+                       ServiceElement service = config.Services.Services [0];
+
+                       Assert.AreEqual ("ServiceType", service.Name, "Name");
+                       Assert.AreEqual ("", service.BehaviorConfiguration, "BehaviorConfiguration");
+                       Assert.AreEqual (3, service.Endpoints.Count, "Endpoints.Count");
+
+                       Assert.AreEqual ("basicHttp", service.Endpoints [0].Name, "Endpoints [0].Name");
+                       Assert.AreEqual ("basicHttpBinding", service.Endpoints [0].Binding, "Endpoints [0].Binding");
+                       Assert.AreEqual ("HttpServiceContract", service.Endpoints [0].Contract, "Endpoints [0].Contract");
+                       Assert.AreEqual ("/rooted.path", service.Endpoints [0].Address.OriginalString, "Endpoints [0].Address");
+
+                       Assert.AreEqual (1, service.Endpoints [0].Headers.Headers.Count, "Endpoints [0].Headers.Headers.Count");
+                       Assert.AreEqual ("Tag", service.Endpoints [0].Headers.Headers [0].Name, "Endpoints [0].Headers.Headers[0].Name");
+                       Assert.AreEqual ("", service.Endpoints [0].Headers.Headers [0].Namespace, "Endpoints [0].Headers.Headers[0].Namespace");
+
+                       Assert.AreEqual ("", service.Endpoints [1].Name, "Endpoints [1].Name");
+                       Assert.AreEqual ("wsHttpBinding", service.Endpoints [1].Binding, "Endpoints [1].Binding");
+                       Assert.AreEqual ("WSServiceContract", service.Endpoints [1].Contract, "Endpoints [1].Contract");
+                       Assert.AreEqual ("http://other.endpoint.com", service.Endpoints [1].Address.OriginalString, "Endpoints [1].Address");
+
+                       Assert.AreEqual ("netTcp", service.Endpoints [2].Name, "Endpoints [2].Name");
+                       Assert.AreEqual ("netTcpBinding", service.Endpoints [2].Binding, "Endpoints [2].Binding");
+                       Assert.AreEqual ("TcpServiceContract", service.Endpoints [2].Contract, "Endpoints [2].Contract");
+                       Assert.AreEqual ("path", service.Endpoints [2].Address.OriginalString, "Endpoints [2].Address");
+
+                       Assert.AreEqual (new TimeSpan (0, 0, 20), service.Host.Timeouts.CloseTimeout, "Host.Timeouts.CloseTimeout");
+                       Assert.AreEqual (new TimeSpan (0, 2, 0), service.Host.Timeouts.OpenTimeout, "Host.Timeouts.OpenTimeout");
+
+                       Assert.AreEqual (2, service.Host.BaseAddresses.Count, "Host.BaseAddresses.Count");
+                       Assert.AreEqual ("http://endpoint.com/some.path", service.Host.BaseAddresses [0].BaseAddress, "Host.BaseAddresses[0].BaseAddress");
+                       Assert.AreEqual ("net.tcp://endpoint.com", service.Host.BaseAddresses [1].BaseAddress, "Host.BaseAddresses[1].BaseAddress");
+               }
+
+               [Test]
+               public void ServiceEndpointCollection () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/service").GetSectionGroup ("system.serviceModel");
+                       ServiceElement service = config.Services.Services [1];
+
+                       Assert.AreEqual (3, service.Endpoints.Count, "Count");
+               }
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceModelConfigurationElementCollectionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceModelConfigurationElementCollectionTest.cs
new file mode 100644 (file)
index 0000000..2281ebb
--- /dev/null
@@ -0,0 +1,132 @@
+//
+// ServiceModelConfigurationElementCollectionTest.cs
+//
+// Author:
+//     Eyal Alaluf <eyala@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.Configuration;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class ServiceModelConfigurationElementCollectionTest
+       {
+               ClaimTypeElementCollection collection;
+
+               private ClaimTypeElement CreateClaimType (string claim, bool isOptional)
+               {
+                       ClaimTypeElement elem = new ClaimTypeElement ();
+                       elem.ClaimType = claim;
+                       elem.IsOptional = isOptional;
+                       return elem;
+               }
+
+               [TearDown]
+               public void TearDownCollection ()
+               {
+                       collection = null;
+               }
+
+               [SetUp]
+               public void SetupCollection ()
+               {
+                       collection = new ClaimTypeElementCollection ();
+                       collection.Add (CreateClaimType ("test1", false));
+                       collection.Add (CreateClaimType ("test2", false));
+               }
+
+               [Test]
+               public void Indexer ()
+               {
+                       Assert.AreEqual ("test1", collection ["test1"].ClaimType, "#01");
+                       collection ["test3"] = CreateClaimType ("test3", false);
+                       Assert.AreEqual ("test3", collection ["test3"].ClaimType, "#02");
+                       collection ["test2"] = CreateClaimType ("test2", true);
+                       Assert.AreEqual (true, collection ["test2"].IsOptional, "#03");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void IndexerSetWithIncorrectKey ()
+               {
+                       collection ["test10"] = CreateClaimType ("test", false);
+               }
+
+               [Test]
+               public void IndexOf ()
+               {
+                       Assert.AreEqual (1, collection.IndexOf (CreateClaimType ("test2", false)), "#01");
+                       Assert.AreEqual (-1, collection.IndexOf (CreateClaimType ("test10", false)), "#02");
+               }
+
+               [Test]
+               public void Remove ()
+               {
+                       ClaimTypeElement elem = collection ["test2"];
+                       collection.Remove (elem);
+                       Assert.AreEqual (-1, collection.IndexOf (elem), "#01");
+                       collection.Add (elem);
+                       Assert.AreEqual (1, collection.IndexOf (elem), "#02");
+                       collection.RemoveAt (1);
+                       Assert.AreEqual (-1, collection.IndexOf (elem), "#03");
+                       collection.Add (elem);
+                       Assert.AreEqual (1, collection.IndexOf (elem), "#04");
+                       collection.RemoveAt ("test2");
+                       Assert.AreEqual (-1, collection.IndexOf (elem), "#05");
+               }
+
+               [Test]
+               public void Clear ()
+               {
+                       ClaimTypeElement elem = collection ["test2"];
+                       collection.Clear ();
+                       Assert.AreEqual (-1, collection.IndexOf (elem), "#01");
+                       Assert.AreEqual (0, collection.Count, "#02");
+               }
+
+               [Test]
+               public void ContainsKey ()
+               {
+                       Assert.AreEqual (true, collection.ContainsKey ("test1"), "#01");
+                       Assert.AreEqual (false, collection.ContainsKey ("test10"), "#02");
+               }
+
+               [Test]
+               public void CopyTo ()
+               {
+                       ClaimTypeElement[] array = new ClaimTypeElement [4];
+                       collection.CopyTo (array, 2);
+                       Assert.AreEqual ("test1", array [2].ClaimType, "#01");
+                       Assert.AreEqual ("test2", array [3].ClaimType, "#02");
+               }
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceModelSectionGroupTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/ServiceModelSectionGroupTest.cs
new file mode 100644 (file)
index 0000000..70496e0
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// ServiceModelSectionGroupTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+using System.Text;
+using System.Xml;
+
+using NUnit.Framework;
+
+using ConfigurationType = System.Configuration.Configuration;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class ServiceModelSectionGroupTest
+       {
+               ServiceModelSectionGroup GetConfig (string file)
+               {
+                       // FIXME: this should work.
+                       //ConfigurationType c = ConfigurationManager.OpenExeConfiguration (file);
+                       //return ServiceModelSectionGroup.GetSectionGroup (c);
+
+                       return (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration (file).GetSectionGroup ("system.serviceModel");
+               }
+
+               [Test]
+               public void GetSectionGroup ()
+               {
+                       ServiceModelSectionGroup g = GetConfig ("Test/config/test1");
+                       Assert.IsNotNull (g.Bindings, "bindings");
+                       Assert.IsNotNull (g.Client, "client");
+                       Assert.IsNotNull (g.Services, "services");
+                       Assert.IsNotNull (g.Client.Endpoints, "client/endpoint*");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void BindingCollections () {
+                       ServiceModelSectionGroup g = GetConfig ("Test/config/test1.config");
+                       List<BindingCollectionElement> coll = g.Bindings.BindingCollections;
+#if NET_3_5
+                       Assert.AreEqual (20, coll.Count, "Count");
+#else
+                       Assert.AreEqual (16, coll.Count, "Count");
+#endif
+               }
+
+               [Test]
+               public void Endpoints ()
+               {
+                       ServiceModelSectionGroup g = GetConfig ("Test/config/test1");
+                       ChannelEndpointElementCollection col = g.Client.Endpoints;
+                       Assert.AreEqual (1, col.Count, "initial count");
+                       ChannelEndpointElement e = col [0];
+                       Assert.AreEqual (String.Empty, e.Name, "0.Name");
+                       Assert.AreEqual ("IFoo", e.Contract, "0.Contract");
+                       Assert.AreEqual ("basicHttpBinding", e.Binding, "0.Binding");
+                       col.Add (new ChannelEndpointElement ());
+                       Assert.AreEqual (2, col.Count, "after Add()");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/StandardBindingCollectionElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/StandardBindingCollectionElementTest.cs
new file mode 100644 (file)
index 0000000..948c42c
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// StandardBindingCollectionElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.ServiceModel;
+using System.Configuration;
+using System.Collections.ObjectModel;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class StandardBindingCollectionElementTest
+       {
+               class Poker : StandardBindingCollectionElement<BasicHttpBinding, BasicHttpBindingElement>
+               {
+                       public ConfigurationPropertyCollection GetProperties () {
+                               return Properties;
+                       }
+
+                       [ConfigurationProperty ("myProperty")]
+                       string MyProperty {
+                               get { return "myProperty"; }
+                               set { }
+                       }
+               }
+
+               [Test]
+               public void Properties () {
+                       Poker poker = new Poker ();
+                       ConfigurationPropertyCollection coll = poker.GetProperties ();
+                       Assert.AreEqual (1, coll.Count, "Count");
+
+                       foreach (ConfigurationProperty prop in coll) {
+                               Assert.AreEqual ("", prop.Name);
+                       }
+               }
+
+               [Test]
+               public void Properties2 () {
+
+                       Poker p1 = new Poker ();
+                       Poker p2 = new Poker ();
+
+                       Assert.AreEqual (false, p1.GetProperties ().Contains ("myProperty"), "Contains myProperty");
+                       Assert.AreEqual (false, p1.GetProperties () == p2.GetProperties (), "#");
+               }
+
+               [Test]
+               public void ConfiguredBindings () {
+                       Poker poker = new Poker ();
+                       Assert.AreEqual (0, poker.ConfiguredBindings.Count, "Count #1");
+
+                       BasicHttpBindingElement elem = new BasicHttpBindingElement ("my_binding");
+                       poker.Bindings.Add (elem);
+                       Assert.AreEqual (1, poker.ConfiguredBindings.Count, "Count #2");
+
+                       Assert.AreEqual (elem, poker.ConfiguredBindings [0], "Instance");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/StandardBindingElementCollectionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/StandardBindingElementCollectionTest.cs
new file mode 100644 (file)
index 0000000..02ad06b
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// StandardBindingElementCollectionTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+using System;
+using System.Configuration;
+using System.ServiceModel.Configuration;
+using System.Text;
+using System.ServiceModel.Security;
+using System.ServiceModel;
+using System.Net.Security;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class StandardBindingElementCollectionTest
+       {
+               [Test]
+               public void BasicHttpBinding () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/basicHttpBinding").GetSectionGroup ("system.serviceModel");
+
+                       BasicHttpBindingCollectionElement basicHttpBinding = config.Bindings.BasicHttpBinding;
+                       Assert.AreEqual (2, basicHttpBinding.Bindings.Count, "count");
+
+                       BasicHttpBindingElement binding = basicHttpBinding.Bindings [0];
+                       Assert.AreEqual ("BasicHttpBinding_Service", binding.Name, "Name");
+                       Assert.AreEqual (Encoding.UTF8, binding.TextEncoding, "Name");
+                       Assert.AreEqual (SecurityAlgorithmSuite.Default, binding.Security.Message.AlgorithmSuite, "Name");
+               }
+
+               [Test]
+               public void NetTcpBinding () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/netTcpBinding").GetSectionGroup ("system.serviceModel");
+
+                       NetTcpBindingCollectionElement netTcpBinding = config.Bindings.NetTcpBinding;
+                       Assert.AreEqual (1, netTcpBinding.Bindings.Count, "count");
+
+                       NetTcpBindingElement binding = netTcpBinding.Bindings [0];
+                       Assert.AreEqual ("NetTcpBinding_IHelloWorldService", binding.Name, "Name");
+                       Assert.AreEqual (TransactionProtocol.OleTransactions, binding.TransactionProtocol, "TransactionProtocol");
+                       Assert.AreEqual (SecurityMode.Transport, binding.Security.Mode, "Security.Mode");
+                       Assert.AreEqual (MessageCredentialType.Windows, binding.Security.Message.ClientCredentialType, "Security.Message.ClientCredentialType");
+                       Assert.AreEqual (ProtectionLevel.EncryptAndSign, binding.Security.Transport.ProtectionLevel, "Security.Transport.ProtectionLevel");
+                       Assert.AreEqual (TcpClientCredentialType.Windows, binding.Security.Transport.ClientCredentialType, "Security.Transport.ProtectionLevel");
+               }
+
+               [Test]
+               public void WSHttpBinding () {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/wsHttpBinding").GetSectionGroup ("system.serviceModel");
+
+                       WSHttpBindingCollectionElement wsHttpBinding = config.Bindings.WSHttpBinding;
+                       Assert.AreEqual (1, wsHttpBinding.Bindings.Count, "count");
+
+                       WSHttpBindingElement binding = wsHttpBinding.Bindings [0];
+                       Assert.AreEqual ("WSHttpBinding_IHelloWorldService", binding.Name, "Name");
+                       Assert.AreEqual (HostNameComparisonMode.StrongWildcard, binding.HostNameComparisonMode, "HostNameComparisonMode");
+                       Assert.AreEqual (SecurityMode.Message, binding.Security.Mode, "Security.Mode");
+                       Assert.AreEqual (MessageCredentialType.Windows, binding.Security.Message.ClientCredentialType, "Security.Message.ClientCredentialType");
+                       Assert.AreEqual (HttpProxyCredentialType.None, binding.Security.Transport.ProxyCredentialType, "Security.Transport.ProtectionLevel");
+                       Assert.AreEqual (HttpClientCredentialType.Windows, binding.Security.Transport.ClientCredentialType, "Security.Transport.ProtectionLevel");
+               }
+
+               [Test]
+               public void CollectionType () {
+                       StandardBindingElementCollection<BasicHttpBindingElement> coll = new StandardBindingElementCollection<BasicHttpBindingElement> ();
+                       Assert.AreEqual (ConfigurationElementCollectionType.AddRemoveClearMap, coll.CollectionType, "CollectionType");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/StandardBindingElementTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/StandardBindingElementTest.cs
new file mode 100644 (file)
index 0000000..9d70011
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// StandardBindingElementTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.ServiceModel.Channels;
+using System.Configuration;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       [TestFixture]
+       public class StandardBindingElementTest
+       {
+               class Poker : StandardBindingElement
+               {
+                       protected override Type BindingElementType {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       protected override void OnApplyConfiguration (Binding binding) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public ConfigurationPropertyCollection GetProperties () {
+                               return Properties;
+                       }
+
+                       [ConfigurationProperty ("myProperty")]
+                       string MyProperty {
+                               get { return "myProperty"; }
+                               set { }
+                       }
+               }
+
+               [Test]
+               public void Properties () {
+
+                       Poker p1 = new Poker ();
+                       Poker p2 = new Poker ();
+
+                       Assert.AreEqual (false, p1.GetProperties ().Contains ("myProperty"), "Contains myProperty");
+                       Assert.AreEqual (false, p1.GetProperties () == p2.GetProperties (), "#");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/UserBinding.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Configuration/UserBinding.cs
new file mode 100644 (file)
index 0000000..a2d48da
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// UserBinding.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Configuration;
+
+namespace MonoTests.System.ServiceModel.Configuration
+{
+       public class UserBinding : Binding
+       {
+               public override BindingElementCollection CreateBindingElements () {
+                       throw new NotImplementedException ();
+               }
+
+               public override string Scheme {
+                       get { return Uri.UriSchemeHttp; }
+               }
+       }
+
+       public class UserBindingCollectionElement : StandardBindingCollectionElement<UserBinding, UserBindingElement>
+       {
+       }
+
+       public class UserBindingElement : StandardBindingElement
+       {
+               public UserBindingElement () {
+               }
+
+               public UserBindingElement (string name) {
+                       Name = name;
+               }
+
+               protected override Type BindingElementType {
+                       get { return typeof (UserBinding); }
+               }
+
+               protected override void OnApplyConfiguration (Binding binding) {
+                       throw new NotImplementedException ();
+               }
+       }
+
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ChangeLog b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ChangeLog
new file mode 100755 (executable)
index 0000000..f7967aa
--- /dev/null
@@ -0,0 +1,204 @@
+2008-05-22  Roei Erez  <roeie@mainsoft.com>
+       * fix ContractDescription.GetContract implementation
+       * Refactor Request processing
+       * Add support for message inspectors
+       * Add support for InstanceContextProvider & InstanceProvider, including lifecycles events
+       like: ReleaseServiceInstance, Open, Close...
+       * Add relevant test cases.
+
+2008-05-01  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ContractDescriptionTest.cs: Add test with method operation, parameters
+         and return value names specified by attributes.
+
+2008-04-21  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceDebugBehaviorTest.cs: new testfixture.
+       * ServiceMetadataBehaviorTest.cs: new testfixture.      
+
+2008-04-21  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * WsdlExporterTest.cs: added new test.
+
+2008-04-10  Eyal Alaluf <eyala@mainsoft.com>
+
+       * TypedMessageConverterTest.cs: Enabled and extended the roundtrip tests.
+         Used XML namespaces for the message data types.
+
+2008-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WsdlExporterTest.cs, WsdlImporterTest.cs,
+         ContractDescriptionTest.cs : marked coupled of tests as NotWorking.
+
+2008-03-23  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * OperationDescriptionTest.cs: added parts and namespace tests
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WsdlImporterTest.cs : fix tests under run-test-ondotnet with 3.5.
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WsdlImporterTest.cs : use one tab instead of "    ".
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WsdlExporterTest.cs : oops, fix errors.
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WsdlImporterTest.cs WsdlExporterTest.cs : warning cleanup.
+
+2007-03-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs : added conceptual test case that shows
+         MessageBodyAttribute is not inferred.
+
+2006-10-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs : added test to reject async operation
+         whose name does not begin with "Begin".
+
+2006-10-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs : added test to reject duplicate
+         operation names.
+
+2006-10-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs : added some async contract tests.
+
+2006-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsTest.cs : split default property value tests into
+         each individual peoperty test, and added some more.
+
+2006-09-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsTest.cs : new test.
+
+2006-09-08  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporterTest.cs: Add more tests. Remove redundant ones.
+
+2006-09-07  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporterTest.cs (ExportContractInvalid1): Remove "NotWorking".
+
+2006-09-07  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporterTest.cs (ExportContractInvalid1): New.
+
+2006-09-07  Ankit Jain  <jankit@novell.com>
+
+       * WsdlExporterTest.cs: New. Incomplete.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs : added ignorable test that treats
+         IRequestChannel as a service contract. We don't need that.
+
+2006-07-28  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsTest.cs : new file.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TypedMessageConverterTest.cs : Added StandardRoundtrip(), though
+         NotWorking.
+
+2006-07-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TypedMessageConverterTest.cs : added StandardToMessage().
+
+2006-07-13  Ankit Jain  <jankit@novell.com>
+
+       * WsdlImporterTest.cs: More June CTP updates.
+       * dump.xml: Regenerated for June CTP.
+       * MetadataResolverTest.cs: New.
+
+2006-07-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs :
+         Added test for async pattern (IMetadataExchange).
+
+2006-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs :
+         Added test for methods that takes and returns Message.
+         Added test for invalid async pattern.
+
+2006-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs, TypedMessageConverterTest.cs :
+         June CTP fixes.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs : [MessageBody] -> [MessageBodyMember].
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WsdlImporterTest.cs,
+         ContractDescriptionTest.cs : reflect June CTP updates.
+
+2006-07-03  Ankit Jain  <jankit@novell.com>
+
+       * WsdlImporterTest.cs: Update for June CTP changes.
+
+2006-07-03  Ankit Jain  <jankit@novell.com>
+
+       * WsdlImporterTest.cs: Use
+       DataContractSerializerMessageContractImporter instead of
+       DataContractSerializerMessageContractConverter.
+
+2006-06-12  Ankit Jain  <jankit@novell.com>
+
+       * WsdlImporterTest.cs : New.
+       * dump.xml: New. Required for WsdlImporterTest.cs 
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TypedMessageConverterTest.cs : new test file.
+
+2006-04-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * OperationDescriptionTest.cs : test MessageDescriptions as well.
+
+2006-04-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs : test to reject operation-less contract.
+
+2006-04-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs : moved from Test/S.SM.Dispatcher.
+       * OperationDescriptionTest.cs : new file.
+
+2006-03-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       (resumed changelogging)
+       * ChannelBuildContextTest.cs :
+         Added tests for null ListenUri arguments.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContextTest.cs : Feb. CTP API changes - chapter 1.
+
+2006-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContextTest.cs : (ConsumeBindingElements)
+         Use BindingElements instead of non-implemented WSHttpBinding.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelBuildContext.cs : new file.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TypeLoaderTest.cs : actually this is rather ContractDescription
+         test, so it is being moved.
+
+2005-10-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TypeLoaderTest.cs : new test.
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ClientCredentialsTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ClientCredentialsTest.cs
new file mode 100644 (file)
index 0000000..9b1f806
--- /dev/null
@@ -0,0 +1,115 @@
+//
+// ClientCredentialsTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Selectors;
+using System.Security.Principal;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       [TestFixture]
+       public class ClientCredentialsTest
+       {
+               [Test]
+               public void ClientCertificate ()
+               {
+                       ClientCredentials c = new ClientCredentials ();
+                       Assert.AreEqual (true, c.SupportInteractive, "#1");
+                       X509CertificateInitiatorClientCredential ccert =
+                               c.ClientCertificate;
+                       Assert.IsNull (ccert.Certificate, "#2");
+               }
+
+               [Test]
+               public void HttpDigest ()
+               {
+                       ClientCredentials c = new ClientCredentials ();
+                       // FIXME: implement
+                       HttpDigestClientCredential http = c.HttpDigest;
+               }
+
+               [Test]
+               public void IssuedToken ()
+               {
+                       ClientCredentials c = new ClientCredentials ();
+                       IssuedTokenClientCredential iss = c.IssuedToken;
+                       Assert.IsNotNull (iss, "#1");
+                       Assert.AreEqual (true, iss.CacheIssuedTokens, "#2");
+                       Assert.AreEqual (SecurityKeyEntropyMode.CombinedEntropy, iss.DefaultKeyEntropyMode, "#3");
+                       Assert.AreEqual (60, iss.IssuedTokenRenewalThresholdPercentage, "#4");
+                       Assert.AreEqual (0, iss.IssuerChannelBehaviors.Count, "#5");
+                       Assert.IsNull (iss.LocalIssuerAddress, "#6");
+                       Assert.IsNull (iss.LocalIssuerBinding, "#7");
+                       Assert.AreEqual (0, iss.LocalIssuerChannelBehaviors.Count, "#8");
+                       Assert.AreEqual (TimeSpan.MaxValue, iss.MaxIssuedTokenCachingTime, "#9");
+               }
+
+               [Test]
+               public void Peer ()
+               {
+                       ClientCredentials c = new ClientCredentials ();
+                       // FIXME: implement
+                       PeerCredential peer = c.Peer;
+               }
+
+               [Test]
+               public void ServiceCertificate ()
+               {
+                       ClientCredentials c = new ClientCredentials ();
+                       // FIXME: implement
+                       X509CertificateRecipientClientCredential scert =
+                               c.ServiceCertificate;
+               }
+
+               [Test]
+               public void UserName ()
+               {
+                       ClientCredentials c = new ClientCredentials ();
+                       // FIXME: implement
+                       UserNamePasswordClientCredential userpass = c.UserName;
+               }
+
+               [Test]
+               public void Windows ()
+               {
+                       ClientCredentials c = new ClientCredentials ();
+                       WindowsClientCredential win = c.Windows;
+                       Assert.IsNotNull (win.ClientCredential, "#1");
+                       Assert.IsTrue (win.AllowNtlm, "#2");
+                       Assert.AreEqual (TokenImpersonationLevel.Identification, win.AllowedImpersonationLevel, "#3");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ContractDescriptionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ContractDescriptionTest.cs
new file mode 100644 (file)
index 0000000..fbc0bd8
--- /dev/null
@@ -0,0 +1,606 @@
+//
+// ContractDescriptionTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ContractDescriptionTest
+       {
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void GetNonContract ()
+               {
+                       ContractDescription cd = ContractDescription.GetContract (
+                               typeof (object));
+               }
+
+               [Test]
+               public void GetContract ()
+               {
+                       InternalTestGetContract (
+                               ContractDescription.GetContract (typeof (IFoo)));
+               }
+
+               [Test]
+               public void GetContractParamRenamed ()
+               {
+                       ContractDescription cd = ContractDescription.GetContract (typeof (IFooMsgParams));
+
+                       Assert.AreEqual (1, cd.Operations.Count, "Operation count");
+
+                       // Operation #1
+                       OperationDescription od = cd.Operations [0];
+
+                       ServiceAssert.AssertOperationDescription (
+                               "MyFoo", null, null, 
+                               typeof (IFooMsgParams).GetMethod ("Foo"),
+                               true, false, false,
+                               od, "MyFoo");
+
+                       // Operation #1 -> Message #1
+                       MessageDescription md = od.Messages [0];
+
+                       ServiceAssert.AssertMessageAndBodyDescription (
+                               "http://tempuri.org/IFooMsgParams/MyFoo",
+                               MessageDirection.Input,
+                               null, "MyFoo", "http://tempuri.org/", false,
+                               md, "MyFoo");
+
+                       ServiceAssert.AssertMessagePartDescription (
+                               "MyParam", "http://tempuri.org/", 0, false,
+                               ProtectionLevel.None, typeof (string), md.Body.Parts [0], "MyFoo.msg");
+
+                       md = od.Messages [1];
+
+                       ServiceAssert.AssertMessageAndBodyDescription (
+                               "http://tempuri.org/IFooMsgParams/MyFooResponse",
+                               MessageDirection.Output,
+                               null, "MyFooResponse",
+                               "http://tempuri.org/", true,
+                               md, "MyFoo");
+
+                       ServiceAssert.AssertMessagePartDescription (
+                               "MyResult", "http://tempuri.org/", 0, false,
+                               ProtectionLevel.None, typeof (string), md.Body.ReturnValue, "MyResult ReturnValue");
+               }
+
+               [Test]
+               public void GetContractConfigName ()
+               {
+                       ContractDescription cd = ContractDescription.GetContract (typeof (ICtorUseCase2));
+                       Assert.AreEqual("CtorUseCase2", cd.ConfigurationName);
+                       Assert.AreEqual("ICtorUseCase2", cd.Name);
+                       cd = ContractDescription.GetContract (typeof (ICtorUseCase1));
+                       Assert.AreEqual("MonoTests.System.ServiceModel.ICtorUseCase1", cd.ConfigurationName);
+                       Assert.AreEqual("ICtorUseCase1", cd.Name);
+               }
+
+               [Test]
+               public void GetContract2 ()
+               {
+                       InternalTestGetContract (
+                               ContractDescription.GetContract (typeof (Foo)));
+               }
+
+               public void InternalTestGetContract (ContractDescription cd)
+               {
+                       ServiceAssert.AssertContractDescription (
+                               "IFoo", "http://tempuri.org/", SessionMode.Allowed, typeof (IFoo), null,
+                               cd, "contract");
+
+                       Assert.AreEqual (2, cd.Operations.Count, "Operation count");
+
+                       // Operation #1
+                       OperationDescription od = cd.Operations [0];
+
+                       ServiceAssert.AssertOperationDescription (
+                               "HeyDude", null, null, 
+                               typeof (IFoo).GetMethod ("HeyDude"),
+                               true, false, false,
+                               od, "HeyDude");
+
+                       // Operation #1 -> Message #1
+                       MessageDescription md = od.Messages [0];
+
+                       ServiceAssert.AssertMessageAndBodyDescription (
+                               "http://tempuri.org/IFoo/HeyDude",
+                               MessageDirection.Input,
+                               null, "HeyDude", "http://tempuri.org/", false,
+                               md, "HeyDude");
+
+                       ServiceAssert.AssertMessagePartDescription (
+                               "msg", "http://tempuri.org/", 0, false,
+                               ProtectionLevel.None, typeof (string), md.Body.Parts [0], "HeyDude.msg");
+                       ServiceAssert.AssertMessagePartDescription (
+                               "msg2", "http://tempuri.org/", 1, false,
+                               ProtectionLevel.None, typeof (string), md.Body.Parts [1], "HeyDude.msg");
+
+                       // Operation #1 -> Message #2
+                       md = od.Messages [1];
+
+                       ServiceAssert.AssertMessageAndBodyDescription (
+                               "http://tempuri.org/IFoo/HeyDudeResponse",
+                               MessageDirection.Output,
+                               null, "HeyDudeResponse",
+                               "http://tempuri.org/", true,
+                               md, "HeyDude");
+
+                       ServiceAssert.AssertMessagePartDescription (
+                               "HeyDudeResult", "http://tempuri.org/", 0, false,
+                               ProtectionLevel.None, typeof (string), md.Body.ReturnValue, "HeyDudeResponse ReturnValue");
+
+                       // Operation #2
+                       od = cd.Operations [1];
+
+                       ServiceAssert.AssertOperationDescription (
+                               "HeyHey", null, null,
+                               typeof (IFoo).GetMethod ("HeyHey"),
+                               true, false, false,
+                               od, "HeyHey");
+
+                       // Operation #2 -> Message #1
+                       md = od.Messages [0];
+
+                       ServiceAssert.AssertMessageAndBodyDescription (
+                               "http://tempuri.org/IFoo/HeyHey",
+                               MessageDirection.Input,
+                               null, "HeyHey", "http://tempuri.org/", false,
+                               md, "HeyHey");
+
+                       ServiceAssert.AssertMessagePartDescription (
+                               "ref1", "http://tempuri.org/", 0, false,
+                               ProtectionLevel.None, typeof (string), md.Body.Parts [0], "HeyHey.ref1");
+
+                       // Operation #2 -> Message #2
+                       md = od.Messages [1];
+
+                       ServiceAssert.AssertMessageAndBodyDescription (
+                               "http://tempuri.org/IFoo/HeyHeyResponse",
+                               MessageDirection.Output,
+                               null, "HeyHeyResponse",
+                               "http://tempuri.org/", true,
+                               md, "HeyHey");
+
+                       ServiceAssert.AssertMessagePartDescription (
+                               "HeyHeyResult", "http://tempuri.org/", 0, false,
+                               ProtectionLevel.None, typeof (void), md.Body.ReturnValue, "HeyHeyResponse ReturnValue");
+
+                       ServiceAssert.AssertMessagePartDescription (
+                               "out1", "http://tempuri.org/", 0, false,
+                               ProtectionLevel.None, typeof (string), md.Body.Parts [0], "HeyHey.out1");
+                       ServiceAssert.AssertMessagePartDescription (
+                               "ref1", "http://tempuri.org/", 1, false,
+                               ProtectionLevel.None, typeof (string), md.Body.Parts [1], "HeyHey.ref1");
+               }
+
+               [Test]
+               public void GetContractInherit ()
+               {
+                       ContractDescription.GetContract (typeof (Foo));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void GetMultipleServiceContract ()
+               {
+                       ContractDescription.GetContract (typeof (FooBar));
+               }
+
+               [Test]
+               // [ExpectedException (typeof (InvalidOperationException))]
+               public void GetContractNoOperation ()
+               {
+                       ContractDescription.GetContract (typeof (INoOperation));
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void GetContractMessageParameter ()
+               {
+                       ContractDescription cd = ContractDescription.GetContract (typeof (IMessageParameter));
+
+                       ServiceAssert.AssertContractDescription (
+                               "IMessageParameter", "http://tempuri.org/", 
+                               SessionMode.Allowed, typeof (IMessageParameter), null,
+                               cd, "contract");
+
+                       OperationDescription od = cd.Operations [0];
+
+                       ServiceAssert.AssertOperationDescription (
+                               "ReturnMessage", null, null, 
+                               typeof (IMessageParameter).GetMethod ("ReturnMessage"),
+                               true, false, false,
+                               od, "operation");
+
+                       MessageDescription md = od.Messages [0];
+
+                       ServiceAssert.AssertMessageAndBodyDescription (
+                               "http://tempuri.org/IMessageParameter/ReturnMessage",
+                               MessageDirection.Input,
+                               // Body.WrapperName is null
+                               null, null, null, false,
+                               md, "ReturnMessage");
+
+                       ServiceAssert.AssertMessagePartDescription (
+                               "arg", "http://tempuri.org/", 0, false,
+                               ProtectionLevel.None, typeof (Message), md.Body.Parts [0], "ReturnMessage input");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void GetContractInvalidAsync ()
+               {
+                       ContractDescription.GetContract (typeof (IInvalidAsync));
+               }
+
+               [Test]
+               // IMetadataExchange contains async patterns.
+               public void GetContractIMetadataExchange ()
+               {
+                       ContractDescription cd = ContractDescription.GetContract (typeof (IMetadataExchange));
+                       OperationDescription od = cd.Operations [0];
+                       Assert.AreEqual (2, od.Messages.Count, "premise: message count");
+                       foreach (MessageDescription md in od.Messages) {
+                               if (md.Direction == MessageDirection.Input) {
+                                       Assert.AreEqual ("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get", md.Action, "#1-1");
+                                       Assert.AreEqual (1, md.Body.Parts.Count, "#1-2");
+                                       Assert.IsNull (md.Body.ReturnValue, "#1-3");
+                                       Assert.AreEqual (typeof (Message), md.Body.Parts [0].Type, "#1-4");
+                               } else {
+                                       Assert.AreEqual ("http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse", md.Action, "#2-1");
+                                       Assert.AreEqual (0, md.Body.Parts.Count, "#2-2");
+                                       Assert.IsNotNull (md.Body.ReturnValue, "#2-3");
+                                       Assert.AreEqual (typeof (Message), md.Body.ReturnValue.Type, "#2-4");
+                               }
+                       }
+               }
+
+               [Test]
+               // enable it if we want to become a compatibility kid. It has
+               // no ServiceContract, thus it should not be accepted. But
+               // there is an abuse of ChannelFactory<IRequestChannel> in
+               // MSDN documentations and probably examples.
+               [Category ("NotWorking")]
+               public void GetContractIRequestChannel ()
+               {
+                       ContractDescription cd = ContractDescription.GetContract (typeof (IRequestChannel));
+                       Assert.AreEqual (typeof (IRequestChannel), cd.ContractType, "#_1");
+                       Assert.AreEqual ("IRequestChannel", cd.Name, "#_2");
+                       Assert.AreEqual ("http://schemas.microsoft.com/2005/07/ServiceModel", cd.Namespace, "#_3");
+                       Assert.AreEqual (false, cd.HasProtectionLevel, "#_4");
+                       Assert.AreEqual (SessionMode.NotAllowed, cd.SessionMode, "#_5");
+                       Assert.AreEqual (0, cd.Behaviors.Count, "#_6");
+                       Assert.AreEqual (1, cd.Operations.Count, "#_7");
+                       OperationDescription od = cd.Operations [0];
+                       Assert.IsNull (od.SyncMethod, "#_8");
+                       Assert.IsNull (od.BeginMethod, "#_9");
+                       Assert.IsNull (od.EndMethod, "#_10");
+                       Assert.AreEqual (false, od.IsOneWay, "#_11");
+                       Assert.AreEqual (false, od.HasProtectionLevel, "#_12");
+                       Assert.AreEqual ("Request", od.Name, "#_13");
+                       Assert.AreEqual (true, od.IsInitiating, "#_14");
+                       Assert.AreEqual (0, od.Behaviors.Count, "#_15");
+                       Assert.AreEqual (2, od.Messages.Count, "#_16");
+                       foreach (MessageDescription md in od.Messages) {
+                               if (md.Direction == MessageDirection.Output) {
+                                       Assert.AreEqual ("*", md.Action, "#_17");
+                                       Assert.AreEqual (false, md.HasProtectionLevel, "#_18");
+                                       Assert.AreEqual (0, md.Headers.Count, "#_19");
+                                       Assert.AreEqual (0, md.Properties.Count, "#_20");
+                                       Assert.IsNull (md.MessageType, "#_21");
+                                       MessageBodyDescription mb = md.Body;
+                                       Assert.AreEqual (null, mb.WrapperName, "#_22");
+                                       Assert.AreEqual (null, mb.WrapperNamespace, "#_23");
+                                       Assert.IsNull (mb.ReturnValue, "#_24");
+                                       Assert.AreEqual (0, mb.Parts.Count, "#_25");
+                               } else {
+                                       Assert.AreEqual ("*", md.Action, "#_17_");
+                                       Assert.AreEqual (false, md.HasProtectionLevel, "#_18_");
+                                       Assert.AreEqual (0, md.Headers.Count, "#_19_");
+                                       Assert.AreEqual (0, md.Properties.Count, "#_20_");
+                                       Assert.IsNull (md.MessageType, "#_21_");
+                                       MessageBodyDescription mb = md.Body;
+                                       Assert.AreEqual (null, mb.WrapperName, "#_22_");
+                                       Assert.AreEqual (null, mb.WrapperNamespace, "#_23_");
+                                       Assert.IsNull (mb.ReturnValue, "#_24_");
+                                       Assert.AreEqual (0, mb.Parts.Count, "#_25_");
+                               }
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void WrongAsyncEndContract ()
+               {
+                       ContractDescription.GetContract (typeof (IWrongAsyncEndContract));
+               }
+
+               [Test]
+               public void AsyncContract1 ()
+               {
+                       ContractDescription cd =
+                               ContractDescription.GetContract (typeof (IAsyncContract1));
+                       Assert.AreEqual (1, cd.Operations.Count);
+                       OperationDescription od = cd.Operations [0];
+                       Assert.AreEqual ("Sum", od.Name, "#1");
+                       Assert.IsNotNull (od.BeginMethod, "#2");
+                       Assert.IsNotNull (od.EndMethod, "#3");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void DuplicateOperationNames ()
+               {
+                       ContractDescription.GetContract (typeof (IDuplicateOperationNames));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AsyncMethodNameDoesNotStartWithBegin ()
+               {
+                       ContractDescription.GetContract (typeof (IAsyncMethodNameDoesNotStartWithBegin));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AsyncNameDoesNotStartWithBeginButExplicitName ()
+               {
+                       // it is still invalid ...
+                       ContractDescription.GetContract (typeof (IAsyncNameDoesNotStartWithBeginButExplicitName));
+               }
+
+               [Test]
+               public void MessageBodyMemberIsNotInferred ()
+               {
+                       ContractDescription cd = ContractDescription.GetContract (typeof (MessageBodyMemberIsNotInferredService));
+                       OperationDescription od = cd.Operations [0];
+                       MessageDescription md = od.Messages [0];
+                       Assert.AreEqual (0, md.Body.Parts.Count);
+               }
+
+               [Test]
+               public void TestContractFromObject () {
+                       ContractDescription cd = ContractDescription.GetContract (typeof (Foo));
+                       ServiceAssert.AssertContractDescription (typeof (IFoo).Name, "http://tempuri.org/", SessionMode.Allowed, typeof (IFoo), null, cd, "#1");
+                       Assert.AreEqual (cd.Operations.Count, 2);
+                       OperationBehaviorAttribute op = cd.Operations.Find ("HeyHey").Behaviors.Find<OperationBehaviorAttribute> ();
+                       Assert.IsNotNull (op);
+                       Assert.AreEqual (
+                               op.ReleaseInstanceMode,
+                               ReleaseInstanceMode.None, "#2");
+
+                       cd = ContractDescription.GetContract (typeof (IFoo), typeof (Foo));
+                       ServiceAssert.AssertContractDescription (typeof (IFoo).Name, "http://tempuri.org/", SessionMode.Allowed, typeof (IFoo), null, cd, "#3");
+                       Assert.AreEqual (cd.Operations.Count, 2, "#4");
+                       Assert.AreEqual (
+                               cd.Operations.Find ("HeyHey").Behaviors.Find<OperationBehaviorAttribute> ().ReleaseInstanceMode,
+                               ReleaseInstanceMode.AfterCall, "#5");
+               }
+
+               // It is for testing attribute search in interfaces.
+               public class Foo : IFoo
+               {
+                       public string HeyDude (string msg, string msg2)
+                       {
+                               return null;
+                       }
+
+                       [OperationBehavior (ReleaseInstanceMode = ReleaseInstanceMode.AfterCall)]
+                       public void HeyHey (out string out1, ref string ref1)
+                       {
+                               out1 = null;
+                       }
+               }
+
+               // It inherits both IFoo and IBar, thus cannot be a contract.
+               public class FooBar : IFoo, IBar
+               {
+                       public string HeyDude (string msg, string msg2)
+                       {
+                               return null;
+                       }
+                       
+                       public void HeyHey (out string out1, ref string ref1)
+                       {
+                               out1 = null;
+                       }
+
+                       public void OpenBar () {}
+               }
+
+               [ServiceContract]
+               public interface IFoo
+               {
+                       [OperationContract]
+                       string HeyDude (string msg, string msg2);
+
+                       [OperationContract]
+                       void HeyHey (out string out1, ref string ref1);
+               }
+
+               [ServiceContract]
+               public interface IFoo2
+               {
+                       // FIXME: it does not pass yet
+                       [OperationContract]
+                       OregoMessage Nanoda (OregoMessage msg);
+
+                       // FIXME: it does not pass yet
+                       [OperationContract]
+                       OregoMessage Nanoda2 (OregoMessage msg1, OregoMessage msg2);
+
+                       // FIXME: it does not pass yet
+                       [OperationContract]
+                       Mona NewMona (Mona source);
+               }
+
+               [ServiceContract]
+               public interface IBar
+               {
+                       [OperationContract]
+                       void OpenBar ();
+               }
+
+               [MessageContract]
+               public class OregoMessage
+               {
+                       [MessageBodyMember]
+                       public string Neutral;
+                       [MessageBodyMember]
+                       public Assembly Huh;
+                       [MessageBodyMember] // it should be ignored ...
+                       public string Setter { set { } }
+                       public string NonMember;
+               }
+
+               public class Mona
+               {
+                       public string OmaeMona;
+                       public string OreMona;
+               }
+
+               [ServiceContract]
+               public interface INoOperation
+               {
+               }
+
+               [ServiceContract]
+               public interface IMessageParameter
+               {
+                       [OperationContract]
+                       Message ReturnMessage (Message arg);
+               }
+
+               [ServiceContract]
+               public interface IInvalidAsync
+               {
+                       [OperationContract]
+                       Message ReturnMessage (Message arg);
+
+                       [OperationContract (AsyncPattern = true)]
+                       IAsyncResult BeginReturnMessage (Message arg, AsyncCallback callback, object state);
+
+                       // and no EndReturnMessage().
+               }
+
+               [ServiceContract]
+               public interface IWrongAsyncEndContract
+               {
+                       [OperationContract]
+                       int Sum (int a, int b);
+
+                       [OperationContract (AsyncPattern = true)]
+                       IAsyncResult BeginSum (int a, int b, AsyncCallback cb, object state);
+
+                       // this OperationContractAttribute is not allowed.
+                       [OperationContract (AsyncPattern = true)]
+                       int EndSum (IAsyncResult result);
+               }
+
+               [ServiceContract]
+               public interface IAsyncContract1
+               {
+                       [OperationContract]
+                       int Sum (int a, int b);
+
+                       [OperationContract (AsyncPattern = true)]
+                       IAsyncResult BeginSum (int a, int b, AsyncCallback cb, object state);
+
+                       int EndSum (IAsyncResult result);
+               }
+
+               [ServiceContract]
+               public interface IAsyncMethodNameDoesNotStartWithBegin
+               {
+                       [OperationContract]
+                       int Sum (int a, int b);
+
+                       [OperationContract (AsyncPattern = true)]
+                       IAsyncResult StartSum (int a, int b, AsyncCallback cb, object state);
+
+                       int EndSum (IAsyncResult result);
+               }
+
+               [ServiceContract]
+               public interface IAsyncNameDoesNotStartWithBeginButExplicitName
+               {
+                       [OperationContract]
+                       int Sum (int a, int b);
+
+                       [OperationContract (Name = "Sum", AsyncPattern = true)]
+                       IAsyncResult StartSum (int a, int b, AsyncCallback cb, object state);
+
+                       int EndSum (IAsyncResult result);
+               }
+
+               [ServiceContract]
+               public interface IDuplicateOperationNames
+               {
+                       [OperationContract]
+                       string Echo (string s);
+
+                       [OperationContract]
+                       string Echo (string s1, string s2);
+               }
+
+               [ServiceContract]
+               public interface IFooMsgParams
+               {
+                       [OperationContract (Name = "MyFoo")]
+                       [return: MessageParameter (Name = "MyResult")]
+                       string Foo ([MessageParameter (Name = "MyParam")] string param);
+               }
+
+               [ServiceContract]
+               public class MessageBodyMemberIsNotInferredService
+               {
+                       [OperationContract]
+                       public void Echo (MessageBodyMemberIsNotInferredContract msg)
+                       {
+                       }
+               }
+
+               [MessageContract]
+               public class MessageBodyMemberIsNotInferredContract
+               {
+                       string foo = "foo";
+                       public string Foo {
+                               get { return foo; }
+                               set { foo = value; }
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataResolverTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/MetadataResolverTest.cs
new file mode 100644 (file)
index 0000000..30c1ffd
--- /dev/null
@@ -0,0 +1,323 @@
+//
+// MetadataResolverTest.cs
+//
+// Author:
+//     Ankit Jain <JAnkit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.Serialization;
+using System.ServiceModel.Description;
+using System.ServiceModel;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       //[TestFixture]
+       public class MetadataResolverTest
+       {
+               //string url = "http://localhost:8080/echo/mex";
+               string url = "http://192.168.0.1:8080/echo/mex";
+
+               [Test]
+               public void ResolveNoEndpoint ()
+               {
+                       ServiceEndpointCollection endpoints = MetadataResolver.Resolve (
+                               typeof (NonExistantContract),
+                               new EndpointAddress (url));
+
+                       Assert.IsNotNull (endpoints);
+                       Assert.AreEqual (0, endpoints.Count);
+               }
+
+               [Test]
+               public void Resolve1 ()
+               {
+                       ServiceEndpointCollection endpoints = MetadataResolver.Resolve (
+                               typeof (IEchoService), new EndpointAddress (url));
+
+                       CheckIEchoServiceEndpoint (endpoints);
+               }
+
+               [Test]
+               public void Resolve2 ()
+               {
+                       ServiceEndpointCollection endpoints = MetadataResolver.Resolve (
+                               typeof (IEchoService),
+                               new Uri (url),
+                               MetadataExchangeClientMode.MetadataExchange);
+
+                       CheckIEchoServiceEndpoint (endpoints);
+               }
+
+               [Test]
+               public void Resolve3 ()
+               {
+                       ContractDescription contract = ContractDescription.GetContract (typeof (IEchoService));
+                       List<ContractDescription> contracts = new List<ContractDescription> ();
+                       contracts.Add (contract);
+
+                       ServiceEndpointCollection endpoints = MetadataResolver.Resolve (
+                               contracts,
+                               new Uri (url),
+                               MetadataExchangeClientMode.MetadataExchange);
+
+                       CheckIEchoServiceEndpoint (endpoints);
+               }
+
+               [Test]
+               public void Resolve4 ()
+               {
+                       ContractDescription contract = ContractDescription.GetContract (typeof (IEchoService));
+                       List<ContractDescription> contracts = new List<ContractDescription> ();
+                       contracts.Add (contract);
+                       contracts.Add (ContractDescription.GetContract (typeof (NonExistantContract)));
+
+                       ServiceEndpointCollection endpoints = MetadataResolver.Resolve (
+                               contracts,
+                               new Uri (url),
+                               MetadataExchangeClientMode.MetadataExchange);
+
+                       CheckIEchoServiceEndpoint (endpoints);
+               }
+
+               [Test]
+               public void Resolve5 ()
+               {
+                       ContractDescription contract = ContractDescription.GetContract (typeof (IEchoService));
+                       List<ContractDescription> contracts = new List<ContractDescription> ();
+                       contracts.Add (contract);
+                       contracts.Add (ContractDescription.GetContract (typeof (NonExistantContract)));
+
+                       //FIXME: What is the 'client' param used for?
+                       //TODO: Write test cases for the related overloads of Resolve
+                       MetadataResolver.Resolve (
+                               contracts,
+                               new EndpointAddress (url),
+                               new MetadataExchangeClient (new EndpointAddress ("http://localhost")));
+               }
+
+               [Test]
+               public void Resolve6 ()
+               {
+                       ContractDescription contract = ContractDescription.GetContract (typeof (IEchoService));
+                       List<ContractDescription> contracts = new List<ContractDescription> ();
+                       contracts.Add (contract);
+                       contracts.Add (ContractDescription.GetContract (typeof (NonExistantContract)));
+
+                       //FIXME: What is the 'client' param used for?
+                       //TODO: Write test cases for the related overloads of Resolve
+                       MetadataResolver.Resolve (
+                               contracts,
+                               new Uri (url),
+                               MetadataExchangeClientMode.MetadataExchange,
+                               new MetadataExchangeClient (new EndpointAddress ("http://localhost")));
+               }
+
+
+               //Negative tests
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ErrResolve1 ()
+               {
+                       MetadataResolver.Resolve (
+                               typeof (IEchoService),
+                               null,
+                               MetadataExchangeClientMode.MetadataExchange);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")]
+               public void ErrResolve2 ()
+               {
+               /* Not working as HttpGet is not implemented yet */
+                       //Mex cannot be fetched with HttpGet from the given url
+                       MetadataResolver.Resolve (
+                               typeof (IEchoService),
+                               new Uri (url),
+                               MetadataExchangeClientMode.HttpGet);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ErrResolve3 ()
+               {
+                       ContractDescription contract = ContractDescription.GetContract (typeof (IEchoService));
+                       List<ContractDescription> contracts = new List<ContractDescription> ();
+                       contracts.Add (contract);
+                       contracts.Add (ContractDescription.GetContract (typeof (NonExistantContract)));
+
+                       MetadataResolver.Resolve (contracts, new EndpointAddress (url),
+                               (MetadataExchangeClient) null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void ErrResolve4 ()
+               {
+                       ContractDescription contract = ContractDescription.GetContract (typeof (IEchoService));
+                       List<ContractDescription> contracts = new List<ContractDescription> ();
+                       contracts.Add (contract);
+                       contracts.Add (ContractDescription.GetContract (typeof (NonExistantContract)));
+
+                       //FIXME: What is the 'client' param used for?
+                       //TODO: Write test cases for the related overloads of Resolve
+                       MetadataResolver.Resolve (
+                               contracts,
+                               new EndpointAddress ("http://localhost"),
+                               new MetadataExchangeClient (new EndpointAddress (url)));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")]
+               public void ErrResolve5 ()
+               {
+               /* Not working as HttpGet is not implemented yet */
+                       ContractDescription contract = ContractDescription.GetContract (typeof (IEchoService));
+                       List<ContractDescription> contracts = new List<ContractDescription> ();
+                       contracts.Add (contract);
+                       contracts.Add (ContractDescription.GetContract (typeof (NonExistantContract)));
+
+                       //FIXME: What is the 'client' param used for?
+                       //TODO: Write test cases for the related overloads of Resolve
+                       MetadataResolver.Resolve (
+                               contracts,
+                               new Uri (url),
+                               MetadataExchangeClientMode.HttpGet,
+                               new MetadataExchangeClient (new EndpointAddress ("http://localhost")));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void ErrResolve6 ()
+               {
+                       ContractDescription contract = ContractDescription.GetContract (typeof (IEchoService));
+                       List<ContractDescription> contracts = new List<ContractDescription> ();
+
+                       //FIXME: What is the 'client' param used for?
+                       //TODO: Write test cases for the related overloads of Resolve
+                       MetadataResolver.Resolve (
+                               contracts,
+                               new Uri (url),
+                               MetadataExchangeClientMode.HttpGet,
+                               new MetadataExchangeClient (new EndpointAddress ("http://localhost")));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ErrResolve7 ()
+               {
+                       MetadataResolver.Resolve (
+                               null,
+                               new Uri (url),
+                               MetadataExchangeClientMode.HttpGet,
+                               new MetadataExchangeClient (new EndpointAddress ("http://localhost")));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ErrResolve8 ()
+               {
+                       ContractDescription contract = ContractDescription.GetContract (typeof (IEchoService));
+                       List<ContractDescription> contracts = new List<ContractDescription> ();
+                       contracts.Add (contract);
+
+                       MetadataResolver.Resolve (contracts, null);
+               }
+
+               /* Test for bad endpoint address */
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void ErrResolve9 ()
+               {
+                       ContractDescription contract = ContractDescription.GetContract (typeof (IEchoService));
+                       List<ContractDescription> contracts = new List<ContractDescription> ();
+                       contracts.Add (contract);
+
+                       MetadataResolver.Resolve (contracts, new EndpointAddress ("http://localhost"));
+               }
+
+               private void CheckIEchoServiceEndpoint (ServiceEndpointCollection endpoints)
+               {
+                       Assert.IsNotNull (endpoints);
+                       Assert.AreEqual (1, endpoints.Count);
+
+                       ServiceEndpoint ep = endpoints [0];
+
+                       //URI Dependent
+                       //Assert.AreEqual ("http://localhost:8080/echo/svc", ep.Address.Uri.AbsoluteUri, "#R1");
+                       Assert.AreEqual ("IEchoService", ep.Contract.Name, "#R3");
+                       Assert.AreEqual ("http://myns/echo", ep.Contract.Namespace, "#R4");
+                       Assert.AreEqual ("BasicHttpBinding_IEchoService", ep.Name, "#R5");
+
+                       Assert.AreEqual (typeof (BasicHttpBinding), ep.Binding.GetType (), "#R2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void ResolveNonContract ()
+               {
+                       MetadataResolver.Resolve (
+                               typeof (Int32), new EndpointAddress (url));
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void ResolveBadUri ()
+               {
+                       MetadataResolver.Resolve (
+                               typeof (IEchoService), new EndpointAddress ("http://localhost"));
+               }
+
+               [DataContract]
+               public class dc
+               {
+                       [DataMember]
+                       string field;
+               }
+
+               [ServiceContract (Namespace = "http://myns/echo")]
+               public interface IEchoService
+               {
+
+                       [OperationContract]
+                       string Echo (string msg, int num, dc d);
+
+                       [OperationContract]
+                       string DoubleIt (int it, string prefix);
+
+               }
+
+               [ServiceContract]
+               public class NonExistantContract
+               {
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/OperationDescriptionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/OperationDescriptionTest.cs
new file mode 100644 (file)
index 0000000..2b7f801
--- /dev/null
@@ -0,0 +1,162 @@
+//
+// OperationDescriptionTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       [TestFixture]
+       public class OperationDescriptionTest
+       {
+               [Test]
+               public void Messages ()
+               {
+                       ContractDescription cd =
+                               ContractDescription.GetContract (typeof (IFoo));
+                       OperationDescription od = cd.Operations [0];
+                       Assert.IsNull (od.Messages.Find ("Echo"), "#1");
+                       MessageDescription md = od.Messages.Find ("http://tempuri.org/IFoo/Echo");
+                       Assert.IsNotNull (md, "#2");
+
+                       Assert.AreEqual ("http://tempuri.org/IFoo/Echo", md.Action, "#3");
+                       Assert.AreEqual (MessageDirection.Input, md.Direction, "#4");
+                       Assert.IsFalse (md.HasProtectionLevel, "#5");
+                       Assert.IsNotNull (md.Headers, "#6");
+                       Assert.AreEqual (0, md.Headers.Count, "#7");
+                       Assert.IsNull (md.MessageType, "#8");
+                       Assert.IsNotNull (md.Properties, "#9");
+                       Assert.AreEqual (0, md.Properties.Count, "#10");
+
+                       MessageBodyDescription mb = md.Body;
+                       Assert.IsNotNull (mb, "#11");
+                       Assert.AreEqual ("Echo", mb.WrapperName, "#12");
+                       Assert.AreEqual ("http://tempuri.org/", mb.WrapperNamespace, "#13");
+                       Assert.IsNotNull (mb.Parts, "#14");
+                       Assert.AreEqual (0, mb.Parts.Count, "#15");
+                       Assert.IsNull (mb.ReturnValue, "#16"); // void Echo()
+               }
+
+               [Test]
+               public void MessagesNameSpace ()
+               {
+                       ContractDescription cd =
+                               ContractDescription.GetContract (typeof (IFoo2));
+                       OperationDescription od = cd.Operations [0];
+                       Assert.IsNull (od.Messages.Find ("Echo"), "#1");
+                       MessageDescription md = od.Messages.Find ("http://MonoTests.System.ServiceModel.Description/IFoo2/Echo");
+                       Assert.IsNotNull (md, "#2");
+
+                       Assert.AreEqual ("http://MonoTests.System.ServiceModel.Description/IFoo2/Echo", md.Action, "#3");
+                       Assert.AreEqual (MessageDirection.Input, md.Direction, "#4");
+                       Assert.IsFalse (md.HasProtectionLevel, "#5");
+                       Assert.IsNotNull (md.Headers, "#6");
+                       Assert.AreEqual (0, md.Headers.Count, "#7");
+                       Assert.IsNull (md.MessageType, "#8");
+                       Assert.IsNotNull (md.Properties, "#9");
+                       Assert.AreEqual (0, md.Properties.Count, "#10");
+
+                       MessageBodyDescription mb = md.Body;
+                       Assert.IsNotNull (mb, "#11");
+                       Assert.AreEqual ("Echo", mb.WrapperName, "#12");
+                       Assert.AreEqual ("http://MonoTests.System.ServiceModel.Description", mb.WrapperNamespace, "#13");
+                       Assert.IsNotNull (mb.Parts, "#14");
+                       Assert.AreEqual (0, mb.Parts.Count, "#15");
+                       Assert.IsNull (mb.ReturnValue, "#16"); // void Echo()
+               }
+
+               [Test]
+               public void Parts ()
+               {
+                       ContractDescription cd =
+                               ContractDescription.GetContract (typeof (IFoo3));
+
+                       MessagePartDescriptionCollection parts =
+                               cd.Operations [0].Messages [0].Body.Parts;
+
+                       Assert.AreEqual (1, parts.Count, "#1");
+                       MessagePartDescription part = parts [0];
+                       Assert.AreEqual ("intValue", part.Name, "#2");
+                       Assert.AreEqual ("http://tempuri.org/", part.Namespace, "#3");
+                       Assert.AreEqual (typeof (int), part.Type, "#4");
+                       Assert.AreEqual (0, part.Index, "#5");
+                       Assert.AreEqual (false, part.Multiple, "#5");
+               }
+
+               [Test]
+               public void PartsNamespace ()
+               {
+                       ContractDescription cd =
+                               ContractDescription.GetContract (typeof (IFoo4));
+
+                       MessagePartDescriptionCollection parts =
+                               cd.Operations [0].Messages [0].Body.Parts;
+
+                       Assert.AreEqual (1, parts.Count, "#1");
+                       MessagePartDescription part = parts [0];
+                       Assert.AreEqual ("intValue", part.Name, "#2");
+                       Assert.AreEqual ("http://MonoTests.System.ServiceModel.Description", part.Namespace, "#3");
+                       Assert.AreEqual (typeof (int), part.Type, "#4");
+                       Assert.AreEqual (0, part.Index, "#5");
+                       Assert.AreEqual (false, part.Multiple, "#5");
+               }
+               
+               [ServiceContract]
+               public interface IFoo
+               {
+                       [OperationContract]
+                       void Echo ();
+               }
+               
+               [ServiceContract(Namespace="http://MonoTests.System.ServiceModel.Description")]
+               public interface IFoo2
+               {
+                       [OperationContract]
+                       void Echo ();
+               }
+
+               [ServiceContract]
+               public interface IFoo3
+               {
+                       [OperationContract]
+                       int Echo (int intValue);
+               }
+
+               [ServiceContract (Namespace = "http://MonoTests.System.ServiceModel.Description")]
+               public interface IFoo4
+               {
+                       [OperationContract]
+                       int Echo (int intValue);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceAuthorizationBehaviorTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceAuthorizationBehaviorTest.cs
new file mode 100644 (file)
index 0000000..719bbb2
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// ServiceAuthorizationBehaviorTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if USE_DEPRECATED
+// This class is not deprecated, but most of members and depending classes
+// have changed, so most of the code is not reusable.
+
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       [TestFixture]
+       public class ServiceAuthorizationBehaviorTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       ServiceAuthorizationBehavior b =
+                               new ServiceAuthorizationBehavior ();
+                       Assert.IsNull (b.AuthorizationDomain, "#1");
+                       Assert.IsFalse (b.ImpersonateCallerForAllServiceOperations,
+                               "#2");
+                       Assert.IsNull (b.OperationRequirement, "#3");
+                       Assert.AreEqual (PrincipalPermissionMode.UseWindowsGroups,
+                               b.PrincipalPermissionMode, "#4");
+               }
+
+               [Test]
+               public void ApplyBehavior ()
+               {
+                       ServiceHost host = new ServiceHost (typeof (object));
+                       EndpointDispatcher d = new EndpointDispatcher (host, "a", "");
+                       DispatchRuntime db = d.Behavior;
+                       EndpointDispatcher d2 = new EndpointDispatcher (host, "a", "");
+                       DispatchRuntime db2 = d2.Behavior;
+
+                       ServiceAuthorizationBehavior b =
+                               new ServiceAuthorizationBehavior ();
+                       b.ImpersonateCallerForAllServiceOperations = true;
+                       b.OperationRequirement = new MyRequirement ();
+                       b.PrincipalPermissionMode = PrincipalPermissionMode.None;
+
+                       Collection<DispatchRuntime> c =
+                               new Collection<DispatchRuntime> (
+                                       new DispatchRuntime [] {db, db2});
+                       Collection<BindingParameterCollection> pc =
+                               new Collection<BindingParameterCollection> (
+                                       new BindingParameterCollection [] {
+                                               new BindingParameterCollection ()});
+                       ((IServiceBehavior) b).ApplyBehavior (null, host, c, pc);
+
+                       Assert.IsNull (db.AuthorizationDomain, "#1-1");
+                       Assert.IsTrue (db.ImpersonateCallerForAllServiceOperations, "#1-2");
+                       Assert.AreEqual (typeof (MyRequirement),
+                               db.OperationRequirement.GetType (), "#1-3");
+                       Assert.AreEqual (PrincipalPermissionMode.None,
+                               db.PrincipalPermissionMode, "#1-4");
+                       Assert.IsNull (db2.AuthorizationDomain, "#2-1");
+                       Assert.IsTrue (db2.ImpersonateCallerForAllServiceOperations, "#2-2");
+                       /*
+                       Assert.AreEqual (typeof (MyRequirement),
+                               db2.OperationRequirement.GetType (), "#2-3");
+                       Assert.AreEqual (PrincipalPermissionMode.None,
+                               db2.PrincipalPermissionMode, "#2-4");
+                       */
+               }
+
+               /*
+               class MyRequirement : OperationRequirement
+               {
+                       public override bool AccessCheck (OperationContext ctx)
+                       {
+                               return true;
+                       }
+               }
+               */
+       }
+}
+#endif
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceCredentialsTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceCredentialsTest.cs
new file mode 100644 (file)
index 0000000..f971a35
--- /dev/null
@@ -0,0 +1,136 @@
+//
+// ServiceCredentialsTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       [TestFixture]
+       public class ServiceCredentialsTest
+       {
+               [Test]
+               public void ClientCertificate ()
+               {
+                       X509CertificateInitiatorServiceCredential cc =
+                               new ServiceCredentials ().ClientCertificate;
+                       Assert.IsNull (cc.Certificate, "#1");
+                       Assert.AreEqual (X509CertificateValidationMode.ChainTrust, cc.Authentication.CertificateValidationMode, "#2-1");
+                       Assert.IsNull (cc.Authentication.CustomCertificateValidator, "#2-2");
+                       Assert.IsTrue (cc.Authentication.IncludeWindowsGroups, "#2-3");
+                       Assert.IsFalse (cc.Authentication.MapClientCertificateToWindowsAccount, "#2-4");
+                       Assert.AreEqual (X509RevocationMode.Online, cc.Authentication.RevocationMode, "#2-5");
+                       Assert.AreEqual (StoreLocation.LocalMachine, cc.Authentication.TrustedStoreLocation, "#2-6");
+               }
+
+               [Test]
+               public void IssuedTokenAuthentication ()
+               {
+                       IssuedTokenServiceCredential ic =
+                               new ServiceCredentials ().IssuedTokenAuthentication;
+                       Assert.IsFalse (ic.AllowUntrustedRsaIssuers, "#1");
+                       Assert.AreEqual (X509CertificateValidationMode.ChainTrust, ic.CertificateValidationMode, "#2");
+                       Assert.IsNull (ic.CustomCertificateValidator, "#3");
+                       Assert.AreEqual (0, ic.KnownCertificates.Count, "#4");
+                       Assert.AreEqual (X509RevocationMode.Online, ic.RevocationMode, "#5");
+                       Assert.IsNull (ic.SamlSerializer, "#6");
+                       Assert.AreEqual (StoreLocation.LocalMachine, ic.TrustedStoreLocation, "#7");
+               }
+
+               [Test]
+               public void Peer ()
+               {
+                       PeerCredential p = new ServiceCredentials ().Peer;
+                       Assert.IsNull (p.Certificate, "#1");
+                       Assert.IsNull (p.MeshPassword, "#2");
+                       X509PeerCertificateAuthentication pa = p.MessageSenderAuthentication;
+                       Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, pa.CertificateValidationMode, "#3-1");
+                       Assert.IsNull (pa.CustomCertificateValidator, "#3-2");
+                       Assert.AreEqual (X509RevocationMode.Online, pa.RevocationMode, "#3-3");
+                       Assert.AreEqual (StoreLocation.CurrentUser, pa.TrustedStoreLocation, "#3-4");
+                       pa = p.PeerAuthentication;
+                       Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, pa.CertificateValidationMode, "#4-1");
+                       Assert.IsNull (pa.CustomCertificateValidator, "#4-2");
+                       Assert.AreEqual (X509RevocationMode.Online, pa.RevocationMode, "#4-3");
+                       Assert.AreEqual (StoreLocation.CurrentUser, pa.TrustedStoreLocation, "#4-4");
+               }
+
+               [Test]
+               public void SecureConversationAuthentication ()
+               {
+                       SecureConversationServiceCredential sc =
+                               new ServiceCredentials ().SecureConversationAuthentication;
+                       Assert.AreEqual (5, sc.SecurityContextClaimTypes.Count, "#1");
+                       Collection<Type> types = new Collection<Type> (new Type [] {
+                               typeof (SamlAuthorizationDecisionClaimResource),
+                               typeof (SamlAuthenticationClaimResource),
+                               typeof (SamlAccessDecision),
+                               typeof (SamlAuthorityBinding),
+                               typeof (SamlNameIdentifierClaimResource)});
+                       foreach (Type type in sc.SecurityContextClaimTypes)
+                               if (!types.Contains (type))
+                                       Assert.Fail (type.ToString ());
+                       DataProtectionSecurityStateEncoder sse = sc.SecurityStateEncoder
+                               as DataProtectionSecurityStateEncoder;
+                       Assert.IsNotNull (sse, "#2-1");
+                       Assert.IsTrue (sse.UseCurrentUserProtectionScope, "#2-2");
+               }
+
+               [Test]
+               public void ServiceCertificate ()
+               {
+                       Assert.IsNull (new ServiceCredentials ().ServiceCertificate.Certificate, "#1");
+               }
+
+               [Test]
+               public void UserNameAuthentication ()
+               {
+                       UserNamePasswordServiceCredential un =
+                               new ServiceCredentials ().UserNameAuthentication;
+                       Assert.AreEqual (TimeSpan.FromMinutes (15), un.CachedLogonTokenLifetime, "#1");
+                       Assert.IsFalse (un.CacheLogonTokens, "#2");
+                       Assert.IsNull (un.CustomUserNamePasswordValidator, "#3");
+                       Assert.IsTrue (un.IncludeWindowsGroups, "#4");
+                       Assert.AreEqual (0x80, un.MaxCachedLogonTokens, "#5");
+                       Assert.IsNull (un.MembershipProvider, "#6");
+                       Assert.AreEqual (UserNamePasswordValidationMode.Windows, un.UserNamePasswordValidationMode, "#7");
+
+                       // TODO: WindowsAuthentication if we have infinite amount of free time.
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceDebugBehaviorTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceDebugBehaviorTest.cs
new file mode 100644 (file)
index 0000000..3517ad6
--- /dev/null
@@ -0,0 +1,213 @@
+//\r
+// ServiceDebugBehaviorTest.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using NUnit.Framework;\r
+using System.ServiceModel;\r
+using System.ServiceModel.Description;\r
+using System.ServiceModel.Dispatcher;\r
+using System.ServiceModel.Channels;\r
+\r
+namespace MonoTests.System.ServiceModel.Description\r
+{\r
+       [TestFixture]\r
+       public class ServiceDebugBehaviorTest\r
+       {\r
+               [ServiceContract]\r
+               interface IMyContract\r
+               {\r
+                       [OperationContract]\r
+                       string GetData ();\r
+               }\r
+\r
+               class MyService : IMyContract\r
+               {\r
+                       public string GetData () {\r
+                               return "Hello World";\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void InitializeRuntime1 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "e1");\r
+\r
+                               Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.AreEqual (2, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");\r
+\r
+                               ChannelDispatcher cd = (ChannelDispatcher) host.ChannelDispatchers [1];\r
+                               Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");\r
+                               Assert.AreEqual ("ServiceMetadataBehaviorHttpGetBinding", cd.BindingName, "BindingName");\r
+                               Assert.AreEqual (host, cd.Host, "Host");\r
+                               //Assert.AreEqual (false, cd.IsTransactedAccept, "IsTransactedAccept");\r
+                               //Assert.AreEqual (false, cd.IsTransactedReceive, "IsTransactedReceive");\r
+\r
+                               EndpointDispatcher ed = cd.Endpoints [0];\r
+                               Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter");\r
+                               Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher");\r
+                               Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter");\r
+                               Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName");\r
+                               Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace");\r
+                               Assert.AreEqual (0, ed.FilterPriority, "FilterPriority");\r
+\r
+                               EndpointAddress ea = ed.EndpointAddress;\r
+                               // TODO\r
+\r
+                               DispatchRuntime dr = ed.DispatchRuntime;\r
+                               // TODO\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void InitializeRuntime2 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");\r
+                               host.Description.Behaviors.Remove<ServiceDebugBehavior> ();\r
+\r
+                               Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.AreEqual (1, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void InitializeRuntime3 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");\r
+                               host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageEnabled = false;\r
+\r
+                               Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.AreEqual (1, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void InitializeRuntime4 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");\r
+                               host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:8080/help");\r
+\r
+                               Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.AreEqual (2, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");\r
+\r
+                               ChannelDispatcher cd = (ChannelDispatcher) host.ChannelDispatchers [1];\r
+                               Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");\r
+                               Assert.AreEqual ("ServiceMetadataBehaviorHttpGetBinding", cd.BindingName, "BindingName");\r
+                               Assert.AreEqual (host, cd.Host, "Host");\r
+                               //Assert.AreEqual (false, cd.IsTransactedAccept, "IsTransactedAccept");\r
+                               //Assert.AreEqual (false, cd.IsTransactedReceive, "IsTransactedReceive");\r
+                               Assert.AreEqual (MessageVersion.None, cd.MessageVersion, "MessageVersion");\r
+\r
+                               EndpointDispatcher ed = cd.Endpoints [0];\r
+                               Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter");\r
+                               Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher");\r
+                               Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter");\r
+                               Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName");\r
+                               Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace");\r
+                               Assert.AreEqual (0, ed.FilterPriority, "FilterPriority");\r
+\r
+                               EndpointAddress ea = ed.EndpointAddress;\r
+                               Assert.AreEqual (new Uri ("http://localhost:8080/help"), ea.Uri, "Uri");\r
+\r
+                               DispatchRuntime dr = ed.DispatchRuntime;\r
+                               Assert.AreEqual (1, dr.Operations.Count, "Operations.Count");\r
+\r
+                               DispatchOperation dispOp = dr.Operations [0];\r
+                               Assert.AreEqual ("*", dispOp.Action, "Operation.Action");\r
+                               Assert.AreEqual ("*", dispOp.ReplyAction, "Operation.ReplyAction");\r
+                               Assert.AreEqual ("Get", dispOp.Name, "Operation.Name");\r
+                               //Assert.IsNotNull (dispOp.Invoker, "Operation.Invoker");\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void ServiceMetadataExtension1 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");\r
+                               host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:8080/help");\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.IsNotNull (host.Extensions.Find<ServiceMetadataExtension> (), "ServiceMetadataExtension #1");\r
+                               Assert.AreEqual (1, host.Extensions.FindAll<ServiceMetadataExtension> ().Count, "ServiceMetadataExtension #2");\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void ServiceMetadataExtension2 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");\r
+                               host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:8080/help");\r
+\r
+                               ServiceMetadataExtension extension = new ServiceMetadataExtension ();\r
+                               host.Extensions.Add (extension);\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.IsNotNull (host.Extensions.Find<ServiceMetadataExtension> (), "ServiceMetadataExtension #1");\r
+                               Assert.AreEqual (1, host.Extensions.FindAll<ServiceMetadataExtension> ().Count, "ServiceMetadataExtension #2");\r
+                               Assert.AreEqual (extension, host.Extensions.Find<ServiceMetadataExtension> (), "ServiceMetadataExtension #3");\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void Defaults () {\r
+                       ServiceDebugBehavior behavior = new ServiceDebugBehavior ();\r
+                       Assert.AreEqual (true, behavior.HttpHelpPageEnabled, "HttpHelpPageEnabled");\r
+                       Assert.IsNull (behavior.HttpHelpPageUrl, "HttpHelpPageUrl");\r
+                       Assert.AreEqual (true, behavior.HttpsHelpPageEnabled, "HttpsHelpPageEnabled");\r
+                       Assert.IsNull (behavior.HttpsHelpPageUrl, "HttpsHelpPageUrl");\r
+                       Assert.AreEqual (false, behavior.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceMetadataBehaviorTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ServiceMetadataBehaviorTest.cs
new file mode 100644 (file)
index 0000000..a33f7c3
--- /dev/null
@@ -0,0 +1,270 @@
+//\r
+// ServiceMetadataBehaviorTest.cs\r
+//\r
+// Author:\r
+//     Igor Zelmanovich <igorz@mainsoft.com>\r
+//\r
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using NUnit.Framework;\r
+using System.ServiceModel;\r
+using System.ServiceModel.Description;\r
+using System.ServiceModel.Dispatcher;\r
+using System.ServiceModel.Channels;\r
+\r
+namespace MonoTests.System.ServiceModel.Description\r
+{\r
+       [TestFixture]\r
+       public class ServiceMetadataBehaviorTest\r
+       {\r
+               [ServiceContract]\r
+               interface IMyContract\r
+               {\r
+                       [OperationContract]\r
+                       string GetData ();\r
+               }\r
+\r
+               class MyService : IMyContract\r
+               {\r
+                       public string GetData () {\r
+                               return "Hello World";\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void InitializeRuntime1 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "e1");\r
+                               host.Description.Behaviors.Add (new ServiceMetadataBehavior () { HttpGetEnabled = true });\r
+\r
+                               Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.AreEqual (2, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");\r
+\r
+                               ChannelDispatcher cd = (ChannelDispatcher) host.ChannelDispatchers [1];\r
+                               Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");\r
+                               Assert.AreEqual ("ServiceMetadataBehaviorHttpGetBinding", cd.BindingName, "BindingName");\r
+                               Assert.AreEqual (host, cd.Host, "Host");\r
+                               //Assert.AreEqual (false, cd.IsTransactedAccept, "IsTransactedAccept");\r
+                               //Assert.AreEqual (false, cd.IsTransactedReceive, "IsTransactedReceive");\r
+\r
+                               EndpointDispatcher ed = cd.Endpoints [0];\r
+                               Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter");\r
+                               Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher");\r
+                               Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter");\r
+                               Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName");\r
+                               Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace");\r
+                               Assert.AreEqual (0, ed.FilterPriority, "FilterPriority");\r
+\r
+                               EndpointAddress ea = ed.EndpointAddress;\r
+                               // TODO\r
+\r
+                               DispatchRuntime dr = ed.DispatchRuntime;\r
+                               // TODO\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void InitializeRuntime2 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");\r
+                               host.Description.Behaviors.Add (new ServiceMetadataBehavior () { HttpGetEnabled = true, HttpGetUrl = new Uri ("http://localhost:8080/mex_and_help") });\r
+                               host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:8080/mex_and_help");\r
+\r
+                               Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.AreEqual (2, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");\r
+\r
+                               ChannelDispatcher cd = (ChannelDispatcher) host.ChannelDispatchers [1];\r
+                               Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");\r
+                               Assert.AreEqual ("ServiceMetadataBehaviorHttpGetBinding", cd.BindingName, "BindingName");\r
+                               Assert.AreEqual (host, cd.Host, "Host");\r
+                               //Assert.AreEqual (false, cd.IsTransactedAccept, "IsTransactedAccept");\r
+                               //Assert.AreEqual (false, cd.IsTransactedReceive, "IsTransactedReceive");\r
+\r
+                               EndpointDispatcher ed = cd.Endpoints [0];\r
+                               Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter");\r
+                               Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher");\r
+                               Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter");\r
+                               Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName");\r
+                               Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace");\r
+                               Assert.AreEqual (0, ed.FilterPriority, "FilterPriority");\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void InitializeRuntime3 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");\r
+                               host.Description.Behaviors.Add (new ServiceMetadataBehavior () { HttpGetEnabled = true, HttpGetUrl = new Uri ("http://localhost:8080/mex") });\r
+                               host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:8080/help");\r
+\r
+                               Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.AreEqual (3, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");\r
+\r
+                               ChannelDispatcher cd = (ChannelDispatcher) host.ChannelDispatchers [1];\r
+                               Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");\r
+\r
+                               EndpointDispatcher ed = cd.Endpoints [0];\r
+                               Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter #1");\r
+                               Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher #1");\r
+                               Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter #1");\r
+                               Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName #1");\r
+                               Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace #1");\r
+                               Assert.AreEqual (0, ed.FilterPriority, "FilterPriority #1");\r
+\r
+                               EndpointAddress ea = ed.EndpointAddress;\r
+                               // TODO\r
+\r
+                               DispatchRuntime dr = ed.DispatchRuntime;\r
+                               // TODO\r
+\r
+                               cd = (ChannelDispatcher) host.ChannelDispatchers [2];\r
+                               Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");\r
+\r
+                               ed = cd.Endpoints [0];\r
+                               Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter #2");\r
+                               Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher #2");\r
+                               Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter #2");\r
+                               Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName #2");\r
+                               Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace #2");\r
+                               Assert.AreEqual (0, ed.FilterPriority, "FilterPriority #2");\r
+\r
+                               ea = ed.EndpointAddress;\r
+                               // TODO\r
+\r
+                               dr = ed.DispatchRuntime;\r
+                               // TODO\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void InitializeRuntime4 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");\r
+                               host.Description.Behaviors.Add (new ServiceMetadataBehavior () { HttpGetEnabled = true, HttpGetUrl = new Uri ("http://localhost:8080/mex") });\r
+                               host.Description.Behaviors.Remove<ServiceDebugBehavior> ();\r
+\r
+                               Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.AreEqual (2, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");\r
+\r
+                               ChannelDispatcher cd = (ChannelDispatcher) host.ChannelDispatchers [1];\r
+                               Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");\r
+                               Assert.AreEqual ("ServiceMetadataBehaviorHttpGetBinding", cd.BindingName, "BindingName");\r
+                               Assert.AreEqual (host, cd.Host, "Host");\r
+                               //Assert.AreEqual (false, cd.IsTransactedAccept, "IsTransactedAccept");\r
+                               //Assert.AreEqual (false, cd.IsTransactedReceive, "IsTransactedReceive");\r
+                               Assert.AreEqual (MessageVersion.None, cd.MessageVersion, "MessageVersion");\r
+\r
+                               EndpointDispatcher ed = cd.Endpoints [0];\r
+                               Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter");\r
+                               Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher");\r
+                               Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter");\r
+                               Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName");\r
+                               Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace");\r
+                               Assert.AreEqual (0, ed.FilterPriority, "FilterPriority");\r
+\r
+                               EndpointAddress ea = ed.EndpointAddress;\r
+                               Assert.AreEqual (new Uri ("http://localhost:8080/mex"), ea.Uri, "Uri");\r
+\r
+                               DispatchRuntime dr = ed.DispatchRuntime;\r
+                               Assert.AreEqual (1, dr.Operations.Count, "Operations.Count");\r
+\r
+                               DispatchOperation dispOp = dr.Operations [0];\r
+                               Assert.AreEqual ("*", dispOp.Action, "Operation.Action");\r
+                               Assert.AreEqual ("*", dispOp.ReplyAction, "Operation.ReplyAction");\r
+                               Assert.AreEqual ("Get", dispOp.Name, "Operation.Name");\r
+                               //Assert.IsNotNull (dispOp.Invoker, "Operation.Invoker");\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void ServiceMetadataExtension1 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");\r
+                               host.Description.Behaviors.Add (new ServiceMetadataBehavior () { HttpGetEnabled = true, HttpGetUrl = new Uri ("http://localhost:8080/mex") });\r
+                               host.Description.Behaviors.Remove<ServiceDebugBehavior> ();\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.IsNotNull (host.Extensions.Find<ServiceMetadataExtension> (), "ServiceMetadataExtension #1");\r
+                               Assert.AreEqual (1, host.Extensions.FindAll<ServiceMetadataExtension> ().Count, "ServiceMetadataExtension #2");\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void ServiceMetadataExtension2 () {\r
+                       using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {\r
+                               host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");\r
+                               host.Description.Behaviors.Add (new ServiceMetadataBehavior () { HttpGetEnabled = true, HttpGetUrl = new Uri ("http://localhost:8080/mex") });\r
+                               host.Description.Behaviors.Remove<ServiceDebugBehavior> ();\r
+\r
+                               ServiceMetadataExtension extension = new ServiceMetadataExtension ();\r
+                               host.Extensions.Add (extension);\r
+\r
+                               host.Open ();\r
+\r
+                               Assert.IsNotNull (host.Extensions.Find<ServiceMetadataExtension> (), "ServiceMetadataExtension #1");\r
+                               Assert.AreEqual (1, host.Extensions.FindAll<ServiceMetadataExtension> ().Count, "ServiceMetadataExtension #2");\r
+                               Assert.AreEqual (extension, host.Extensions.Find<ServiceMetadataExtension> (), "ServiceMetadataExtension #3");\r
+\r
+                               host.Close ();\r
+                       }\r
+               }\r
+\r
+               [Test]\r
+               public void Defaults () {\r
+                       ServiceMetadataBehavior behavior = new ServiceMetadataBehavior ();\r
+                       Assert.IsNull (behavior.ExternalMetadataLocation, "ExternalMetadataLocation");\r
+                       Assert.AreEqual (false, behavior.HttpGetEnabled, "HttpGetEnabled");\r
+                       Assert.IsNull (behavior.HttpGetUrl, "HttpGetUrl");\r
+                       Assert.AreEqual (false, behavior.HttpsGetEnabled, "HttpsGetEnabled");\r
+                       Assert.IsNull (behavior.HttpsGetUrl, "HttpsGetUrl");\r
+                       Assert.IsNotNull (behavior.MetadataExporter, "MetadataExporter #1");\r
+                       Assert.AreEqual (typeof (WsdlExporter), behavior.MetadataExporter.GetType (), "MetadataExporter #2");\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/TypedMessageConverterTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/TypedMessageConverterTest.cs
new file mode 100644 (file)
index 0000000..230d1f1
--- /dev/null
@@ -0,0 +1,125 @@
+//
+// TypedMessageConverterTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       [TestFixture]
+       public class TypedMessageConverterTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void InvalidArgumentType ()
+               {
+                       TypedMessageConverter.Create (
+                               typeof (int), "http://tempuri.org/MyTest");
+               }
+
+               [Test]
+               // It is imported from samples/typed-message-converter.
+               public void StandardToMessage ()
+               {
+                       TypedMessageConverter c = TypedMessageConverter.Create (
+                               typeof (Test1), "http://tempuri.org/MyTest");
+                       Message msg = c.ToMessage (new Test1 ());
+
+                       XmlDocument doc = new XmlDocument ();
+                       doc.LoadXml (msg.ToString ());
+
+                       XmlNamespaceManager nss = new XmlNamespaceManager (doc.NameTable);
+                       nss.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
+                       nss.AddNamespace ("t", "http://tempuri.org/");
+                       nss.AddNamespace ("v", "space");
+                       nss.AddNamespace ("w", "yy1");
+                       XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/v:MyName", nss) as XmlElement;
+                       Assert.IsNotNull (el, "#1");
+                       XmlNode part = el.SelectSingleNode ("t:body2", nss);
+                       Assert.IsNotNull (part, "#2");
+                       Assert.AreEqual ("TEST body", part.InnerText, "#3");
+                       Assert.IsNotNull (el.SelectSingleNode ("w:xx1", nss), "#4");
+                       part = el.SelectSingleNode ("w:xx1/v:msg", nss);
+                       Assert.IsNotNull (part, "#5");
+                       Assert.AreEqual ("default", part.InnerText, "#6");
+               }
+
+               [Test]
+               public void StandardRoundtrip ()
+               {
+                       TypedMessageConverter c = TypedMessageConverter.Create (
+                               typeof (Test1), "http://tempuri.org/MyTest");
+                       Test1 t1 = new Test1 ();
+                       t1.echo.msg = "test";
+                       t1.body2 = "testtest";
+                       Message msg = c.ToMessage (t1);
+                       Test1 t2 = (Test1) c.FromMessage (msg);
+                       Assert.AreEqual ("test", t2.echo.msg, "#01");
+                       Assert.AreEqual ("testtest", t2.body2, "#01");
+               }
+
+               [Test]
+               public void XmlSerializerdRoundtrip ()
+               {
+                       TypedMessageConverter c = TypedMessageConverter.Create (
+                               typeof (Test1), "http://tempuri.org/MyTest", new XmlSerializerFormatAttribute ());
+                       Test1 t1 = new Test1 ();
+                       t1.echo.msg = "test";
+                       t1.body2 = "testtest";
+                       Message msg = c.ToMessage (t1);
+                       Test1 t2 = (Test1) c.FromMessage (msg);
+                       Assert.AreEqual ("test", t2.echo.msg, "#01");
+                       Assert.AreEqual ("testtest", t2.body2, "#01");
+               }
+       }
+
+       [MessageContract (WrapperNamespace = "space", WrapperName = "MyName")]
+       public class Test1
+       {
+               [MessageBodyMember (Name = "xx1", Namespace = "yy1")]
+               public Echo echo = new Echo ();
+
+               [MessageBodyMember]
+               public string body2 = "TEST body";
+       }
+
+       [DataContract (Namespace = "space")]
+       public class Echo
+       {
+               [DataMember]
+               public string msg = "default";
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/WsdlExporterTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/WsdlExporterTest.cs
new file mode 100644 (file)
index 0000000..67af057
--- /dev/null
@@ -0,0 +1,772 @@
+//
+// WsdlExporterTest.cs
+//
+// Author:
+//     Ankit Jain <JAnkit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.Web.Services;
+
+using WSServiceDescription = System.Web.Services.Description.ServiceDescription;
+using WSMessage = System.Web.Services.Description.Message;
+using WSBinding = System.Web.Services.Description.Binding;
+using QName = System.Xml.XmlQualifiedName;
+
+using SMMessage = System.ServiceModel.Channels.Message;
+
+using System.Xml;
+using System.Web.Services.Description;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+using System.Reflection;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       [TestFixture]
+       public class WsdlExporterTest
+       {
+               [Test]
+               [Category ("NotWorking")]
+               public void Ctor1 ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+
+                       Assert.IsNotNull (we.GetGeneratedMetadata ());
+                       Assert.IsNotNull (we.GeneratedWsdlDocuments, "#c1");
+                       Assert.AreEqual (0, we.GeneratedWsdlDocuments.Count, "#c2");
+
+                       Assert.IsNotNull (we.GeneratedXmlSchemas, "#c3");
+                       Assert.AreEqual (0, we.GeneratedXmlSchemas.Count, "#c4");
+               }
+
+               [Test]
+               public void ExportEndpointTest ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+
+                       ServiceEndpoint se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService)));
+                       se.Binding = new BasicHttpBinding ();
+                       se.Address = new EndpointAddress ("http://localhost:8080");
+                       //TEST Invalid name: 5se.Name = "Service#1";
+                       //se.Name = "Service0";
+                       //se.ListenUri = new Uri ("http://localhost:8080/svc");
+
+                       we.ExportEndpoint (se);
+
+                       MetadataSet ms = we.GetGeneratedMetadata ();
+                       Assert.AreEqual (6, ms.MetadataSections.Count);
+                       CheckContract_IEchoService (ms, "#eet01");
+
+                       WSServiceDescription sd = GetServiceDescription (ms, "http://tempuri.org/", "ExportEndpointTest");
+                       CheckServicePort (GetService (sd, "service", "ExportEndpointTest"),
+                               "BasicHttpBinding_IEchoService", new XmlQualifiedName ("BasicHttpBinding_IEchoService", "http://tempuri.org/"),
+                               "http://localhost:8080/", "#eet02");
+
+                       CheckBasicHttpBinding (sd, "BasicHttpBinding_IEchoService", new XmlQualifiedName ("IEchoService", "http://myns/echo"),
+                               "Echo", "http://myns/echo/IEchoService/Echo", true, true, "#eet03");
+               }
+
+               [Test]
+               public void ExportEndpointTest2 ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+
+                       ServiceEndpoint se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService2)));
+                       se.Binding = new BasicHttpBinding ();
+                       se.Address = new EndpointAddress ("http://localhost:8080");
+                       we.ExportEndpoint (se);
+
+                       MetadataSet ms = we.GetGeneratedMetadata ();
+                       Assert.AreEqual (5, ms.MetadataSections.Count);
+
+                       WSServiceDescription sd = ms.MetadataSections [0].Metadata as WSServiceDescription;
+                       CheckContract_IEchoService2 (ms, "#eet20");
+                       CheckServicePort (GetService (GetServiceDescription (ms, "http://tempuri.org/", "#eet21"), "service", "ExportEndpointTest"),
+                               "BasicHttpBinding_ThisIsEchoService", new XmlQualifiedName ("BasicHttpBinding_ThisIsEchoService", "http://tempuri.org/"),
+                               "http://localhost:8080/", "#eet22");
+
+                       CheckBasicHttpBinding (sd, "BasicHttpBinding_ThisIsEchoService",
+                               new XmlQualifiedName ("ThisIsEchoService", "http://tempuri.org/"),
+                               "Echo", "http://tempuri.org/ThisIsEchoService/Echo", true, true, "#eet03");
+
+                       //FIXME: CheckXmlSchema
+               }
+
+               [Test]
+               public void ExportEndpointTest3 ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+                       /*ContractDescription contract =*/ ContractDescription.GetContract (typeof (IEchoService2));
+
+                       ServiceEndpoint se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService2)));
+                       se.Binding = new BasicHttpBinding ();
+                       se.Address = new EndpointAddress ("http://localhost:8080");
+                       we.ExportEndpoint (se);
+
+                       se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService)));
+                       se.Binding = new BasicHttpBinding ();
+                       se.Address = new EndpointAddress ("http://somehost");
+                       we.ExportEndpoint (se);
+
+                       MetadataSet ms = we.GetGeneratedMetadata ();
+                       Assert.AreEqual (7, ms.MetadataSections.Count);
+
+                       Service svc = GetService (
+                                       GetServiceDescription (ms, "http://tempuri.org/", "ExportEndpointTest"),
+                                       "service", "ExportEndpointTest");
+
+                       CheckContract_IEchoService (ms, "#eet31");
+                       CheckServicePort (svc, "BasicHttpBinding_IEchoService",
+                               new XmlQualifiedName ("BasicHttpBinding_IEchoService", "http://tempuri.org/"),
+                               "http://somehost/", "#eet32");
+
+                       CheckContract_IEchoService2 (ms, "#eet33");
+                       CheckServicePort (svc, "BasicHttpBinding_ThisIsEchoService",
+                               new XmlQualifiedName ("BasicHttpBinding_ThisIsEchoService", "http://tempuri.org/"),
+                               "http://localhost:8080/", "#eet34");
+
+
+                       WSServiceDescription sd = ms.MetadataSections [0].Metadata as WSServiceDescription;
+                       CheckBasicHttpBinding (sd, "BasicHttpBinding_IEchoService", new XmlQualifiedName ("IEchoService", "http://myns/echo"),
+                               "Echo", "http://myns/echo/IEchoService/Echo", true, true, "#eet35");
+
+                       CheckBasicHttpBinding (sd, "BasicHttpBinding_ThisIsEchoService", new XmlQualifiedName ("ThisIsEchoService", "http://tempuri.org/"),
+                               "Echo", "http://tempuri.org/ThisIsEchoService/Echo", true, true, "#eet36");
+
+
+                       //FIXME: CheckXmlSchema
+               }
+
+               [Test]
+               public void ExportContractInvalid1 ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+
+                       we.ExportContract (ContractDescription.GetContract (typeof (IEchoService2)));
+                       //Duplicate contract QNames not allowed
+                       ExportContractExpectException (we, ContractDescription.GetContract (typeof (IEchoService2)),
+                               typeof (ArgumentException), "ExportContractInvalid1");
+               }
+
+               [Test]
+               public void ExportContractInvalid2 ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+
+                       we.ExportContract (ContractDescription.GetContract (typeof (IEchoService2)));
+                       //Invalid as IEchoService3.Echo is http://tempuri.org/Echo message which has already been exported
+                       //Even though, the service name is different
+                       ExportContractExpectException (we, ContractDescription.GetContract (typeof (IEchoService3)),
+                               typeof (InvalidOperationException), "ExportContractInvalid2");
+               }
+
+               [Test]
+               public void ExportContract1 ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+                       we.ExportContract (ContractDescription.GetContract (typeof (IEchoService)));
+
+                       MetadataSet ms = we.GetGeneratedMetadata ();
+                       Assert.AreEqual (5, ms.MetadataSections.Count);
+
+                       CheckContract_IEchoService (ms, "ExportContract1");
+               }
+
+               [Test]
+               public void ExportContract2 ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+                       we.ExportContract (ContractDescription.GetContract (typeof (IFoo1)));
+
+                       MetadataSet ms = we.GetGeneratedMetadata ();
+                       Assert.AreEqual (5, ms.MetadataSections.Count);
+               }
+
+               [Test]
+               public void ExportContract2a ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+                       we.ExportContract (ContractDescription.GetContract (typeof (IFoo1)));
+                       //IFoo1a.Op1 is the same operations as IFoo1.Op1, so cant be exported
+                       //the message element for both is the same
+                       //(Compared by names not signature)
+                       ExportContractExpectException (we, ContractDescription.GetContract (typeof (IFoo1a)),
+                               typeof (InvalidOperationException), "ExportContract2a");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ExportMessageContract ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+                       ContractDescription cd = ContractDescription.GetContract (typeof (IFoo2));
+                       we.ExportContract (cd);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               //FIXME: One check not working, BeginGetResult
+               public void ExportMexContract ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+                       ContractDescription cd = ContractDescription.GetContract (typeof (IMetadataExchange));
+                       we.ExportContract (cd);
+
+                       MetadataSet ms = we.GetGeneratedMetadata ();
+
+                       WSServiceDescription sd = GetServiceDescription (ms, "http://schemas.microsoft.com/2006/04/mex", "ExportMexContract");
+
+                       CheckMessage (sd, "IMetadataExchange_Get_InputMessage", "request", "http://schemas.microsoft.com/Message:MessageBody", true, "#exc0");
+                       CheckMessage (sd, "IMetadataExchange_Get_OutputMessage", "GetResult", "http://schemas.microsoft.com/Message:MessageBody", true, "#exc1");
+
+                       //PortType
+                       PortType port_type = sd.PortTypes ["IMetadataExchange"];
+                       Assert.IsNotNull (port_type, "#exc2, PortType named IMetadataExchange not found.");
+
+                       Assert.AreEqual (1, port_type.Operations.Count, "#exc3");
+                       Operation op = port_type.Operations [0];
+                       Assert.AreEqual ("Get", op.Name, "#exc4");
+
+                       Assert.AreEqual (2, op.Messages.Count, "#exc5");
+                       CheckOperationMessage (op.Messages [0], "http://schemas.microsoft.com/2006/04/mex:IMetadataExchange_Get_InputMessage", 
+                               typeof (OperationInput), "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get");
+                       
+                       CheckOperationMessage (op.Messages [1], "http://schemas.microsoft.com/2006/04/mex:IMetadataExchange_Get_OutputMessage", 
+                               typeof (OperationOutput), "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse");
+
+                       CheckSpecialMessage (ms, "#exc6");
+
+                       Assert.AreEqual (1, we.GeneratedWsdlDocuments.Count, "GeneratedWsdlDocuments.Count");
+                       Assert.AreEqual (1, we.GeneratedXmlSchemas.Count, "GeneratedXmlSchemas.Count");
+               }
+
+               [Test]
+               //Currently throws InvalidDataContractException on mono, but once the code is
+               //moved to a IWsdlExportExtension, InvalidOperationException will get throw
+               [Category ("NotWorking")]
+               public void ExportBar1Contract ()
+               {
+                       WsdlExporter we = new WsdlExporter ();
+                       ContractDescription cd = ContractDescription.GetContract (typeof (Bar1));
+
+                       //Cannot export as operation Foo has >1 param so Message param gets treated
+                       //as any other param, but it is not serializable!
+                       ExportContractExpectException (we, cd, typeof (InvalidOperationException), "ExportBar1Contract");
+               }
+
+               //Helper methods
+
+               //Checks the ComplexType emitted for CLR type Message
+               void CheckSpecialMessage (MetadataSet ms, string label)
+               {
+                       //Check ComplexType MessageBody
+                       XmlSchema xs = GetXmlSchema (ms, "http://schemas.microsoft.com/Message", label + " #csm0");
+                       foreach (XmlSchemaObject o in xs.SchemaTypes.Values) {
+                               XmlSchemaComplexType complex_type = o as XmlSchemaComplexType;
+                               if (complex_type == null)
+                                       continue;
+                               if (complex_type.Name != "MessageBody")
+                                       continue;
+
+                               //MessageBody
+                               Assert.IsNotNull (complex_type.Particle, label + " #cms1");
+                               Assert.AreEqual (typeof (XmlSchemaSequence), complex_type.Particle.GetType (), label + " #cms2");
+                               XmlSchemaSequence seq = (XmlSchemaSequence) complex_type.Particle;
+                       
+                               Assert.AreEqual (1, seq.Items.Count, label + " #cms3");
+                               Assert.AreEqual (typeof (XmlSchemaAny), seq.Items [0].GetType (), label + " #cms4");
+                               XmlSchemaAny any = (XmlSchemaAny) seq.Items [0];
+
+                               Assert.AreEqual ("##any", any.Namespace, label + " #cms5");
+                               Assert.AreEqual (0, any.MinOccurs, label + " #cms6");
+                               Assert.AreEqual ("unbounded", any.MaxOccursString, label + " #cms6");
+                       }
+               }
+
+               //somebody fix this name!
+               void ExportContractExpectException (WsdlExporter we, ContractDescription cd, Type exception_type, string msg)
+               {
+                       try {
+                               we.ExportContract (cd);
+                       } catch (Exception e) {
+                               if (e.GetType () == exception_type)
+                                       return;
+                               Assert.Fail (String.Format ("[{0}] Expected {1}, but got : {2}", msg, exception_type, e));
+                       }
+
+                       Assert.Fail (String.Format ("[{0}] Expected {1}", msg, exception_type));
+               }
+
+               WSServiceDescription GetServiceDescription (MetadataSet ms, string ns, string msg)
+               {
+                       foreach (MetadataSection section in ms.MetadataSections) {
+                               WSServiceDescription sd = section.Metadata as WSServiceDescription;
+                               if (sd == null)
+                                       continue;
+                               if (sd.TargetNamespace == ns) {
+                                       /*Assert.AreEqual ("http://schemas.xmlsoap.org/wsdl/", section.Dialect, msg + " Dialect");
+                                       Assert.AreEqual (id, section.Identifier, msg + "Identifier");
+                                       Assert.AreEqual (0, section.Attributes.Count, "#cw4");*/
+
+                                       return sd;
+                               }
+                       }
+
+                       Assert.Fail (String.Format ("[{0}] ServiceDescription for ns : {1} not found.", msg, ns));
+                       return null;
+               }
+
+               XmlSchema GetXmlSchema (MetadataSet ms, string ns, string msg)
+               {
+                       foreach (MetadataSection section in ms.MetadataSections) {
+                               XmlSchema xs = section.Metadata as XmlSchema;
+                               if (xs == null)
+                                       continue;
+                               if (xs.TargetNamespace == ns) {
+                                       /*Assert.AreEqual ("http://schemas.xmlsoap.org/wxsl/", section.Dialect, msg + " Dialect");
+                                       Assert.AreEqual (id, section.Identifier, msg + "Identifier");
+                                       Assert.AreEqual (0, section.Attributes.Count, "#cw4");*/
+
+                                       return xs;
+                               }
+                       }
+
+                       Assert.Fail (String.Format ("[{0}] XmlSchema for tns : {1} not found.", msg, ns));
+                       return null;
+               }
+               Service GetService (WSServiceDescription sd, string name, string label)
+               {
+                       Service ret = sd.Services [name];
+                       if (ret == null)
+                               Assert.Fail (String.Format ("[{0}] Service named '{1}' not found.", label, name));
+                       return ret;
+               }
+
+               WSBinding GetBinding (WSServiceDescription sd, string name, string label)
+               {
+                       WSBinding ret = sd.Bindings [name];
+                       if (ret == null)
+                               Assert.Fail (String.Format ("[{0}] Binding named '{1}' not found.", label, name));
+                       return ret;
+               }
+
+               OperationBinding GetOperationBinding (WSBinding b, string name, string label)
+               {
+                       foreach (OperationBinding op in b.Operations)
+                               if (op.Name == name)
+                                       return op;
+
+                       Assert.Fail (String.Format ("[{0}] OperationBinding named '{1}' not found.", label, name));
+                       return null;
+               }
+
+               void CheckBasicHttpBinding (WSServiceDescription wsd, string binding_name, XmlQualifiedName binding_type,
+                       string operation_name, string action, bool has_input, bool has_output, string label)
+               {
+                       WSBinding b = GetBinding (wsd, binding_name, label);
+                       OperationBinding op = GetOperationBinding (b, operation_name, label + " CheckBasicHttpBinding");
+
+                       Assert.AreEqual (binding_type, b.Type, label + " #cbh0");
+
+                       if (has_input) {
+                               InputBinding inb = op.Input;
+                               Assert.IsNotNull (inb, label + " #cbh1");
+                               Assert.AreEqual (1, inb.Extensions.Count, label + " #cbh2");
+
+                               Assert.AreEqual (typeof (SoapBodyBinding), inb.Extensions [0].GetType (), label + " #cbh3");
+                               SoapBodyBinding soap_binding = (SoapBodyBinding) inb.Extensions [0];
+                               Assert.AreEqual (SoapBindingUse.Literal, soap_binding.Use, label + " #cbh4");
+
+                               if (action != null) {
+                                       Assert.AreEqual (1, op.Extensions.Count, label + " #chb5");
+                                       Assert.AreEqual (typeof (SoapOperationBinding), op.Extensions [0].GetType (), label + " #cbh6");
+                                       SoapOperationBinding sopb = (SoapOperationBinding) op.Extensions [0];
+                                       Assert.AreEqual (action, sopb.SoapAction, label + " #cbh7");
+                               }
+                       }
+
+                       if (has_output) {
+                               OutputBinding outb = op.Output;
+                               Assert.IsNotNull (outb, label + " #cbh10");
+                               Assert.AreEqual (1, outb.Extensions.Count, label + " #cbh11");
+
+                               Assert.AreEqual (typeof (SoapBodyBinding), outb.Extensions [0].GetType (), label + " #cbh12");
+                               SoapBodyBinding soap_binding = (SoapBodyBinding) outb.Extensions [0];
+                               Assert.AreEqual (SoapBindingUse.Literal, soap_binding.Use, label + " #cbh13");
+                       }
+
+                       Assert.AreEqual (1, b.Extensions.Count, label + " #cbh20");
+                       Assert.AreEqual (typeof (SoapBinding), b.Extensions [0].GetType (), label + " #cbh21");
+                       SoapBinding sb = (SoapBinding) b.Extensions [0];
+                       Assert.AreEqual (SoapBinding.HttpTransport, sb.Transport, label + " #cbh22");
+               }
+
+               void CheckServicePort (Service svc, string port_name, XmlQualifiedName binding_name, string address, string label)
+               {
+                       Port port = svc.Ports [port_name];
+                       Assert.IsNotNull (port, label + " #csp0");
+                       Assert.AreEqual (port.Binding, binding_name, label + " #csp1");
+
+                       Assert.AreEqual (1, port.Extensions.Count, label + " #csp2");
+                       Assert.AreEqual (typeof (SoapAddressBinding), port.Extensions [0].GetType (), label + " #csp3");
+                       SoapAddressBinding sab = (SoapAddressBinding) port.Extensions [0];
+                       Assert.AreEqual (address, sab.Location, label + " #csp3");
+               }
+
+               void CheckContract_IEchoService2 (MetadataSet ms, string label)
+               {
+                       WSServiceDescription wsd = GetServiceDescription (ms, "http://tempuri.org/", label + "#a1");
+                       Assert.AreEqual (3, wsd.Messages.Count, "#cw5");
+
+                       Assert.IsNotNull (wsd.Messages [0]);
+                       // WSMessage m = wsd.Messages [0];
+                       CheckMessage (wsd, "ThisIsEchoService_Echo_InputMessage", "http://tempuri.org/:Echo");
+                       CheckMessage (wsd, "ThisIsEchoService_Echo_OutputMessage", "http://tempuri.org/:EchoResponse");
+
+                       CheckMessage (wsd, "ThisIsEchoService_DoubleIt_InputMessage", "http://tempuri.org/:DoubleIt");
+
+                       //PortTypes
+                       Assert.AreEqual (1, wsd.PortTypes.Count, "#cw6");
+                       PortType port = wsd.PortTypes [0];
+                       Assert.AreEqual ("ThisIsEchoService", port.Name, "#cw7");
+
+                       //Operations
+                       Assert.AreEqual (2, port.Operations.Count, "#cw8");
+                       //Operations [0]
+                       Operation op = port.Operations [0];
+                       Assert.AreEqual ("Echo", op.Name, "#co1");
+                       Assert.AreEqual (0, op.Extensions.Count, "#co2");
+                       Assert.IsNull (op.ParameterOrder, "#co3");
+                       Assert.AreEqual ("", op.ParameterOrderString, "#co4");
+                       Assert.AreEqual (0, op.Faults.Count, "#co5");
+
+                       //OperationMessages
+                       Assert.AreEqual (2, op.Messages.Count, "#co6");
+                       Assert.AreEqual (OperationFlow.RequestResponse, op.Messages.Flow, "#co7");
+
+                       CheckOperationMessage (op.Messages [0], "http://tempuri.org/:ThisIsEchoService_Echo_InputMessage",
+                               typeof (OperationInput), "http://tempuri.org/ThisIsEchoService/Echo");
+                       CheckOperationMessage (op.Messages [1], "http://tempuri.org/:ThisIsEchoService_Echo_OutputMessage",
+                               typeof (OperationOutput), "http://tempuri.org/ThisIsEchoService/EchoResponse");
+
+                       op = port.Operations [1];
+                       Assert.AreEqual ("DoubleIt", op.Name, "#co8");
+                       Assert.AreEqual (0, op.Extensions.Count, "#co9");
+                       Assert.IsNull (op.ParameterOrder, "#co10");
+                       Assert.AreEqual ("", op.ParameterOrderString, "#co11");
+                       Assert.AreEqual (0, op.Faults.Count, "#co12");
+
+                       //OperationMessages
+                       Assert.AreEqual (1, op.Messages.Count, "#co13");
+                       Assert.AreEqual (OperationFlow.OneWay, op.Messages.Flow, "#co14");
+
+                       CheckOperationMessage (op.Messages [0], "http://tempuri.org/:ThisIsEchoService_DoubleIt_InputMessage",
+                               typeof (OperationInput), "http://tempuri.org/ThisIsEchoService/DoubleIt");
+
+                       /* FIXME: Assert.AreEqual (1, wsd.Types.Schemas.Count, "#co20");
+                       XmlSchema xs = wsd.Types.Schemas [0];
+
+                       Assert.AreEqual (4, xs.Includes.Count);
+                       //FIXME: Check the imports.. */
+               }
+
+               void CheckContract_IEchoService (MetadataSet ms, string label)
+               {
+                       WSServiceDescription wsd = GetServiceDescription (ms, "http://myns/echo", label + "#a0");
+                       Assert.AreEqual (4, wsd.Messages.Count, "#cw5");
+
+                       Assert.IsNotNull (wsd.Messages [0]);
+                       //WSMessage m = wsd.Messages [0];
+
+                       CheckMessage (wsd, "IEchoService_Echo_InputMessage", "http://myns/echo:Echo");
+                       CheckMessage (wsd, "IEchoService_Echo_OutputMessage", "http://myns/echo:EchoResponse");
+
+                       CheckMessage (wsd, "IEchoService_DoubleIt_InputMessage", "http://myns/echo:DoubleIt");
+                       CheckMessage (wsd, "IEchoService_DoubleIt_OutputMessage", "http://myns/echo:DoubleItResponse");
+
+                       //PortTypes
+                       Assert.AreEqual (1, wsd.PortTypes.Count, "#cw6");
+                       PortType port = wsd.PortTypes [0];
+                       Assert.AreEqual ("IEchoService", port.Name, "#cw7");
+
+                       //Operations
+                       Assert.AreEqual (2, port.Operations.Count, "#cw8");
+                       //Operations [0]
+                       Operation op = port.Operations [0];
+                       Assert.AreEqual ("Echo", op.Name, "#co1");
+                       Assert.AreEqual (0, op.Extensions.Count, "#co2");
+                       Assert.IsNull (op.ParameterOrder, "#co3");
+                       Assert.AreEqual ("", op.ParameterOrderString, "#co4");
+                       Assert.AreEqual (0, op.Faults.Count, "#co5");
+
+                       //OperationMessages
+                       Assert.AreEqual (2, op.Messages.Count, "#co6");
+                       Assert.AreEqual (OperationFlow.RequestResponse, op.Messages.Flow, "#co7");
+
+                       CheckOperationMessage (op.Messages [0], "http://myns/echo:IEchoService_Echo_InputMessage", typeof (OperationInput), "http://myns/echo/IEchoService/Echo");
+                       CheckOperationMessage (op.Messages [1], "http://myns/echo:IEchoService_Echo_OutputMessage", typeof (OperationOutput), "http://myns/echo/IEchoService/EchoResponse");
+
+                       op = port.Operations [1];
+                       Assert.AreEqual ("DoubleIt", op.Name, "#co8");
+                       Assert.AreEqual (0, op.Extensions.Count, "#co9");
+                       Assert.IsNull (op.ParameterOrder, "#co10");
+                       Assert.AreEqual ("", op.ParameterOrderString, "#co11");
+                       Assert.AreEqual (0, op.Faults.Count, "#co12");
+
+                       //OperationMessages
+                       Assert.AreEqual (2, op.Messages.Count, "#co13");
+                       Assert.AreEqual (OperationFlow.RequestResponse, op.Messages.Flow, "#co14");
+
+                       CheckOperationMessage (op.Messages [0], "http://myns/echo:IEchoService_DoubleIt_InputMessage", typeof (OperationInput), "http://myns/echo/IEchoService/DoubleIt");
+                       CheckOperationMessage (op.Messages [1], "http://myns/echo:IEchoService_DoubleIt_OutputMessage", typeof (OperationOutput), "http://myns/echo/IEchoService/DoubleItResponse");
+
+                       /* FIXME: Assert.AreEqual (1, wsd.Types.Schemas.Count, "#co20");
+                       XmlSchema xs = wsd.Types.Schemas [0];
+
+                       Assert.AreEqual (4, xs.Includes.Count);
+                       //FIXME: Check the imports.. */
+               }
+
+               void CheckOperationMessage (OperationMessage opmsg, string msg, Type type, string action)
+               {
+                       Assert.AreEqual (type, opmsg.GetType (), "#com1");
+                       Assert.AreEqual (msg, opmsg.Message.ToString (), "#com2");
+                       Assert.AreEqual (0, opmsg.Extensions.Count, "#com3");
+                       Assert.AreEqual (1, opmsg.ExtensibleAttributes.Length, "#com4");
+                       Assert.IsNull (opmsg.Name, "#com5");
+
+                       XmlAttribute attr = opmsg.ExtensibleAttributes [0];
+                       Assert.AreEqual ("Action", attr.LocalName, "#ca1");
+                       Assert.AreEqual ("http://www.w3.org/2006/05/addressing/wsdl", attr.NamespaceURI, "#ca2");
+                       Assert.AreEqual (action, attr.Value, "#ca3");
+               }
+
+               void CheckMessage (WSServiceDescription sd, string msg_name, string part_type)
+               {
+                       CheckMessage (sd, msg_name, "parameters", part_type, false, "");
+               }
+
+               void CheckMessage (WSServiceDescription sd, string msg_name, string part_name, string part_type, bool is_type, string label)
+               {
+                       WSMessage m = sd.Messages [msg_name];
+                       Assert.IsNotNull (m, label + " : Message named " + msg_name + " not found.");
+
+                       Assert.AreEqual (msg_name, m.Name, label + " #cm1");
+                       Assert.AreEqual (0, m.Extensions.Count, label + " #cm2");
+
+                       Assert.IsNull (m.ExtensibleAttributes, label + " #cm3a");
+                       Assert.AreEqual (1, m.Parts.Count, label + " #cm3");
+
+                       Assert.AreEqual (part_name, m.Parts [0].Name, label + " #cm9");
+
+                       if (is_type) {
+                               Assert.AreEqual ("", m.Parts [0].Element.ToString (), label + " #cm4");
+                               Assert.AreEqual (part_type, m.Parts [0].Type.ToString (), label + " #cm4a");
+                       } else {
+                               Assert.AreEqual ("", m.Parts [0].Type.ToString (), label + " #cm5");
+                               Assert.AreEqual (part_type, m.Parts [0].Element.ToString (), label + " #cm5a");
+                       }
+
+                       Assert.IsNull (m.Parts [0].ExtensibleAttributes, label + " #cm6");
+                       Assert.AreEqual (0, m.Parts [0].Extensions.Count, label + " #cm7");
+               }
+
+               void WriteTo (WsdlExporter we, string name)
+               {
+                       using (XmlTextWriter xw = new XmlTextWriter (name, Encoding.UTF8)) {
+                               xw.Formatting = Formatting.Indented;
+                               we.GetGeneratedMetadata ().WriteTo (xw);
+                       }
+               }
+
+               [Test]
+               public void ExportEndpointTest5 () {
+                       WsdlExporter we = new WsdlExporter ();
+
+                       ServiceEndpoint se = new ServiceEndpoint (ContractDescription.GetContract (typeof (IEchoService)));
+                       se.Binding = new BasicHttpBinding ();
+                       se.Address = new EndpointAddress ("http://localhost:8080");
+
+                       we.ExportEndpoint (se);
+
+                       MetadataSet ms = we.GetGeneratedMetadata ();
+                       Assert.AreEqual (6, ms.MetadataSections.Count);
+                       WSServiceDescription wsd = GetServiceDescription (ms, "http://tempuri.org/", "ExportEndpointTest5#1");
+
+                       SoapBinding soapBinding = (SoapBinding) wsd.Bindings [0].Extensions [0];
+                       Assert.AreEqual (SoapBindingStyle.Document, soapBinding.Style, "soapBinding.Style");
+                       Assert.AreEqual (SoapBinding.HttpTransport, soapBinding.Transport, "soapBinding.Transport");
+               }
+
+       }
+
+       [DataContract]
+       public class dc
+       {
+               [DataMember]
+               string foo;
+
+               /*  [DataMember]
+                       dc me;
+
+                       [DataMember]
+                       some_enum en;
+
+                       [DataMember]
+                       NotReferenced nr;*/
+
+               [DataMember]
+               public FooNS.bar bb;
+       }
+
+       [ServiceContract (Namespace = "http://myns/echo")]
+       public interface IEchoService
+       {
+
+               [OperationContract]
+               string Echo (string msg, int num, dc d);
+
+               [OperationContract]
+               void DoubleIt (int it, string prefix);
+
+               /*[OperationContract]
+               void foo ();*/
+
+       }
+
+       [ServiceContract (Name = "ThisIsEchoService")]
+       public interface IEchoService2
+       {
+
+               [OperationContract]
+               string Echo (string msg, int num, dc d);
+
+               [OperationContract (IsOneWay = true)]
+               void DoubleIt (int it, string prefix);
+
+               /*[OperationContract]
+               void foo ();*/
+       }
+
+       [ServiceContract (Name = "AnotherService")]
+       public interface IEchoService3
+       {
+               [OperationContract]
+               string Echo (string msg, int num, dc d);
+
+               [OperationContract (IsOneWay = true)]
+               void DoubleIt (int it, string prefix);
+
+               /*[OperationContract]
+               void foo ();*/
+       }
+
+       [ServiceContract]
+       public class Bar1
+       {
+               [OperationContract]
+               public void Foo (SMMessage msg, string s)
+               {
+               }
+       }
+
+       [ServiceContract]
+       public interface IFoo1
+       {
+               //Same DataContract used in different operations
+
+               [OperationContract]
+               void Op1 (dc d); 
+
+               [OperationContract]
+               void Op2 (dc d); 
+       }
+
+       //Used to check whether both IFoo1 & IFoo1a
+       //can be exported
+       //Operations are not Service scoped
+       [ServiceContract]
+       public interface IFoo1a
+       {
+               [OperationContract]
+               void Op1 (string s);
+       }
+
+       [ServiceContract]
+       public interface IFoo2
+       {
+               // FIXME: it does not pass yet
+               [OperationContract]
+               OregoMessage Nanoda (OregoMessage msg);
+
+               // FIXME: it does not pass yet
+               [OperationContract]
+               Mona NewMona (Mona source);
+       }
+
+       [MessageContract]
+       public class OregoMessage
+       {
+               [MessageBodyMember]
+               public string Neutral;
+
+               [MessageBodyMember]
+               public Assembly Huh;
+
+               [MessageBodyMember] // it should be ignored ...
+               public string Setter { set { } }
+
+               public string NonMember;
+       }
+
+       [DataContract]
+       public class Mona
+       {
+               [DataMember]
+               public string OmaeMona;
+
+               [DataMember]
+               public string OreMona;
+       }
+
+}
+namespace FooNS
+{
+       [DataContract]
+       public class bar
+       {
+               [DataMember]
+               public string foo;
+       }
+}
+
+
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/WsdlImporterTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/WsdlImporterTest.cs
new file mode 100644 (file)
index 0000000..4f331e9
--- /dev/null
@@ -0,0 +1,553 @@
+//
+// WsdlImporterTest.cs
+//
+// Author:
+//     Ankit Jain <JAnkit@novell.com>
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.ServiceModel.Description;
+using System.Web.Services;
+using System.IO;
+using System.Xml;
+using NUnit.Framework;
+using System.ServiceModel.Channels;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+
+using WSServiceDescription = System.Web.Services.Description.ServiceDescription;
+using SMBinding = System.ServiceModel.Channels.Binding;
+using System.Xml.Schema;
+using System.Web.Services.Description;
+
+namespace MonoTests.System.ServiceModel.Description
+{
+       [TestFixture]
+       public class WsdlImporterTest
+       {
+               MetadataSet ms = null;
+               WsdlImporter wi = null;
+               XmlReader xtr = null;
+
+               void NoExtensionsSetup ()
+               {
+                       XmlReaderSettings xs = new XmlReaderSettings ();
+                       xs.IgnoreWhitespace = true;
+                       xtr = XmlTextReader.Create ("Test/System.ServiceModel.Description/dump.xml", xs);
+
+                       xtr.Read ();
+
+                       //FIXME: skipping Headers
+                       while (xtr.LocalName != "Body") {
+                               if (!xtr.Read ())
+                                       return;
+                       }
+
+                       //Move to <Metadata ..
+                       xtr.Read ();
+                       ms = MetadataSet.ReadFrom (xtr);
+
+                       //MyWsdlImportExtension mw = new MyWsdlImportExtension ();
+                       List<IWsdlImportExtension> list = new List<IWsdlImportExtension> ();
+                       //list.Add (mw);
+                       list.Add (new DataContractSerializerMessageContractImporter ());
+
+                       /*list.Add (new MessageEncodingBindingElementImporter ());
+                       list.Add (new TransportBindingElementImporter ());
+                       list.Add (new StandardBindingImporter ());*/
+
+                       wi = new WsdlImporter (ms, null, list);
+               }
+
+               [TearDown]
+               public void TearDown ()
+               {
+                       if (xtr != null)
+                               xtr.Close ();
+               }
+
+               [Test]
+               public void CtorTest ()
+               {
+                       NoExtensionsSetup ();
+                       Assert.AreEqual (2, wi.WsdlDocuments.Count, "#CT1");
+                       Assert.AreEqual (3, wi.XmlSchemas.Count, "#CT2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorNullTest1 ()
+               {
+                       new WsdlImporter (null);
+               }
+
+               private void CheckDefaultPolicyImportExtensions (KeyedByTypeCollection<IPolicyImportExtension> list)
+               {
+                       Assert.IsNotNull (list, "#CN1");
+                       // 9 in 3.0, 10 in 3.5
+                       // Assert.AreEqual (10, list.Count, "#CN2");
+
+                       Assert.AreEqual (typeof (PrivacyNoticeBindingElementImporter), list [0].GetType (), "#CN3");
+                       Assert.AreEqual (typeof (UseManagedPresentationBindingElementImporter), list [1].GetType (), "#CN4");
+                       Assert.AreEqual (typeof (TransactionFlowBindingElementImporter), list [2].GetType (), "#CN5");
+                       Assert.AreEqual (typeof (ReliableSessionBindingElementImporter), list [3].GetType (), "#CN6");
+                       Assert.AreEqual (typeof (SecurityBindingElementImporter), list [4].GetType (), "#CN7");
+                       Assert.AreEqual (typeof (CompositeDuplexBindingElementImporter), list [5].GetType (), "#CN8");
+                       Assert.AreEqual (typeof (OneWayBindingElementImporter), list [6].GetType (), "#CN9");
+                       Assert.AreEqual (typeof (MessageEncodingBindingElementImporter), list [7].GetType (), "#CN10");
+                       Assert.AreEqual (typeof (TransportBindingElementImporter), list [8].GetType (), "#CN11");
+                       // It is in System.WorkflowServices.dll (3.5)
+                       //Assert.AreEqual (typeof (ContextBindingElementImporter), list [9].GetType (), "#CN12");
+               }
+
+               private void CheckDefaultWsdlImportExtensions (KeyedByTypeCollection<IWsdlImportExtension> list)
+               {
+                       Assert.IsNotNull (list, "#CN20");
+                       // 5 in 3.0, 6 in 3.5
+                       // Assert.AreEqual (6, list.Count, "#CN21");
+
+                       Assert.AreEqual (typeof (DataContractSerializerMessageContractImporter), list [0].GetType (), "#CN22");
+                       Assert.AreEqual (typeof (XmlSerializerMessageContractImporter), list [1].GetType (), "#CN23");
+                       Assert.AreEqual (typeof (MessageEncodingBindingElementImporter), list [2].GetType (), "#CN24");
+                       Assert.AreEqual (typeof (TransportBindingElementImporter), list [3].GetType (), "#CN25");
+                       Assert.AreEqual (typeof (StandardBindingImporter), list [4].GetType (), "#CN26");
+                       // It is in System.WorkflowServices.dll (3.5)
+                       //Assert.AreEqual (typeof (ContextBindingElementImporter), list [5].GetType (), "#CN27");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void CtorNullTest2 ()
+               {
+                       WsdlImporter wi = new WsdlImporter (new MetadataSet (), null, new List<IWsdlImportExtension> ());
+
+                       Assert.IsNotNull (wi.WsdlImportExtensions, "#CN12");
+                       Assert.AreEqual (0, wi.WsdlImportExtensions.Count, "#CN13");
+
+                       /* FIXME: Not all importers are implemented yet */
+                       CheckDefaultPolicyImportExtensions (wi.PolicyImportExtensions);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void CtorNullTest3 ()
+               {
+                       WsdlImporter wi = new WsdlImporter (new MetadataSet (), new List<IPolicyImportExtension> (), null);
+
+                       Assert.IsNotNull (wi.PolicyImportExtensions, "#CN18");
+                       Assert.AreEqual (0, wi.PolicyImportExtensions.Count, "#CN19");
+
+                       /* FIXME: Not all importers are implemented yet */
+                       CheckDefaultWsdlImportExtensions (wi.WsdlImportExtensions);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void CtorNullTest4 ()
+               {
+                       WsdlImporter wi = new WsdlImporter (new MetadataSet (), null, null);
+                       /* FIXME: Not all importers are implemented yet */
+                       CheckDefaultPolicyImportExtensions (wi.PolicyImportExtensions);
+                       CheckDefaultWsdlImportExtensions (wi.WsdlImportExtensions);
+               }
+
+               public void CtorNullTest5 ()
+               {
+                       WsdlImporter wi = new WsdlImporter (new MetadataSet ());
+                       CheckDefaultWsdlImportExtensions (wi.WsdlImportExtensions);
+                       CheckDefaultPolicyImportExtensions (wi.PolicyImportExtensions);
+               }
+
+               [Test]
+               public void ExtensionsTest ()
+               {
+                       XmlReaderSettings xs = new XmlReaderSettings ();
+                       xs.IgnoreWhitespace = true;
+                       xtr = XmlTextReader.Create ("Test/System.ServiceModel.Description/dump.xml", xs);
+
+                       xtr.Read ();
+
+                       //FIXME: skipping Headers
+                       while (xtr.LocalName != "Body") {
+                               if (!xtr.Read ())
+                                       return;
+                       }
+
+                       //Move to <Metadata ..
+                       xtr.Read ();
+                       ms = MetadataSet.ReadFrom (xtr);
+
+                       Assert.AreEqual (typeof (WSServiceDescription), ms.MetadataSections [0].Metadata.GetType (), "#ET1");
+                       WSServiceDescription wsd = ms.MetadataSections [1].Metadata as WSServiceDescription;
+
+                       //ServiceDescription
+                       Assert.IsNotNull (wsd.Extensions, "#ET2");
+                       Assert.AreEqual (0, wsd.Extensions.Count, "#ET3");
+
+                       //Binding [0]
+                       Assert.IsNotNull (wsd.Bindings [0].Extensions, "#ET4");
+                       Assert.AreEqual (1, wsd.Bindings [0].Extensions.Count, "#ET5");
+                       Assert.AreEqual (typeof (SoapBinding), wsd.Bindings [0].Extensions [0].GetType (), "#ET6");
+
+                       //Binding [0].Operations [0]
+                       Assert.IsNotNull (wsd.Bindings [0].Operations [0].Extensions, "#ET7");
+                       Assert.AreEqual (1, wsd.Bindings [0].Operations [0].Extensions.Count, "#ET8");
+                       Assert.AreEqual (typeof (SoapOperationBinding), wsd.Bindings [0].Operations [0].Extensions [0].GetType (), "#ET9");
+
+                       //Binding [0].Operations [1]
+                       Assert.IsNotNull (wsd.Bindings [0].Operations [1].Extensions, "#ET10");
+                       Assert.AreEqual (1, wsd.Bindings [0].Operations [1].Extensions.Count, "#ET11");
+                       Assert.AreEqual (typeof (SoapOperationBinding), wsd.Bindings [0].Operations [1].Extensions [0].GetType (), "#ET12");
+
+                       //Service.Port
+                       Assert.IsNotNull (wsd.Services [0].Ports [0].Extensions, "#ET13");
+                       Assert.AreEqual (1, wsd.Services [0].Ports [0].Extensions.Count, "#ET14");
+                       Assert.AreEqual (typeof (SoapAddressBinding), wsd.Services [0].Ports [0].Extensions [0].GetType (), "#ET15");
+               }
+
+               void CheckXmlElement (object o, string name)
+               {
+                       Assert.AreEqual (typeof (XmlElement), o.GetType ());
+                       Assert.AreEqual (name, ((XmlElement) o).Name);
+               }
+
+               [Test]
+               public void BindingsTest ()
+               {
+                       NoExtensionsSetup ();
+                       IEnumerable<SMBinding> bindings = wi.ImportAllBindings ();
+
+                       int count = 0;
+                       foreach (SMBinding b in bindings) {
+                               Assert.AreEqual (typeof (CustomBinding), b.GetType (), "#B1");
+                               Assert.AreEqual ("BasicHttpBinding_IEchoService", b.Name, "#B2");
+                               Assert.AreEqual ("http://tempuri.org/", b.Namespace, "#B3");
+                               Assert.AreEqual ("", b.Scheme, "#B4");
+
+                               //FIXME: Test BindingElements
+
+                               count++;
+                       }
+                       Assert.AreEqual (1, count);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ContractsTest ()
+               {
+                       NoExtensionsSetup ();
+                       Collection<ContractDescription> cds = wi.ImportAllContracts ();
+
+                       Assert.AreEqual (1, cds.Count);
+                       CheckContractDescription (cds [0]);
+
+               }
+
+               //Used only for contract from test.xml
+               private void CheckContractDescription (ContractDescription cd)
+               {
+                       Assert.AreEqual ("IEchoService", cd.Name, "#CD1");
+                       Assert.AreEqual ("http://myns/echo", cd.Namespace, "#CD2");
+                       Assert.AreEqual (0, cd.Behaviors.Count, "#CD3");
+
+                       Assert.IsNull (cd.CallbackContractType, "#CD4");
+                       Assert.IsNull (cd.ContractType, "#CD5");
+
+                       Assert.IsFalse (cd.HasProtectionLevel, "#CD6");
+                       Assert.AreEqual (SessionMode.Allowed, cd.SessionMode, "#CD7");
+
+                       //Operations
+                       Assert.AreEqual (2, cd.Operations.Count, "#CD8");
+                       Assert.AreEqual (cd, cd.Operations [1].DeclaringContract, "#CD10");
+                       CheckOperationDescriptionEcho (cd.Operations [0]);
+                       CheckOperationDescriptionDouble_it (cd.Operations [1]);
+
+               }
+
+               public void CheckOperationDescriptionEcho (OperationDescription od)
+               {
+                       //OperationDescription od = cd.Operations [0];
+                       Assert.AreEqual ("Echo", od.Name, "#CD9");
+
+                       Assert.IsNull (od.BeginMethod, "#CD11");
+                       Assert.IsNull (od.EndMethod, "#CD12");
+
+                       Assert.AreEqual (0, od.Faults.Count, "#CD13");
+                       Assert.IsTrue (od.IsInitiating, "#CD14");
+                       Assert.IsFalse (od.IsOneWay, "#CD15");
+                       Assert.IsFalse (od.IsTerminating, "#CD16");
+
+                       //FIXME: Behaviors
+
+                       //OperationDescription.Message
+                       Assert.AreEqual (2, od.Messages.Count, "#CD17");
+
+                       MessageDescription md = od.Messages [0];
+                       #region MessageDescription 0
+                       Assert.AreEqual ("http://myns/echo/IEchoService/Echo", md.Action, "#CD18");
+                       Assert.AreEqual (MessageDirection.Input, md.Direction, "#CD19");
+                       Assert.AreEqual (0, md.Headers.Count, "#CD20");
+                       Assert.AreEqual (0, md.Properties.Count, "#CD21");
+
+                       //MessageDescription.MessageBodyDescription
+
+                       Assert.IsNull (md.Body.ReturnValue, "#CD22");
+                       Assert.AreEqual ("Echo", md.Body.WrapperName, "#CD23");
+                       Assert.AreEqual ("http://myns/echo", md.Body.WrapperNamespace, "#CD24");
+                       #region MessagePartDescription
+                       //MessagePartDescription 0
+
+                       Assert.AreEqual (3, md.Body.Parts.Count, "#CD25");
+                       MessagePartDescription mpd = md.Body.Parts [0];
+
+                       Assert.AreEqual (0, mpd.Index, "#CD26");
+                       Assert.IsFalse (mpd.Multiple, "#CD27");
+                       Assert.AreEqual ("msg", mpd.Name, "#CD28");
+                       Assert.AreEqual ("http://myns/echo", mpd.Namespace, "#CD29");
+                       Assert.IsNull (mpd.Type, "#CD30");
+
+                       //MessagePartDescription 1
+
+                       mpd = md.Body.Parts [1];
+
+                       Assert.AreEqual (0, mpd.Index, "#CD31");
+                       Assert.IsFalse (mpd.Multiple, "#CD32");
+                       Assert.AreEqual ("num", mpd.Name, "#CD33");
+                       Assert.AreEqual ("http://myns/echo", mpd.Namespace, "#CD34");
+                       Assert.IsNull (mpd.Type, "#CD35");
+
+                       //MessagePartDescription 2
+
+                       mpd = md.Body.Parts [2];
+
+                       Assert.AreEqual (0, mpd.Index, "#CD31");
+                       Assert.IsFalse (mpd.Multiple, "#CD32");
+                       Assert.AreEqual ("d", mpd.Name, "#CD33");
+                       Assert.AreEqual ("http://myns/echo", mpd.Namespace, "#CD34");
+                       Assert.IsNull (mpd.Type, "#CD35");
+
+                       #endregion
+                       #endregion
+
+                       md = od.Messages [1];
+
+                       #region MessageDescription 1
+
+                       Assert.AreEqual ("http://myns/echo/IEchoService/EchoResponse", md.Action, "#CD36");
+                       Assert.AreEqual (MessageDirection.Output, md.Direction, "#CD37");
+                       Assert.AreEqual (0, md.Headers.Count, "#CD38");
+                       Assert.AreEqual (0, md.Properties.Count, "#CD39");
+
+                       //MessageDescription.MessageBodyDescription
+
+                       //Return value
+                       Assert.IsNotNull (md.Body.ReturnValue, "#CD40");
+
+                       Assert.AreEqual ("EchoResponse", md.Body.WrapperName, "#CD44");
+                       Assert.AreEqual ("http://myns/echo", md.Body.WrapperNamespace, "#CD45");
+                       Assert.AreEqual (0, md.Body.Parts.Count, "#CD46");
+
+                       #endregion
+
+               }
+
+               public void CheckOperationDescriptionDouble_it (OperationDescription od)
+               {
+                       //OperationDescription od = cd.Operations [0];
+                       Assert.AreEqual ("DoubleIt", od.Name, "#CD9");
+
+                       Assert.IsNull (od.BeginMethod, "#CD11");
+                       Assert.IsNull (od.EndMethod, "#CD12");
+
+                       Assert.AreEqual (0, od.Faults.Count, "#CD13");
+                       Assert.IsTrue (od.IsInitiating, "#CD14");
+                       Assert.IsFalse (od.IsOneWay, "#CD15");
+                       Assert.IsFalse (od.IsTerminating, "#CD16");
+
+                       //FIXME: Behaviors
+
+                       //OperationDescription.Message
+                       Assert.AreEqual (2, od.Messages.Count, "#CD17");
+
+                       MessageDescription md = od.Messages [0];
+                       #region MessageDescription 0
+                       Assert.AreEqual ("http://myns/echo/IEchoService/DoubleIt", md.Action, "#CD18");
+                       Assert.AreEqual (MessageDirection.Input, md.Direction, "#CD19");
+                       Assert.AreEqual (0, md.Headers.Count, "#CD20");
+                       Assert.AreEqual (0, md.Properties.Count, "#CD21");
+
+                       //MessageDescription.MessageBodyDescription
+
+                       Assert.IsNull (md.Body.ReturnValue, "#CD22");
+                       Assert.AreEqual ("DoubleIt", md.Body.WrapperName, "#CD23");
+                       Assert.AreEqual ("http://myns/echo", md.Body.WrapperNamespace, "#CD24");
+                       #region MessagePartDescription
+                       //MessagePartDescription 0
+
+                       //Assert.AreEqual (0, md.Body.Parts.Count, "#CD25");
+                       MessagePartDescription mpd = md.Body.Parts [0];
+
+                       Assert.AreEqual (0, mpd.Index, "#CD26");
+                       Assert.IsFalse (mpd.Multiple, "#CD27");
+                       Assert.AreEqual ("it", mpd.Name, "#CD28");
+                       Assert.AreEqual ("http://myns/echo", mpd.Namespace, "#CD29");
+                       Assert.IsNull (mpd.Type, "#CD30");
+
+                       //MessagePartDescription 1
+
+                       mpd = md.Body.Parts [1];
+
+                       Assert.AreEqual (0, mpd.Index, "#CD31");
+                       Assert.IsFalse (mpd.Multiple, "#CD32");
+                       Assert.AreEqual ("prefix", mpd.Name, "#CD33");
+                       Assert.AreEqual ("http://myns/echo", mpd.Namespace, "#CD34");
+                       Assert.IsNull (mpd.Type, "#CD35");
+
+                       #endregion
+                       #endregion
+
+                       md = od.Messages [1];
+
+                       #region MessageDescription 1
+
+                       Assert.AreEqual ("http://myns/echo/IEchoService/DoubleItResponse", md.Action, "#CD36");
+                       Assert.AreEqual (MessageDirection.Output, md.Direction, "#CD37");
+                       Assert.AreEqual (0, md.Headers.Count, "#CD38");
+                       Assert.AreEqual (0, md.Properties.Count, "#CD39");
+
+                       //MessageDescription.MessageBodyDescription
+
+                       //Return value
+                       Assert.IsNotNull (md.Body.ReturnValue, "#CD40");
+
+                       Assert.AreEqual ("DoubleItResponse", md.Body.WrapperName, "#CD44");
+                       Assert.AreEqual ("http://myns/echo", md.Body.WrapperNamespace, "#CD45");
+                       Assert.AreEqual (0, md.Body.Parts.Count, "#CD46");
+
+                       #endregion
+
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void EndpointsTest ()
+               {
+                       NoExtensionsSetup ();
+                       ServiceEndpointCollection sec = wi.ImportAllEndpoints ();
+
+                       Assert.AreEqual (1, sec.Count);
+
+                       ServiceEndpoint se = sec [0];
+
+                       //.Address
+                       Assert.IsNull (se.Address, "#ep1");
+
+                       Assert.AreEqual (0, se.Behaviors.Count, "#ep6");
+
+                       //Binding
+                       Assert.AreEqual (typeof (CustomBinding), se.Binding.GetType (), "#ep7");
+
+                       CustomBinding c = (CustomBinding) se.Binding;
+
+                       Assert.AreEqual ("BasicHttpBinding_IEchoService", c.Name, "#ep8");
+                       Assert.AreEqual ("http://tempuri.org/", c.Namespace, "#ep9");
+                       Assert.AreEqual ("", c.Scheme, "#ep10");
+
+                       Assert.AreEqual (1, c.Elements.Count, "#ep11");
+                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement), c.Elements [0].GetType (), "#ep12");
+                       //FIXME: Check c.Elements [0]. properties?
+
+                       CheckContractDescription (se.Contract);
+
+                       Assert.IsNull (se.ListenUri, "#ep13");
+                       Assert.AreEqual (ListenUriMode.Explicit, se.ListenUriMode, "#ep14");
+               }
+
+               void ExtensionsSetup (List<IWsdlImportExtension> list)
+               {
+                       XmlReaderSettings xs = new XmlReaderSettings ();
+                       xs.IgnoreWhitespace = true;
+                       //xtr = XmlTextReader.Create ("Test/System.ServiceModel.Description/test2a.xml", xs);
+                       xtr = XmlTextReader.Create ("Test/System.ServiceModel.Description/dump.xml", xs);
+
+                       xtr.Read ();
+
+                       //FIXME: skipping Headers
+                       while (xtr.LocalName != "Body") {
+                               if (!xtr.Read ())
+                                       return;
+                       }
+
+                       //Move to <Metadata ..
+                       xtr.Read ();
+                       ms = MetadataSet.ReadFrom (xtr);
+
+                       /*MyWsdlImportExtension mw = new MyWsdlImportExtension ();
+                       List<IWsdlImportExtension> list = new List<IWsdlImportExtension> ();
+                       list.Add (mw);
+                       list.Add (new DataContractSerializerMessageContractImporter ());
+
+                       /*list.Add (new MessageEncodingBindingElementImporter ());
+                       list.Add (new TransportBindingElementImporter ());
+                       list.Add (new StandardBindingImporter ());*/
+
+                       wi = new WsdlImporter (ms, null, list);
+               }
+
+
+               [Test]
+               [Category ("NotWorking")]
+               public void EndpointTestWithExtensions ()
+               {
+                       List<IWsdlImportExtension> list = new List<IWsdlImportExtension> ();
+                       list.Add (new TransportBindingElementImporter ());
+
+                       ExtensionsSetup (list);
+                       ServiceEndpointCollection sec = wi.ImportAllEndpoints ();
+
+                       Assert.AreEqual (1, sec.Count, "#epe0");
+                       ServiceEndpoint se = sec [0];
+
+                       Assert.IsNotNull (se.Address, "#epe1");
+                       Assert.AreEqual (0, se.Address.Headers.Count, "#epe2");
+                       Assert.IsNull (se.Address.Identity, "#epe3");
+                       Assert.AreEqual (new Uri ("http://localhost:8080/echo/svc"), se.Address.Uri, "#epe4");
+
+                       //Bindings
+                       Assert.AreEqual (typeof (CustomBinding), se.Binding.GetType (), "#epe5");
+                       CustomBinding cb = se.Binding as CustomBinding;
+                       Assert.AreEqual (2, cb.Elements.Count, "#epe6");
+                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement), cb.Elements [0].GetType (), "#epe7");
+                       Assert.AreEqual (typeof (HttpTransportBindingElement), cb.Elements [1].GetType (), "#epe8");
+
+                       Assert.AreEqual (new Uri ("http://localhost:8080/echo/svc"), se.ListenUri, "#epe9");
+                       Assert.AreEqual ("http", cb.Scheme, "#epe10");
+
+               }
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/dump.xml b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/dump.xml
new file mode 100644 (file)
index 0000000..0b198bb
--- /dev/null
@@ -0,0 +1 @@
+<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse</a:Action><a:RelatesTo>urn:uuid:fc9042cc-b557-4ecc-a66d-5e007be384ff</a:RelatesTo></s:Header><s:Body><Metadata xmlns="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"><wsx:MetadataSection Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://myns/echo" xmlns=""><wsdl:definitions targetNamespace="http://myns/echo" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://myns/echo" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing"><wsdl:types><xsd:schema targetNamespace="http://myns/echo/Imports"><xsd:import namespace="http://myns/echo"/><xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/"/><xsd:import namespace="http://schemas.datacontract.org/2004/07/"/></xsd:schema></wsdl:types><wsdl:message name="IEchoService_Echo_InputMessage"><wsdl:part name="parameters" element="tns:Echo"/></wsdl:message><wsdl:message name="IEchoService_Echo_OutputMessage"><wsdl:part name="parameters" element="tns:EchoResponse"/></wsdl:message><wsdl:message name="IEchoService_DoubleIt_InputMessage"><wsdl:part name="parameters" element="tns:DoubleIt"/></wsdl:message><wsdl:message name="IEchoService_DoubleIt_OutputMessage"><wsdl:part name="parameters" element="tns:DoubleItResponse"/></wsdl:message><wsdl:portType name="IEchoService"><wsdl:operation name="Echo"><wsdl:input wsaw:Action="http://myns/echo/IEchoService/Echo" message="tns:IEchoService_Echo_InputMessage"/><wsdl:output wsaw:Action="http://myns/echo/IEchoService/EchoResponse" message="tns:IEchoService_Echo_OutputMessage"/></wsdl:operation><wsdl:operation name="DoubleIt"><wsdl:input wsaw:Action="http://myns/echo/IEchoService/DoubleIt" message="tns:IEchoService_DoubleIt_InputMessage"/><wsdl:output wsaw:Action="http://myns/echo/IEchoService/DoubleItResponse" message="tns:IEchoService_DoubleIt_OutputMessage"/></wsdl:operation></wsdl:portType></wsdl:definitions></wsx:MetadataSection><wsx:MetadataSection Dialect="http://schemas.xmlsoap.org/wsdl/" Identifier="http://tempuri.org/" xmlns=""><wsdl:definitions name="EchoService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://myns/echo" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa10="http://www.w3.org/2005/08/addressing"><wsdl:import namespace="http://myns/echo" location=""/><wsdl:types/><wsdl:binding name="BasicHttpBinding_IEchoService" type="i0:IEchoService"><soap:binding transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="Echo"><soap:operation soapAction="http://myns/echo/IEchoService/Echo" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation><wsdl:operation name="DoubleIt"><soap:operation soapAction="http://myns/echo/IEchoService/DoubleIt" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="EchoService"><wsdl:port name="BasicHttpBinding_IEchoService" binding="tns:BasicHttpBinding_IEchoService"><soap:address location="http://localhost:8080/echo/svc"/></wsdl:port></wsdl:service></wsdl:definitions></wsx:MetadataSection><wsx:MetadataSection Dialect="http://www.w3.org/2001/XMLSchema" Identifier="http://myns/echo" xmlns=""><xs:schema elementFormDefault="qualified" targetNamespace="http://myns/echo" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://myns/echo"><xs:import namespace="http://schemas.datacontract.org/2004/07/"/><xs:element name="Echo"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="msg" nillable="true" type="xs:string"/><xs:element minOccurs="0" name="num" type="xs:int"/><xs:element minOccurs="0" name="d" nillable="true" type="q1:dc" xmlns:q1="http://schemas.datacontract.org/2004/07/"/></xs:sequence></xs:complexType></xs:element><xs:element name="EchoResponse"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="EchoResult" nillable="true" type="xs:string"/></xs:sequence></xs:complexType></xs:element><xs:element name="DoubleIt"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="it" type="xs:int"/><xs:element minOccurs="0" name="prefix" nillable="true" type="xs:string"/></xs:sequence></xs:complexType></xs:element><xs:element name="DoubleItResponse"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="DoubleItResult" nillable="true" type="xs:string"/></xs:sequence></xs:complexType></xs:element></xs:schema></wsx:MetadataSection><wsx:MetadataSection Dialect="http://www.w3.org/2001/XMLSchema" Identifier="http://schemas.microsoft.com/2003/10/Serialization/" xmlns=""><xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/"><xs:element name="anyType" nillable="true" type="xs:anyType"/><xs:element name="anyURI" nillable="true" type="xs:anyURI"/><xs:element name="base64Binary" nillable="true" type="xs:base64Binary"/><xs:element name="boolean" nillable="true" type="xs:boolean"/><xs:element name="byte" nillable="true" type="xs:byte"/><xs:element name="dateTime" nillable="true" type="xs:dateTime"/><xs:element name="decimal" nillable="true" type="xs:decimal"/><xs:element name="double" nillable="true" type="xs:double"/><xs:element name="float" nillable="true" type="xs:float"/><xs:element name="int" nillable="true" type="xs:int"/><xs:element name="long" nillable="true" type="xs:long"/><xs:element name="QName" nillable="true" type="xs:QName"/><xs:element name="short" nillable="true" type="xs:short"/><xs:element name="string" nillable="true" type="xs:string"/><xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte"/><xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt"/><xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong"/><xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort"/><xs:element name="char" nillable="true" type="tns:char"/><xs:simpleType name="char"><xs:restriction base="xs:int"/></xs:simpleType><xs:element name="duration" nillable="true" type="tns:duration"/><xs:simpleType name="duration"><xs:restriction base="xs:duration"><xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/><xs:minInclusive value="-P10675199DT2H48M5.4775808S"/><xs:maxInclusive value="P10675199DT2H48M5.4775807S"/></xs:restriction></xs:simpleType><xs:element name="guid" nillable="true" type="tns:guid"/><xs:simpleType name="guid"><xs:restriction base="xs:string"><xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/></xs:restriction></xs:simpleType><xs:attribute name="FactoryType" type="xs:QName"/></xs:schema></wsx:MetadataSection><wsx:MetadataSection Dialect="http://www.w3.org/2001/XMLSchema" Identifier="http://schemas.datacontract.org/2004/07/" xmlns=""><xs:schema elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/"><xs:complexType name="dc"><xs:sequence><xs:element minOccurs="0" name="field" nillable="true" type="xs:string"/></xs:sequence></xs:complexType><xs:element name="dc" nillable="true" type="tns:dc"/></xs:schema></wsx:MetadataSection></Metadata></s:Body></s:Envelope>
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ActionFilterTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ActionFilterTest.cs
new file mode 100644 (file)
index 0000000..cb07d26
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// ActionMessageFilterTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.Text;
+using NUnit.Framework;
+
+using Element = System.ServiceModel.Channels.TextMessageEncodingBindingElement;
+
+namespace MonoTests.System.ServiceModel.Dispatcher
+{
+       [TestFixture]
+       public class ActionMessageFilterTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNull ()
+               {
+                       new ActionMessageFilter (null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNull2 ()
+               {
+                       new ActionMessageFilter ("foo", null);
+               }
+
+               [Test]
+               public void Match ()
+               {
+                       ActionMessageFilter f = new ActionMessageFilter ("foo");
+                       Assert.AreEqual (1, f.Actions.Count, "#1");
+                       Message msg = Message.CreateMessage (MessageVersion.Default, "foo");
+                       Assert.AreEqual ("foo", msg.Headers.Action, "#2");
+                       Assert.IsTrue (f.Match (msg), "#3");
+                       msg = Message.CreateMessage (MessageVersion.Default, "bar");
+                       Assert.IsFalse (f.Match (msg), "#4");
+
+                       f = new ActionMessageFilter ("foo", "bar");
+                       Assert.AreEqual (2, f.Actions.Count, "#5");
+                       Assert.IsTrue (f.Match (msg), "#6");
+               }
+
+/*
+               [Test]
+               public void CreateMessageFilterTable ()
+               {
+                       ActionMessageFilter f = new ActionMessageFilter ("foo");
+                       IMessageFilterTable<int> t = f.CreateFilterTable<int> ();
+                       Assert.AreEqual (0, t.Count, "#1");
+
+                       t.Add (f, 0);
+                       Assert.AreEqual (1, t.Count, "#2");
+               }
+*/
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ChangeLog b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ChangeLog
new file mode 100644 (file)
index 0000000..244d042
--- /dev/null
@@ -0,0 +1,50 @@
+2008-05-22  Roei Erez  <roeie@mainsoft.com>
+       * fix ContractDescription.GetContract implementation
+       * Refactor Request processing
+       * Add support for message inspectors
+       * Add support for InstanceContextProvider & InstanceProvider, including lifecycles events
+       like: ReleaseServiceInstance, Open, Close...
+       * Add relevant test cases.
+
+2008-04-08  Roei Erez <roeie@mainsoft.com>
+       * Add tests ChannelDispatcherTest, EndpointDispatcherTest
+
+2008-04-06  Roei Erez <roeie@mainsoft.com>
+
+       * EndpointDiaptcher: Added new tests (MessageFilter, ContractFilter)
+
+2008-02-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ExceptionHandlerTest.cs : disabled a test that is not in effect.
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * PrefixEndpointAddressMessageFilterTest.cs : new test (not working).
+
+2006-10-18  Ankit Jain  <jankit@novell.com>
+
+       * EndpointAddressMessageFilterTest.cs (Match): Add more tests.
+
+2006-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressMessageFilterTest.cs : new test.
+       * EndpointDispatcherTest.cs : test type of the filter as well.
+
+2006-08-10  Duncan Mak  <duncan@novell.com>
+
+       * ExceptionHandlerTest.cs: New test.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InvalidBodyAccessExceptionTest.cs, DispatchOperationTest.cs :
+         fix tests for beta2. Reduced evil English-only tests.
+
+2006-04-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs : added test to make sure to return
+         ContractDescription for the contract interface, not the actual type.
+
+2006-03-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatchOperationTest.cs DispatchRuntimeTest.cs : new tests.
+
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ChannelDispatcherTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ChannelDispatcherTest.cs
new file mode 100644 (file)
index 0000000..4bedf8b
--- /dev/null
@@ -0,0 +1,155 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Dispatcher;
+
+namespace MonoTests.System.ServiceModel.Dispatcher
+{
+       [TestFixture]
+       public class ChannelDispatcherTest
+       {
+               [Test]                  
+               public void Collection_Add_Remove () {
+                       Console.WriteLine ("STart test Collection_Add_Remove");
+                       ServiceHost h = new ServiceHost (typeof (TestContract), new Uri ("http://localhost:8080"));
+                       h.AddServiceEndpoint (typeof (TestContract).FullName, new BasicHttpBinding (), "address");
+                       MyChannelDispatcher d = new MyChannelDispatcher (new MyChannelListener ());
+                       h.ChannelDispatchers.Add (d);
+                       Assert.IsTrue (d.Attached, "#1");
+                       h.ChannelDispatchers.Remove (d);
+                       Assert.IsFalse (d.Attached, "#2");
+                       h.ChannelDispatchers.Insert (0, d);
+                       Assert.IsTrue (d.Attached, "#3");
+                       h.ChannelDispatchers.Add (new MyChannelDispatcher (new MyChannelListener ()));
+                       h.ChannelDispatchers.Clear ();
+                       Assert.IsFalse (d.Attached, "#4");
+               }
+
+               [Test]
+               [Category("NotWorking")]
+               public void EndpointDispatcherAddTest () {
+                       ServiceHost h = new ServiceHost (typeof (TestContract), new Uri ("http://localhost:8080"));
+                       h.AddServiceEndpoint (typeof (TestContract).FullName, new BasicHttpBinding (), "address");
+                       MyChannelDispatcher d = new MyChannelDispatcher (new MyChannelListener ());                     
+                       d.Endpoints.Add (new EndpointDispatcher (new EndpointAddress (""), "", ""));
+               }
+
+
+               [ServiceContract]
+               public class TestContract
+               {
+                       [OperationContract]
+                       public void Process (string input) {
+                       }
+               }
+
+               class MyChannelDispatcher : ChannelDispatcher
+               {
+                       public bool Attached = false;
+
+                       public MyChannelDispatcher (IChannelListener l) : base (l) { }
+                       protected override void Attach (ServiceHostBase host) {
+                               base.Attach (host);
+                               Attached = true;                                
+                       }
+
+                       protected override void Detach (ServiceHostBase host) {
+                               base.Detach (host);
+                               Attached = false;                               
+                       }
+               }
+
+               class MyChannelListener : IChannelListener
+               {
+                       #region IChannelListener Members
+
+                       public IAsyncResult BeginWaitForChannel (TimeSpan timeout, AsyncCallback callback, object state) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public bool EndWaitForChannel (IAsyncResult result) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public T GetProperty<T> () where T : class {
+                               throw new NotImplementedException ();
+                       }
+
+                       public Uri Uri {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       public bool WaitForChannel (TimeSpan timeout) {
+                               throw new NotImplementedException ();
+                       }
+
+                       #endregion
+
+                       #region ICommunicationObject Members
+
+                       public void Abort () {
+                               throw new NotImplementedException ();
+                       }
+
+                       public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public IAsyncResult BeginClose (AsyncCallback callback, object state) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public IAsyncResult BeginOpen (AsyncCallback callback, object state) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public void Close (TimeSpan timeout) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public void Close () {
+                               throw new NotImplementedException ();
+                       }
+
+                       public event EventHandler Closed;
+
+                       public event EventHandler Closing;
+
+                       public void EndClose (IAsyncResult result) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public void EndOpen (IAsyncResult result) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public event EventHandler Faulted;
+
+                       public void Open (TimeSpan timeout) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public void Open () {
+                               throw new NotImplementedException ();
+                       }
+
+                       public event EventHandler Opened;
+
+                       public event EventHandler Opening;
+
+                       public CommunicationState State {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       #endregion
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/DispatchOperationTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/DispatchOperationTest.cs
new file mode 100644 (file)
index 0000000..5b3eade
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// DispatchOperationTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Dispatcher
+{
+       [TestFixture]
+       public class DispatchOperationTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void TestConstructorNullName ()
+               {
+                       new DispatchOperation (CreateRuntime (), null, null);
+               }
+
+               [Test]
+               public void TestConstructorNullAction ()
+               {
+                       DispatchRuntime r = CreateRuntime ();
+                       // null Action is allowed.
+                       new DispatchOperation (r, String.Empty, null);
+                       // null ReplyAction as well.
+                       new DispatchOperation (r, String.Empty, null, null);
+               }
+
+               [Test]
+               public void TestConstructor ()
+               {
+                       DispatchOperation o = new DispatchOperation (
+                               CreateRuntime (), String.Empty, null, null);
+                       Assert.IsTrue (o.DeserializeRequest, "#1");
+                       Assert.IsTrue (o.SerializeReply, "#2");
+                       Assert.IsNull (o.Formatter, "#3");
+                       // FIXME: FaultDetailTypes -> FaultContractInfos
+                       //Assert.AreEqual (0, o.FaultDetailTypes.Count, "#4");
+                       Assert.IsNull (o.Invoker, "#5");
+                       Assert.IsFalse (o.IsOneWay, "#6");
+                       Assert.IsFalse (o.IsTerminating, "#7");
+                       Assert.IsFalse (o.ReleaseInstanceBeforeCall, "#8");
+                       Assert.IsFalse (o.ReleaseInstanceAfterCall, "#9");
+                       Assert.IsFalse (o.TransactionAutoComplete, "#10");
+                       Assert.IsFalse (o.TransactionRequired, "#11");
+                       Assert.AreEqual (0, o.ParameterInspectors.Count, "#12");
+               }
+
+               DispatchRuntime CreateRuntime ()
+               {
+                       return new EndpointDispatcher (
+                               new EndpointAddress ("http://localhost:8080"), "IFoo", "urn:foo").DispatchRuntime;
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/DispatchRuntimeTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/DispatchRuntimeTest.cs
new file mode 100644 (file)
index 0000000..251e854
--- /dev/null
@@ -0,0 +1,391 @@
+//
+// DispatchRuntimeTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security;
+using System.Xml;
+using NUnit.Framework;
+using System.Collections.ObjectModel;
+using SMMessage = System.ServiceModel.Channels.Message;
+using System.Threading;
+
+namespace MonoTests.System.ServiceModel.Dispatcher
+{
+       [TestFixture]
+       public class DispatchRuntimeTest
+       {
+               [Test]
+               public void TestConstructor ()
+               {
+                       // This test is rather to just detect implementation 
+                       // differences than digging in-depth meanings, so feel
+                       // free to change if MS implementation does not make 
+                       // sense.
+                       DispatchRuntime r = new EndpointDispatcher (
+                               new EndpointAddress ("http://localhost:8080"), "IFoo", "urn:foo").DispatchRuntime;
+                       Assert.AreEqual (AuditLogLocation.Default,
+                                        r.SecurityAuditLogLocation, "#1");
+
+                       Assert.IsTrue (r.AutomaticInputSessionShutdown, "#2");
+                       Assert.IsNotNull (r.CallbackClientRuntime, "#3");
+                       Assert.IsNull (r.ExternalAuthorizationPolicies, "#4");
+                       Assert.IsFalse (r.IgnoreTransactionMessageProperty, "#5");
+                       Assert.IsFalse (r.ImpersonateCallerForAllOperations, "#6");
+                       Assert.AreEqual (0, r.InputSessionShutdownHandlers.Count, "#7");
+                       Assert.AreEqual (0, r.InstanceContextInitializers.Count, "#8");
+                       //Assert.AreEqual (0, r.InstanceContextLifetimes.Count, "#9");
+                       Assert.IsNull (r.InstanceProvider, "#10");
+                       Assert.AreEqual (AuditLevel.None,
+                                        r.MessageAuthenticationAuditLevel, "#11");
+                       Assert.AreEqual (0, r.MessageInspectors.Count, "#12");
+                       Assert.AreEqual (0, r.Operations.Count, "#13");
+                       Assert.IsNull (r.OperationSelector, "#14");
+                       // This is silly, but anyways there will be similar 
+                       // functionality that just represents unix "Groups".
+                       Assert.AreEqual (PrincipalPermissionMode.UseWindowsGroups,
+                                        r.PrincipalPermissionMode, "#15");
+                       Assert.IsFalse (r.ReleaseServiceInstanceOnTransactionComplete, "#16");
+                       Assert.IsNull (r.RoleProvider, "#17");
+                       Assert.AreEqual (AuditLevel.None, r.ServiceAuthorizationAuditLevel, "#18");
+                       Assert.IsNull (r.ServiceAuthorizationManager, "#19");
+                       Assert.IsTrue (r.SuppressAuditFailure, "#20");
+                       Assert.IsNull (r.SynchronizationContext, "#21");
+                       Assert.IsFalse (r.TransactionAutoCompleteOnSessionClose, "#22");
+                       Assert.IsNull (r.Type, "#23");
+                       Assert.IsNotNull (r.UnhandledDispatchOperation, "#24");
+                       DispatchOperation udo = r.UnhandledDispatchOperation;
+                       Assert.AreEqual ("*", udo.Name, "#24-2");
+                       Assert.AreEqual ("*", udo.Action, "#24-3");
+                       Assert.AreEqual ("*", udo.ReplyAction, "#24-4");
+                       Assert.IsFalse (udo.IsOneWay, "#24-5");
+               }
+
+               [Test]
+               public void TestInstanceBehavior1()
+               {
+                       
+                       Result res = new Result ();
+                       MessageInspectBehavior b = new MessageInspectBehavior ();
+                       b.instanceCtxInitializer = new MyInstanceContextInitializer (res);
+                       b.instanceCtxProvider = new MyInstanceContextProvider (null, res);
+                       //b.instanceProvider = new MyInstanceProvider (null, res);
+                       b.msgInspect = new MyMessageInspector (res);
+                       string expected = "GetExistingInstanceContext , InitializeInstanceContext , OperationContext , InstanceContext = Opening , Initialize , OperationContext , InstanceContext = Opening , AfterReceiveRequest , OperationContext , InstanceContext = Opened , BeforeSendReply , OperationContext , InstanceContext = Opened , IsIdle , OperationContext , InstanceContext = Opened , NotifyIdle , OperationContext , InstanceContext = Opened , ";
+                       TestInstanceBehavior (b, expected, res, 1);
+               }
+
+               [Test]          
+               public void TestInstanceBehavior2 () {
+
+                       Result res = new Result ();
+                       MessageInspectBehavior b = new MessageInspectBehavior ();
+                       b.instanceCtxInitializer = new MyInstanceContextInitializer (res);
+                       b.instanceCtxProvider = new MyInstanceContextProvider (null, res);
+                       b.instanceProvider = new MyInstanceProvider (new AllActions (res), res);
+                       b.msgInspect = new MyMessageInspector (res);
+                       string expected = "GetExistingInstanceContext , InitializeInstanceContext , OperationContext , InstanceContext = Opening , Initialize , OperationContext , InstanceContext = Opening , AfterReceiveRequest , OperationContext , InstanceContext = Opened , GetInstance1 , OperationContext , InstanceContext = Opened , BeforeSendReply , OperationContext , InstanceContext = Opened , ReleaseInstance , OperationContext , InstanceContext = Opened , IsIdle , OperationContext , InstanceContext = Opened , NotifyIdle , OperationContext , InstanceContext = Opened , ";
+                       TestInstanceBehavior (b, expected, res, 1);
+               }
+
+               [Test]          
+               public void TestInstanceBehavior3 () {
+
+                       Result res = new Result ();
+                       MessageInspectBehavior b = new MessageInspectBehavior ();
+                       b.instanceCtxInitializer = new MyInstanceContextInitializer (res);
+
+                       InstanceContext c = new InstanceContext (new AllActions (res));
+                       
+                       b.instanceCtxProvider = new MyInstanceContextProvider (c, res);
+                       b.instanceProvider = new MyInstanceProvider (new AllActions (res), res);
+                       b.msgInspect = new MyMessageInspector (res);
+                       string expected = "GetExistingInstanceContext , InitializeInstanceContext , OperationContext , InstanceContext = Opening , Initialize , OperationContext , InstanceContext = Opening , AfterReceiveRequest , OperationContext , InstanceContext = Opened , BeforeSendReply , OperationContext , InstanceContext = Opened , ";
+                       TestInstanceBehavior (b, expected, res, 1);                     
+               }
+
+               [Test]          
+               public void TestInstanceBehavior4 () {
+
+                       Result res = new Result ();
+                       MessageInspectBehavior b = new MessageInspectBehavior ();
+                       b.instanceCtxInitializer = new MyInstanceContextInitializer (res);      
+               
+                       b.instanceCtxProvider = new MyInstanceContextProvider (null, res);
+                       b.instanceProvider = new MyInstanceProvider (new AllActions (res), res);
+                       b.msgInspect = new MyMessageInspector (res);
+                       string expected = "GetExistingInstanceContext , InitializeInstanceContext , OperationContext , InstanceContext = Opening , Initialize , OperationContext , InstanceContext = Opening , AfterReceiveRequest , OperationContext , InstanceContext = Opened , GetInstance1 , OperationContext , InstanceContext = Opened , BeforeSendReply , OperationContext , InstanceContext = Opened , ReleaseInstance , OperationContext , InstanceContext = Opened , IsIdle , OperationContext , InstanceContext = Opened , NotifyIdle , OperationContext , InstanceContext = Opened , GetExistingInstanceContext , InitializeInstanceContext , OperationContext , InstanceContext = Opening , Initialize , OperationContext , InstanceContext = Opening , AfterReceiveRequest , OperationContext , InstanceContext = Opened , GetInstance1 , OperationContext , InstanceContext = Opened , BeforeSendReply , OperationContext , InstanceContext = Opened , ReleaseInstance , OperationContext , InstanceContext = Opened , IsIdle , OperationContext , InstanceContext = Opened , NotifyIdle , OperationContext , InstanceContext = Opened , ";
+                       TestInstanceBehavior (b, expected, res, 2);                     
+               }
+
+               void TestInstanceBehavior (MessageInspectBehavior b, string expected, Result actual, int invocations) {
+                       ServiceHost h = new ServiceHost (typeof (AllActions), new Uri ("http://localhost:8080"));
+                       try {
+                               h.AddServiceEndpoint (typeof (IAllActions).FullName, new BasicHttpBinding (), "AllActions");
+                               h.Description.Behaviors.Add (b);
+                               ServiceDebugBehavior db = h.Description.Behaviors.Find<ServiceDebugBehavior> ();
+                               db.IncludeExceptionDetailInFaults = true;
+                               h.Open ();
+                               AllActionsProxy p = new AllActionsProxy (new BasicHttpBinding (), new EndpointAddress ("http://localhost:8080/AllActions"));
+
+                               for (int i = 0; i < invocations; ++i)
+                                       p.Get (10);
+
+                               //let ther server finish his work
+                               Thread.Sleep (100);
+                               Assert.AreEqual (expected, actual.string_res);
+                       }
+                       finally {                               
+                               h.Close ();
+                       }
+               }
+       }
+
+
+#region helpers
+
+       #region message inspectors
+
+       public class MessageInspectBehavior : IServiceBehavior
+       {
+               public MyMessageInspector msgInspect;
+               public MyInstanceContextProvider instanceCtxProvider;
+               public MyInstanceProvider instanceProvider;
+               public MyInstanceContextInitializer instanceCtxInitializer;
+
+               public void AddBindingParameters (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) {
+                       
+               }
+
+               public void ApplyDispatchBehavior (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) {
+                       ChannelDispatcher d = serviceHostBase.ChannelDispatchers [0] as ChannelDispatcher;
+                       d.Endpoints [0].DispatchRuntime.MessageInspectors.Add (msgInspect);
+                       d.Endpoints [0].DispatchRuntime.InstanceContextProvider = instanceCtxProvider;
+                       d.Endpoints [0].DispatchRuntime.InstanceProvider = instanceProvider;
+                       d.Endpoints [0].DispatchRuntime.InstanceContextInitializers.Add (instanceCtxInitializer);
+               }
+
+               public void Validate (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) {
+                       
+               }
+       }
+
+       public class MyMessageInspector : IDispatchMessageInspector
+       {
+               Result res;
+
+               public MyMessageInspector (Result result) {
+                       res = result;
+               }
+               #region IDispatchMessageInspector Members
+
+               public object AfterReceiveRequest (ref Message request, IClientChannel channel, InstanceContext instanceContext) {
+                       res.string_res += "AfterReceiveRequest , ";
+                       res.AddCurrentOperationContextInfo ();
+                       return null;
+               }
+
+               public void BeforeSendReply (ref Message reply, object correlationState) {
+                       res.string_res += "BeforeSendReply , ";
+                       res.AddCurrentOperationContextInfo ();
+               }
+
+               #endregion
+       }
+
+       #endregion
+
+       #region InstanceProvider
+
+       public class MyInstanceProvider : IInstanceProvider
+       {               
+               object instance;
+               Result res;
+
+               public MyInstanceProvider (object obj, Result result) {
+                       instance = obj;
+                       res = result;
+               }
+
+               #region IInstanceProvider Members
+
+               public object GetInstance (InstanceContext instanceContext, Message message) {
+                       res.string_res += "GetInstance1 , ";
+                       res.AddCurrentOperationContextInfo ();
+                       return instance;
+               }
+
+               public object GetInstance (InstanceContext instanceContext) {
+                       res.string_res += "GetInstance2 , ";
+                       res.AddCurrentOperationContextInfo ();
+                       return instance;
+               }
+
+               public void ReleaseInstance (InstanceContext instanceContext, object instance) {
+                       res.string_res += "ReleaseInstance , ";
+                       res.AddCurrentOperationContextInfo ();
+               }
+
+               #endregion
+       }
+
+       #endregion
+
+       #region InstanceContextProvider
+
+       public class MyInstanceContextProvider : IInstanceContextProvider
+       {
+
+               InstanceContext existing;
+               Result res;
+
+               public MyInstanceContextProvider (InstanceContext exist, Result result) {
+                       existing = exist;
+                       res = result;
+               }
+
+               #region IInstanceContextProvider Members
+
+               public InstanceContext GetExistingInstanceContext (Message message, IContextChannel channel) {
+                       res.string_res += "GetExistingInstanceContext , ";
+                       res.AddCurrentOperationContextInfo ();
+                       return existing;
+               }
+
+               public void InitializeInstanceContext (InstanceContext instanceContext, Message message, IContextChannel channel) {
+                       res.string_res += "InitializeInstanceContext , ";
+                       res.AddCurrentOperationContextInfo ();
+               }
+
+               public bool IsIdle (InstanceContext instanceContext) {
+                       res.string_res += "IsIdle , ";
+                       res.AddCurrentOperationContextInfo ();
+                       return false;
+               }
+
+               public void NotifyIdle (InstanceContextIdleCallback callback, InstanceContext instanceContext) {
+                       res.string_res += "NotifyIdle , ";
+                       res.AddCurrentOperationContextInfo ();                  
+               }
+
+               #endregion
+       }
+
+       #endregion
+
+       #region InstanceContextInitializer
+
+       public class MyInstanceContextInitializer : IInstanceContextInitializer
+       {
+               Result res;
+
+               public MyInstanceContextInitializer (Result result) {
+                       res = result;
+               }
+
+               public void Initialize (InstanceContext instanceContext, Message message) {
+                       res.string_res += "Initialize , ";
+                       res.AddCurrentOperationContextInfo ();
+               }
+       }
+
+       #endregion
+
+       #region Helpers
+
+       public class Result
+       {
+               public string string_res = "";
+
+               public void AddCurrentOperationContextInfo()
+               {
+                       if (OperationContext.Current != null) {
+                               string_res += "OperationContext , ";
+                               if (OperationContext.Current.InstanceContext != null) {
+                                       string_res += ("InstanceContext = " + OperationContext.Current.InstanceContext.State + " , ");
+                                       //if (OperationContext.Current.InstanceContext != null)
+                                       //    string_res += ("Instance = " + OperationContext.Current.InstanceContext.GetServiceInstance () + " , ");
+                               }
+                       }
+               }
+       }
+
+       class AllActions : IAllActions, IDisposable
+       {
+               Result res;
+
+               public AllActions () { }
+
+               public AllActions (Result result) {
+                       res = result;
+               }
+
+               [OperationBehavior (ReleaseInstanceMode = ReleaseInstanceMode.BeforeAndAfterCall)]
+               public int Get(int i)
+               {
+                       return i;
+               }
+
+               public void Dispose () {
+                       if (res != null)
+                               res.string_res += "Disposed , ";
+               }
+       }
+
+       [ServiceContract (Namespace = "http://MonoTests.System.ServiceModel.Dispatcher")]
+       public interface IAllActions
+       {               
+               [OperationContract]             
+               int Get(int i);
+       }
+
+       #endregion
+
+       #region ClientProxy
+       
+       public class AllActionsProxy : ClientBase<IAllActions>, IAllActions
+       {
+               public AllActionsProxy (Binding binding, EndpointAddress remoteAddress) :
+                       base (binding, remoteAddress)
+               {
+               }
+
+               public int Get (int i) {
+                       return base.Channel.Get (i);
+               }
+       }       
+
+       #endregion
+#endregion
+
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/EndpointAddressMessageFilterTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/EndpointAddressMessageFilterTest.cs
new file mode 100644 (file)
index 0000000..b3859f2
--- /dev/null
@@ -0,0 +1,82 @@
+//
+// EndpointAddressMessageFilterTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Dispatcher
+{
+       [TestFixture]
+       public class EndpointAddressMessageFilterTest
+       {
+               const string anonymous_uri = "http://www.w3.org/2005/08/addressing/anonymous";
+
+               static Message CreateMessageWithTo (string to)
+               {
+                       return CreateMessageWithTo (new Uri (to));
+               }
+
+               static Message CreateMessageWithTo (Uri to)
+               {
+                       Message msg = Message.CreateMessage (MessageVersion.Default, "urn:myaction");
+                       msg.Headers.Add (MessageHeader.CreateHeader ("To", "http://www.w3.org/2005/08/addressing", to));
+                       return msg;
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void Match ()
+               {
+                       EndpointAddressMessageFilter f =
+                               new EndpointAddressMessageFilter (new EndpointAddress ("http://localhost:8080"));
+                       Assert.IsTrue (f.Match (CreateMessageWithTo ("http://localhost:8080")), "#1");
+                       Assert.IsTrue (f.Match (CreateMessageWithTo (new Uri ("http://localhost:8080"))), "#1-2");
+                       Assert.IsFalse (f.Match (CreateMessageWithTo (anonymous_uri)), "#2");
+                       Assert.IsFalse (f.Match (CreateMessageWithTo (EndpointAddress.AnonymousUri)), "#3");
+                       Assert.IsFalse (f.Match (CreateMessageWithTo (EndpointAddress.NoneUri)), "#4");
+                       // no To header
+                       Assert.IsFalse (f.Match (Message.CreateMessage (MessageVersion.Default, "urn:myaction")), "#5");
+                       
+                       Assert.IsTrue (f.Match (CreateMessageWithTo ("http://10.1.1.1:8080")), "#6");
+                       Assert.IsFalse (f.Match (CreateMessageWithTo ("http://10.1.1.1:8081")), "#7");
+
+                       f = new EndpointAddressMessageFilter (new EndpointAddress ("http://localhost:8080/abc"), true);
+                       Assert.IsFalse (f.Match (CreateMessageWithTo ("http://127.0.0.2:8080/abc")), "#8");
+
+                       Assert.IsTrue (f.Match (CreateMessageWithTo ("http://localhost:8080/abc?wsdl")), "#9");
+
+                       f = new EndpointAddressMessageFilter (new EndpointAddress ("http://localhost:8080/abc?foo"), true);
+                       Assert.IsTrue (f.Match (CreateMessageWithTo ("http://localhost:8080/abc?wsdl")), "#10");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/EndpointDispatcherTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/EndpointDispatcherTest.cs
new file mode 100644 (file)
index 0000000..d6c86f5
--- /dev/null
@@ -0,0 +1,111 @@
+//
+// EndpointDispatcherTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using NUnit.Framework;
+using SMMessage = System.ServiceModel.Channels.Message;
+
+namespace MonoTests.System.ServiceModel.Dispatcher
+{
+       [TestFixture]
+       public class EndpointDispatcherTest
+       {
+               [Test]
+               public void Ctor ()
+               {
+                       EndpointDispatcher d = new EndpointDispatcher (
+                               new EndpointAddress ("localhost:8080"),
+                               "test", "urn:foo");
+                       // properties at the Created state.
+                       Assert.IsTrue (d.AddressFilter is EndpointAddressMessageFilter, "#1");
+                       Assert.IsNull (d.ChannelDispatcher, "#2");
+                       Assert.IsNotNull (d.ContractFilter, "#3");
+                       Assert.AreEqual ("test", d.ContractName, "#4");
+                       Assert.AreEqual ("urn:foo", d.ContractNamespace, "#5");
+                       Assert.IsNotNull (d.DispatchRuntime, "#6");
+                       Assert.AreEqual (
+                               new EndpointAddress ("localhost:8080"),
+                               d.EndpointAddress, "#7");
+                       Assert.AreEqual (0, d.FilterPriority, "#8");
+
+                       Assert.IsNull (d.DispatchRuntime.OperationSelector, "#2-1");
+                       Assert.AreEqual (0, d.DispatchRuntime.Operations.Count, "#2-2");
+               }
+
+               [Test]
+               public void MatchTest () {
+                       EndpointDispatcher d = new EndpointDispatcher (
+                               new EndpointAddress ("http://localhost:8000"), "test", "http://MonoTests.Tests");
+                       Message mess = Message.CreateMessage (MessageVersion.Default, "action1", (object)null);
+                       mess.Headers.To = new Uri ("http://localhost:8000");
+                       Assert.IsTrue (d.AddressFilter.Match (mess), "#1");
+                       mess.Headers.To = new Uri ("http://localhost:8001");
+                       Assert.IsFalse (d.AddressFilter.Match (mess), "#2");                    
+                       mess.Headers.Action = "Fail";
+                       //MatchAllMessageFilter
+                       Assert.IsTrue (d.ContractFilter.Match (mess), "#3");
+
+                       d.ContractFilter = new ActionMessageFilter ("action1");
+                       Assert.IsFalse (d.ContractFilter.Match (mess), "#4");
+                       mess.Headers.Action = "action1";
+                       Assert.IsTrue (d.ContractFilter.Match (mess), "#5");                    
+               }
+
+               [Test]
+               public void ActionMessageFilterTest () {
+                       ServiceHost h = new ServiceHost (typeof (SpecificAction), new Uri ("http://localhost:8000"));
+                       EndpointDispatcher ed = new EndpointDispatcher (new EndpointAddress ("http://localhost:8000/address"),
+                                                       typeof (SpecificAction).FullName,
+                                                       typeof (SpecificAction).Namespace);
+                       Assert.IsTrue (ed.ContractFilter is MatchAllMessageFilter, "#1");
+               }
+
+               [Test]          
+               public void DispatchRuntimeProperty () {
+                       ServiceHost h = new ServiceHost (typeof (SpecificAction), new Uri ("http://localhost:8000"));
+                       EndpointDispatcher ed = new EndpointDispatcher (new EndpointAddress ("http://localhost:8000/address"),
+                                                       typeof (SpecificAction).FullName,
+                                                       typeof (SpecificAction).Namespace);
+                       Assert.IsNotNull (ed.DispatchRuntime, "#1");
+               }
+
+               [ServiceContract]
+               class SpecificAction
+               {
+                       [OperationContract (Action = "Specific", ReplyAction = "*")]
+                       public SMMessage Get (SMMessage req) {
+                               return null;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ExceptionHandlerTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/ExceptionHandlerTest.cs
new file mode 100644 (file)
index 0000000..476bb6a
--- /dev/null
@@ -0,0 +1,64 @@
+//
+// ExceptionHandlerTest.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Runtime.ConstrainedExecution;
+using System.ServiceModel.Dispatcher;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Dispatcher {
+
+       [TestFixture]
+       public class ExceptionHandlerTest
+       {
+               [Test]
+               public void Ctor ()
+               {
+                       Assert.IsTrue (ExceptionHandler.AlwaysHandle.HandleException (new Exception ()),
+                                      "AlwaysHandle");
+                       Assert.IsNull (ExceptionHandler.AsynchronousThreadExceptionHandler,
+                                      "AsynchronousThreadExceptionHandler");
+                       Assert.IsTrue (ExceptionHandler.TransportExceptionHandler.HandleException (new Exception ()),
+                                      "TransportExceptionHandler");
+               }
+
+               [Test]
+               [Ignore ("Wrong. Also, we don't have CER")]
+               public void AsynchronousThreadExceptionHandler ()
+               {
+                       PropertyInfo p = typeof (ExceptionHandler).GetProperty ("AsynchronousThreadExceptionHandler");
+                       object [] attrs = p.GetGetMethod ().GetCustomAttributes (false);
+                       ReliabilityContractAttribute attr = attrs [0] as ReliabilityContractAttribute;
+                       
+                       Assert.AreEqual (1, attrs.Length, "Contains only 1 attribute");
+                       Assert.AreEqual (Cer.Success, attr.Cer,  "attribute value #1");
+                       Assert.AreEqual (Consistency.WillNotCorruptState,
+                                        attr.ConsistencyGuarantee, "attribute value #2");
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/FilterTableTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/FilterTableTest.cs
new file mode 100644 (file)
index 0000000..0ec6582
--- /dev/null
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Dispatcher;
+using System.Text;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Dispatcher
+{
+       [TestFixture]
+       public class MessageFilterTableTest
+       {
+               [Test]
+               public void TestGetPriority ()
+               {
+                       MessageFilterTable<int> table = new MessageFilterTable<int> ();
+                       MessageFilter f = new XPathMessageFilter ();
+
+                       table.Add (f, 0);
+
+                       Console.WriteLine (table.GetPriority (f));
+               }
+               [Test]
+               public void TestAdd ()
+               {
+                       Console.WriteLine ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/InvalidBodyAccessExceptionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/InvalidBodyAccessExceptionTest.cs
new file mode 100644 (file)
index 0000000..ccee65e
--- /dev/null
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.ServiceModel.Dispatcher;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Dispatcher
+{
+       [TestFixture]
+       public class InvalidBodyAccessExceptionTest
+       {
+               [Test]
+               public void TestConstructor ()
+               {
+                       FilterInvalidBodyAccessException e = new FilterInvalidBodyAccessException ();
+                       NavigatorInvalidBodyAccessException f = new NavigatorInvalidBodyAccessException ();
+                       // Don't expect Engligh.
+                       // Assert.AreEqual ("Not allowed to navigate to body.", e.Message);
+                       Assert.AreEqual (e.Message, f.Message);
+               }
+       }
+}
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/PrefixEndpointAddressMessageFilterTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Dispatcher/PrefixEndpointAddressMessageFilterTest.cs
new file mode 100644 (file)
index 0000000..f531500
--- /dev/null
@@ -0,0 +1,82 @@
+//
+// PrefixEndpointAddressMessageFilterTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2008 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Dispatcher
+{
+       [TestFixture]
+       public class PrefixEndpointAddressMessageFilterTest
+       {
+               const string anonymous_uri = "http://www.w3.org/2005/08/addressing/anonymous";
+
+               static Message CreateMessageWithTo (string to)
+               {
+                       return CreateMessageWithTo (new Uri (to));
+               }
+
+               static Message CreateMessageWithTo (Uri to)
+               {
+                       Message msg = Message.CreateMessage (MessageVersion.Default, "urn:myaction");
+                       msg.Headers.Add (MessageHeader.CreateHeader ("To", "http://www.w3.org/2005/08/addressing", to));
+                       return msg;
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void Match ()
+               {
+                       PrefixEndpointAddressMessageFilter f =
+                               new PrefixEndpointAddressMessageFilter (new EndpointAddress ("http://localhost:8080"));
+                       Assert.IsTrue (f.Match (CreateMessageWithTo ("http://localhost:8080")), "#1");
+                       Assert.IsTrue (f.Match (CreateMessageWithTo (new Uri ("http://localhost:8080"))), "#1-2");
+                       Assert.IsTrue (f.Match (CreateMessageWithTo (anonymous_uri)), "#2");
+                       Assert.IsTrue (f.Match (CreateMessageWithTo (EndpointAddress.AnonymousUri)), "#3");
+                       Assert.IsTrue (f.Match (CreateMessageWithTo (EndpointAddress.NoneUri)), "#4");
+                       // no To header
+                       Assert.IsFalse (f.Match (Message.CreateMessage (MessageVersion.Default, "urn:myaction")), "#5");
+                       
+                       Assert.IsTrue (f.Match (CreateMessageWithTo ("http://10.1.1.1:8080")), "#6");
+                       Assert.IsTrue (f.Match (CreateMessageWithTo ("http://10.1.1.1:8081")), "#7");
+
+                       f = new PrefixEndpointAddressMessageFilter (new EndpointAddress ("http://localhost:8080/abc"), true);
+                       Assert.IsFalse (f.Match (CreateMessageWithTo ("http://127.0.0.2:8080/abc")), "#8");
+
+                       Assert.IsTrue (f.Match (CreateMessageWithTo ("http://localhost:8080/abc?wsdl")), "#9");
+
+                       f = new PrefixEndpointAddressMessageFilter (new EndpointAddress ("http://localhost:8080/abc?foo"), true);
+                       Assert.IsTrue (f.Match (CreateMessageWithTo ("http://localhost:8080/abc?wsdl")), "#10");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.PeerResolvers/CustomPeerResolverServiceTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.PeerResolvers/CustomPeerResolverServiceTest.cs
new file mode 100644 (file)
index 0000000..2a56a62
--- /dev/null
@@ -0,0 +1,197 @@
+// 
+// CustomPeerResolverServiceTest.cs
+// 
+// Author: 
+//     Marcos Cobena (marcoscobena@gmail.com)
+// 
+// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
+// 
+
+using System;
+using System.Collections.Generic;
+using System.ServiceModel.PeerResolvers;
+using System.Text;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.PeerResolvers
+{
+    [TestFixture]
+    public class CustomPeerResolverServiceTest
+    {
+        private CustomPeerResolverService cprs;
+
+        [SetUp]
+        protected void SetUp ()
+        {
+            cprs = new CustomPeerResolverService ();
+        }
+
+        [Test]
+        public void CloseTest ()
+        {
+            cprs.Open ();
+            cprs.Close ();
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void CloseTest1 ()
+        {
+            cprs.Close ();
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void GetServiceSettingsTest ()
+        {
+            ServiceSettingsResponseInfo ssri;
+
+            ssri = cprs.GetServiceSettings ();
+        }
+
+        [Test]
+        public void OpenTest ()
+        {
+            cprs.Open ();
+        }
+
+        [Test]
+        [ExpectedException (typeof (ArgumentException))]
+        public void OpenTest1 ()
+        {
+            cprs.CleanupInterval = TimeSpan.Zero;
+            cprs.Open ();
+        }
+
+        [Test]
+        [ExpectedException (typeof (ArgumentException))]
+        public void OpenTest2 ()
+        {
+            cprs.RefreshInterval = TimeSpan.Zero;
+            cprs.Open ();
+        }
+
+        [Test]
+        [ExpectedException (typeof (ArgumentException))]
+        public void OpenTest3 ()
+        {
+            cprs.CleanupInterval = TimeSpan.Zero;
+            cprs.RefreshInterval = TimeSpan.Zero;
+            cprs.Open ();
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void OpenTest4 ()
+        {
+            cprs.Open ();
+            cprs.Open ();
+        }
+
+        [Test]
+        [ExpectedException (typeof (ArgumentException))]
+        public void RefreshTest ()
+        {
+            cprs.Refresh (null);
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void RefreshTest1 ()
+        {
+            cprs.Refresh (new RefreshInfo ());
+        }
+
+        //[Test]
+        //public void RefreshTest2 ()
+        //{
+        //    cprs.Open ();
+        //    cprs.Refresh(new RefreshInfo ("foo", new Guid ()));
+        //}
+
+        [Test]
+        [ExpectedException (typeof( ArgumentException))]
+        public void RegisterTest ()
+        {
+            cprs.Register (null);
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void RegisterTest1 ()
+        {
+            cprs.Register (new RegisterInfo ());
+        }
+
+        //[Test]
+        //public void RegisterTest2 ()
+        //{
+        //    cprs.Open ();
+        //    cprs.Register(new RegisterInfo ());
+        //}
+
+        [Test]
+        [ExpectedException (typeof (ArgumentException))]
+        public void ResolveTest ()
+        {
+            cprs.Resolve (null);
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void ResolveTest1 ()
+        {
+            cprs.Resolve (new ResolveInfo ());
+        }
+
+        //[Test]
+        //public void ResolveTest2 ()
+        //{
+        //    cprs.Open ();
+        //    cprs.Resolve (new ResolveInfo ());
+        //}
+
+        [Test]
+        [ExpectedException (typeof (ArgumentException))]
+        public void UnregisterTest ()
+        {
+            cprs.Unregister (null);
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void UnregisterTest1 ()
+        {
+            cprs.Unregister (new UnregisterInfo ());
+        }
+
+        //[Test]
+        //public void UnregisterTest2 ()
+        //{
+        //    cprs.Open ();
+        //    cprs.Unregister (new UnregisterInfo ());
+        //}
+
+        [Test]
+        [ExpectedException (typeof (ArgumentException))]
+        public void UpdateTest ()
+        {
+            cprs.Update (null);
+        }
+
+        [Test]
+        [ExpectedException (typeof (InvalidOperationException))]
+        public void UpdateTest1 ()
+        {
+            cprs.Update (new UpdateInfo ());
+        }
+
+        //[Test]
+        //public void UpdateTest2 ()
+        //{
+        //    cprs.Open ();
+        //    cprs.Update (new UpdateInfo ());
+        //}
+    }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/ChangeLog b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/ChangeLog
new file mode 100755 (executable)
index 0000000..5202ce4
--- /dev/null
@@ -0,0 +1,164 @@
+2007-04-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenParametersTest.cs :
+         added test for CreateRequestParameters().
+
+2007-04-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenParametersTest.cs : test both anonymous and mutual
+         sslnego provider creation (error) for recipient.
+
+2007-03-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SspiSecurityTokenParametersTest.cs : Added test for security
+         token provider as a communication object.
+         Added test for authenticator.
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenParametersTest.cs : test for creating key clause
+         for SCT.
+       * SecurityContextSecurityTokenTest.cs : new test, for SCT.
+
+2007-03-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenParametersTest.cs : for requirement initialization,
+         test IssuedSecurityTokenParametersProperty existence.
+
+2007-03-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenParametersTest.cs : warning fixes. Test for
+         creating recipient provider (looks like unsupported).
+
+2007-02-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityTokenTest.cs : test GetWrappedKey() value
+         (identical to the raw key only when decrypted).
+
+2007-02-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityTokenTest.cs : added test for 
+         CreateKeyIdentifierClause() (don't return input identifiers).
+
+2007-02-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityTokenTest.cs : added tests for keywrap algorithm
+         [in]consistency.
+
+2007-01-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WrappedKeySecurityTokenTest.cs : new test.
+
+2006-12-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureConversationSecurityTokenParametersTest.cs :
+         test ChannelProtectionRequirements properties.
+
+2006-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * X509SecurityTokenParametersTest.cs :
+         Added case for InclusionMode.Never.
+
+2006-10-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * X509ListedCertificateValidator.cs : new file to support some
+         x509 channel validation tests.
+
+2006-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UserNameSecurityTokenParametersTest.cs : added tests for
+         CreateSecurityKeyIdentifierClause().
+
+2006-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenParametersTest.cs,
+       * SslSecurityTokenParametersTest.cs : more property value tests.
+
+2006-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenParametersTest.cs : tiny namespace fix.
+
+2006-09-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * X509SecurityTokenParametersTest.cs :
+         added test for CreateKeyIdentifierClause().
+
+2006-08-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UserNameSecurityTokenParametersTest.cs,
+         X509SecurityTokenParametersTest.cs : new tests.
+
+2006-08-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SslSecurityTokenParametersTest.cs : new test.
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureConversationSecurityTokenParametersTest.cs :
+         test for InitializeSecurityTokenRequirement(), but not working now.
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecureConversationSecurityTokenParametersTest.cs : new test.
+
+2006-08-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProviderTest.cs : split input verification test
+         to two parts, and (will) generate reply source only in the second
+         one. Added todo for entropy test.
+
+2006-08-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProviderTest.cs : I found out how to avoid
+         DerivedKeyToken. The input verification will go well.
+
+2006-08-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceModelSecurityTokenTypesTest.cs : new test (for constants).
+
+2006-08-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProviderTest.cs : added some attempt to
+         decrypt the secure message, but no luck yet. It already spent
+         my two days :-(
+
+2006-08-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProviderTest.cs : added some comments.
+
+2006-08-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProviderTest.cs : added GetTokenUnsignedReply ().
+         In VerifyInput() use MessageBuffer.
+
+2006-08-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProviderTest.cs : changes caused by
+         HandlerTransportBindingElement changes.
+
+2006-08-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProviderTest.cs : removed some NotWorking.
+
+2006-08-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProviderTest.cs : some minor refactoring.
+
+2006-08-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProviderTest.cs : more GetToken() tests for
+         several condition.
+
+2006-08-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProviderTest.cs : added some GetToken() tests to
+         check premises.
+
+2006-08-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenProviderTest.cs : new test.
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IssuedSecurityTokenParametersTest.cs,
+         SecurityTokenParametersTest.cs : new files.
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/IssuedSecurityTokenParametersTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/IssuedSecurityTokenParametersTest.cs
new file mode 100644 (file)
index 0000000..20007ca
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// IssuedSecurityTokenParametersTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class IssuedSecurityTokenParametersTest
+       {
+               class MyParameters : IssuedSecurityTokenParameters
+               {
+                       public bool HasAsymmetricKeyEx {
+                               get { return HasAsymmetricKey; }
+                       }
+
+                       public bool SupportsClientAuthenticationEx {
+                               get { return SupportsClientAuthentication; }
+                       }
+
+                       public bool SupportsClientWindowsIdentityEx {
+                               get { return SupportsClientWindowsIdentity; }
+                       }
+
+                       public bool SupportsServerAuthenticationEx {
+                               get { return SupportsServerAuthentication; }
+                       }
+
+                       public SecurityKeyIdentifierClause CallCreateKeyIdentifierClause (
+                               SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+                       {
+                               return CreateKeyIdentifierClause (token, referenceStyle);
+                       }
+
+                       public void InitRequirement (SecurityTokenRequirement requirement)
+                       {
+                               InitializeSecurityTokenRequirement (requirement);
+                       }
+               }
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient, tp.InclusionMode, "#1");
+                       Assert.AreEqual (SecurityTokenReferenceStyle.Internal, tp.ReferenceStyle, "#2");
+                       Assert.AreEqual (true, tp.RequireDerivedKeys, "#3");
+
+                       Assert.AreEqual (false, tp.HasAsymmetricKeyEx, "#4");
+                       Assert.AreEqual (true, tp.SupportsClientAuthenticationEx, "#5");
+                       Assert.AreEqual (false, tp.SupportsClientWindowsIdentityEx, "#6");
+                       Assert.AreEqual (true, tp.SupportsServerAuthenticationEx, "#7");
+
+               }
+
+               [Test]
+               public void CreateRequestParameters ()
+               {
+                       IssuedSecurityTokenParameters p =
+                               new IssuedSecurityTokenParameters ();
+                       p.ClaimTypeRequirements.Add (new ClaimTypeRequirement (ClaimTypes.Name, true));
+                       p.AdditionalRequestParameters.Add (new XmlDocument ()
+                               .CreateElement ("AdditionalFoo"));
+                       Collection<XmlElement> c = p.CreateRequestParameters (
+                               MessageSecurityVersion.Default,
+                               WSSecurityTokenSerializer.DefaultInstance);
+                       StringWriter sw = new StringWriter ();
+                       XmlWriterSettings settings = new XmlWriterSettings ();
+                       settings.OmitXmlDeclaration = true;
+                       foreach (XmlElement el in c) {
+                               XmlWriter w = XmlWriter.Create (sw, settings);
+                               el.WriteTo (w);
+                               w.Close ();
+                       }
+
+                       string expected = @"<t:KeyType xmlns:t='http://schemas.xmlsoap.org/ws/2005/02/trust'>http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey</t:KeyType><t:Claims xmlns:t='http://schemas.xmlsoap.org/ws/2005/02/trust'><wsid:ClaimType Uri='http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name' Optional='true' xmlns:wsid='http://schemas.xmlsoap.org/ws/2005/05/identity' /></t:Claims><AdditionalFoo />";
+                       Assert.AreEqual (expected.Replace ('\'', '"'), sw.ToString ());
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/IssuedSecurityTokenProviderTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/IssuedSecurityTokenProviderTest.cs
new file mode 100644 (file)
index 0000000..16aebab
--- /dev/null
@@ -0,0 +1,622 @@
+//
+// IssuedSecurityTokenProviderTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.IdentityModel.Tokens;
+using System.Text;
+using System.Xml;
+using NUnit.Framework;
+
+using MonoTests.System.ServiceModel.Channels;
+
+namespace MonoTests.System.ServiceModel.Security.Tokens
+{
+       [TestFixture]
+       public class IssuedSecurityTokenProviderTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       IssuedSecurityTokenProvider p =
+                               new IssuedSecurityTokenProvider ();
+                       Assert.AreEqual (true, p.CacheIssuedTokens, "#1");
+                       Assert.AreEqual (TimeSpan.FromMinutes (1), p.DefaultOpenTimeout, "#2");
+                       Assert.AreEqual (TimeSpan.FromMinutes (1), p.DefaultCloseTimeout, "#3");
+                       Assert.IsNotNull (p.IdentityVerifier, "#4");
+                       Assert.AreEqual (60, p.IssuedTokenRenewalThresholdPercentage, "#5");
+                       Assert.IsNull (p.IssuerAddress, "#6");
+                       Assert.AreEqual (0, p.IssuerChannelBehaviors.Count, "#7");
+                       Assert.AreEqual (SecurityKeyEntropyMode.CombinedEntropy, p.KeyEntropyMode, "#8");
+                       Assert.AreEqual (TimeSpan.MaxValue, p.MaxIssuedTokenCachingTime, "#9");
+                       Assert.AreEqual (MessageSecurityVersion.Default,
+                               p.MessageSecurityVersion, "#10");
+                       Assert.IsNull (p.SecurityAlgorithmSuite, "#11");
+                       Assert.IsNull (p.SecurityTokenSerializer, "#12");
+                       Assert.IsNull (p.TargetAddress, "#13");
+                       Assert.AreEqual (true, p.SupportsTokenCancellation, "#14");
+                       Assert.AreEqual (0, p.TokenRequestParameters.Count, "#15");
+                       Assert.IsNull (p.IssuerBinding, "#16");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void OpenWithoutSerializer ()
+               {
+                       IssuedSecurityTokenProvider p =
+                               new IssuedSecurityTokenProvider ();
+                       p.Open ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void OpenWithoutIssuerAddress ()
+               {
+                       IssuedSecurityTokenProvider p =
+                               new IssuedSecurityTokenProvider ();
+                       p.SecurityTokenSerializer = WSSecurityTokenSerializer.DefaultInstance;
+                       p.Open ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void OpenWithoutBinding ()
+               {
+                       IssuedSecurityTokenProvider p =
+                               new IssuedSecurityTokenProvider ();
+                       p.SecurityTokenSerializer = WSSecurityTokenSerializer.DefaultInstance;
+                       p.IssuerAddress = new EndpointAddress ("http://localhost:8080");
+                       p.Open ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void OpenWithoutTargetAddress ()
+               {
+                       IssuedSecurityTokenProvider p =
+                               new IssuedSecurityTokenProvider ();
+                       p.SecurityTokenSerializer = WSSecurityTokenSerializer.DefaultInstance;
+                       p.IssuerAddress = new EndpointAddress ("http://localhost:8080");
+                       p.IssuerBinding = new BasicHttpBinding ();
+
+                       // wiithout it indigo causes NRE
+                       p.SecurityAlgorithmSuite = SecurityAlgorithmSuite.Default;
+                       p.Open ();
+               }
+
+               [Test]
+               public void Open ()
+               {
+                       IssuedSecurityTokenProvider p = SetupProvider (new BasicHttpBinding ());
+                       try {
+                               p.Open ();
+                       } finally {
+                               if (p.State == CommunicationState.Opened)
+                                       p.Close ();
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void GetTokenWithoutOpen ()
+               {
+                       IssuedSecurityTokenProvider p =
+                               new IssuedSecurityTokenProvider ();
+                       p.GetToken (TimeSpan.FromSeconds (10));
+               }
+
+               // From WinFX beta2:
+               // System.ServiceModel.Security.SecurityNegotiationException : 
+               // SOAP security negotiation with 'stream:dummy' for target
+               // 'stream:dummy' failed. See inner exception for more details.
+               // ----> System.InvalidOperationException : The request
+               // message must be protected. This is required by an operation
+               // of the contract ('IWsTrustFeb2005SecurityTokenService',
+               // 'http://tempuri.org/'). The protection must be provided by
+               // the binding ('BasicHttpBinding','http://tempuri.org/').
+               [Test]
+               [ExpectedException (typeof (SecurityNegotiationException))]
+               [Category ("NotWorking")]
+               public void GetTokenNoSecureBinding ()
+               {
+                       IssuedSecurityTokenProvider p = SetupProvider (new BasicHttpBinding ());
+                       try {
+                               p.Open ();
+                               p.GetToken (TimeSpan.FromSeconds (10));
+                       } finally {
+                               if (p.State == CommunicationState.Opened)
+                                       p.Close ();
+                       }
+               }
+
+               [Test]
+               // SymmetricSecurityBindingElement requires protection
+               // token parameters to build a channel or listener factory.
+               [ExpectedException (typeof (SecurityNegotiationException))]
+               [Category ("NotWorking")]
+               public void GetTokenWithoutProtectionTokenParameters ()
+               {
+                       IssuedSecurityTokenProvider p = SetupProvider (CreateIssuerBinding (null, false));
+                       try {
+                               p.Open ();
+                               p.GetToken (TimeSpan.FromSeconds (10));
+                       } finally {
+                               if (p.State == CommunicationState.Opened)
+                                       p.Close ();
+                       }
+               }
+
+               // SecurityNegotiationException (InvalidOperationException (
+               //   "The service certificate is not provided for target
+               //   'stream:dummy'. Specify a service certificate in 
+               //   ClientCredentials."))
+               [Test]
+               [ExpectedException (typeof (SecurityNegotiationException))]
+               [Category ("NotWorking")]
+               public void GetTokenWithoutServiceCertificate ()
+               {
+                       IssuedSecurityTokenProvider p = SetupProvider (CreateIssuerBinding (null, true));
+                       p.IssuerAddress = new EndpointAddress ("stream:dummy");
+                       try {
+                               p.Open (TimeSpan.FromSeconds (5));
+                               p.GetToken (TimeSpan.FromSeconds (10));
+                       } finally {
+                               if (p.State == CommunicationState.Opened)
+                                       p.Close ();
+                       }
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               [ExpectedException (typeof (MyException))]
+               public void GetTokenWrongResponse ()
+               {
+                       IssuedSecurityTokenProvider p = SetupProvider (CreateIssuerBinding (new RequestSender (OnGetTokenWrongResponse), true));
+                       try {
+                               p.Open (TimeSpan.FromSeconds (5));
+                               p.GetToken (TimeSpan.FromSeconds (10));
+                       } finally {
+                               if (p.State == CommunicationState.Opened)
+                                       p.Close ();
+                       }
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               [ExpectedException (typeof (MessageSecurityException))]
+               public void GetTokenUnsignedReply ()
+               {
+                       IssuedSecurityTokenProvider p = SetupProvider (CreateIssuerBinding (new RequestSender (OnGetTokenUnsignedReply), true));
+                       try {
+                               p.Open (TimeSpan.FromSeconds (5));
+                               p.GetToken (TimeSpan.FromSeconds (10));
+                       } finally {
+                               if (p.State == CommunicationState.Opened)
+                                       p.Close ();
+                       }
+               }
+
+               // InnerException: System.InvalidOperationException:
+               // The issuer must provide a computed key in key entropy mode
+               // 'CombinedEntropy'.
+               [Test]
+               [Ignore ("todo")]
+               [ExpectedException (typeof (SecurityNegotiationException))]
+               public void GetTokenNoEntropyInResponseInCombinedMode ()
+               {
+                       // FIXME: implement it after we get working token issuer.
+                       // In the reply, do not include Nonce
+               }
+
+               // on the other hand, in Client entropy mode it must not
+               // provide entropy.
+               [Test]
+               [Ignore ("todo")]
+               [ExpectedException (typeof (SecurityNegotiationException))]
+               public void GetTokenIncludesEntropyInResponseInClientMode ()
+               {
+                       // FIXME: implement it after we get working token issuer.
+                       // specify SecurityKeyEntropyMode.ClientEntropy on 
+                       // client side. And in the reply, include Nonce.
+               }
+
+               [Test]
+               [Ignore ("need to implement response")]
+               [Category ("NotWorking")]
+               public void GetToken ()
+               {
+                       IssuedSecurityTokenProvider p = SetupProvider (CreateIssuerBinding (new RequestSender (OnGetToken), true));
+                       try {
+                               p.Open (TimeSpan.FromSeconds (5));
+                               p.GetToken (TimeSpan.FromSeconds (10));
+                       } finally {
+                               if (p.State == CommunicationState.Opened)
+                                       p.Close ();
+                       }
+               }
+
+               class MyException : Exception
+               {
+               }
+
+               Message OnGetTokenWrongResponse (Message input)
+               {
+                       VerifyInput (input.CreateBufferedCopy (10000));
+
+                       throw new MyException ();
+               }
+
+               Message OnGetTokenUnsignedReply (Message input)
+               {
+                       XmlDocument doc = new XmlDocument ();
+                       doc.LoadXml ("<Response>RESPONSE</Response>");
+
+                       Message msg = Message.CreateMessage (input.Version, "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/IssueResponse", doc.DocumentElement);
+                       msg.Headers.Add (MessageHeader.CreateHeader (
+                               "Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", null, true));
+
+                       return msg;
+               }
+
+               Message OnGetToken (Message input)
+               {
+                       MessageBuffer buf = input.CreateBufferedCopy (10000);
+                       VerifyInput2 (buf);
+
+                       // FIXME: create response message (when I understand what I should return.)
+//                     throw new MyException ();
+//*
+                       XmlDocument doc = new XmlDocument ();
+                       doc.LoadXml ("<Response>RESPONSE</Response>");
+                       X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+                       SignedXml sxml = new SignedXml (doc);
+                       MemoryStream ms = new MemoryStream (new byte [] {1, 2, 3});
+                       sxml.AddReference (new Reference (ms));
+                       sxml.SigningKey = cert.PrivateKey;
+                       sxml.ComputeSignature ();
+
+                       Message msg = Message.CreateMessage (input.Version, "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue", sxml.GetXml ());
+                       msg.Headers.Add (MessageHeader.CreateHeader (
+                               "Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", null, true));
+
+                       return msg;
+//*/
+               }
+
+               void VerifyInput (MessageBuffer buf)
+               {
+                       Message input = buf.CreateMessage ();
+/*
+XmlWriterSettings settings = new XmlWriterSettings ();
+settings.Indent = true;
+using (XmlWriter w = XmlWriter.Create (Console.Error, settings)) {
+buf.CreateMessage ().WriteMessage (w);
+}
+Console.Error.WriteLine ("******************** DONE ********************");
+Console.Error.Flush ();
+*/
+
+                       Assert.AreEqual ("http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue", input.Headers.Action, "GetToken.Request.Action");
+                       Assert.IsNotNull (input.Headers.MessageId, "GetToken.Request.MessageID");
+                       // in the raw Message it is "http://www.w3.org/2005/08/addressing/anonymous", but it is replaced by MessageHeaders implementation.
+                       Assert.AreEqual (new EndpointAddress ("http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/Anonymous"), input.Headers.ReplyTo, "GetToken.Request.ReplyTo");
+
+                       // o:Security
+                       // FIXME: test WSSecurity more
+                       // <o:Security>
+                       //  <u:Timestamp>
+                       //   <u:Created>...</u:Created>
+                       //   <u:Expires>...</u:Expires>
+                       //  </u:Timestamp>
+                       //  <o:BinarySecurityToken>...</o:BinarySecurityToken>
+                       //  <e:EncryptedKey>
+                       //   <e:EncryptionMethod><DigestMethod/></e:EncryptionMethod>
+                       //   <KeyInfo>
+                       //    <o:SecurityTokenReference><o:Reference/></o:SecurityTokenReference>
+                       //   </KeyInfo>
+                       //   <e:CipherData>
+                       //    <e:CipherValue>...</e:CipherValue>
+                       //   </e:CipherData>
+                       //  </e:EncryptedKey>
+                       //  [
+                       //  <c:DerivedKeyToken>
+                       //   <o:SecurityTokenReference><o:Reference/></o:SecurityTokenReference>
+                       //   <c:Offset>...</c:Offset>
+                       //   <c:Length>...</c:Length>
+                       //   <c:Nonce>...</c:Nonce>
+                       //  </c:DerivedKeyToken>
+                       //  ]
+                       //  <e:ReferenceList>
+                       //   [
+                       //   <e:DataReference>
+                       //   ]
+                       //  </e:ReferenceList>
+                       //  <e:EncryptedData>
+                       //   <e:EncryptionMethod/>
+                       //   <KeyInfo> {{....}} </KeyInfo>
+                       //   <e:CipherData> {{....}} </e:CipherData>
+                       //  </e:EncryptedData>
+                       // </o:Security>
+                       int i = input.Headers.FindHeader ("Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
+                       Assert.IsTrue (i >= 0, "Security header existence");
+                       MessageHeaderInfo info = input.Headers [i];
+                       Assert.IsNotNull (info, "Security header item");
+                       XmlReader r = input.Headers.GetReaderAtHeader (i);
+
+                       // FIXME: test WSSecurity more
+                       // <o:Security>
+                       r.MoveToContent ();
+                       r.ReadStartElement ("Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
+                       //  <u:Timestamp>
+                       r.MoveToContent ();
+                       r.ReadStartElement ("Timestamp", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
+                       //   <u:Created>...</u:Created>
+                       r.MoveToContent ();
+                       r.ReadStartElement ("Created", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
+                       r.ReadString ();
+                       r.MoveToContent ();
+                       r.ReadEndElement ();
+                       //   <u:Expires>...</u:Expires>
+                       r.MoveToContent ();
+                       r.ReadStartElement ("Expires", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
+                       r.ReadString ();
+                       r.MoveToContent ();
+                       r.ReadEndElement ();
+                       //  </u:Timestamp>
+                       r.MoveToContent ();
+                       r.ReadEndElement ();
+                       //  <o:BinarySecurityToken>...</o:BinarySecurityToken>
+                       r.MoveToContent ();
+                       r.ReadStartElement ("BinarySecurityToken", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
+                       byte [] rawcert = Convert.FromBase64String (r.ReadString ());
+                       r.ReadEndElement ();
+                       X509Certificate2 cert = new X509Certificate2 (rawcert);
+
+                       // FIXME: test EncryptedKey
+                       r.MoveToContent ();
+                       r.Skip ();
+                       //  <e:EncryptedKey>
+                       //   <e:EncryptionMethod><DigestMethod/></e:EncryptionMethod>
+                       //   <KeyInfo>
+                       //    <o:SecurityTokenReference><o:Reference/></o:SecurityTokenReference>
+                       //   </KeyInfo>
+                       //   <e:CipherData>
+                       //    <e:CipherValue>...</e:CipherValue>
+                       //   </e:CipherData>
+                       //  </e:EncryptedKey>
+
+                       // FIXME: test DerivedKeyTokens
+                       r.MoveToContent ();
+                       while (r.LocalName == "DerivedKeyToken") {
+                               r.Skip ();
+                               r.MoveToContent ();
+                       }
+                       //  [
+                       //  <c:DerivedKeyToken>
+                       //   <o:SecurityTokenReference><o:Reference/></o:SecurityTokenReference>
+                       //   <c:Offset>...</c:Offset>
+                       //   <c:Length>...</c:Length>
+                       //   <c:Nonce>...</c:Nonce>
+                       //  </c:DerivedKeyToken>
+                       //  ]
+                       
+                       //  <e:ReferenceList>
+                       //   [
+                       //   <e:DataReference>
+                       //   ]
+                       //  </e:ReferenceList>
+                       //  <e:EncryptedData>
+                       //   <e:EncryptionMethod/>
+                       //   <KeyInfo> {{....}} </KeyInfo>
+                       //   <e:CipherData> {{....}} </e:CipherData>
+                       //  </e:EncryptedData>
+                       // </o:Security>
+
+                       // SOAP Body
+                       r = input.GetReaderAtBodyContents (); // just verifying itself ;)
+               }
+
+               XmlElement VerifyInput2 (MessageBuffer buf)
+               {
+                       Message msg2 = buf.CreateMessage ();
+                       StringWriter sw = new StringWriter ();
+                       using (XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (sw))) {
+                               msg2.WriteMessage (w);
+                       }
+                       XmlDocument doc = new XmlDocument ();
+                       doc.PreserveWhitespace = true;
+                       doc.LoadXml (sw.ToString ());
+
+                       // decrypt the key with service certificate privkey
+                       PaddingMode mode = PaddingMode.PKCS7; // not sure which is correct ... ANSIX923, ISO10126, PKCS7, Zeros, None.
+                       EncryptedXml encXml = new EncryptedXml (doc);
+                       encXml.Padding = mode;
+                       X509Certificate2 cert2 = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+                       XmlNamespaceManager nsmgr = new XmlNamespaceManager (doc.NameTable);
+                       nsmgr.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
+                       nsmgr.AddNamespace ("c", "http://schemas.xmlsoap.org/ws/2005/02/sc");
+                       nsmgr.AddNamespace ("o", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
+                       nsmgr.AddNamespace ("e", "http://www.w3.org/2001/04/xmlenc#");
+                       nsmgr.AddNamespace ("dsig", "http://www.w3.org/2000/09/xmldsig#");
+                       XmlNode n = doc.SelectSingleNode ("//o:Security/e:EncryptedKey/e:CipherData/e:CipherValue", nsmgr);
+                       Assert.IsNotNull (n, "premise: enckey does not exist");
+                       string raw = n.InnerText;
+                       byte [] rawbytes = Convert.FromBase64String (raw);
+                       RSACryptoServiceProvider rsa = (RSACryptoServiceProvider) cert2.PrivateKey;
+                       byte [] decryptedKey = EncryptedXml.DecryptKey (rawbytes, rsa, true);//rsa.Decrypt (rawbytes, true);
+
+#if false
+                       // create derived keys
+                       Dictionary<string,byte[]> keys = new Dictionary<string,byte[]> ();
+                       InMemorySymmetricSecurityKey skey =
+                               new InMemorySymmetricSecurityKey (decryptedKey);
+                       foreach (XmlElement el in doc.SelectNodes ("//o:Security/c:DerivedKeyToken", nsmgr)) {
+                               n = el.SelectSingleNode ("c:Offset", nsmgr);
+                               int offset = (n == null) ? 0 :
+                                       int.Parse (n.InnerText, CultureInfo.InvariantCulture);
+                               n = el.SelectSingleNode ("c:Length", nsmgr);
+                               int length = (n == null) ? 32 :
+                                       int.Parse (n.InnerText, CultureInfo.InvariantCulture);
+                               n = el.SelectSingleNode ("c:Label", nsmgr);
+                               byte [] label = (n == null) ? decryptedKey :
+                                       Convert.FromBase64String (n.InnerText);
+                               n = el.SelectSingleNode ("c:Nonce", nsmgr);
+                               byte [] nonce = (n == null) ? new byte [0] :
+                                       Convert.FromBase64String (n.InnerText);
+                               byte [] derkey = skey.GenerateDerivedKey (
+                                       //SecurityAlgorithms.Psha1KeyDerivation,
+                                       "http://schemas.xmlsoap.org/ws/2005/02/sc/dk/p_sha1",
+// FIXME: maybe due to the label, this key resolution somehow does not seem to work.
+                                       label,
+                                       nonce,
+                                       length * 8,
+                                       offset);
+
+                               keys [el.GetAttribute ("Id", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd")] = derkey;
+                       }
+#endif
+
+                       // decrypt the signature with the decrypted key
+#if true
+                       n = doc.SelectSingleNode ("//o:Security/e:EncryptedData/e:CipherData/e:CipherValue", nsmgr);
+                       Assert.IsNotNull (n, "premise: encdata does not exist");
+                       raw = n.InnerText;
+                       rawbytes = Convert.FromBase64String (raw);
+                       Rijndael aes = RijndaelManaged.Create ();
+//                     aes.Key = keys [n.SelectSingleNode ("../../dsig:KeyInfo/o:SecurityTokenReference/o:Reference/@URI", nsmgr).InnerText.Substring (1)];
+                       aes.Key = decryptedKey;
+                       aes.Mode = CipherMode.CBC;
+                       aes.Padding = mode;
+                       MemoryStream ms = new MemoryStream ();
+                       CryptoStream cs = new CryptoStream (ms, aes.CreateDecryptor (), CryptoStreamMode.Write);
+                       cs.Write (rawbytes, 0, rawbytes.Length);
+                       cs.Close ();
+                       byte [] decryptedSignature = ms.ToArray ();
+#else
+                       Rijndael aes = RijndaelManaged.Create ();
+//                     aes.Key = keys [n.SelectSingleNode ("../../dsig:KeyInfo/o:SecurityTokenReference/o:Reference/@URI", nsmgr).InnerText.Substring (1)];
+                       aes.Key = decryptedKey;
+                       aes.Mode = CipherMode.CBC;
+                       aes.Padding = mode;
+
+                       EncryptedData ed = new EncryptedData ();
+                       n = doc.SelectSingleNode ("//o:Security/e:EncryptedData", nsmgr);
+                       Assert.IsNotNull (n, "premise: encdata does not exist");
+                       ed.LoadXml (n as XmlElement);
+                       byte [] decryptedSignature = encXml.DecryptData (ed, aes);
+#endif
+//Console.Error.WriteLine (Encoding.UTF8.GetString (decryptedSignature));
+//Console.Error.WriteLine ("============= Decrypted Signature End ===========");
+
+                       // decrypt the body with the decrypted key
+#if true
+                       n = doc.SelectSingleNode ("//s:Body/e:EncryptedData/e:CipherData/e:CipherValue", nsmgr);
+                       Assert.IsNotNull (n, "premise: encdata does not exist");
+                       raw = n.InnerText;
+                       rawbytes = Convert.FromBase64String (raw);
+//                     aes.Key = keys [n.SelectSingleNode ("../../dsig:KeyInfo/o:SecurityTokenReference/o:Reference/@URI", nsmgr).InnerText.Substring (1)];
+                       aes.Key = decryptedKey;
+                       ms = new MemoryStream ();
+                       cs = new CryptoStream (ms, aes.CreateDecryptor (), CryptoStreamMode.Write);
+                       cs.Write (rawbytes, 0, rawbytes.Length);
+                       cs.Close ();
+                       byte [] decryptedBody = ms.ToArray ();
+#else
+                       // decrypt the body with the decrypted key
+                       EncryptedData ed2 = new EncryptedData ();
+                       XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/e:EncryptedData", nsmgr) as XmlElement;
+                       ed2.LoadXml (el);
+//                     aes.Key = keys [n.SelectSingleNode ("../../dsig:KeyInfo/o:SecurityTokenReference/o:Reference/@URI", nsmgr).InnerText.Substring (1)];
+                       aes.Key = decryptedKey;
+                       byte [] decryptedBody = encXml.DecryptData (ed2, aes);
+#endif
+//foreach (byte b in decryptedBody) Console.Error.Write ("{0:X02} ", b);
+Console.Error.WriteLine (Encoding.UTF8.GetString (decryptedBody));
+Console.Error.WriteLine ("============= Decrypted Body End ===========");
+
+                       // FIXME: find out what first 16 bytes mean.
+                       for (int mmm = 0; mmm < 16; mmm++) decryptedBody [mmm] = 0x20;
+                       doc.LoadXml (Encoding.UTF8.GetString (decryptedBody));
+                       Assert.AreEqual ("RequestSecurityToken", doc.DocumentElement.LocalName, "#b-1");
+                       Assert.AreEqual ("http://schemas.xmlsoap.org/ws/2005/02/trust", doc.DocumentElement.NamespaceURI, "#b-2");
+
+                       return doc.DocumentElement;
+               }
+
+               Binding CreateIssuerBinding (RequestSender handler, bool tokenParams)
+               {
+                       SymmetricSecurityBindingElement sbe =
+                               new SymmetricSecurityBindingElement ();
+                       if (tokenParams)
+                               sbe.ProtectionTokenParameters = new X509SecurityTokenParameters ();
+                       sbe.LocalServiceSettings.NegotiationTimeout = TimeSpan.FromSeconds (5);
+                       sbe.KeyEntropyMode = SecurityKeyEntropyMode.ClientEntropy;
+                       //sbe.IncludeTimestamp = false;
+                       //sbe.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
+
+                       // for ease of decryption, let's remove DerivedKeyToken.
+                       sbe.SetKeyDerivation (false);
+
+                       return new CustomBinding (
+//                             new DebugBindingElement (),
+                               sbe,
+                               new TextMessageEncodingBindingElement (),
+                               new HandlerTransportBindingElement (handler));
+               }
+
+               EndpointAddress GetSecureEndpointAddress (string uri)
+               {
+                       return new EndpointAddress (new Uri (uri),
+                               new X509CertificateEndpointIdentity (
+                                       new X509Certificate2 ("Test/Resources/test.pfx", "mono")));
+               }
+
+               IssuedSecurityTokenProvider SetupProvider (Binding binding)
+               {
+                       IssuedSecurityTokenProvider p =
+                               new IssuedSecurityTokenProvider ();
+                       p.SecurityTokenSerializer = WSSecurityTokenSerializer.DefaultInstance;
+                       p.IssuerAddress = GetSecureEndpointAddress ("stream:dummy");
+                       p.IssuerBinding = binding;
+
+                       // wiithout it indigo causes NRE
+                       p.SecurityAlgorithmSuite = SecurityAlgorithmSuite.Default;
+
+                       p.TargetAddress = new EndpointAddress ("http://localhost:9090");
+                       return p;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/RsaSecurityTokenParametersTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/RsaSecurityTokenParametersTest.cs
new file mode 100644 (file)
index 0000000..81c44bd
--- /dev/null
@@ -0,0 +1,122 @@
+//
+// RsaSecurityTokenParametersTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class RsaSecurityTokenParametersTest
+       {
+               class MyRsaSecurityTokenParameters : RsaSecurityTokenParameters
+               {
+                       public bool HasAsymmetricKeyEx {
+                               get { return HasAsymmetricKey; }
+                       }
+
+                       public bool SupportsClientAuthenticationEx {
+                               get { return SupportsClientAuthentication; }
+                       }
+
+                       public bool SupportsClientWindowsIdentityEx {
+                               get { return SupportsClientWindowsIdentity; }
+                       }
+
+                       public bool SupportsServerAuthenticationEx {
+                               get { return SupportsServerAuthentication; }
+                       }
+
+                       public SecurityKeyIdentifierClause CreateKeyClause (
+                               SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+                       {
+                               return CreateKeyIdentifierClause (token, referenceStyle);
+                       }
+
+                       public void InitRequirement (SecurityTokenRequirement requirement)
+                       {
+                               InitializeSecurityTokenRequirement (requirement);
+                       }
+               }
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       MyRsaSecurityTokenParameters tp = new MyRsaSecurityTokenParameters ();
+                       Assert.AreEqual (SecurityTokenInclusionMode.Never, tp.InclusionMode, "#1");
+                       Assert.AreEqual (SecurityTokenReferenceStyle.Internal, tp.ReferenceStyle, "#2");
+                       Assert.AreEqual (true, tp.RequireDerivedKeys, "#3");
+                       Assert.AreEqual (true, tp.HasAsymmetricKeyEx, "#4");
+                       Assert.AreEqual (true, tp.SupportsClientAuthenticationEx, "#5");
+                       Assert.AreEqual (false, tp.SupportsClientWindowsIdentityEx, "#6");
+                       Assert.AreEqual (true, tp.SupportsServerAuthenticationEx, "#7");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CreateKeyIdentifierClauseNullToken ()
+               {
+                       MyRsaSecurityTokenParameters tp = new MyRsaSecurityTokenParameters ();
+                       tp.CreateKeyClause (
+                               null,
+                               SecurityTokenReferenceStyle.External);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateKeyIdentifierClauseWrongToken ()
+               {
+                       MyRsaSecurityTokenParameters tp = new MyRsaSecurityTokenParameters ();
+                       tp.CreateKeyClause (
+                               new UserNameSecurityToken ("mono", "mono"),
+                               SecurityTokenReferenceStyle.External);
+               }
+
+               [Test]
+               public void CreateKeyIdentifierClause ()
+               {
+                       MyRsaSecurityTokenParameters tp = new MyRsaSecurityTokenParameters ();
+                       SecurityKeyIdentifierClause c = tp.CreateKeyClause (
+                               new RsaSecurityToken (RSA.Create ()),
+                               SecurityTokenReferenceStyle.Internal);
+                       Assert.IsTrue (c is RsaKeyIdentifierClause, "#1");
+                       c = tp.CreateKeyClause (
+                               new RsaSecurityToken (RSA.Create ()),
+                               SecurityTokenReferenceStyle.External);
+                       Assert.IsTrue (c is RsaKeyIdentifierClause, "#2");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenParametersTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SecureConversationSecurityTokenParametersTest.cs
new file mode 100644 (file)
index 0000000..b6dcd29
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// SecureConversationSecurityTokenParametersTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+using Parameters = System.ServiceModel.Security.Tokens.SecureConversationSecurityTokenParameters;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class SecureConversationSecurityTokenParametersTest
+       {
+               class MyParameters : Parameters
+               {
+                       public MyParameters ()
+                       {
+                       }
+
+                       public MyParameters (SecurityBindingElement element)
+                               : base (element)
+                       {
+                       }
+
+                       public MyParameters (SecurityBindingElement element,
+                               bool cancel,
+                               ChannelProtectionRequirements requirements)
+                               : base (element, cancel, requirements)
+                       {
+                       }
+
+                       public bool Asym {
+                               get { return HasAsymmetricKey; }
+                       }
+
+                       public bool Client {
+                               get { return SupportsClientAuthentication; }
+                       }
+
+                       public bool Win {
+                               get { return SupportsClientWindowsIdentity; }
+                       }
+
+                       public bool Server {
+                               get { return SupportsServerAuthentication; }
+                       }
+
+                       public void InitRequirement (SecurityTokenRequirement r)
+                       {
+                               InitializeSecurityTokenRequirement (r);
+                       }
+               }
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       MyParameters p = new MyParameters ();
+                       Assert.IsNull (p.BootstrapSecurityBindingElement, "#1-1");
+                       Assert.IsNotNull (p.BootstrapProtectionRequirements, "#1-2");
+                       Assert.AreEqual (true, p.RequireCancellation, "#1-3");
+
+                       Assert.AreEqual (false, p.Asym, "#1-4");
+                       // they cause NRE on winfx, likely a bug.
+                       //Assert.AreEqual (true, p.Client, "#1-5");
+                       //Assert.AreEqual (true, p.Win, "#1-6");
+                       //Assert.AreEqual (true, p.Server, "#1-7");
+
+                       p = new MyParameters (new AsymmetricSecurityBindingElement ());
+                       Assert.IsNotNull (p.BootstrapSecurityBindingElement, "#2-1");
+                       Assert.IsNotNull (p.BootstrapProtectionRequirements, "#2-2");
+                       Assert.AreEqual (true, p.RequireCancellation, "#2-3");
+
+                       Assert.AreEqual (false, p.Asym, "#2-4"); // regardless of binding element.
+                       Assert.AreEqual (false, p.Client, "#2-5");
+                       Assert.AreEqual (false, p.Win, "#2-6");
+                       Assert.AreEqual (false, p.Server, "#2-7");
+
+                       ChannelProtectionRequirements r =
+                               p.BootstrapProtectionRequirements;
+                       Assert.IsTrue (r.IncomingSignatureParts.ChannelParts.IsBodyIncluded, "#3-1");
+                       Assert.IsTrue (r.OutgoingSignatureParts.ChannelParts.IsBodyIncluded, "#3-2");
+                       Assert.IsTrue (r.IncomingEncryptionParts.ChannelParts.IsBodyIncluded, "#3-3");
+                       Assert.IsTrue (r.OutgoingEncryptionParts.ChannelParts.IsBodyIncluded, "#3-4");
+               }
+
+               [Test]
+               public void NullArgs ()
+               {
+                       new Parameters ((SecurityBindingElement) null);
+                       new Parameters (null, false, null);
+               }
+
+               [Test]
+               [Ignore ("winfx bug")]
+               public void InitializeSecurityTokenRequirement ()
+               {
+                       ServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       SymmetricSecurityBindingElement sbe = 
+//                             new SymmetricSecurityBindingElement ();
+                               new WSHttpBinding ().CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       sbe.ProtectionTokenParameters = new X509SecurityTokenParameters ();
+//                     MyParameters p = new MyParameters (sbe);
+                       // NRE occurs on winfx (likely a bug).
+//                     p.InitRequirement (r);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SecurityContextSecurityTokenTest.cs
new file mode 100644 (file)
index 0000000..d8239da
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// SecurityContextSecurityTokenTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class SecurityContextSecurityTokenTest
+       {
+               [Test]
+               public void ConstructorNullPolicies () // allowed
+               {
+                       SecurityContextSecurityToken sct = new SecurityContextSecurityToken (
+                               new UniqueId (), "urn:id-1", new byte [32],
+                               DateTime.MinValue, DateTime.MaxValue,
+                               null);
+                       Assert.IsNotNull (sct.AuthorizationPolicies, "#1");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SecurityTokenParametersTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SecurityTokenParametersTest.cs
new file mode 100644 (file)
index 0000000..195c96e
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// SecurityTokenParametersTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class SecurityTokenParametersTest
+       {
+               class MySecurityTokenParameters : SecurityTokenParameters
+               {
+                       protected override bool HasAsymmetricKey {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       protected override bool SupportsClientAuthentication {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       protected override bool SupportsClientWindowsIdentity {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       protected override bool SupportsServerAuthentication {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       protected override SecurityTokenParameters CloneCore ()
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                               SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+                       {
+                               throw new NotImplementedException ();
+                       }
+               }
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       MySecurityTokenParameters tp = new MySecurityTokenParameters ();
+                       Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient, tp.InclusionMode, "#1");
+                       Assert.AreEqual (SecurityTokenReferenceStyle.Internal, tp.ReferenceStyle, "#2");
+                       Assert.AreEqual (true, tp.RequireDerivedKeys, "#3");
+
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenTypesTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/ServiceModelSecurityTokenTypesTest.cs
new file mode 100644 (file)
index 0000000..045fc91
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// ServiceModelSecurityTokenTypesTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ServiceModelSecurityTokenTypesTest
+       {
+               [Test]
+               public void Strings ()
+               {
+                       Assert.AreEqual ("http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/AnonymousSslnego", ServiceModelSecurityTokenTypes.AnonymousSslnego, "#1");
+                       Assert.AreEqual ("http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/MutualSslnego", ServiceModelSecurityTokenTypes.MutualSslnego, "#2");
+                       Assert.AreEqual ("http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/SecureConversation", ServiceModelSecurityTokenTypes.SecureConversation, "#3");
+                       Assert.AreEqual ("http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/SecurityContextToken", ServiceModelSecurityTokenTypes.SecurityContext, "#4");
+                       Assert.AreEqual ("http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/Spnego", ServiceModelSecurityTokenTypes.Spnego, "#5");
+                       Assert.AreEqual ("http://schemas.microsoft.com/ws/2006/05/servicemodel/tokens/SspiCredential", ServiceModelSecurityTokenTypes.SspiCredential, "#6");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SslSecurityTokenParametersTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SslSecurityTokenParametersTest.cs
new file mode 100644 (file)
index 0000000..6ae0adc
--- /dev/null
@@ -0,0 +1,277 @@
+//
+// SslSecurityTokenParametersTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using NUnit.Framework;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace MonoTests.System.ServiceModel.Security.Tokens
+{
+       [TestFixture]
+       public class SslSecurityTokenParametersTest
+       {
+               class MyParameters : SslSecurityTokenParameters
+               {
+                       public bool HasAsymmetricKeyEx {
+                               get { return HasAsymmetricKey; }
+                       }
+
+                       public bool SupportsClientAuthenticationEx {
+                               get { return SupportsClientAuthentication; }
+                       }
+
+                       public bool SupportsClientWindowsIdentityEx {
+                               get { return SupportsClientWindowsIdentity; }
+                       }
+
+                       public bool SupportsServerAuthenticationEx {
+                               get { return SupportsServerAuthentication; }
+                       }
+
+                       public SecurityKeyIdentifierClause CallCreateKeyIdentifierClause (
+                               SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+                       {
+                               return CreateKeyIdentifierClause (token, referenceStyle);
+                       }
+
+                       public void InitRequirement (SecurityTokenRequirement requirement)
+                       {
+                               InitializeSecurityTokenRequirement (requirement);
+                       }
+               }
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient, tp.InclusionMode, "#1");
+                       Assert.AreEqual (SecurityTokenReferenceStyle.Internal, tp.ReferenceStyle, "#2");
+                       Assert.AreEqual (true, tp.RequireDerivedKeys, "#3");
+
+                       Assert.AreEqual (false, tp.HasAsymmetricKeyEx, "#4");
+                       Assert.AreEqual (false, tp.SupportsClientAuthenticationEx, "#5");
+                       Assert.AreEqual (false, tp.SupportsClientWindowsIdentityEx, "#6");
+                       Assert.AreEqual (true, tp.SupportsServerAuthenticationEx, "#7");
+
+                       Assert.AreEqual (false, tp.RequireCancellation, "#2-1");
+                       Assert.AreEqual (false, tp.RequireClientCertificate, "#2-2");
+               }
+
+               [Test]
+               public void InitializeSecurityTokenParameters ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+
+                       Assert.AreEqual (ServiceModelSecurityTokenTypes.AnonymousSslnego, r.TokenType, "#1");
+                       Assert.AreEqual (false, r.Properties [ReqType.SupportSecurityContextCancellationProperty], "#2");
+                       SslSecurityTokenParameters dummy;
+                       Assert.IsTrue (r.TryGetProperty<SslSecurityTokenParameters> (ReqType.IssuedSecurityTokenParametersProperty, out dummy), "#3");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderNoTargetAddress ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       manager.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderNoSecurityBindingElement ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       manager.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderNoIssuerBindingContext ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       manager.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderNoMessageSecurityVersion ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (),
+                                       new BindingParameterCollection ());
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       manager.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               public void CreateProvider ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (),
+                                       new BindingParameterCollection ());
+                       r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion;
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       manager.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [Ignore ("This ends up to fail to connect. Anyways it's too implementation dependent.")]
+               public void CreateProviderGetToken ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (new HttpTransportBindingElement ()),
+                                       new BindingParameterCollection ());
+                       r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion;
+                       // This is required at GetToken().
+                       r.SecurityAlgorithmSuite = SecurityAlgorithmSuite.Default;
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       // TLS negotiation token provider is created.
+                       SecurityTokenProvider p =
+                               manager.CreateSecurityTokenProvider (r);
+
+                       ((ICommunicationObject) p).Open ();
+
+                       p.GetToken (TimeSpan.FromSeconds (5));
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateRecipientProviderAnonymous ()
+               {
+                       CreateRecipientProviderCore (false);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateRecipientProviderMutual ()
+               {
+                       CreateRecipientProviderCore (true);
+               }
+
+               void CreateRecipientProviderCore (bool mutual)
+               {
+                       MyParameters tp = new MyParameters ();
+                       tp.RequireClientCertificate = true;
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+                       r.ListenUri = new Uri ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (),
+                                       new BindingParameterCollection ());
+                       r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion;
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       manager.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               public void CreateKeyIdentifierClauseSCT ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       SecurityContextSecurityToken sct =
+                               new SecurityContextSecurityToken (new UniqueId (), new byte [32], DateTime.MinValue, DateTime.MaxValue);
+                       SecurityKeyIdentifierClause kic =
+                               tp.CallCreateKeyIdentifierClause (sct, SecurityTokenReferenceStyle.Internal);
+                       Assert.IsTrue (kic is LocalIdKeyIdentifierClause, "#1");
+                       SecurityContextKeyIdentifierClause scic = tp.CallCreateKeyIdentifierClause (sct, SecurityTokenReferenceStyle.External)
+                               as SecurityContextKeyIdentifierClause;
+                       Assert.IsNotNull (scic, "#2");
+                       Assert.IsNull (scic.Generation, "#3");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SspiSecurityTokenParametersTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/SspiSecurityTokenParametersTest.cs
new file mode 100644 (file)
index 0000000..ea3443f
--- /dev/null
@@ -0,0 +1,257 @@
+//
+// SspiSecurityTokenParametersTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace MonoTests.System.ServiceModel.Security.Tokens
+{
+       [TestFixture]
+       public class SspiSecurityTokenParametersTest
+       {
+               class MyParameters : SspiSecurityTokenParameters
+               {
+                       public bool HasAsymmetricKeyEx {
+                               get { return HasAsymmetricKey; }
+                       }
+
+                       public bool SupportsClientAuthenticationEx {
+                               get { return SupportsClientAuthentication; }
+                       }
+
+                       public bool SupportsClientWindowsIdentityEx {
+                               get { return SupportsClientWindowsIdentity; }
+                       }
+
+                       public bool SupportsServerAuthenticationEx {
+                               get { return SupportsServerAuthentication; }
+                       }
+
+                       public SecurityKeyIdentifierClause CallCreateKeyIdentifierClause (
+                               SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+                       {
+                               return CreateKeyIdentifierClause (token, referenceStyle);
+                       }
+
+                       public void InitRequirement (SecurityTokenRequirement requirement)
+                       {
+                               InitializeSecurityTokenRequirement (requirement);
+                       }
+               }
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient, tp.InclusionMode, "#1");
+                       Assert.AreEqual (SecurityTokenReferenceStyle.Internal, tp.ReferenceStyle, "#2");
+                       Assert.AreEqual (true, tp.RequireDerivedKeys, "#3");
+
+                       Assert.AreEqual (false, tp.HasAsymmetricKeyEx, "#4");
+                       Assert.AreEqual (true, tp.SupportsClientAuthenticationEx, "#5");
+                       Assert.AreEqual (true, tp.SupportsClientWindowsIdentityEx, "#6");
+                       Assert.AreEqual (true, tp.SupportsServerAuthenticationEx, "#7");
+
+                       Assert.AreEqual (false, tp.RequireCancellation, "#2-1");
+               }
+
+               [Test]
+               public void InitializeSecurityTokenParameters ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+
+                       Assert.AreEqual (ServiceModelSecurityTokenTypes.Spnego, r.TokenType, "#1");
+                       Assert.AreEqual (false, r.Properties [ReqType.SupportSecurityContextCancellationProperty], "#2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderNoTargetAddress ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       manager.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderNoSecurityBindingElement ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       manager.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderNoIssuerBindingContext ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       //SecurityTokenProvider p =
+                               manager.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderNoMessageSecurityVersion ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (),
+                                       new BindingParameterCollection ());
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       //SecurityTokenProvider p =
+                               manager.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               public void CreateProvider ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (),
+                                       new BindingParameterCollection ());
+                       r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion;
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       //SecurityTokenProvider p =
+                               manager.CreateSecurityTokenProvider (r);
+               }
+
+               void CreateProviderOpenGetToken (bool getToken)
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (new HttpTransportBindingElement ()),
+                                       new BindingParameterCollection ());
+                       r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion;
+                       // This is required at GetToken().
+                       r.SecurityAlgorithmSuite = SecurityAlgorithmSuite.Default;
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+                       // TLS negotiation token provider is created.
+                       SecurityTokenProvider p =
+                               manager.CreateSecurityTokenProvider (r);
+
+                       ((ICommunicationObject) p).Open ();
+
+                       if (!getToken)
+                               return;
+
+                       p.GetToken (TimeSpan.FromSeconds (5));
+               }
+
+               [Test]
+               public void CreateProviderOpen ()
+               {
+                       CreateProviderOpenGetToken (false);
+               }
+
+               [Test]
+               [Ignore ("This ends up to fail to connect. Anyways it's too implementation dependent.")]
+               public void CreateProviderGetToken ()
+               {
+                       CreateProviderOpenGetToken (true);
+               }
+
+               [Test]
+               public void CreateAuthenticator ()
+               {
+                       MyParameters tp = new MyParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       tp.InitRequirement (r);
+
+                       ClientCredentials cred = new ClientCredentials ();
+                       ClientCredentialsSecurityTokenManager manager =
+                               new ClientCredentialsSecurityTokenManager (cred);
+
+                       SecurityTokenResolver resolver;
+//                     SecurityTokenAuthenticator authenticator =
+                               manager.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/UserNameSecurityTokenParametersTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/UserNameSecurityTokenParametersTest.cs
new file mode 100644 (file)
index 0000000..a90fe9e
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// UserNameSecurityTokenParametersTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class UserNameSecurityTokenParametersTest
+       {
+               class MyUserNameSecurityTokenParameters : UserNameSecurityTokenParameters
+               {
+                       public bool HasAsymmetricKeyEx {
+                               get { return HasAsymmetricKey; }
+                       }
+
+                       public bool SupportsClientAuthenticationEx {
+                               get { return SupportsClientAuthentication; }
+                       }
+
+                       public bool SupportsClientWindowsIdentityEx {
+                               get { return SupportsClientWindowsIdentity; }
+                       }
+
+                       public bool SupportsServerAuthenticationEx {
+                               get { return SupportsServerAuthentication; }
+                       }
+
+                       public SecurityKeyIdentifierClause CreateKeyClause (
+                               SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+                       {
+                               return CreateKeyIdentifierClause (token, referenceStyle);
+                       }
+
+                       public void InitRequirement (SecurityTokenRequirement requirement)
+                       {
+                               InitializeSecurityTokenRequirement (requirement);
+                       }
+               }
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       MyUserNameSecurityTokenParameters tp = new MyUserNameSecurityTokenParameters ();
+                       Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient, tp.InclusionMode, "#1");
+                       Assert.AreEqual (SecurityTokenReferenceStyle.Internal, tp.ReferenceStyle, "#2");
+                       Assert.AreEqual (false, tp.RequireDerivedKeys, "#3");
+                       Assert.AreEqual (false, tp.HasAsymmetricKeyEx, "#4");
+                       Assert.AreEqual (true, tp.SupportsClientAuthenticationEx, "#5");
+                       Assert.AreEqual (true, tp.SupportsClientWindowsIdentityEx, "#6");
+                       Assert.AreEqual (false, tp.SupportsServerAuthenticationEx, "#7");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CreateKeyIdentifierClauseNullToken ()
+               {
+                       new MyUserNameSecurityTokenParameters ().CreateKeyClause (null, SecurityTokenReferenceStyle.Internal);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateKeyIdentifierClauseNotSupportedToken ()
+               {
+                       new MyUserNameSecurityTokenParameters ().CreateKeyClause (new RsaSecurityToken (RSA.Create ()), SecurityTokenReferenceStyle.Internal);
+               }
+
+               [Test]
+               public void CreateKeyIdentifierClause ()
+               {
+                       MyUserNameSecurityTokenParameters p =
+                               new MyUserNameSecurityTokenParameters ();
+                       UserNameSecurityToken token =
+                               new UserNameSecurityToken ("mono", "pass");
+                       SecurityKeyIdentifierClause c = p.CreateKeyClause (token, SecurityTokenReferenceStyle.Internal);
+                       Assert.IsTrue (c is LocalIdKeyIdentifierClause, "#1");
+
+                       try {
+                               p.CreateKeyClause (token, SecurityTokenReferenceStyle.External);
+                               Assert.Fail ("External identifier clause cannot be created.");
+                       } catch (NotSupportedException) {
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/WrappedKeySecurityTokenTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/WrappedKeySecurityTokenTest.cs
new file mode 100644 (file)
index 0000000..6b11475
--- /dev/null
@@ -0,0 +1,206 @@
+//
+// WrappedKeySecurityTokenTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class WrappedKeySecurityTokenTest
+       {
+               static readonly X509Certificate2 cert =
+                       new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+
+               WrappedKeySecurityToken GetReferent ()
+               {
+                       string id = "referent";
+                       byte [] key = new byte [32];
+                       X509SecurityToken token = new X509SecurityToken (cert);
+                       SecurityKeyIdentifierClause kic =
+                               new X509ThumbprintKeyIdentifierClause (cert);
+                       string alg = SecurityAlgorithms.RsaOaepKeyWrap;
+                       return new WrappedKeySecurityToken (id, key, alg, token,
+                               new SecurityKeyIdentifier (kic));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorNullId ()
+               {
+                       WrappedKeySecurityToken w = GetReferent ();
+                       new WrappedKeySecurityToken (null, new byte [32],
+                               w.WrappingAlgorithm,
+                               w.WrappingToken,
+                               w.WrappingTokenReference);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorNullKey ()
+               {
+                       WrappedKeySecurityToken w = GetReferent ();
+                       new WrappedKeySecurityToken (w.Id, null,
+                               w.WrappingAlgorithm,
+                               w.WrappingToken,
+                               w.WrappingTokenReference);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorNullWrappingAlgorithm ()
+               {
+                       WrappedKeySecurityToken w = GetReferent ();
+                       new WrappedKeySecurityToken (w.Id, new byte [32],
+                               null,
+                               w.WrappingToken,
+                               w.WrappingTokenReference);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorNullWrappingToken ()
+               {
+                       WrappedKeySecurityToken w = GetReferent ();
+                       new WrappedKeySecurityToken (w.Id, new byte [32],
+                               w.WrappingAlgorithm,
+                               null,
+                               w.WrappingTokenReference);
+               }
+
+               [Test]
+               // null SecurityKeyIdentifier is allowed.
+               //[ExpectedException (typeof (ArgumentNullException))]
+               public void CtorNullWrappingTokenReference ()
+               {
+                       WrappedKeySecurityToken w = GetReferent ();
+                       new WrappedKeySecurityToken (w.Id, new byte [32],
+                               w.WrappingAlgorithm,
+                               w.WrappingToken,
+                               null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void UserNameToken () // it does not support any encryption operation.
+               {
+                       byte [] bytes = new byte [32];
+                       SecurityToken wt = new UserNameSecurityToken ("eno", "enopass");
+                       SecurityKeyIdentifierClause kic =
+                               new X509ThumbprintKeyIdentifierClause (cert);
+                       new WrappedKeySecurityToken ("urn:gyabo",
+                               bytes, SecurityAlgorithms.RsaOaepKeyWrap, wt,
+                               new SecurityKeyIdentifier (kic));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void X509TokenForSymmetricKeyWrap ()
+               {
+                       byte [] bytes = new byte [32];
+                       SecurityToken wt = new X509SecurityToken (cert);
+                       SecurityKeyIdentifierClause kic =
+                               new X509ThumbprintKeyIdentifierClause (cert);
+                       new WrappedKeySecurityToken ("urn:gyabo",
+                               bytes, SecurityAlgorithms.Aes256KeyWrap, wt,
+                               new SecurityKeyIdentifier (kic));
+               }
+
+               [Test]
+               public void BinarySecretTokenForSymmetricKeyWrap ()
+               {
+                       byte [] bytes = new byte [32];
+                       SecurityToken wt = new BinarySecretSecurityToken (bytes);
+                       SecurityKeyIdentifierClause kic =
+                               new X509ThumbprintKeyIdentifierClause (cert);
+                       new WrappedKeySecurityToken ("urn:gyabo",
+                               bytes, SecurityAlgorithms.Aes256KeyWrap, wt,
+                               new SecurityKeyIdentifier (kic));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void BinarySecretTokenForAsymmetricKeyWrap ()
+               {
+                       byte [] bytes = new byte [32];
+                       SecurityToken wt = new BinarySecretSecurityToken (bytes);
+                       SecurityKeyIdentifierClause kic =
+                               new X509ThumbprintKeyIdentifierClause (cert);
+                       new WrappedKeySecurityToken ("urn:gyabo",
+                               bytes, SecurityAlgorithms.RsaOaepKeyWrap, wt,
+                               new SecurityKeyIdentifier (kic));
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateBinarySecretKeyIdentifierClause ()
+               {
+                       byte [] bytes = new byte [32];
+                       SecurityToken wt = new BinarySecretSecurityToken (bytes);
+                       SecurityKeyIdentifierClause kic =
+                               new BinarySecretKeyIdentifierClause (bytes);
+                       WrappedKeySecurityToken token = new WrappedKeySecurityToken ("urn:gyabo",
+                               bytes, SecurityAlgorithms.Aes256KeyWrap, wt,
+                               new SecurityKeyIdentifier (kic));
+                       token.CreateKeyIdentifierClause<BinarySecretKeyIdentifierClause> ();
+               }
+
+               [Test]
+               public void X509WrappingToken1 ()
+               {
+                       byte [] bytes = new byte [32];
+                       X509SecurityToken xt = new X509SecurityToken (cert);
+                       SecurityKeyIdentifierClause kic =
+                               new X509ThumbprintKeyIdentifierClause (cert);
+                       string alg = SecurityAlgorithms.RsaOaepKeyWrap;
+                       WrappedKeySecurityToken token = new WrappedKeySecurityToken ("urn:gyabo",
+                               bytes, alg, xt,
+                               new SecurityKeyIdentifier (kic));
+                       Assert.AreEqual ("urn:gyabo", token.Id, "#1");
+                       Assert.AreEqual (alg, token.WrappingAlgorithm, "#3");
+                       Assert.AreEqual (xt, token.WrappingToken, "#4");
+                       Assert.AreEqual (1, token.WrappingTokenReference.Count, "#5");
+                       Assert.AreEqual (1, token.SecurityKeys.Count, "#6");
+                       Assert.IsTrue (token.SecurityKeys [0] is InMemorySymmetricSecurityKey, "#7");
+                       Assert.AreEqual (bytes, new X509AsymmetricSecurityKey (cert).DecryptKey (token.WrappingAlgorithm, token.GetWrappedKey ()), "#8");
+                       // wrapped keys cannot be compared, due to the nature of rsa-oaep.
+                       // Assert.AreEqual (new X509AsymmetricSecurityKey (cert).EncryptKey (token.WrappingAlgorithm, bytes), token.GetWrappedKey (), "#9-1");
+                       // Assert.AreEqual (token.GetWrappedKey (), new WrappedKeySecurityToken ("urn:gyabo",
+                       //      bytes, alg, xt,
+                       //      new SecurityKeyIdentifier (kic)).GetWrappedKey (), "#9");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/X509ListedCertificateValidator.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/X509ListedCertificateValidator.cs
new file mode 100644 (file)
index 0000000..564d8d5
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// X509ListedCertificateValidator.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Security.Tokens
+{
+       public class X509ListedCertificateValidator : X509CertificateValidator
+       {
+               Collection<X509Certificate2> certs =
+                       new Collection<X509Certificate2> ();
+
+               public X509ListedCertificateValidator (params X509Certificate2 [] certificates)
+                       : this ((IEnumerable<X509Certificate2>) certificates)
+               {
+               }
+
+               public X509ListedCertificateValidator (IEnumerable<X509Certificate2> certificates)
+               {
+                       foreach (X509Certificate2 cert in certificates)
+                               certs.Add (cert);
+               }
+
+               public override void Validate (X509Certificate2 certificate)
+               {
+                       foreach (X509Certificate2 c in certs)
+                               if (c.Thumbprint == certificate.Thumbprint)
+                                       return;
+                       throw new ArgumentException ("The argument certificate is not listed as a trusted certificate in this validator.");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/X509SecurityTokenParametersTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security.Tokens/X509SecurityTokenParametersTest.cs
new file mode 100644 (file)
index 0000000..37ff1f6
--- /dev/null
@@ -0,0 +1,126 @@
+//
+// X509SecurityTokenParametersTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class X509SecurityTokenParametersTest
+       {
+               class MyX509SecurityTokenParameters : X509SecurityTokenParameters
+               {
+                       public bool HasAsymmetricKeyEx {
+                               get { return HasAsymmetricKey; }
+                       }
+
+                       public bool SupportsClientAuthenticationEx {
+                               get { return SupportsClientAuthentication; }
+                       }
+
+                       public bool SupportsClientWindowsIdentityEx {
+                               get { return SupportsClientWindowsIdentity; }
+                       }
+
+                       public bool SupportsServerAuthenticationEx {
+                               get { return SupportsServerAuthentication; }
+                       }
+
+                       public SecurityKeyIdentifierClause CallCreateKeyIdentifierClause (
+                               SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+                       {
+                               return CreateKeyIdentifierClause (token, referenceStyle);
+                       }
+
+                       public void InitRequirement (SecurityTokenRequirement requirement)
+                       {
+                               InitializeSecurityTokenRequirement (requirement);
+                       }
+               }
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       MyX509SecurityTokenParameters tp = new MyX509SecurityTokenParameters ();
+                       Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient, tp.InclusionMode, "#1");
+                       Assert.AreEqual (SecurityTokenReferenceStyle.Internal, tp.ReferenceStyle, "#2");
+                       Assert.AreEqual (true, tp.RequireDerivedKeys, "#3");
+                       Assert.AreEqual (true, tp.HasAsymmetricKeyEx, "#4");
+                       Assert.AreEqual (true, tp.SupportsClientAuthenticationEx, "#5");
+                       Assert.AreEqual (true, tp.SupportsClientWindowsIdentityEx, "#6");
+                       Assert.AreEqual (true, tp.SupportsServerAuthenticationEx, "#7");
+
+                       Assert.AreEqual (X509KeyIdentifierClauseType.Any, tp.X509ReferenceStyle, "#2-1");
+               }
+
+               [Test]
+               public void InitializeRequirement ()
+               {
+                       MyX509SecurityTokenParameters p =
+                               new MyX509SecurityTokenParameters ();
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       int before = r.Properties.Count;
+                       p.InitRequirement (r);
+                       Assert.AreEqual (1, r.Properties.Count - before, "#1"); // i.e. only TokenType is set.
+                       Assert.AreEqual (SecurityTokenTypes.X509Certificate, r.TokenType, "#2");
+               }
+
+               [Test]
+               public void CreateKeyIdentifierClause ()
+               {
+                       SecurityKeyIdentifierClause clause;
+
+                       MyX509SecurityTokenParameters p =
+                               new MyX509SecurityTokenParameters ();
+                       X509SecurityToken token = new X509SecurityToken (
+                               new X509Certificate2 ("Test/Resources/test.pfx", "mono"));
+                       clause = p.CallCreateKeyIdentifierClause (
+                               token, SecurityTokenReferenceStyle.External);
+                       Assert.AreEqual (typeof (X509IssuerSerialKeyIdentifierClause), clause.GetType (), "#1");
+                       clause = p.CallCreateKeyIdentifierClause (
+                               token, SecurityTokenReferenceStyle.Internal);
+                       Assert.AreEqual (typeof (LocalIdKeyIdentifierClause), clause.GetType (), "#2");
+
+                       p.InclusionMode = SecurityTokenInclusionMode.Never;
+                       // it still results in LocalId reference
+                       clause = p.CallCreateKeyIdentifierClause (
+                               token, SecurityTokenReferenceStyle.Internal);
+                       Assert.AreEqual (typeof (LocalIdKeyIdentifierClause), clause.GetType (), "#3");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ChangeLog
new file mode 100755 (executable)
index 0000000..ddaf2a9
--- /dev/null
@@ -0,0 +1,246 @@
+2008-02-28  Eyal Alaluf <eyala@mainsoft.com>
+
+       * WSSecurityTokenSerializerTest.cs: Fixed test run on Windows (failed also
+         on .Net).
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs
+         ServiceCredentialsSecurityTokenManagerTest.cs
+         ScopedMessagePartSpecificationTest.cs : warning cleanup.
+
+2007-04-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManagerTest.cs : test that ssl
+         authenticator implements IIssuanceSecurityTokenAuthenticator.
+
+2007-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : removed SCT reader test which
+         was DPAPI dependent, and added new DPAPI independent one.
+
+2007-03-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : so, RequestedProofToken content
+         is unlikely readable here.
+
+2007-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManagerTest.cs : test DedaultValues().
+       * WSSecurityTokenSerializerTest.cs : added tests for SCT read/write.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManagerTest.cs :
+         test for InitializeSecurityTokenRequirement() for several token
+         parameters (like existing tests in client credentials manager).
+
+2007-03-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManagerTest.cs : more tests for
+         AnonymousSslnego token authenticator.
+
+2007-02-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : fixed DerivedKeyToken reader
+         tests, and added more.
+
+2007-02-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : more WrappedKeySecurityToken.
+
+2007-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added WrappedKeySecurityToken
+         reader test.
+
+2007-02-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added test for reading
+         empty (invalid) UsernameToken.
+
+2007-02-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added test for reading
+         EncryptedKeySHA1 embedded key.
+
+2007-02-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added more tests for
+         EncryptedKey clause and BinarySecret clause writers.
+
+2007-01-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added correct reader test for
+         SecurityTokenReference with KeyIdentifier. Existing test was broken.
+
+2007-01-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs: some tests for writing derived-
+         key-involved key identifier clauses.
+
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added some tests for 
+         EmitBspRequiredAttributes.
+
+2007-01-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added somewhat wrong test for
+         serialization for LocalIdKeyIdentifierClause with OwnerType.
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : some tests for 
+         SecurityContextSecurityToken.
+       * SecurityTokenSpeficicationTest.cs : new test.
+
+2007-01-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added a few x509 tests for
+         SecurityVersion.WSSecurity10.
+
+2006-12-09  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : finished incomplete
+         WriteWrappedKeySecurityToken() test.
+
+2006-12-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityMessagePropertyTest.cs : test SenderIdPrefix as well.
+       * WSSecurityTokenSerializerTest.cs : added test for writing
+         LocalIdKeyIdentifierClause.
+
+2006-12-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceSecurityContextTest.cs : new test.
+       * SecurityMessagePropertyTest.cs : after making several effort to
+         make GetOrCreateSecureMessage() pass (with new 
+         InterceptorBindingElement), it turned out that GetOrCreate() does
+         not populate security information by itself...
+
+2006-12-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessagePartSpecificationTest.cs : new test.
+       * ScopedMessagePartSpecificationTest.cs : added AddParts() tests.
+
+2006-12-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added test for reading
+         EncryptedKeyIdentifierClause. Added test for writing
+         EncryptedKeyIdentifierClause which includes KeyIdentifier.
+
+2006-12-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs :
+         enabled X509IssuerSerialKeyIdentifierClause writer test.
+
+2006-12-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added test for
+         X509ThumbprintKeyIdentifierClause writer. Removed some NotWorking.
+
+2006-10-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added test for writing
+         EncryptedKeyIdentifierClause. It is not the thing I needed for
+         non-included key serialization thus it's not implemented yet.
+
+2006-10-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityMessagePropertyTest.cs : new file.
+
+2006-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManagerTest.cs :
+         a few more lines in Ssl create authenticator test.
+
+2006-09-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs :
+         WriteToken() test for SecurityContextSecurityToken.
+         Incomplete/NotWorking ReadToken() test for DerivedKeyToken.
+
+2006-09-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityAlgorithmSuiteTest.cs : fixed AsymmetricSignatureAlgorithm.
+         Use SecurityAlgorithms constants.
+
+2006-09-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added test for LocalId 
+         ReadKeyIdentifierClause().
+
+2006-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManagerTest.cs :
+         removed some NotWorking.
+
+2006-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManagerTest.cs :
+         some are notworking yet.
+
+2006-09-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceCredentialsSecurityTokenManagerTest.cs : new test.
+
+2006-09-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : test that RsaSecurityToken is
+         not supported.
+
+2006-09-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : cleaning up NotWorking.
+
+2006-08-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ScopedMessagePartSpecificationTest.cs : new test.
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelProtectionRequirementsTest.cs : new test.
+
+2006-08-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added GetTokenTypeUri test.
+
+2006-08-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs :
+         Added incomplete test for WriteWrappedKeySecurityToken(), but
+         I couldn't find any usable key identifier yet.
+
+2006-08-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs :
+         Added test for GenericXmlSecurityToken serialization. Hmm, seems
+         like it is also useless for ws-trust.
+
+2006-08-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs :
+         added test for WriteToken[Core] for BinarySecurityToken.
+
+2006-08-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : added test for 
+         WriteKeyIdentifierClause[Core] though not working.
+
+2006-08-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : test some WriteToken[Core].
+
+2006-07-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : test DefaultInstance as well.
+
+2006-07-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSSecurityTokenSerializerTest.cs : new test.
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SecurityAlgorithmSuiteTest.cs,
+         SupportingTokenParametersTest.cs : new tests.
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ChannelProtectionRequirementsTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ChannelProtectionRequirementsTest.cs
new file mode 100644 (file)
index 0000000..cb4d7dd
--- /dev/null
@@ -0,0 +1,66 @@
+//
+// ChannelProtectionRequirementsTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Security.Cryptography.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Security
+{
+       [TestFixture]
+       public class ChannelProtectionRequirementsTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       ChannelProtectionRequirements r =
+                               new ChannelProtectionRequirements ();
+                       Assert.AreEqual (false, r.IsReadOnly, "#1");
+                       Assert.IsNotNull (r.IncomingSignatureParts, "#2");
+                       Assert.IsNotNull (r.IncomingEncryptionParts, "#3");
+                       Assert.IsNotNull (r.OutgoingSignatureParts, "#4");
+                       Assert.IsNotNull (r.OutgoingEncryptionParts, "#5");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddToReadOnly ()
+               {
+                       ChannelProtectionRequirements r =
+                               new ChannelProtectionRequirements ();
+                       r.MakeReadOnly ();
+                       r.Add (new ChannelProtectionRequirements ());
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/MessagePartSpecificationTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/MessagePartSpecificationTest.cs
new file mode 100644 (file)
index 0000000..ede9306
--- /dev/null
@@ -0,0 +1,88 @@
+//
+// MessagePartSpecificationTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class MessagePartSpecificationTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       MessagePartSpecification s =
+                               new MessagePartSpecification ();
+                       Assert.IsFalse (s.IsBodyIncluded, "#1");
+                       Assert.AreEqual (0, s.HeaderTypes.Count, "#2");
+
+                       s = new MessagePartSpecification (new XmlQualifiedName [] {new XmlQualifiedName ("foo", "urn:foo")});
+                       Assert.IsFalse (s.IsBodyIncluded, "#3");
+                       Assert.AreEqual (1, s.HeaderTypes.Count, "#4");
+               }
+
+               [Test]
+               public void Union ()
+               {
+                       XmlQualifiedName q1, q2, q3;
+                       q1 = new XmlQualifiedName ("foo");
+                       q2 = new XmlQualifiedName ("bar");
+                       q3 = new XmlQualifiedName ("baz");
+                       MessagePartSpecification p1 =
+                               new MessagePartSpecification (false, new XmlQualifiedName [] {q1, q2});
+                       MessagePartSpecification p2 =
+                               new MessagePartSpecification (true, new XmlQualifiedName [] {q3, q2});
+                       p1.Union (p2);
+                       Assert.IsTrue (p1.IsBodyIncluded, "#1");
+                       // Sigh. It does not exclude duplicates.
+                       Assert.AreEqual (4, p1.HeaderTypes.Count, "#1-2");
+                       Assert.IsTrue (p1.HeaderTypes.Contains (q1), "#2");
+                       Assert.IsTrue (p1.HeaderTypes.Contains (q2), "#3");
+                       Assert.IsTrue (p1.HeaderTypes.Contains (q3), "#4");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void UnionReadOnlyPart ()
+               {
+                       MessagePartSpecification s =
+                               new MessagePartSpecification ();
+                       s.MakeReadOnly ();
+                       Assert.AreEqual (true, s.IsReadOnly, "#1");
+                       s.Union (new MessagePartSpecification ());
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ScopedMessagePartSpecificationTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ScopedMessagePartSpecificationTest.cs
new file mode 100644 (file)
index 0000000..ef0537f
--- /dev/null
@@ -0,0 +1,134 @@
+//
+// ScopedMessagePartSpecificationTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ScopedMessagePartSpecificationTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       ScopedMessagePartSpecification s =
+                               new ScopedMessagePartSpecification ();
+                       Assert.IsNotNull (s.ChannelParts, "#1");
+                       Assert.AreEqual (0, s.Actions.Count, "#2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void AddPartsNull ()
+               {
+                       ScopedMessagePartSpecification s =
+                               new ScopedMessagePartSpecification ();
+                       s.AddParts (null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void AddPartsNull2 ()
+               {
+                       ScopedMessagePartSpecification s =
+                               new ScopedMessagePartSpecification ();
+                       s.AddParts (null, "urn:foo");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void AddPartsNull3 ()
+               {
+                       ScopedMessagePartSpecification s =
+                               new ScopedMessagePartSpecification ();
+                       s.AddParts (new MessagePartSpecification (), null);
+               }
+
+               [Test]
+               public void AddParts ()
+               {
+                       ScopedMessagePartSpecification s =
+                               new ScopedMessagePartSpecification ();
+                       Assert.IsFalse (s.ChannelParts.IsBodyIncluded, "#1");
+                       s.AddParts (new MessagePartSpecification (true));
+                       Assert.AreEqual (0, s.Actions.Count, "#2");
+                       Assert.IsTrue (s.ChannelParts.IsBodyIncluded, "#3");
+
+                       XmlQualifiedName foo = new XmlQualifiedName ("foo");
+                       XmlQualifiedName bar = new XmlQualifiedName ("bar");
+
+                       s.AddParts (new MessagePartSpecification (new XmlQualifiedName [] {foo}), "urn:foo");
+                       Assert.AreEqual (1, s.Actions.Count, "#4");
+                       MessagePartSpecification m;
+                       s.TryGetParts ("urn:foo", out m);
+                       Assert.IsNotNull (m, "#5");
+                       Assert.AreEqual (1, m.HeaderTypes.Count, "#6");
+
+                       s.AddParts (new MessagePartSpecification (true, new XmlQualifiedName [] {bar}), "urn:foo");
+                       Assert.AreEqual (1, s.Actions.Count, "#7");
+                       s.TryGetParts ("urn:foo", out m);
+                       Assert.IsNotNull (m, "#8");
+                       //List<XmlQualifiedName> l = new List<XmlQualifiedName> (m.HeaderTypes);
+                       Assert.AreEqual (2, m.HeaderTypes.Count, "#9");
+                       Assert.IsTrue (m.IsBodyIncluded, "#10");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddToReadOnlyCollection ()
+               {
+                       ScopedMessagePartSpecification s =
+                               new ScopedMessagePartSpecification ();
+                       s.MakeReadOnly ();
+                       Assert.AreEqual (true, s.IsReadOnly, "#1");
+                       s.AddParts (new MessagePartSpecification (), "urn:myaction");
+               }
+
+               [Test]
+               public void TryGetParts ()
+               {
+                       ScopedMessagePartSpecification s =
+                               new ScopedMessagePartSpecification ();
+                       MessagePartSpecification ret;
+                       Assert.IsFalse (s.TryGetParts ("urn:myaction", out ret));
+                       Assert.IsFalse (s.TryGetParts ("urn:myaction", true, out ret));
+                       Assert.IsFalse (s.TryGetParts ("urn:myaction", false, out ret));
+
+                       s.AddParts (new MessagePartSpecification (), "urn:myaction");
+                       Assert.IsTrue (s.TryGetParts ("urn:myaction", out ret));
+                       Assert.IsTrue (s.TryGetParts ("urn:myaction", true, out ret));
+                       Assert.IsTrue (s.TryGetParts ("urn:myaction", false, out ret));
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SecurityAlgorithmSuiteTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SecurityAlgorithmSuiteTest.cs
new file mode 100644 (file)
index 0000000..ffb6fbd
--- /dev/null
@@ -0,0 +1,246 @@
+//
+// SecurityAlgorithmSuiteTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Tokens;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Security.Cryptography.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class SecurityAlgorithmSuiteTest
+       {
+               static void AssertSecurityAlgorithmSuite (
+                       string defaultAsymmetricKeyWrapAlgorithm,
+                       string defaultAsymmetricSignatureAlgorithm,
+                       string defaultCanonicalizationAlgorithm,
+                       string defaultDigestAlgorithm,
+                       string defaultEncryptionAlgorithm,
+                       int defaultEncryptionKeyDerivationLength,
+                       int defaultSignatureKeyDerivationLength,
+                       int defaultSymmetricKeyLength,
+                       string defaultSymmetricKeyWrapAlgorithm,
+                       string defaultSymmetricSignatureAlgorithm,
+                       SecurityAlgorithmSuite target,
+                       string label)
+               {
+                       Assert.AreEqual (defaultAsymmetricKeyWrapAlgorithm,
+                               target.DefaultAsymmetricKeyWrapAlgorithm,
+                               label + ".DefaultAsymmetricKeyWrapAlgorithm");
+                       Assert.AreEqual (defaultAsymmetricSignatureAlgorithm,
+                               target.DefaultAsymmetricSignatureAlgorithm,
+                               label + ".DefaultAsymmetricSignatureAlgorithm");
+                       Assert.AreEqual (defaultCanonicalizationAlgorithm,
+                               target.DefaultCanonicalizationAlgorithm,
+                               label + ".DefaultCanonicalizationAlgorithm");
+                       Assert.AreEqual (defaultDigestAlgorithm,
+                               target.DefaultDigestAlgorithm,
+                               label + ".DefaultDigestAlgorithm");
+                       Assert.AreEqual (defaultEncryptionAlgorithm,
+                               target.DefaultEncryptionAlgorithm,
+                               label + ".DefaultEncryptionAlgorithm");
+                       Assert.AreEqual (defaultEncryptionKeyDerivationLength,
+                               target.DefaultEncryptionKeyDerivationLength,
+                               label + ".DefaultEncryptionKeyDerivationLength");
+                       Assert.AreEqual (defaultSignatureKeyDerivationLength,
+                               target.DefaultSignatureKeyDerivationLength,
+                               label + ".DefaultSignatureKeyDerivationLength");
+                       Assert.AreEqual (defaultSymmetricKeyLength,
+                               target.DefaultSymmetricKeyLength,
+                               label + ".DefaultSymmetricKeyLength");
+                       Assert.AreEqual (defaultSymmetricKeyWrapAlgorithm,
+                               target.DefaultSymmetricKeyWrapAlgorithm,
+                               label + ".DefaultSymmetricKeyWrapAlgorithm");
+                       Assert.AreEqual (defaultSymmetricSignatureAlgorithm,
+                               target.DefaultSymmetricSignatureAlgorithm,
+                               label + ".DefaultSymmetricSignatureAlgorithm");
+               }
+
+               [Test]
+               public void DefaultAlgorithm ()
+               {
+                       Assert.AreEqual (
+                               SecurityAlgorithmSuite.Basic256,
+                               SecurityAlgorithmSuite.Default, "#1");
+               }
+
+               [Test]
+               public void StaticPropertyValues ()
+               {
+                       AssertSecurityAlgorithmSuite (
+                               EncryptedXml.XmlEncRSAOAEPUrl,
+                               SignedXml.XmlDsigRSASHA1Url,
+                               SignedXml.XmlDsigExcC14NTransformUrl,
+                               SignedXml.XmlDsigSHA1Url,
+                               EncryptedXml.XmlEncAES128Url,
+                               // enc, sig, sym
+                               128, 128, 128,
+                               EncryptedXml.XmlEncAES128KeyWrapUrl,
+                               SignedXml.XmlDsigHMACSHA1Url,
+                               SecurityAlgorithmSuite.Basic128,
+                               "Basic128");
+
+                       AssertSecurityAlgorithmSuite (
+                               EncryptedXml.XmlEncRSA15Url,
+                               SignedXml.XmlDsigRSASHA1Url,
+                               SignedXml.XmlDsigExcC14NTransformUrl,
+                               SignedXml.XmlDsigSHA1Url,
+                               EncryptedXml.XmlEncAES128Url,
+                               // enc, sig, sym
+                               128, 128, 128,
+                               EncryptedXml.XmlEncAES128KeyWrapUrl,
+                               SignedXml.XmlDsigHMACSHA1Url,
+                               SecurityAlgorithmSuite.Basic128Rsa15,
+                               "Basic128Rsa15");
+
+                       AssertSecurityAlgorithmSuite (
+                               EncryptedXml.XmlEncRSAOAEPUrl,
+                               SecurityAlgorithms.RsaSha256Signature,
+                               SignedXml.XmlDsigExcC14NTransformUrl,
+                               EncryptedXml.XmlEncSHA256Url,
+                               EncryptedXml.XmlEncAES128Url,
+                               // enc, sig, sym
+                               128, 128, 128,
+                               EncryptedXml.XmlEncAES128KeyWrapUrl,
+                               // Can't we get the same string from some const?
+                               SecurityAlgorithms.HmacSha256Signature,
+                               SecurityAlgorithmSuite.Basic128Sha256,
+                               "Basic128Sha256");
+
+                       AssertSecurityAlgorithmSuite (
+                               EncryptedXml.XmlEncRSA15Url,
+                               SecurityAlgorithms.RsaSha256Signature,
+                               SignedXml.XmlDsigExcC14NTransformUrl,
+                               EncryptedXml.XmlEncSHA256Url,
+                               EncryptedXml.XmlEncAES128Url,
+                               // enc, sig, sym
+                               128, 128, 128,
+                               EncryptedXml.XmlEncAES128KeyWrapUrl,
+                               // Can't we get the same string from some const?
+                               SecurityAlgorithms.HmacSha256Signature,
+                               SecurityAlgorithmSuite.Basic128Sha256Rsa15,
+                               "Basic128Sha256Rsa15");
+
+                       // ...192
+
+                       AssertSecurityAlgorithmSuite (
+                               EncryptedXml.XmlEncRSA15Url,
+                               SecurityAlgorithms.RsaSha256Signature,
+                               SignedXml.XmlDsigExcC14NTransformUrl,
+                               EncryptedXml.XmlEncSHA256Url,
+                               EncryptedXml.XmlEncAES192Url,
+                               // enc, sig, sym
+                               192, 192, 192,
+                               EncryptedXml.XmlEncAES192KeyWrapUrl,
+                               // Can't we get the same string from some const?
+                               SecurityAlgorithms.HmacSha256Signature,
+                               SecurityAlgorithmSuite.Basic192Sha256Rsa15,
+                               "Basic192Sha256Rsa15");
+
+                       // ...256
+
+                       AssertSecurityAlgorithmSuite (
+                               EncryptedXml.XmlEncRSAOAEPUrl,
+                               SecurityAlgorithms.RsaSha256Signature,
+                               SignedXml.XmlDsigExcC14NTransformUrl,
+                               EncryptedXml.XmlEncSHA256Url,
+                               EncryptedXml.XmlEncAES256Url,
+                               // enc, sig, sym
+                               256, 192, 256, // hmm, why 192 here?
+                               EncryptedXml.XmlEncAES256KeyWrapUrl,
+                               // Can't we get the same string from some const?
+                               SecurityAlgorithms.HmacSha256Signature,
+                               SecurityAlgorithmSuite.Basic256Sha256,
+                               "Basic256Sha256");
+
+                       // 3DES
+
+                       AssertSecurityAlgorithmSuite (
+                               EncryptedXml.XmlEncRSAOAEPUrl,
+                               SignedXml.XmlDsigRSASHA1Url,
+                               SignedXml.XmlDsigExcC14NTransformUrl,
+                               SignedXml.XmlDsigSHA1Url,
+                               EncryptedXml.XmlEncTripleDESUrl,
+                               // enc, sig, sym
+                               192, 192, 192,
+                               EncryptedXml.XmlEncTripleDESKeyWrapUrl,
+                               SignedXml.XmlDsigHMACSHA1Url,
+                               SecurityAlgorithmSuite.TripleDes,
+                               "TripleDes");
+
+                       AssertSecurityAlgorithmSuite (
+                               EncryptedXml.XmlEncRSA15Url,
+                               SignedXml.XmlDsigRSASHA1Url,
+                               SignedXml.XmlDsigExcC14NTransformUrl,
+                               SignedXml.XmlDsigSHA1Url,
+                               EncryptedXml.XmlEncTripleDESUrl,
+                               // enc, sig, sym
+                               192, 192, 192,
+                               EncryptedXml.XmlEncTripleDESKeyWrapUrl,
+                               SignedXml.XmlDsigHMACSHA1Url,
+                               SecurityAlgorithmSuite.TripleDesRsa15,
+                               "TripleDesRsa15");
+
+                       AssertSecurityAlgorithmSuite (
+                               EncryptedXml.XmlEncRSAOAEPUrl,
+                               SecurityAlgorithms.RsaSha256Signature,
+                               SignedXml.XmlDsigExcC14NTransformUrl,
+                               EncryptedXml.XmlEncSHA256Url,
+                               EncryptedXml.XmlEncTripleDESUrl,
+                               // enc, sig, sym
+                               192, 192, 192,
+                               EncryptedXml.XmlEncTripleDESKeyWrapUrl,
+                               // Can't we get the same string from some const?
+                               SecurityAlgorithms.HmacSha256Signature,
+                               SecurityAlgorithmSuite.TripleDesSha256,
+                               "TripleDesSha256");
+
+                       AssertSecurityAlgorithmSuite (
+                               EncryptedXml.XmlEncRSA15Url,
+                               SecurityAlgorithms.RsaSha256Signature,
+                               SignedXml.XmlDsigExcC14NTransformUrl,
+                               EncryptedXml.XmlEncSHA256Url,
+                               EncryptedXml.XmlEncTripleDESUrl,
+                               // enc, sig, sym
+                               192, 192, 192,
+                               EncryptedXml.XmlEncTripleDESKeyWrapUrl,
+                               // Can't we get the same string from some const?
+                               SecurityAlgorithms.HmacSha256Signature,
+                               SecurityAlgorithmSuite.TripleDesSha256Rsa15,
+                               "TripleDesSha256Rsa15");
+
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SecurityMessagePropertyTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SecurityMessagePropertyTest.cs
new file mode 100644 (file)
index 0000000..9624258
--- /dev/null
@@ -0,0 +1,295 @@
+//
+// SecurityMessagePropertyTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.Security.Principal;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Security.Cryptography.Xml;
+using System.Threading;
+using NUnit.Framework;
+
+using MonoTests.System.ServiceModel.Channels;
+
+namespace MonoTests.System.ServiceModel.Security
+{
+       [TestFixture]
+       public class SecurityMessagePropertyTest
+       {
+               static X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+               static X509Certificate2 cert2 = new X509Certificate2 ("Test/Resources/test2.pfx", "mono");
+
+               [ServiceContract]
+               public interface ICalc
+               {
+                       [OperationContract]
+                       int Sum (int a, int b);
+
+                       [OperationContract (AsyncPattern = true)]
+                       IAsyncResult BeginSum (int a, int b, AsyncCallback cb, object state);
+
+                       int EndSum (IAsyncResult result);
+               }
+
+               public class CalcProxy : ClientBase<ICalc>, ICalc
+               {
+                       public CalcProxy (Binding binding, EndpointAddress address)
+                               : base (binding, address)
+                       {
+                       }
+
+                       public int Sum (int a, int b)
+                       {
+                               return Channel.Sum (a, b);
+                       }
+
+                       public IAsyncResult BeginSum (int a, int b, AsyncCallback cb, object state)
+                       {
+                               return Channel.BeginSum (a, b, cb, state);
+                       }
+
+                       public int EndSum (IAsyncResult result)
+                       {
+                               return Channel.EndSum (result);
+                       }
+               }
+
+               public class CalcService : ICalc
+               {
+                       public int Sum (int a, int b)
+                       {
+                               return a + b;
+                       }
+
+                       public IAsyncResult BeginSum (int a, int b, AsyncCallback cb, object state)
+                       {
+                               return new CalcAsyncResult (a, b, cb, state);
+                       }
+
+                       public int EndSum (IAsyncResult result)
+                       {
+                               CalcAsyncResult c = (CalcAsyncResult) result;
+                               return c.A + c.B;
+                       }
+               }
+
+               class CalcAsyncResult : IAsyncResult
+               {
+                       public int A, B;
+                       AsyncCallback callback;
+                       object state;
+
+                       public CalcAsyncResult (int a, int b, AsyncCallback cb, object state)
+                       {
+                               A = a;
+                               B = b;
+                               callback = cb;
+                               this.state = state;
+                       }
+
+                       public object AsyncState {
+                               get { return state; }
+                       }
+
+                       public WaitHandle AsyncWaitHandle {
+                               get { return null; }
+                       }
+
+                       public bool CompletedSynchronously {
+                               get { return true; }
+                       }
+
+                       public bool IsCompleted {
+                               get { return true; }
+                       }
+               }
+
+               [Test]
+               public void GetOrCreateNonSecureMessage ()
+               {
+                       Message m = Message.CreateMessage (MessageVersion.Default, "urn:myaction");
+                       SecurityMessageProperty p =
+                               SecurityMessageProperty.GetOrCreate (m);
+                       Assert.IsNull (p.InitiatorToken, "#1");
+                       Assert.IsNull (p.RecipientToken, "#2");
+                       Assert.IsNull (p.ProtectionToken, "#3");
+                       Assert.IsNull (p.TransportToken, "#4");
+                       Assert.IsNull (p.ExternalAuthorizationPolicies, "#5");
+//                     Assert.AreEqual (0, p.ExternalAuthorizationPolicies.Count, "#5");
+                       Assert.IsFalse (p.HasIncomingSupportingTokens, "#6");
+                       Assert.IsNotNull (p.IncomingSupportingTokens, "#6-2");
+                       Assert.AreEqual ("_", p.SenderIdPrefix, "#6-3");
+                       ServiceSecurityContext ssc = p.ServiceSecurityContext;
+                       Assert.IsNotNull (ssc, "#7");
+
+                       // not sure if it is worthy of testing though ...
+                       GenericIdentity identity = ssc.PrimaryIdentity as GenericIdentity;
+                       Assert.IsNotNull (identity, "#8-1");
+                       Assert.AreEqual ("", identity.Name, "#8-2");
+                       Assert.AreEqual ("", identity.AuthenticationType, "#8-3");
+
+                       Assert.AreEqual (0, ssc.AuthorizationPolicies.Count, "#9");
+                       Assert.IsTrue (ssc.IsAnonymous, "#10");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               // not sure how "good" this test is ... if it fails at
+               // service side, it just results in timeout error.
+               // The assertion makes sure that it passes all the tests, but
+               // in case it failed, there is almost no hint ...
+               public void GetOrCreateSecureMessage ()
+               {
+                       bool passed = false;
+                       ServiceHost host = new ServiceHost (typeof (CalcService));
+                       InterceptorRequestContextHandler handler = delegate (MessageBuffer src) {
+                               Message msg = src.CreateMessage ();
+                               GetOrCreateSecureMessageAtService (msg);
+                               passed = true;
+                       };
+
+                       try {
+                               SymmetricSecurityBindingElement clisbe =
+                                       new SymmetricSecurityBindingElement ();
+                               clisbe.ProtectionTokenParameters =
+                                       new X509SecurityTokenParameters (X509KeyIdentifierClauseType.Thumbprint, SecurityTokenInclusionMode.Never);
+                               BindingElement transport = new HttpTransportBindingElement ();
+                               BindingElement sintercept = new InterceptorBindingElement (handler);
+                               CustomBinding b_res = new CustomBinding (clisbe,
+                                       sintercept,
+                                       transport);
+                               b_res.ReceiveTimeout = b_res.SendTimeout = TimeSpan.FromSeconds (5);
+                               host.AddServiceEndpoint (typeof (ICalc), b_res, "http://localhost:37564");
+
+                               ServiceCredentials cred = new ServiceCredentials ();
+                               cred.ServiceCertificate.Certificate = cert;
+                               cred.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
+                               host.Description.Behaviors.Add (cred);
+
+                               host.Open ();
+
+                               ProcessClient ();
+
+                       } finally {
+                               if (host.State == CommunicationState.Opened)
+                                       host.Close ();
+                       }
+                       if (!passed)
+                               Assert.Fail ("Didn't pass the interceptor.");
+               }
+
+               void ProcessClient ()
+               {
+                       SymmetricSecurityBindingElement svcsbe =
+                               new SymmetricSecurityBindingElement ();
+                       svcsbe.ProtectionTokenParameters =
+                               new X509SecurityTokenParameters (X509KeyIdentifierClauseType.Thumbprint, SecurityTokenInclusionMode.Never);
+
+                       BindingElement cintercept = new InterceptorBindingElement (null);
+                       CustomBinding b_req = new CustomBinding (svcsbe,
+                               cintercept,
+                               new HttpTransportBindingElement ());
+
+                       b_req.ReceiveTimeout = b_req.SendTimeout = TimeSpan.FromSeconds (5);
+                       EndpointAddress remaddr = new EndpointAddress (
+                               new Uri ("http://localhost:37564"),
+                               new X509CertificateEndpointIdentity (cert));
+                       CalcProxy proxy = new CalcProxy (b_req, remaddr);
+                       proxy.ClientCredentials.ClientCertificate.Certificate = cert2;
+
+                       proxy.Sum (1, 2);
+                       proxy.Close ();
+               }
+
+               static void GetOrCreateSecureMessageAtClient (Message msg)
+               {
+                       foreach (object o in msg.Properties)
+                               if (o is SecurityMessageProperty)
+                                       Assert.Fail ("The input msg should not contain SecurityMessageProperty yet.");
+                       SecurityMessageProperty p = SecurityMessageProperty.GetOrCreate (msg);
+
+                       Assert.AreEqual (null, p.InitiatorToken, "#1");
+                       Assert.AreEqual (null, p.RecipientToken, "#2");
+                       Assert.IsNull (p.ProtectionToken, "#3");
+                       Assert.IsNull (p.TransportToken, "#4");
+                       Assert.IsNull (p.ExternalAuthorizationPolicies, "#5");
+//                     Assert.AreEqual (0, p.ExternalAuthorizationPolicies.Count, "#5");
+                       Assert.IsFalse (p.HasIncomingSupportingTokens, "#6");
+                       Assert.IsNotNull (p.IncomingSupportingTokens, "#6-2");
+                       Assert.AreEqual ("_", p.SenderIdPrefix, "#6-3");
+                       ServiceSecurityContext ssc = p.ServiceSecurityContext;
+                       Assert.IsNotNull (ssc, "#7");
+
+                       // not sure if it is worthy of testing though ...
+                       GenericIdentity identity = ssc.PrimaryIdentity as GenericIdentity;
+                       Assert.IsNotNull (identity, "#8-1");
+                       Assert.AreEqual ("", identity.Name, "#8-2");
+                       Assert.AreEqual ("", identity.AuthenticationType, "#8-3");
+
+                       Assert.AreEqual (0, ssc.AuthorizationPolicies.Count, "#9");
+                       Assert.IsTrue (ssc.IsAnonymous, "#10");
+               }
+
+               static void GetOrCreateSecureMessageAtService (Message msg)
+               {
+                       Assert.IsNull (msg.Properties.Security, "#0");
+                       foreach (object o in msg.Properties)
+                               if (o is SecurityMessageProperty)
+                                       Assert.Fail ("The input msg should not contain SecurityMessageProperty yet.");
+                       SecurityMessageProperty p = SecurityMessageProperty.GetOrCreate (msg);
+                       Assert.IsNotNull (msg.Properties.Security, "#0-2");
+
+                       Assert.AreEqual (null, p.InitiatorToken, "#1");
+                       Assert.AreEqual (null, p.RecipientToken, "#2");
+                       Assert.IsNull (p.ProtectionToken, "#3");
+                       Assert.IsNull (p.TransportToken, "#4");
+                       Assert.IsNull (p.ExternalAuthorizationPolicies, "#5");
+//                     Assert.AreEqual (0, p.ExternalAuthorizationPolicies.Count, "#5");
+                       Assert.IsFalse (p.HasIncomingSupportingTokens, "#6");
+                       Assert.IsNotNull (p.IncomingSupportingTokens, "#6-2");
+                       Assert.AreEqual ("_", p.SenderIdPrefix, "#6-3");
+                       ServiceSecurityContext ssc = p.ServiceSecurityContext;
+                       Assert.IsNotNull (ssc, "#7");
+
+                       // not sure if it is worthy of testing though ...
+                       GenericIdentity identity = ssc.PrimaryIdentity as GenericIdentity;
+                       Assert.IsNotNull (identity, "#8-1");
+                       Assert.AreEqual ("", identity.Name, "#8-2");
+                       Assert.AreEqual ("", identity.AuthenticationType, "#8-3");
+
+                       Assert.AreEqual (0, ssc.AuthorizationPolicies.Count, "#9");
+                       Assert.IsTrue (ssc.IsAnonymous, "#10");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SecurityTokenSpeficicationTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SecurityTokenSpeficicationTest.cs
new file mode 100644 (file)
index 0000000..b5daacd
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// SecurityTokenSpeficicationTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Tokens;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Security.Cryptography.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class SecurityTokenSpeficicationTest
+       {
+               [Test]
+               public void ConstructorNullPolicies ()
+               {
+                       new SecurityTokenSpecification (new UserNameSecurityToken ("mono", "monopass"), new ReadOnlyCollection<IAuthorizationPolicy> (new IAuthorizationPolicy [0]));
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManagerTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ServiceCredentialsSecurityTokenManagerTest.cs
new file mode 100644 (file)
index 0000000..8b2a36f
--- /dev/null
@@ -0,0 +1,585 @@
+//
+// ServiceCredentialsSecurityTokenManagerTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006-2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Net;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using NUnit.Framework;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace MonoTests.System.ServiceModel.Security
+{
+       [TestFixture]
+       public class ServiceCredentialsSecurityTokenManagerTest
+       {
+               class MyManager : ServiceCredentialsSecurityTokenManager
+               {
+                       public MyManager ()
+                               : this (new ServiceCredentials ())
+                       {
+                       }
+
+                       public MyManager (ServiceCredentials cred)
+                               : base (cred)
+                       {
+                       }
+
+                       public bool IsIssued (SecurityTokenRequirement r)
+                       {
+                               return IsIssuedSecurityTokenRequirement (r);
+                       }
+               }
+
+               class MySslSecurityTokenParameters : SslSecurityTokenParameters
+               {
+                       public void InitRequirement (SecurityTokenRequirement r)
+                       {
+                               InitializeSecurityTokenRequirement (r);
+                       }
+               }
+
+               MyManager def_c;
+
+               [SetUp]
+               public void Initialize ()
+               {
+                       def_c = new MyManager ();
+               }
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       // FIXME: check more
+                       MyManager mgr = new MyManager ();
+                       Assert.IsTrue (mgr.ServiceCredentials.SecureConversationAuthentication.SecurityStateEncoder is DataProtectionSecurityStateEncoder, "#n-1");
+               }
+
+               [Test]
+               public void IsIssuedSecurityTokenRequirement ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r;
+                       MyManager mgr = new MyManager ();
+
+                       r = new RecipientServiceModelSecurityTokenRequirement ();
+                       MySslSecurityTokenParameters ssl =
+                               new MySslSecurityTokenParameters ();
+                       ssl.InitRequirement (r);
+                       Assert.IsFalse (mgr.IsIssued (r), "ssl");
+
+                       r = new RecipientServiceModelSecurityTokenRequirement ();
+                       MySspiSecurityTokenParameters sspi =
+                               new MySspiSecurityTokenParameters ();
+                       sspi.InitRequirement (r);
+                       Assert.IsFalse (mgr.IsIssued (r), "sspi");
+
+                       r = new RecipientServiceModelSecurityTokenRequirement ();
+                       MyIssuedSecurityTokenParameters issued =
+                               new MyIssuedSecurityTokenParameters ();
+                       issued.InitRequirement (r);
+                       Assert.IsTrue (mgr.IsIssued (r), "issued");
+
+/*
+                       r = new RecipientServiceModelSecurityTokenRequirement ();
+                       MySecureConversationSecurityTokenParameters sc =
+                               new MySecureConversationSecurityTokenParameters (
+                                       new SymmetricSecurityBindingElement (new X509SecurityTokenParameters ()),
+                                       false,
+                                       new ChannelProtectionRequirements ());
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (), new BindingParameterCollection ());
+                       r.Properties [ReqType.MessageSecurityVersionProperty] =
+                               MessageSecurityVersion.Default;
+                       r.Properties [ReqType.ChannelParametersCollectionProperty] =
+                               new ChannelParameterCollection ();
+                       r.Properties [ReqType.IssuedSecurityTokenParametersProperty] = sc.Clone ();
+                       r.Properties [ReqType.IssuerBindingProperty] =
+                               new CustomBinding (new HttpTransportBindingElement ());
+                       r.Properties [ReqType.MessageDirectionProperty] =
+                               MessageDirection.Input;
+                       r.SecureConversationSecurityBindingElement =
+                               new SymmetricSecurityBindingElement (
+                                       new X509SecurityTokenParameters ());
+                       r.SecurityAlgorithmSuite = SecurityAlgorithmSuite.Default;
+                       r.Properties [ReqType.SupportSecurityContextCancellationProperty] = true;
+                       r.ListenUri = new Uri ("http://localhost:8080");
+                       r.KeySize = 256;
+                       sc.InitRequirement (r);
+                       Assert.IsFalse (mgr.IsIssued (r), "sc");
+*/
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateProviderDefault ()
+               {
+                       SecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Ignore ("")]
+               public void CreateProviderUserNameWithoutName ()
+               {
+                       SecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.UserName;
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateProviderUserName ()
+               {
+                       SecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.UserName;
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               class MyUserNameValidator : UserNamePasswordValidator
+               {
+                       public override void Validate (string userName, string password)
+                       {
+                               throw new Exception ();
+                       }
+               }
+
+               [Test]
+               public void CreateAuthenticatorUserName ()
+               {
+                       SecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.UserName;
+                       SecurityTokenResolver resolver;
+
+                       SecurityTokenAuthenticator a =
+                               def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+                       Assert.AreEqual (typeof (WindowsUserNameSecurityTokenAuthenticator), a.GetType (), "#1");
+                       Assert.IsNull (resolver, "#2");
+
+                       def_c.ServiceCredentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom;
+                       def_c.ServiceCredentials.UserNameAuthentication.CustomUserNamePasswordValidator = new MyUserNameValidator ();
+                       a = def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+                       Assert.AreEqual (typeof (CustomUserNameSecurityTokenAuthenticator), a.GetType (), "#3");
+                       Assert.IsNull (resolver, "#4");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateAuthenticatorUserNameCustomWithoutValidator ()
+               {
+                       SecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.UserName;
+                       SecurityTokenResolver resolver;
+                       def_c.ServiceCredentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateProviderRsaDefault ()
+               {
+                       // actually is Rsa usable here??
+
+                       SecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.Rsa;
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               public void CreateAuthenticatorRsaDefault ()
+               {
+                       SecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       SecurityTokenResolver resolver;
+                       r.TokenType = SecurityTokenTypes.Rsa;
+                       SecurityTokenAuthenticator a = def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+                       Assert.AreEqual (typeof (RsaSecurityTokenAuthenticator), a.GetType (), "#1");
+                       Assert.IsNull (resolver, "#2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateProviderX509WithoutCert ()
+               {
+                       SecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderX509PublicOnlyKey ()
+               {
+                       SecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.cer");
+                       def_c.ServiceCredentials.ServiceCertificate.Certificate = cert;
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               public void CreateProviderX509 ()
+               {
+                       SecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       def_c.ServiceCredentials.ServiceCertificate.Certificate =
+                               new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+                       X509SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r)
+                               as X509SecurityTokenProvider;
+                       Assert.IsNotNull (p, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateProviderX509Initiator ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       r.KeyUsage = SecurityKeyUsage.Exchange;
+                       // ClientCredential is somehow required ...
+                       def_c.ServiceCredentials.ServiceCertificate.Certificate =
+                               new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+
+                       X509SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r)
+                               as X509SecurityTokenProvider;
+                       Assert.IsNotNull (p, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateProviderAnonSslError ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = ServiceModelSecurityTokenTypes.AnonymousSslnego;
+                       r.ListenUri = new Uri ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (), new BindingParameterCollection ());
+                       r.MessageSecurityVersion =
+                               MessageSecurityVersion.Default.SecurityTokenVersion;
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+               }
+
+               [Test]
+               [Ignore ("incomplete")]
+               [Category ("NotWorking")]
+               public void CreateProviderAnonSsl ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       new MySslSecurityTokenParameters ().InitRequirement (r);
+
+                       Assert.IsFalse (r.Properties.ContainsKey (ReqType.ChannelParametersCollectionProperty), "#1");
+                       Assert.IsFalse (r.Properties.ContainsKey (ReqType.EndpointFilterTableProperty), "#2");
+                       Assert.IsFalse (r.Properties.ContainsKey (ReqType.HttpAuthenticationSchemeProperty), "#3");
+                       Assert.IsFalse (r.Properties.ContainsKey (ReqType.IsOutOfBandTokenProperty), "#4");
+                       Assert.IsFalse (r.Properties.ContainsKey (ReqType.IssuerAddressProperty), "#5");
+                       Assert.IsFalse (r.Properties.ContainsKey (ReqType.MessageDirectionProperty), "#6");
+                       Assert.IsFalse (r.Properties.ContainsKey (ReqType.MessageSecurityVersionProperty), "#7");
+                       //Assert.IsTrue (r.Properties.ContainsKey (SecurityTokenRequirement.PeerAuthenticationMode), "#8");
+                       Assert.IsFalse (r.Properties.ContainsKey (ReqType.SecurityAlgorithmSuiteProperty), "#9");
+                       Assert.IsFalse (r.Properties.ContainsKey (ReqType.SecurityBindingElementProperty), "#10");
+                       Assert.IsFalse (r.Properties.ContainsKey (ReqType.SupportingTokenAttachmentModeProperty), "#11");
+                       Assert.AreEqual (null, r.TransportScheme, "#12");
+
+                       r.TokenType = ServiceModelSecurityTokenTypes.AnonymousSslnego;
+                       r.ListenUri = new Uri ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (), new BindingParameterCollection ());
+                       r.MessageSecurityVersion =
+                               MessageSecurityVersion.Default.SecurityTokenVersion;
+
+                       r.Properties [ReqType.SecurityAlgorithmSuiteProperty] =
+                               SecurityAlgorithmSuite.Default;
+                       r.TransportScheme = "https";
+
+                       r.Properties [ReqType.ChannelParametersCollectionProperty] = new ChannelParameterCollection ();
+                       r.Properties [ReqType.EndpointFilterTableProperty] = null;
+                       r.Properties [ReqType.HttpAuthenticationSchemeProperty] = AuthenticationSchemes.Anonymous;
+                       r.Properties [ReqType.IsOutOfBandTokenProperty] = true;
+                       r.Properties [ReqType.IssuerAddressProperty] = new EndpointAddress ("http://localhost:9090");
+//                     r.Properties [ReqType.MessageDirectionProperty] = MessageDirection.Input;
+                       r.Properties [ReqType.SecurityBindingElementProperty] = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.SupportingTokenAttachmentModeProperty] = SecurityTokenAttachmentMode.Signed;
+
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+               }
+
+               RecipientServiceModelSecurityTokenRequirement CreateAnonSslRequirement ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       MySslSecurityTokenParameters p = new MySslSecurityTokenParameters ();
+                       p.InitRequirement (r);
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement (new X509SecurityTokenParameters ());
+                       r.Properties [ReqType.IssuedSecurityTokenParametersProperty] = p.Clone ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (new HttpTransportBindingElement ()), new BindingParameterCollection ());
+                       r.Properties [ReqType.MessageSecurityVersionProperty] =
+                               MessageSecurityVersion.Default.SecurityTokenVersion;
+                       return r;
+               }
+
+               RecipientServiceModelSecurityTokenRequirement CreateSecureConvRequirement ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateRecipientRequirement (ServiceModelSecurityTokenTypes.SecureConversation);
+                       r.Properties [ReqType.IssuedSecurityTokenParametersProperty] = new SecureConversationSecurityTokenParameters (new SymmetricSecurityBindingElement (new X509SecurityTokenParameters ()));
+                       // without it, "The key length (...) is not a multiple of 8 for symmetric keys" occurs.
+                       r.SecureConversationSecurityBindingElement =
+                               new SymmetricSecurityBindingElement ();
+                       return r;
+               }
+
+               RecipientServiceModelSecurityTokenRequirement CreateRecipientRequirement (string tokenType)
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = tokenType;
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (), new BindingParameterCollection ());
+                       r.Properties [ReqType.IssuedSecurityTokenParametersProperty] = new IssuedSecurityTokenParameters ();
+                       r.MessageSecurityVersion =
+                               MessageSecurityVersion.Default.SecurityTokenVersion;
+                       return r;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateAuthenticatorAnonSslNoSecurityBindingElement ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateAnonSslRequirement ();
+                       r.SecurityBindingElement = null;
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateAuthenticatorAnonSslNoIssuedSecurityTokenParameters ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateAnonSslRequirement ();
+                       r.Properties.Remove (ReqType.IssuedSecurityTokenParametersProperty);
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateAuthenticatorAnonSslNoIssuerBindingContext ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateAnonSslRequirement ();
+                       r.Properties.Remove (ReqType.IssuerBindingContextProperty);
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               // The type of exception should not matter though.
+               [ExpectedException (typeof (NotSupportedException))]
+               [Category ("NotWorking")]
+               public void CreateAuthenticatorAnonSslNullMessageSecurityVersion ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateAnonSslRequirement ();
+                       r.MessageSecurityVersion = null;
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateAuthenticatorAnonSslNoMessageSecurityVersion ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateAnonSslRequirement ();
+                       r.Properties.Remove (ReqType.MessageSecurityVersionProperty);
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")]
+               public void CreateAuthenticatorAnonSslNoServiceCertificate ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateAnonSslRequirement ();
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateAuthenticatorAnonSslCertPublicOnly ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateAnonSslRequirement ();
+                       SecurityTokenResolver resolver;
+                       def_c.ServiceCredentials.ServiceCertificate.Certificate =
+                               new X509Certificate2 ("Test/Resources/test.cer");
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void CreateAuthenticatorAnonSsl ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateAnonSslRequirement ();
+                       SecurityTokenResolver resolver;
+                       X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+                       def_c.ServiceCredentials.ServiceCertificate.Certificate = cert;
+                       SecurityTokenAuthenticator a = def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+                       // non-standard authenticator type.
+                       Assert.IsNotNull (resolver, "#1");
+                       Assert.IsTrue (a is IIssuanceSecurityTokenAuthenticator, "#2");
+
+                       try {
+                               a.ValidateToken (new X509SecurityToken (cert));
+                               Assert.Fail ("It cannot validate raw X509SecurityToken");
+                       } catch (SecurityTokenValidationException) {
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateProviderSecureConv ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = ServiceModelSecurityTokenTypes.SecureConversation;
+                       r.ListenUri = new Uri ("http://localhost:8080");
+                       r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion;
+                       r.KeySize = 256;
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               [Category ("NotWorking")]
+               public void CreateAuthenticatorSecureConvNoSecurityBindingElement ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateSecureConvRequirement ();
+                       r.SecurityBindingElement = null;
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               [Category ("NotWorking")]
+               public void CreateAuthenticatorSecureConvNoIssuedSecurityTokenParameters ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateSecureConvRequirement ();
+                       r.Properties.Remove (ReqType.IssuedSecurityTokenParametersProperty);
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               [Category ("NotWorking")]
+               public void CreateAuthenticatorSecureConvNoIssuerBindingContext ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateSecureConvRequirement ();
+                       r.Properties.Remove (ReqType.IssuerBindingContextProperty);
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               // The type of exception should not matter though.
+               [ExpectedException (typeof (NotSupportedException))]
+               [Category ("NotWorking")]
+               public void CreateAuthenticatorSecureConvNullMessageSecurityVersion ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateSecureConvRequirement ();
+                       r.MessageSecurityVersion = null;
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               [Category ("NotWorking")]
+               public void CreateAuthenticatorSecureConvNoMessageSecurityVersion ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateSecureConvRequirement ();
+                       r.Properties.Remove (ReqType.MessageSecurityVersionProperty);
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               public void CreateAuthenticatorSecureConv ()
+               {
+                       // service certificate is not required
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               CreateSecureConvRequirement ();
+                       SecurityTokenResolver resolver;
+                       //SecurityTokenAuthenticator a =
+                               def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+                       Assert.IsNotNull (resolver, "#1");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ServiceSecurityContextTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/ServiceSecurityContextTest.cs
new file mode 100644 (file)
index 0000000..b13141a
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// ServiceSecurityContextTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.IdentityModel.Policy;
+using System.Security.Principal;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+using PolicyList = System.Collections.ObjectModel.ReadOnlyCollection<System.IdentityModel.Policy.IAuthorizationPolicy>;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ServiceSecurityContextTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullArgs1 ()
+               {
+                       new ServiceSecurityContext (null, null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullArgs2 ()
+               {
+                       new ServiceSecurityContext ((AuthorizationContext) null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullArgs3 ()
+               {
+                       new ServiceSecurityContext ((PolicyList) null);
+               }
+
+               [Test]
+               public void Constructor ()
+               {
+                       ServiceSecurityContext c = new ServiceSecurityContext (new PolicyList (new IAuthorizationPolicy [0]));
+                       Assert.IsNotNull (c.AuthorizationContext, "#1");
+                       Assert.AreEqual (0, c.AuthorizationPolicies.Count, "#2");
+                       // it is somehow treated as anonymous ...
+                       Assert.IsTrue (c.IsAnonymous, "#3");
+                       // FIXME: test PrimaryIdentity
+               }
+
+               [Test]
+               public void Anonymous ()
+               {
+                       ServiceSecurityContext c = ServiceSecurityContext.Anonymous;
+                       Assert.IsNotNull (c.AuthorizationContext, "#1");
+                       Assert.AreEqual (0, c.AuthorizationPolicies.Count, "#2");
+                       Assert.IsTrue (c.IsAnonymous, "#3");
+                       // FIXME: test PrimaryIdentity
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SupportingTokenParametersTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/SupportingTokenParametersTest.cs
new file mode 100644 (file)
index 0000000..9d7fcf8
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// SupportingTokenParametersTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Security.Cryptography.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class SupportingTokenParametersTest
+       {
+               [Test]
+               public void DefaultItems ()
+               {
+                       SupportingTokenParameters p = new SupportingTokenParameters ();
+                       Assert.AreEqual (0, p.Endorsing.Count, "#1");
+                       Assert.AreEqual (0, p.Signed.Count, "#2");
+                       Assert.AreEqual (0, p.SignedEncrypted.Count, "#3");
+                       Assert.AreEqual (0, p.SignedEndorsing.Count, "#4");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Security/WSSecurityTokenSerializerTest.cs
new file mode 100644 (file)
index 0000000..a037465
--- /dev/null
@@ -0,0 +1,971 @@
+//
+// WSSecurityTokenSerializerTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.IdentityModel.Policy;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel.Security
+{
+       [TestFixture]
+       public class WSSecurityTokenSerializerTest
+       {
+               const string wssNS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
+               const string wsuNS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
+
+               static X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+
+               const string derived_key_token1 = @"<c:DerivedKeyToken u:Id='_1' xmlns:u='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' xmlns:c='http://schemas.xmlsoap.org/ws/2005/02/sc'>
+        <o:SecurityTokenReference xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
+          <o:Reference ValueType='http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey' URI='#uuid:urn:abc' />
+        </o:SecurityTokenReference>
+        <c:Offset>0</c:Offset>
+        <c:Length>24</c:Length>
+        <c:Nonce>BIUeTKeOhR5HeE646ZyA+w==</c:Nonce>
+      </c:DerivedKeyToken>";
+
+               const string derived_key_token2 = @"<c:DerivedKeyToken u:Id='_1' xmlns:u='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' xmlns:c='http://schemas.xmlsoap.org/ws/2005/02/sc'>
+        <o:SecurityTokenReference xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
+          <o:Reference ValueType='urn:my-own-way' URI='#uuid:urn:abc' />
+        </o:SecurityTokenReference>
+        <c:Offset>0</c:Offset>
+        <c:Length>24</c:Length>
+        <c:Nonce>BIUeTKeOhR5HeE646ZyA+w==</c:Nonce>
+      </c:DerivedKeyToken>";
+
+               const string wrapped_key1 = @"<e:EncryptedKey Id='_0' xmlns:e='http://www.w3.org/2001/04/xmlenc#'>
+  <e:EncryptionMethod Algorithm='http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p'>
+    <DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1' xmlns='http://www.w3.org/2000/09/xmldsig#'></DigestMethod>
+  </e:EncryptionMethod>
+  <KeyInfo xmlns='http://www.w3.org/2000/09/xmldsig#'>
+    <o:SecurityTokenReference xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
+<o:KeyIdentifier ValueType='http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1'>GQ3YHlGQhDF1bvMixHliX4uLjlY=</o:KeyIdentifier>
+    </o:SecurityTokenReference>
+  </KeyInfo>
+  <e:CipherData>
+    <e:CipherValue>RLRUq81oJNSKPZz4ToCmin7ymCdMpCJiiRx5c1RGZuILiLcU3zCZI2bN9UNgfTHnE4arcJzjwSOeuzFSn948Lr0w6kUaZQjJVzLozu2hBhhb8Kps4ekLWmrsca2c2VmjT9kKEihfCX4s1Pfv9aJyVpT3EGwH7vd9fr9k5G2RtKY=</e:CipherValue>
+  </e:CipherData>
+  <e:ReferenceList>
+    <e:DataReference URI='#_2'></e:DataReference>
+  </e:ReferenceList>
+</e:EncryptedKey>";
+
+               XmlWriterSettings GetWriterSettings ()
+               {
+                       XmlWriterSettings s = new XmlWriterSettings ();
+                       s.OmitXmlDeclaration = true;
+                       return s;
+               }
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       WSSecurityTokenSerializer ser = new WSSecurityTokenSerializer ();
+                       DefaultValues (ser);
+                       DefaultValues (WSSecurityTokenSerializer.DefaultInstance);
+               }
+
+               void DefaultValues (WSSecurityTokenSerializer ser)
+               {
+                       Assert.AreEqual (false, ser.EmitBspRequiredAttributes, "#1");
+                       Assert.AreEqual (128, ser.MaximumKeyDerivationLabelLength, "#2");
+                       Assert.AreEqual (128, ser.MaximumKeyDerivationNonceLength, "#3");
+                       Assert.AreEqual (64, ser.MaximumKeyDerivationOffset, "#4");
+                       Assert.AreEqual (SecurityVersion.WSSecurity11, ser.SecurityVersion, "#5");
+               }
+
+               [Test]
+               public void WriteX509SecurityToken1 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       X509SecurityToken t = new X509SecurityToken (cert, "urn:x509:1");
+                       Assert.IsNotNull (cert.GetRawCertData (), "premise: X509Certificate2.RawData");
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteToken (w, t);
+                       }
+                       string rawdata = Convert.ToBase64String (cert.RawData);
+                       Assert.AreEqual ("<o:BinarySecurityToken u:Id=\"urn:x509:1\" ValueType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3\" xmlns:u=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">" + rawdata + "</o:BinarySecurityToken>", sw.ToString ());
+               }
+
+               [Test]
+               public void WriteUserNameSecurityToken1 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       UserNameSecurityToken t = new UserNameSecurityToken ("mono", "poly", "urn:username:1");
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteToken (w, t);
+                       }
+                       // Hmm, no PasswordToken (and TokenType) ?
+                       Assert.AreEqual ("<o:UsernameToken u:Id=\"urn:username:1\" xmlns:u=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:Username>mono</o:Username><o:Password>poly</o:Password></o:UsernameToken>", sw.ToString ());
+               }
+
+               [Test]
+               public void WriteBinarySecretSecurityToken1 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       byte [] bytes = new byte [] {0, 1, 2, 3, 4, 5, 6, 7};
+                       BinarySecretSecurityToken t = new BinarySecretSecurityToken ("urn:binary:1", bytes);
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteToken (w, t);
+                       }
+                       // AAECAwQFBgc=
+                       string base64 = Convert.ToBase64String (bytes);
+                       Assert.AreEqual ("<t:BinarySecret u:Id=\"urn:binary:1\" xmlns:u=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" xmlns:t=\"http://schemas.xmlsoap.org/ws/2005/02/trust\">" + base64 + "</t:BinarySecret>", sw.ToString ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void WriteRsaSecurityToken ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       RSA rsa = (RSA) cert.PublicKey.Key;
+                       RsaSecurityToken t = new RsaSecurityToken (rsa, "urn:rsa:1");
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteToken (w, t);
+                       }
+               }
+
+               [Test]
+               public void WriteGenericXmlSecurityToken1 ()
+               {
+                       StringWriter sw = new StringWriter ();
+
+                       XmlElement xml = new XmlDocument ().CreateElement ("foo");
+                       SecurityToken token = new X509SecurityToken (new X509Certificate2 ("Test/Resources/test.pfx", "mono"));
+                       SecurityKeyIdentifierClause intref =
+                               token.CreateKeyIdentifierClause<X509IssuerSerialKeyIdentifierClause> ();
+                       SecurityKeyIdentifierClause extref =
+                       null; //        token.CreateKeyIdentifierClause<X509IssuerSerialKeyIdentifierClause> ();
+                       ReadOnlyCollection<IAuthorizationPolicy> policies =
+                               new ReadOnlyCollection<IAuthorizationPolicy> (
+                                       new IAuthorizationPolicy [0]);
+
+                       GenericXmlSecurityToken t = new GenericXmlSecurityToken (xml, token, DateTime.Now, new DateTime (2112, 9, 3), intref, extref, policies);
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteToken (w, t);
+                       }
+                       // Huh?
+                       Assert.AreEqual ("<foo />", sw.ToString ());
+               }
+
+               [Test]
+               public void WriteWrappedKeySecurityToken ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       byte [] bytes = new byte [64];
+                       for (byte i = 1; i < 64; i++)
+                               bytes [i] = i;
+
+                       SecurityToken wt = new X509SecurityToken (cert);
+                       SecurityKeyIdentifier ski = new SecurityKeyIdentifier (
+                               wt.CreateKeyIdentifierClause< X509ThumbprintKeyIdentifierClause> ());
+                       WrappedKeySecurityToken t = new WrappedKeySecurityToken (
+                               "urn:wrapper-key:1", bytes, SecurityAlgorithms.RsaOaepKeyWrap, wt, ski);
+
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteToken (w, t);
+                       }
+                       string actual = sw.ToString ();
+                       int idx = actual.IndexOf ("<e:CipherValue>", StringComparison.Ordinal);
+                       Assert.IsTrue (idx >= 0, "No <CipherValue>");
+                       actual = 
+                               actual.Substring (0, idx) +
+                               "<e:CipherValue>removed here" +
+                               actual.Substring (actual.IndexOf ("</e:CipherValue>", StringComparison.Ordinal));
+                       Assert.AreEqual ("GQ3YHlGQhDF1bvMixHliX4uLjlY=", Convert.ToBase64String (cert.GetCertHash ()), "premise#1");
+                       Assert.AreEqual (
+                               String.Format ("<e:EncryptedKey Id=\"urn:wrapper-key:1\" xmlns:e=\"{0}\"><e:EncryptionMethod Algorithm=\"{1}\"><DigestMethod Algorithm=\"{2}\" xmlns=\"{3}\" /></e:EncryptionMethod><KeyInfo xmlns=\"{3}\"><o:SecurityTokenReference xmlns:o=\"{4}\"><o:KeyIdentifier ValueType=\"{5}\">{6}</o:KeyIdentifier></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>removed here</e:CipherValue></e:CipherData></e:EncryptedKey>",
+                                       EncryptedXml.XmlEncNamespaceUrl,
+                                       SecurityAlgorithms.RsaOaepKeyWrap,
+                                       SignedXml.XmlDsigSHA1Url,
+                                       SignedXml.XmlDsigNamespaceUrl,
+                                       "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
+                                       "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1",
+                                       Convert.ToBase64String (cert.GetCertHash ())),// "GQ3YHlGQhDF1bvMixHliX4uLjlY="
+                               actual);
+               }
+
+               [Test]
+               public void WriteSecurityContextSecurityToken ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       SecurityContextSecurityToken t = new SecurityContextSecurityToken (
+                               new UniqueId ("urn:unique-id:securitycontext:1"),
+                               "urn:securitycontext:1",
+                               Convert.FromBase64String ("o/ilseZu+keLBBWGGPlUHweqxIPc4gzZEFWr2nBt640="),
+                               new DateTime (2006, 9, 26), new DateTime (2006, 9, 27));
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteToken (w, t);
+                       }
+                       Assert.AreEqual ("<c:SecurityContextToken u:Id=\"urn:securitycontext:1\" xmlns:u=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" xmlns:c=\"http://schemas.xmlsoap.org/ws/2005/02/sc\"><c:Identifier>urn:unique-id:securitycontext:1</c:Identifier></c:SecurityContextToken>", sw.ToString ());
+               }
+
+               [Test]
+               public void WriteX509IssuerSerialKeyIdentifierClause1 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       X509IssuerSerialKeyIdentifierClause ic = new X509IssuerSerialKeyIdentifierClause  (cert);
+                       string expected = "<o:SecurityTokenReference xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509IssuerSerial><X509IssuerName>CN=Mono Test Root Agency</X509IssuerName><X509SerialNumber>22491767666218099257720700881460366085</X509SerialNumber></X509IssuerSerial></X509Data></o:SecurityTokenReference>";
+
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       Assert.AreEqual (expected, sw.ToString (), "WSS1.1");
+
+                       sw = new StringWriter ();
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               new WSSecurityTokenSerializer (SecurityVersion.WSSecurity10).WriteKeyIdentifierClause (w, ic);
+                       Assert.AreEqual (expected, sw.ToString (), "WSS1.0");
+                       }
+               }
+
+               [Test]
+               public void WriteX509ThumbprintKeyIdentifierClause1 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       X509ThumbprintKeyIdentifierClause ic = new X509ThumbprintKeyIdentifierClause (cert);
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       Assert.AreEqual ("<o:SecurityTokenReference xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:KeyIdentifier ValueType=\"http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1\">GQ3YHlGQhDF1bvMixHliX4uLjlY=</o:KeyIdentifier></o:SecurityTokenReference>", sw.ToString ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void WriteX509ThumbprintKeyIdentifierClause2 ()
+               {
+                       // WS-Security1.0 x thumbprint = death
+                       using (XmlWriter w = XmlWriter.Create (TextWriter.Null)) {
+                               new WSSecurityTokenSerializer (SecurityVersion.WSSecurity10)
+                                       .WriteKeyIdentifierClause (w, new X509ThumbprintKeyIdentifierClause (cert));
+                       }
+               }
+
+               [Test]
+               public void WriteX509ThumbprintKeyIdentifierClause3 ()
+               {
+                       // EmitBspRequiredAttributes
+                       StringWriter sw = new StringWriter ();
+                       X509ThumbprintKeyIdentifierClause ic = new X509ThumbprintKeyIdentifierClause (cert);
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               new WSSecurityTokenSerializer (true).WriteKeyIdentifierClause (w, ic);
+                       }
+                       Assert.AreEqual ("<o:SecurityTokenReference xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:KeyIdentifier ValueType=\"http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1\" EncodingType=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">GQ3YHlGQhDF1bvMixHliX4uLjlY=</o:KeyIdentifier></o:SecurityTokenReference>", sw.ToString ());
+               }
+
+               [Test]
+               public void WriteEncryptedKeyIdentifierClause ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       byte [] bytes = new byte [32];
+                       SecurityKeyIdentifier cki = new SecurityKeyIdentifier ();
+                       cki.Add (new X509ThumbprintKeyIdentifierClause (cert));
+                       EncryptedKeyIdentifierClause ic =
+                               new EncryptedKeyIdentifierClause (bytes, SecurityAlgorithms.Aes256KeyWrap, cki);
+                       
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       string expected = String.Format ("<e:EncryptedKey xmlns:e=\"{0}\"><e:EncryptionMethod Algorithm=\"{1}\" /><KeyInfo xmlns=\"{2}\"><o:SecurityTokenReference xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:KeyIdentifier ValueType=\"{3}\">GQ3YHlGQhDF1bvMixHliX4uLjlY=</o:KeyIdentifier></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</e:CipherValue></e:CipherData></e:EncryptedKey>",
+                               EncryptedXml.XmlEncNamespaceUrl,
+                               SecurityAlgorithms.Aes256KeyWrap,
+                               SignedXml.XmlDsigNamespaceUrl,
+                               "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1");
+                       Assert.AreEqual (expected, sw.ToString ());
+               }
+
+               [Test]
+               public void WriteEncryptedKeyIdentifierClause2 () // derived key
+               {
+                       StringWriter sw = new StringWriter ();
+                       byte [] bytes = new byte [32];
+                       SecurityKeyIdentifier cki = new SecurityKeyIdentifier ();
+                       cki.Add (new X509ThumbprintKeyIdentifierClause (cert));
+                       EncryptedKeyIdentifierClause ic =
+                               new EncryptedKeyIdentifierClause (bytes, SecurityAlgorithms.Aes256KeyWrap, cki, "carriedKeyNaaaaame", new byte [32], 32);
+                       
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       string expected = String.Format ("<e:EncryptedKey xmlns:e=\"{0}\"><e:EncryptionMethod Algorithm=\"{1}\" /><KeyInfo xmlns=\"{2}\"><o:SecurityTokenReference xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:KeyIdentifier ValueType=\"{3}\">GQ3YHlGQhDF1bvMixHliX4uLjlY=</o:KeyIdentifier></o:SecurityTokenReference></KeyInfo><e:CipherData><e:CipherValue>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</e:CipherValue></e:CipherData><e:CarriedKeyName>carriedKeyNaaaaame</e:CarriedKeyName></e:EncryptedKey>",
+                               EncryptedXml.XmlEncNamespaceUrl,
+                               SecurityAlgorithms.Aes256KeyWrap,
+                               SignedXml.XmlDsigNamespaceUrl,
+                               "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1");
+                       Assert.AreEqual (expected, sw.ToString ());
+               }
+
+               [Test]
+               public void WriteEncryptedKeyIdentifierClause3 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       byte [] bytes = new byte [32];
+                       SecurityKeyIdentifier cki = new SecurityKeyIdentifier ();
+                       cki.Add (new X509ThumbprintKeyIdentifierClause (cert));
+                       EncryptedKeyIdentifierClause ic =
+                               new EncryptedKeyIdentifierClause (bytes, SecurityAlgorithms.Aes256Encryption);
+                       
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       string expected = String.Format ("<e:EncryptedKey xmlns:e=\"{0}\"><e:EncryptionMethod Algorithm=\"{1}\" /><e:CipherData><e:CipherValue>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</e:CipherValue></e:CipherData></e:EncryptedKey>",
+                               EncryptedXml.XmlEncNamespaceUrl,
+                               SecurityAlgorithms.Aes256Encryption,
+                               SignedXml.XmlDsigNamespaceUrl,
+                               "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1");
+                       Assert.AreEqual (expected, sw.ToString ());
+               }
+
+               [Test]
+               public void WriteEncryptedKeyIdentifierClause4 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       byte [] bytes = new byte [32];
+                       SecurityKeyIdentifier cki = new SecurityKeyIdentifier ();
+                       cki.Add (new BinarySecretKeyIdentifierClause (bytes));
+                       EncryptedKeyIdentifierClause ic =
+                               new EncryptedKeyIdentifierClause (bytes, SecurityAlgorithms.Aes256Encryption);
+                       
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       string expected = String.Format ("<e:EncryptedKey xmlns:e=\"{0}\"><e:EncryptionMethod Algorithm=\"{1}\" /><e:CipherData><e:CipherValue>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</e:CipherValue></e:CipherData></e:EncryptedKey>",
+                               EncryptedXml.XmlEncNamespaceUrl,
+                               SecurityAlgorithms.Aes256Encryption,
+                               SignedXml.XmlDsigNamespaceUrl,
+                               "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1");
+                       Assert.AreEqual (expected, sw.ToString ());
+               }
+
+               [Test]
+               public void WriteBinarySecretKeyIdentifierClause1 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       byte [] bytes = new byte [32];
+                       BinarySecretKeyIdentifierClause ic = new BinarySecretKeyIdentifierClause (bytes);
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       string expected = String.Format ("<t:BinarySecret xmlns:t=\"http://schemas.xmlsoap.org/ws/2005/02/trust\">{0}</t:BinarySecret>", Convert.ToBase64String (bytes));
+                       Assert.AreEqual (expected, sw.ToString (), "#1");
+               }
+
+               class MySecurityTokenParameters : SecurityTokenParameters
+               {
+                       public SecurityKeyIdentifierClause CallCreateKeyIdentifierClause (SecurityToken token, SecurityTokenReferenceStyle style)
+                       {
+                               return CreateKeyIdentifierClause (token, style);
+                       }
+
+                       protected override SecurityTokenParameters CloneCore ()
+                       {
+                               return this;
+                       }
+
+                       protected override bool HasAsymmetricKey {
+                               get { return false; }
+                       }
+                       protected override bool SupportsServerAuthentication {
+                               get { return false; }
+                       }
+                       protected override bool SupportsClientAuthentication {
+                               get { return false; }
+                       }
+                       protected override bool SupportsClientWindowsIdentity {
+                               get { return false; }
+                       }
+                       protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement r)
+                       {
+                       }
+
+                       protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (SecurityToken token, SecurityTokenReferenceStyle style)
+                       {
+                               throw new Exception ();
+                       }
+               }
+
+/* FIXME: something should output key identifier clause xml like this ...
+               [Test]
+               public void WriteInternalWrappedKeyIdentifierClause ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       byte [] bytes = new byte [32];
+                       EncryptedKeyIdentifierClause eic =
+                               new EncryptedKeyIdentifierClause (bytes, SecurityAlgorithms.Sha1Digest);
+                       SecurityKeyIdentifier ski = new SecurityKeyIdentifier (eic);
+                       WrappedKeySecurityToken token = new WrappedKeySecurityToken ("urn:foo", bytes, SecurityAlgorithms.RsaOaepKeyWrap, new X509SecurityToken (cert), ski);
+
+                       MySecurityTokenParameters p = new MySecurityTokenParameters ();
+                       SecurityKeyIdentifierClause ic =
+                               p.CallCreateKeyIdentifierClause (token, SecurityTokenReferenceStyle.External);
+
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       string expected = String.Format ("<o:SecurityTokenReference xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:KeyIdentifier ValueType=\"{0}\" Value=\"{1}\" /></o:SecurityTokenReference>",
+                               "http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKeySHA1", Convert.ToBase64String (bytes));
+                       Assert.AreEqual (expected, sw.ToString (), "#1");
+               }
+*/
+
+               [Test]
+               public void WriteLocalIdKeyIdentifierClause1 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       LocalIdKeyIdentifierClause ic = new LocalIdKeyIdentifierClause ("urn:myIDValue");
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       Assert.AreEqual ("<o:SecurityTokenReference xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:Reference URI=\"#urn:myIDValue\" /></o:SecurityTokenReference>", sw.ToString (), "#1");
+               }
+
+               [Test]
+               public void WriteLocalIdKeyIdentifierClause2 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       LocalIdKeyIdentifierClause ic = new LocalIdKeyIdentifierClause ("#urn:myIDValue");
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       // ... so, specifying an URI including '#' does not make sense
+                       Assert.AreEqual ("<o:SecurityTokenReference xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:Reference URI=\"##urn:myIDValue\" /></o:SecurityTokenReference>", sw.ToString (), "#2");
+               }
+
+               [Test]
+               public void WriteLocalIdKeyIdentifierClause3 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       LocalIdKeyIdentifierClause ic = new LocalIdKeyIdentifierClause ("urn:myIDValue", typeof (WrappedKeySecurityToken));
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       Assert.AreEqual ("<o:SecurityTokenReference xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:Reference URI=\"#urn:myIDValue\" /></o:SecurityTokenReference>", sw.ToString (), "#1");
+               }
+
+               [Test]
+               public void WriteLocalIdKeyIdentifierClause4 () // EmitBsp
+               {
+                       StringWriter sw = new StringWriter ();
+                       LocalIdKeyIdentifierClause ic = new LocalIdKeyIdentifierClause ("urn:myIDValue", typeof (WrappedKeySecurityToken));
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               new WSSecurityTokenSerializer (true).WriteKeyIdentifierClause (w, ic);
+                       }
+                       Assert.AreEqual ("<o:SecurityTokenReference xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:Reference ValueType=\"http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey\" URI=\"#urn:myIDValue\" /></o:SecurityTokenReference>", sw.ToString (), "#1");
+               }
+
+               [Test]
+               [Ignore ("fails on .net; no further verification")]
+               public void WriteLocalIdKeyIdentifierClause5 () // derivedKey
+               {
+                       StringWriter sw = new StringWriter ();
+                       LocalIdKeyIdentifierClause ic = new LocalIdKeyIdentifierClause ("urn:myIDValue", new byte [32], 16, typeof (WrappedKeySecurityToken));
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               new WSSecurityTokenSerializer (true).WriteKeyIdentifierClause (w, ic);
+                       }
+                       Assert.AreEqual ("<o:SecurityTokenReference xmlns:o=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"><o:Reference ValueType=\"http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey\" URI=\"#urn:myIDValue\" /></o:SecurityTokenReference>", sw.ToString (), "#1");
+               }
+
+               [Test]
+               public void WriteSecurityContextKeyIdentifierClause ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       SecurityContextKeyIdentifierClause ic = new SecurityContextKeyIdentifierClause (new UniqueId ("urn:foo:1"), null);
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       Assert.AreEqual (@"<o:SecurityTokenReference xmlns:o=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd""><o:Reference URI=""urn:foo:1"" ValueType=""http://schemas.xmlsoap.org/ws/2005/02/sc/sct"" /></o:SecurityTokenReference>", sw.ToString (), "#1");
+                       XmlReader reader = XmlReader.Create (new StringReader (sw.ToString ()));
+                       ic = WSSecurityTokenSerializer.DefaultInstance.ReadKeyIdentifierClause (reader) as SecurityContextKeyIdentifierClause;
+                       Assert.IsNotNull (ic, "#2");
+               }
+
+               class MySslParameters : SslSecurityTokenParameters
+               {
+                       public SecurityKeyIdentifierClause CallCreateKeyIdentifierClause (
+                               SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+                       {
+                               return CreateKeyIdentifierClause (token, referenceStyle);
+                       }
+               }
+
+               [Test]
+               public void WriteSecurityContextKeyIdentifierClause2 ()
+               {
+                       StringWriter sw = new StringWriter ();
+                       MySslParameters tp = new MySslParameters ();
+                       SecurityContextSecurityToken sct =
+                               new SecurityContextSecurityToken (new UniqueId ("urn:foo:1"), "urn:foo:2", new byte [32], DateTime.MinValue, DateTime.MaxValue);
+                       SecurityKeyIdentifierClause ic =
+                               tp.CallCreateKeyIdentifierClause (sct, SecurityTokenReferenceStyle.Internal);
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               WSSecurityTokenSerializer.DefaultInstance.WriteKeyIdentifierClause (w, ic);
+                       }
+                       Assert.AreEqual (@"<o:SecurityTokenReference xmlns:o=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd""><o:Reference URI=""#urn:foo:2"" /></o:SecurityTokenReference>", sw.ToString (), "#1");
+                       XmlReader reader = XmlReader.Create (new StringReader (sw.ToString ()));
+                       ic = WSSecurityTokenSerializer.DefaultInstance.ReadKeyIdentifierClause (reader) as LocalIdKeyIdentifierClause;
+                       Assert.IsNotNull (ic, "#2");
+               }
+
+               [Test]
+               public void ReadKeyIdentifierClause ()
+               {
+                       string xml = @"<o:SecurityTokenReference xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
+            <o:Reference URI='#uuid-9c90d2c7-c82f-4c63-9b28-fc24479ee3a7-2' />
+          </o:SecurityTokenReference>";
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (xml))) {
+                               SecurityKeyIdentifierClause kic = serializer.ReadKeyIdentifierClause (xr);
+                               Assert.IsTrue (kic is LocalIdKeyIdentifierClause, "#1");
+                       }
+               }
+
+               [Test]
+               public void ReadEncryptedKeyIdentifierClause ()
+               {
+                       string xml = @"<e:EncryptedKey xmlns:ds='http://www.w3.org/2000/09/xmldsig#' xmlns:e='http://www.w3.org/2001/04/xmlenc#' Id='ID_EncryptedKeyClause'>  <e:EncryptionMethod Algorithm='http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p'>  <ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1' />  </e:EncryptionMethod>  <ds:KeyInfo>  <o:SecurityTokenReference xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>  <o:Reference URI='#uuid-9c90d2c7-c82f-4c63-9b28-fc24479ee3a7-2' />  </o:SecurityTokenReference>  </ds:KeyInfo>  <e:CipherData>  <e:CipherValue>Iwg585s5eQP5If4/bY/PPBmHVFt23z6MaHDaD9/u1Ua7hveRfoER3d6sJTk7PL4LoLHjwaAa6EGHZyrgq7He+efvsiAhJYTeh/C/RYO7jKdSr8Gp1IIY7wA+/CBhV7SUhRZs4YJ1GE+rIQ/No6FPk/MbpIALEZ6RpqiLYVVCvUI=</e:CipherValue>  </e:CipherData></e:EncryptedKey>";
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       EncryptedKeyIdentifierClause kic;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (xml))) {
+                               kic = serializer.ReadKeyIdentifierClause (xr) as EncryptedKeyIdentifierClause;
+                       }
+                       Assert.IsNotNull (kic, "#1");
+                       Assert.IsNull (kic.CarriedKeyName, "#2");
+                       Assert.AreEqual (EncryptedXml.XmlEncRSAOAEPUrl, kic.EncryptionMethod, "#3");
+                       Assert.AreEqual (1, kic.EncryptingKeyIdentifier.Count, "#4");
+                       LocalIdKeyIdentifierClause ekic = kic.EncryptingKeyIdentifier [0] as LocalIdKeyIdentifierClause;
+                       Assert.IsNotNull (ekic, "#5");
+                       Assert.AreEqual ("uuid-9c90d2c7-c82f-4c63-9b28-fc24479ee3a7-2", ekic.LocalId, "#6");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))] // .NET says that KeyIdentifier is not the expected element, but actually it is because of ValueType.
+               public void ReadKeyIdentifierReferenceWrongVallueType ()
+               {
+                       string xml = @"<o:SecurityTokenReference xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
+            <o:KeyIdentifier ValueType='hogehoge'>xr42fAKDBNItO0aRPKFqc0kaiiU=</o:KeyIdentifier>
+          </o:SecurityTokenReference>";
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (xml))) {
+                               SecurityKeyIdentifierClause kic = serializer.ReadKeyIdentifierClause (xr);
+                               Assert.IsTrue (kic is X509ThumbprintKeyIdentifierClause, "#1");
+                       }
+               }
+
+               [Test]
+               public void ReadKeyIdentifierThumbprint ()
+               {
+                       string xml = @"<o:SecurityTokenReference xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
+            <o:KeyIdentifier ValueType='http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1' EncodingType='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'>xr42fAKDBNItO0aRPKFqc0kaiiU=</o:KeyIdentifier>
+          </o:SecurityTokenReference>";
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (xml))) {
+                               SecurityKeyIdentifierClause kic = serializer.ReadKeyIdentifierClause (xr);
+                               Assert.IsTrue (kic is X509ThumbprintKeyIdentifierClause, "#1");
+                       }
+               }
+
+               [Test]
+               public void ReadKeyIdentifierEncryptedKey ()
+               {
+                       string xml = @"<o:SecurityTokenReference xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
+            <o:KeyIdentifier ValueType='http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKeySHA1'>xr42fAKDBNItO0aRPKFqc0kaiiU=</o:KeyIdentifier>
+          </o:SecurityTokenReference>";
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (xml))) {
+                               SecurityKeyIdentifierClause kic = serializer.ReadKeyIdentifierClause (xr);
+                               Assert.IsTrue (kic is BinaryKeyIdentifierClause, "#1");
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))] // not sure how this exception type makes sense...
+               public void ReadEmptyUsernameToken ()
+               {
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (String.Format ("<o:UsernameToken u:Id='urn:foo' xmlns:o='{0}' xmlns:u='{1}' />", wssNS, wsuNS)))) {
+                               serializer.ReadToken (xr, null);
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))] // tokenResolver is null
+               public void ReadTokenDerivedKeyTokenNullResolver ()
+               {
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (derived_key_token1))) {
+                               serializer.ReadToken (xr, null);
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))] // DerivedKeyToken requires a reference to an existent token.
+               public void ReadTokenDerivedKeyTokenRefToNonExistent ()
+               {
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (derived_key_token1))) {
+                               serializer.ReadToken (xr, GetResolver ());
+                       }
+               }
+
+               [Test]
+               public void ReadWriteTokenDerivedKeyTokenRefToExistent ()
+               {
+                       WSSecurityTokenSerializer serializer =
+                               new WSSecurityTokenSerializer (true); // emitBSP
+                       SecurityToken token;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (derived_key_token1))) {
+                               token = serializer.ReadToken (xr,
+                                       GetResolver (
+                                               new WrappedKeySecurityToken ("uuid:urn:abc", new byte [32], SecurityAlgorithms.RsaOaepKeyWrap, new X509SecurityToken (cert), null)
+                                       ));
+                       }
+                       StringWriter sw = new StringWriter ();
+                       using (XmlWriter w = XmlWriter.Create (sw, GetWriterSettings ())) {
+                               serializer.WriteToken (w, token);
+                       }
+                       Assert.AreEqual (derived_key_token1.Replace ('\'', '"').Replace ("  ", "").Replace ("\n", "").Replace ("\r", ""), sw.ToString ());
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))] // not sure how this exception type makes sense.
+               public void ReadTokenDerivedKeyTokenRefToExistent2 ()
+               {
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (derived_key_token1))) {
+                               // different token value type to be resolved 
+                               // than what is explicitly specified in
+                               // <o:Reference>.
+                               serializer.ReadToken (xr,
+                                       GetResolver (new X509SecurityToken (cert, "uuid:urn:abc")));
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))] // not sure how this exception type makes sense.
+               public void ReadTokenDerivedKeyTokenRefUnsupported ()
+               {
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (derived_key_token2))) {
+                               // different token value type to be resolved 
+                               // than what is explicitly specified in
+                               // <o:Reference>.
+                               serializer.ReadToken (xr,
+                                       GetResolver (new X509SecurityToken (cert, "uuid:urn:abc")));
+                       }
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ReadSecurityContextSecurityTokenNoRegisteredToken ()
+               {
+                       try {
+                               ReadSecurityContextSecurityTokenNoRegisteredTokenCore ();
+                               Assert.Fail ("Exception expected.");
+                       } catch (SecurityTokenException) {
+                       }
+               }
+
+               void ReadSecurityContextSecurityTokenNoRegisteredTokenCore ()
+               {
+                       string xml = "<c:SecurityContextToken u:Id=\"urn:securitycontext:1\" xmlns:u=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" xmlns:c=\"http://schemas.xmlsoap.org/ws/2005/02/sc\"><c:Identifier>urn:unique-id:securitycontext:1</c:Identifier></c:SecurityContextToken>";
+
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (xml))) {
+                               serializer.ReadToken (xr, GetResolver (new X509SecurityToken (cert, "urn:unique-id:securitycontext:1")));
+                       }
+               }
+
+               [Test]
+               public void ReadSslnegoSCTNoStateEncoder ()
+               {
+                       string cookie = "QgBCAoNCBpkrdXVpZC03MDlhYjYwOC0yMDA0LTQ0ZDUtYjM5Mi1mM2M1YmY3YzY3ZmItMUIErZ3da7enifVFg+e0dObwRLNCCJ4egLowfrwP4Hgn0lOSqlA2fr0k4NAKgRZX+0BVs2EOnwJ6xkIOjzCAEnLHQMkIQhCPMJC+QxtByQhCFI8wgBJyx0DJCEIWjzCQvkMbQckIAQ==";
+                       string xml = String.Format (@"<c:SecurityContextToken u:Id='uuid-709ab608-2004-44d5-b392-f3c5bf7c67fb-1' xmlns:c='http://schemas.xmlsoap.org/ws/2005/02/sc' xmlns:u='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
+  <c:Identifier>urn:uuid:b76bdd9d-89a7-45f5-83e7-b474e6f044b3</c:Identifier>
+  <dnse:Cookie xmlns:dnse='http://schemas.microsoft.com/ws/2006/05/security'>{0}</dnse:Cookie>
+</c:SecurityContextToken>", cookie);
+                       string expectedKey = "gLowfrwP4Hgn0lOSqlA2fr0k4NAKgRZX+0BVs2EOesY=";
+
+                       WSSecurityTokenSerializer serializer =
+                               new WSSecurityTokenSerializer (MessageSecurityVersion.Default.SecurityVersion,
+                                       false,
+                                       new SamlSerializer (),
+                                       new MyStateEncoder (),
+                                       null);
+                       SecurityContextSecurityToken sct;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (xml))) {
+                               // Token is not registered, but is restored from the cookie
+                               sct = serializer.ReadToken (xr, null) as SecurityContextSecurityToken;
+                       }
+                       Assert.IsNotNull (sct, "#1");
+                       Assert.AreEqual (new UniqueId ("urn:uuid:b76bdd9d-89a7-45f5-83e7-b474e6f044b3"), sct.ContextId, "#2");
+                       Assert.IsNotNull (sct.AuthorizationPolicies.Count, "#3");
+                       Assert.AreEqual (0, sct.AuthorizationPolicies.Count, "#4");
+                       Assert.AreEqual (1, sct.SecurityKeys.Count, "#5");
+                       Assert.AreEqual (expectedKey, Convert.ToBase64String (((SymmetricSecurityKey) sct.SecurityKeys [0]).GetSymmetricKey ()), "#6");
+
+                       byte [] xmlbin = Convert.FromBase64String (cookie);
+                       XmlDictionary dic = new XmlDictionary ();
+                       for (int i = 0; i < 12; i++)
+                               dic.Add ("n" + i);
+                       XmlDictionaryReader br = XmlDictionaryReader.CreateBinaryReader (xmlbin, 0, xmlbin.Length, dic, new XmlDictionaryReaderQuotas ());
+                       while (br.LocalName != "n4")
+                               if (!br.Read ())
+                                       Assert.Fail ("Unxpected binary xmlreader failure.");
+                       byte [] key = br.ReadElementContentAsBase64 ();
+                       // Hmm, so, looks like the Cookie binary depends not
+                       // on SSL protection but on the state encoder ...
+                       // does it make sense, or is a different key resolved
+                       // as a result of TLS negotiation?
+                       Assert.AreEqual (expectedKey, Convert.ToBase64String (key), "#7");
+               }
+
+               class MyStateEncoder : SecurityStateEncoder
+               {
+                       protected override byte [] DecodeSecurityState (byte [] src)
+                       {
+                               return src;
+                       }
+                       protected override byte [] EncodeSecurityState (byte [] src)
+                       {
+                               return src;
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void ReadSecurityContextSecurityTokenSslnego3 ()
+               {
+                       // full RSTR ... fails
+                       string xml = @"<t:RequestSecurityTokenResponse Context='uuid-d88a7f14-97b7-4663-a548-c59a2a1c652f' xmlns:t='http://schemas.xmlsoap.org/ws/2005/02/trust' xmlns:u='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
+        <t:TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</t:TokenType>
+        <t:RequestedSecurityToken>
+          <c:SecurityContextToken u:Id='uuid-8921c433-1f44-4ff1-99c7-c70ba90c56c3-1' xmlns:c='http://schemas.xmlsoap.org/ws/2005/02/sc'>
+            <c:Identifier>urn:uuid:6ee2d642-484a-4e08-a9f4-a2bfe4f2d540</c:Identifier>
+            <dnse:Cookie xmlns:dnse='http://schemas.microsoft.com/ws/2006/05/security'>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAbwpVqF25WkyFYDXHavE7SwAAAAACAAAAAAADZgAAqAAAABAAAAD+ZtWd8MLaBeaMn+xLvyAhAAAAAASAAACgAAAAEAAAAKxhFZ5l669I+hLsZTunH12gAAAAQKjqxZo4eRtLLRO0kA0qHCNaazWddGbVdVzeMY8uIjBgl6UAMroZ6N5MAsACNbKLcYfdtEvZa1P1MTT+8dpsnWRCy5/UcQkg6mlrBAkYzEMYT8yNxRF/xEIXMpRAB5e2De4tUTFwIBIRBBKoay+oWP1M4Hcq7C8HDAqOjNyMOAUILIcz5hMFjtBDwJ4EfogiUVr02xGiXoHqEodxT75wKxQAAABQ3v/KgM1WGIDVcDypm1sNE6SASQ==</dnse:Cookie>
+          </c:SecurityContextToken>
+        </t:RequestedSecurityToken>
+        <t:RequestedAttachedReference>
+          <o:SecurityTokenReference xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
+            <o:Reference URI='#uuid-8921c433-1f44-4ff1-99c7-c70ba90c56c3-1'>
+            </o:Reference>
+          </o:SecurityTokenReference>
+        </t:RequestedAttachedReference>
+        <t:RequestedUnattachedReference>
+          <o:SecurityTokenReference xmlns:o='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'>
+            <o:Reference URI='urn:uuid:6ee2d642-484a-4e08-a9f4-a2bfe4f2d540' ValueType='http://schemas.xmlsoap.org/ws/2005/02/sc/sct'>
+            </o:Reference>
+          </o:SecurityTokenReference>
+        </t:RequestedUnattachedReference>
+        <t:RequestedProofToken>
+          <e:EncryptedKey xmlns:e='http://www.w3.org/2001/04/xmlenc#'>
+            <e:EncryptionMethod Algorithm='http://schemas.xmlsoap.org/2005/02/trust/tlsnego#TLS_Wrap'>
+            </e:EncryptionMethod>
+            <e:CipherData>
+              <e:CipherValue>FwMBADB9aB76Af+8UmE6nuo5bSh1OwbBjlImD1BY2NUbcByLmCgIARvC+KutimPRXwnMio8=</e:CipherValue>
+            </e:CipherData>
+          </e:EncryptedKey>
+        </t:RequestedProofToken>
+        <t:Lifetime>
+          <u:Created>2007-03-09T18:51:37.109Z</u:Created>
+          <u:Expires>2007-03-10T04:51:37.109Z</u:Expires>
+        </t:Lifetime>
+        <t:KeySize>256</t:KeySize>
+        <t:BinaryExchange ValueType=' http://schemas.xmlsoap.org/ws/2005/02/trust/tlsnego' EncodingType='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'>FAMBAAEBFgMBACALQXwZMThkzZ0m4ICTSg/tcKk2eB+IKLRIhwFKHm+G6w==</t:BinaryExchange>
+      </t:RequestSecurityTokenResponse>
+      <t:RequestSecurityTokenResponse Context='uuid-d88a7f14-97b7-4663-a548-c59a2a1c652f' xmlns:u='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'>
+        <t:Authenticator>
+          <t:CombinedHash>O6A+tpZvcUnI/+HMW2qWREreuFHDV3SVfMCJ2haq27A=</t:CombinedHash>
+        </t:Authenticator>
+      </t:RequestSecurityTokenResponse>";
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (xml))) {
+                               serializer.ReadToken (xr, null);
+                       }
+               }
+
+
+               [Test]
+               public void ReadWrappedKeySecurityToken ()
+               {
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (wrapped_key1))) {
+                               WrappedKeySecurityToken token = serializer.ReadToken (xr, GetResolver (new X509SecurityToken (cert))) as WrappedKeySecurityToken;
+                               Assert.IsNotNull (token, "#1");
+                               Assert.AreEqual (1, token.SecurityKeys.Count, "#2");
+                               SymmetricSecurityKey sk = token.SecurityKeys [0] as SymmetricSecurityKey;
+                               Assert.IsNotNull (sk, "#3");
+                               byte [] wk = Convert.FromBase64String ("RLRUq81oJNSKPZz4ToCmin7ymCdMpCJiiRx5c1RGZuILiLcU3zCZI2bN9UNgfTHnE4arcJzjwSOeuzFSn948Lr0w6kUaZQjJVzLozu2hBhhb8Kps4ekLWmrsca2c2VmjT9kKEihfCX4s1Pfv9aJyVpT3EGwH7vd9fr9k5G2RtKY=");
+                               Assert.AreEqual (wk, token.GetWrappedKey (), "#4");
+                       }
+               }
+
+               [Test]
+               public void ReadWrappedKeySecurityTokenImplCheck ()
+               {
+                       SecurityTokenResolver tokenResolver = GetResolver (new X509SecurityToken (cert));
+                       XmlReader reader = XmlReader.Create (new StringReader (wrapped_key1));
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+
+                       EncryptedKey ek = new EncryptedKey ();
+                       ek.LoadXml (new XmlDocument ().ReadNode (reader) as XmlElement);
+                       SecurityKeyIdentifier ki = new SecurityKeyIdentifier ();
+                       foreach (KeyInfoClause kic in ek.KeyInfo)
+                               ki.Add (serializer.ReadKeyIdentifierClause (new XmlNodeReader (kic.GetXml ())));
+                       SecurityToken token = tokenResolver.ResolveToken (ki);
+                       string alg = ek.EncryptionMethod.KeyAlgorithm;
+
+                       SecurityKey skey = token.SecurityKeys [0];
+                       Assert.IsTrue (skey is X509AsymmetricSecurityKey, "#1");
+                       Assert.IsTrue (skey.IsSupportedAlgorithm (alg), "#2");
+                       Assert.AreEqual (
+                               EncryptedXml.DecryptKey (ek.CipherData.CipherValue, cert.PrivateKey as RSA, true),
+                               skey.DecryptKey (alg, ek.CipherData.CipherValue),
+                               "#3");
+
+                       byte [] key = skey.DecryptKey (alg, ek.CipherData.CipherValue);
+                       WrappedKeySecurityToken wk =
+                               new WrappedKeySecurityToken (ek.Id, key, alg, token, ki);
+                       Assert.AreEqual (
+                               EncryptedXml.DecryptKey (ek.CipherData.CipherValue, cert.PrivateKey as RSA, true),
+                               skey.DecryptKey (alg, wk.GetWrappedKey ()),
+                               "#4");
+               }
+
+               [Test]
+               // It raises strange XmlException that wraps ArgumentNullException. Too silly to follow.
+               public void ReadWrappedKeySecurityTokenNullResolver ()
+               {
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (wrapped_key1))) {
+                               try {
+                                       serializer.ReadToken (xr, null);
+                                       Assert.Fail ("Should fail due to the lack of resolver");
+                               } catch {
+                               }
+                       }
+               }
+
+               [Test]
+               [Ignore ("not sure how we can consume this RequestedProofToken yet.")]
+               public void ReadTlsnegoRequestedProofToken ()
+               {
+                       string xml = @"<e:EncryptedKey xmlns:e=""http://www.w3.org/2001/04/xmlenc#""><e:EncryptionMethod Algorithm=""http://schemas.xmlsoap.org/2005/02/trust/tlsnego#TLS_Wrap""></e:EncryptionMethod><e:CipherData><e:CipherValue>FwMBADD/I64jS8yQM4+yn1FPr1+enSjRwoyw1c/hdEDWqfkW/parE9yq5zNKwO0g7zQaFXg=</e:CipherValue></e:CipherData></e:EncryptedKey>";
+
+                       WSSecurityTokenSerializer serializer =
+                               WSSecurityTokenSerializer.DefaultInstance;
+                       using (XmlReader xr = XmlReader.Create (new StringReader (xml))) {
+                               serializer.ReadToken (xr, GetResolver (new X509SecurityToken (cert, "urn:unique-id:foo")));
+                       }
+               }
+
+               class MyResolver : SecurityTokenResolver
+               {
+                       protected override bool TryResolveTokenCore (SecurityKeyIdentifier ident, out SecurityToken token)
+                       {
+throw new Exception ("1");
+//                             token = null;
+//                             return false;
+                       }
+
+                       protected override bool TryResolveTokenCore (SecurityKeyIdentifierClause clause, out SecurityToken token)
+                       {
+throw new Exception ("2");
+//                             token = null;
+//                             return false;
+                       }
+
+                       protected override bool TryResolveSecurityKeyCore (SecurityKeyIdentifierClause clause, out SecurityKey key)
+                       {
+throw new Exception ("3");
+//                             key = null;
+//                             return false;
+                       }
+               }
+
+               SecurityTokenResolver GetResolver (params SecurityToken [] tokens)
+               {
+                       return SecurityTokenResolver.CreateDefaultSecurityTokenResolver (
+                               new ReadOnlyCollection<SecurityToken> (tokens), true);
+               }
+
+               [Test]
+               public void GetTokenTypeUri ()
+               {
+                       new MyWSSecurityTokenSerializer ().TestGetTokenTypeUri ();
+               }
+       }
+
+       class MyWSSecurityTokenSerializer : WSSecurityTokenSerializer
+       {
+               public void TestGetTokenTypeUri ()
+               {
+                       Assert.IsNull (GetTokenTypeUri (GetType ()), "#1");
+                       Assert.AreEqual ("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3",
+                               GetTokenTypeUri (typeof (X509SecurityToken)), "#2");
+                       Assert.IsNull (GetTokenTypeUri (typeof (RsaSecurityToken)), "#3");
+                       Assert.AreEqual ("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1",
+                               GetTokenTypeUri (typeof (SamlSecurityToken)), "#4");
+                       Assert.AreEqual ("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken",
+                               GetTokenTypeUri (typeof (UserNameSecurityToken)), "#5");
+                       Assert.IsNull (GetTokenTypeUri (typeof (SspiSecurityToken)), "#6");
+                       Assert.AreEqual ("http://schemas.xmlsoap.org/ws/2005/02/sc/sct",
+                               GetTokenTypeUri (typeof (SecurityContextSecurityToken)), "#7");
+                       Assert.IsNull (GetTokenTypeUri (typeof (GenericXmlSecurityToken)), "#8");
+                       Assert.AreEqual ("http://docs.oasis-open.org/wss/oasis-wss-kerberos-token-profile-1.1#GSS_Kerberosv5_AP_REQ",
+                               GetTokenTypeUri (typeof (KerberosRequestorSecurityToken)), "#9");
+                       Assert.AreEqual ("http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey",
+                               GetTokenTypeUri (typeof (WrappedKeySecurityToken)), "#10");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/BasicHttpBindingTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/BasicHttpBindingTest.cs
new file mode 100644 (file)
index 0000000..efd2208
--- /dev/null
@@ -0,0 +1,263 @@
+//
+// BasicHttpBindingTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using NUnit.Framework;
+using System.ServiceModel.Configuration;
+using System.Configuration;
+using System.Text;
+using System.Net;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class BasicHttpBindingTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       BasicHttpBinding b = new BasicHttpBinding ();
+                       DefaultValues (b);
+
+                       // BasicHttpSecurity
+                       BasicHttpSecurity sec = b.Security;
+                       Assert.IsNotNull (sec, "#2-1");
+                       Assert.AreEqual (BasicHttpSecurityMode.None, sec.Mode, "#2-2");
+                       BasicHttpMessageSecurity msg = sec.Message;
+                       Assert.IsNotNull (msg, "#2-3-1");
+                       Assert.AreEqual (SecurityAlgorithmSuite.Default, msg.AlgorithmSuite, "#2-3-2");
+                       Assert.AreEqual (BasicHttpMessageCredentialType.UserName, msg.ClientCredentialType, "#2-3-3");
+                       HttpTransportSecurity trans = sec.Transport;
+                       Assert.IsNotNull (trans, "#2-4-1");
+                       Assert.AreEqual (HttpClientCredentialType.None, trans.ClientCredentialType, "#2-4-2");
+                       Assert.AreEqual (HttpProxyCredentialType.None, trans.ProxyCredentialType, "#2-4-3");
+                       Assert.AreEqual ("", trans.Realm, "#2-4-4");
+
+                       // Binding elements
+                       BindingElementCollection bec = b.CreateBindingElements ();
+                       Assert.AreEqual (2, bec.Count, "#5-1");
+                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement),
+                               bec [0].GetType (), "#5-2");
+                       Assert.AreEqual (typeof (HttpTransportBindingElement),
+                               bec [1].GetType (), "#5-3");
+               }
+
+               [Test]
+               public void DefaultValueSecurityModeMessage ()
+               {
+                       BasicHttpBinding b = new BasicHttpBinding (BasicHttpSecurityMode.Message);
+                       b.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate;
+                       DefaultValues (b);
+
+                       // BasicHttpSecurity
+                       BasicHttpSecurity sec = b.Security;
+                       Assert.IsNotNull (sec, "#2-1");
+                       Assert.AreEqual (BasicHttpSecurityMode.Message, sec.Mode, "#2-2");
+                       BasicHttpMessageSecurity msg = sec.Message;
+                       Assert.IsNotNull (msg, "#2-3-1");
+                       Assert.AreEqual (SecurityAlgorithmSuite.Default, msg.AlgorithmSuite, "#2-3-2");
+                       Assert.AreEqual (BasicHttpMessageCredentialType.Certificate, msg.ClientCredentialType, "#2-3-3");
+                       HttpTransportSecurity trans = sec.Transport;
+                       Assert.IsNotNull (trans, "#2-4-1");
+                       Assert.AreEqual (HttpClientCredentialType.None, trans.ClientCredentialType, "#2-4-2");
+                       Assert.AreEqual (HttpProxyCredentialType.None, trans.ProxyCredentialType, "#2-4-3");
+                       Assert.AreEqual ("", trans.Realm, "#2-4-4");
+
+                       // Binding elements
+                       BindingElementCollection bec = b.CreateBindingElements ();
+                       Assert.AreEqual (3, bec.Count, "#5-1");
+                       Assert.AreEqual (typeof (AsymmetricSecurityBindingElement),
+                               bec [0].GetType (), "#5-2");
+                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement),
+                               bec [1].GetType (), "#5-3");
+                       Assert.AreEqual (typeof (HttpTransportBindingElement),
+                               bec [2].GetType (), "#5-4");
+               }
+
+               void DefaultValues (BasicHttpBinding b)
+               {
+                       Assert.AreEqual (false, b.BypassProxyOnLocal, "#1");
+                       Assert.AreEqual (HostNameComparisonMode.StrongWildcard,
+                               b.HostNameComparisonMode, "#2");
+                       Assert.AreEqual (0x80000, b.MaxBufferPoolSize, "#3");
+                       Assert.AreEqual (0x10000, b.MaxBufferSize, "#4");
+                       Assert.AreEqual (0x10000, b.MaxReceivedMessageSize, "#5");
+                       Assert.AreEqual (WSMessageEncoding.Text, b.MessageEncoding, "#6");
+                       Assert.IsNull (b.ProxyAddress, "#7");
+                       // FIXME: test b.ReaderQuotas
+                       Assert.AreEqual ("http", b.Scheme, "#8");
+                       Assert.AreEqual (EnvelopeVersion.Soap11, b.EnvelopeVersion, "#9");
+                       Assert.AreEqual (65001, b.TextEncoding.CodePage, "#10"); // utf-8
+                       Assert.AreEqual (TransferMode.Buffered, b.TransferMode, "#11");
+                       Assert.AreEqual (true, b.UseDefaultWebProxy, "#12");
+
+/*
+                       // Interfaces
+                       IBindingDeliveryCapabilities ib = (IBindingDeliveryCapabilities ) b;
+                       Assert.AreEqual (false, ib.AssuresOrderedDelivery, "#2-1");
+                       Assert.AreEqual (false, ib.QueuedDelivery, "#2-3");
+
+                       IBindingMulticastCapabilities imc = (IBindingMulticastCapabilities) b;
+                       Assert.AreEqual (false, imc.IsMulticast, "#2.2-1");
+
+                       IBindingRuntimePreferences ir =
+                               (IBindingRuntimePreferences) b;
+                       Assert.AreEqual (false, ir.ReceiveSynchronously, "#3-1");
+
+                       ISecurityCapabilities ic = b as ISecurityCapabilities;
+                       Assert.AreEqual (ProtectionLevel.None,
+                               ic.SupportedRequestProtectionLevel, "#4-1");
+                       Assert.AreEqual (ProtectionLevel.None,
+                               ic.SupportedResponseProtectionLevel, "#4-2");
+                       Assert.AreEqual (false, ic.SupportsClientAuthentication, "#4-3");
+                       Assert.AreEqual (false, ic.SupportsClientWindowsIdentity, "#4-4");
+                       Assert.AreEqual (false, ic.SupportsServerAuthentication, "#4-5");
+*/
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void DefaultValueSecurityModeMessageError ()
+               {
+                       BasicHttpBinding b = new BasicHttpBinding (BasicHttpSecurityMode.Message);
+                       // "BasicHttp binding requires that BasicHttpBinding.Security.Message.ClientCredentialType be equivalent to the BasicHttpMessageCredentialType.Certificate credential type for secure messages. Select Transport or TransportWithMessageCredential security for UserName credentials."
+                       b.CreateBindingElements ();
+               }
+
+               [Test]
+               public void MessageEncoding ()
+               {
+                       BasicHttpBinding b = new BasicHttpBinding ();
+                       foreach (BindingElement be in b.CreateBindingElements ()) {
+                               MessageEncodingBindingElement mbe =
+                                       be as MessageEncodingBindingElement;
+                               if (mbe != null) {
+                                       MessageEncoderFactory f = mbe.CreateMessageEncoderFactory ();
+                                       MessageEncoder e = f.Encoder;
+
+                                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement), mbe.GetType (), "#1-1");
+                                       Assert.AreEqual (MessageVersion.Soap11, f.MessageVersion, "#2-1");
+                                       Assert.AreEqual ("text/xml; charset=utf-8", e.ContentType, "#3-1");
+                                       Assert.AreEqual ("text/xml", e.MediaType, "#3-2");
+                                       return;
+                               }
+                       }
+                       Assert.Fail ("No message encodiing binding element.");
+               }
+
+               [Test]
+               public void ApplyConfiguration ()
+               {
+                       BasicHttpBinding b = CreateBindingFromConfig ();
+
+                       Assert.AreEqual (true, b.AllowCookies, "#1");
+                       Assert.AreEqual (true, b.BypassProxyOnLocal, "#2");
+                       Assert.AreEqual (HostNameComparisonMode.Exact, b.HostNameComparisonMode, "#3");
+                       Assert.AreEqual (262144, b.MaxBufferPoolSize, "#4");
+                       Assert.AreEqual (32768, b.MaxBufferSize, "#5");
+                       Assert.AreEqual (32768, b.MaxReceivedMessageSize, "#6");
+                       Assert.AreEqual ("proxy", b.ProxyAddress.ToString (), "#7");
+                       Assert.AreEqual (Encoding.Unicode, b.TextEncoding, "#7");
+                       Assert.AreEqual (TransferMode.Streamed, b.TransferMode, "#7");
+               }
+
+               [Test]
+               public void CreateBindingElements ()
+               {
+                       BasicHttpBinding b = CreateBindingFromConfig ();
+
+                       // Binding elements
+                       BindingElementCollection bec = b.CreateBindingElements ();
+                       Assert.AreEqual (2, bec.Count, "#1");
+                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement),
+                               bec [0].GetType (), "#2");
+                       Assert.AreEqual (typeof (HttpTransportBindingElement),
+                               bec [1].GetType (), "#3");
+               }
+
+               [Test]
+               public void Elements_MessageEncodingBindingElement ()
+               {
+                       BasicHttpBinding b = CreateBindingFromConfig ();
+                       BindingElementCollection bec = b.CreateBindingElements ();
+                       TextMessageEncodingBindingElement m =
+                               (TextMessageEncodingBindingElement) bec [0];
+
+                       Assert.AreEqual (64, m.MaxReadPoolSize, "#1");
+                       Assert.AreEqual (16, m.MaxWritePoolSize, "#2");
+                       Assert.AreEqual (4096, m.ReaderQuotas.MaxArrayLength, "#3");
+                       Assert.AreEqual (8192, m.ReaderQuotas.MaxBytesPerRead, "#4");
+                       Assert.AreEqual (64, m.ReaderQuotas.MaxDepth, "#5");
+                       Assert.AreEqual (8192, m.ReaderQuotas.MaxNameTableCharCount, "#6");
+                       Assert.AreEqual (16384, m.ReaderQuotas.MaxStringContentLength, "#7");
+                       Assert.AreEqual (Encoding.Unicode, m.WriteEncoding, "#8");
+               }
+
+               [Test]
+               public void Elements_TransportBindingElement ()
+               {
+                       BasicHttpBinding b = CreateBindingFromConfig ();
+                       BindingElementCollection bec = b.CreateBindingElements ();
+                       HttpTransportBindingElement t =
+                               (HttpTransportBindingElement) bec [1];
+
+                       Assert.AreEqual (true, t.AllowCookies, "#1");
+                       Assert.AreEqual (AuthenticationSchemes.Anonymous, t.AuthenticationScheme, "#2");
+                       Assert.AreEqual (true, t.BypassProxyOnLocal, "#3");
+                       Assert.AreEqual (HostNameComparisonMode.Exact, t.HostNameComparisonMode, "#4");
+                       Assert.AreEqual (true, t.KeepAliveEnabled, "#5");
+                       Assert.AreEqual (false, t.ManualAddressing, "#6");
+                       Assert.AreEqual (262144, t.MaxBufferPoolSize, "#7");
+                       Assert.AreEqual (32768, t.MaxBufferSize, "#8");
+                       Assert.AreEqual (32768, t.MaxReceivedMessageSize, "#9");
+                       Assert.AreEqual ("proxy", t.ProxyAddress.ToString (), "#10");
+                       Assert.AreEqual (AuthenticationSchemes.Anonymous, t.ProxyAuthenticationScheme, "#11");
+                       Assert.AreEqual ("", t.Realm, "#12");
+                       Assert.AreEqual ("http", t.Scheme, "#13");
+                       Assert.AreEqual (TransferMode.Streamed, t.TransferMode, "#14");
+                       Assert.AreEqual (false, t.UnsafeConnectionNtlmAuthentication, "#15");
+                       Assert.AreEqual (false, t.UseDefaultWebProxy, "#16");
+               }
+
+               private BasicHttpBinding CreateBindingFromConfig ()
+               {
+                       ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/basicHttpBinding").GetSectionGroup ("system.serviceModel");
+                       BindingsSection section = (BindingsSection) config.Bindings;
+                       BasicHttpBindingElement el = section.BasicHttpBinding.Bindings ["BasicHttpBinding2_Service"];
+
+                       BasicHttpBinding b = new BasicHttpBinding ();
+                       el.ApplyConfiguration (b);
+
+                       return b;
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ChangeLog b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ChangeLog
new file mode 100755 (executable)
index 0000000..8bf6225
--- /dev/null
@@ -0,0 +1,752 @@
+2008-05-22  Roei Erez  <roeie@mainsoft.com>
+       * fix ContractDescription.GetContract implementation
+       * Refactor Request processing
+       * Add support for message inspectors
+       * Add support for InstanceContextProvider & InstanceProvider, including lifecycles events
+       like: ReleaseServiceInstance, Open, Close...
+       * Add relevant test cases.
+
+2008-05-07  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ChannelFactory_1Test.cs: Test Enum in/out parameters with code generation.
+
+2008-05-01  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ChannelFactory_1Test.cs: Add test with out params and void return.
+
+2008-04-14  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ExtensionCollectionTest.cs: new test.
+
+2008-04-10  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ChannelFactory_1Test.cs: Added test to check serialization of parameters
+         and deserialization of return values and out parameters. The tests are
+         currently checking only the client side and not the server side.
+
+2008-04-08  Roei Erez <roeie@mainsoft.com>
+       * Add tests for ServiceHostBaseTest.cs
+
+2008-04-06  Roei Erez <roeie@mainsoft.com>
+
+       * ServiceHostBaseTests: Added new tests
+
+2008-04-03  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceHostBaseTest.cs.cs: new test for InitializeRuntime.
+
+2008-04-03  Roei Erez <roeie@mainsoft.com>
+
+       * ServiceHostBaseTest.cs: new test for negative flow in ApplyConfiguration.
+
+2008-04-02  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * BasicHttpBindingTest.cs: added tests
+
+2008-04-02  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceHostBaseTest.cs.cs: new test, remove NotWorking attribute.
+
+2008-04-01  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * ServiceHostBaseTest.cs: new test.
+
+2008-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingTest.cs : mark MessageSecurityIssuedToken as NotWorking.
+       * EndpointAddress10Test.cs : mark SerializeDeserialize as NotWorking.
+
+2008-03-04  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ChannelFactory_1Test.cs: Add tests for different ctors.
+       * CommonUseCases.cs: Move common intefaces that are also configured by the
+         test dll config file.
+       * ChannelFactoryTest.cs: Add tests for the protected methods
+         InitializeEndpoint and ApplyConfiguration.
+       * ClientBaseTest.cs: Add test cases with default ("*") configuration. Moved
+         interfaces to CommonUseCases.cs.
+
+
+2008-02-28  Eyal Alaluf <eyala@mainsoft.com>
+
+       * ServiceHostTest.cs: Marjed test as not working since it caused a crash(!)
+       * ClientBaseTest.cs: Add tests for ClientBase<T> constructors.
+
+2008-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressTest.cs : test for rejecting relative Uri.
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs
+         ChannelFactory_1Test.cs EndpointAddressTest.cs
+         EndpointAddress10Test.cs ServiceHostTest.cs : warning cleanup.
+
+2007-08-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostTest.cs : added test for InstanceContextMode in
+         ServiceBehaviorAttribute.
+
+2007-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * NetMsmqBindingTest.cs : new test.
+
+2007-04-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressTest.cs : fixed some warnings.
+       * EndpointAddress10Test.cs : new test.
+
+2007-04-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressTest.cs : added WriteContentsTo and WriteTo tests
+         with WSAddressing10 mode.
+       * WSHttpBindingTest.cs : added test for IssuedToken security.
+       * EndpointIdentityTest.cs : new test (not working yet).
+
+2007-04-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IntegratedConnectionTest.cs, ClientBaseTest.cs :
+         marked some failing tests (on Orcas) as ignored. Some fixes to
+         make sure that open connection things be closed.
+
+2007-04-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs :
+         added mutual ssonego provider creation without client certificate.
+
+2007-03-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingTest.cs : added MessageSecurity test for SPNego case.
+
+2007-03-07  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs :
+         added another secure conversation parameter .ctor().
+
+2007-03-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs :
+         for ssl parameters, just use exposed requirement initialization.
+         Rewrote and enabled IsIssuedSecurityTokenRequirement() tests.
+
+2007-02-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingTest.cs : added MessageSecurityUserName(), and some
+         tests for RequireSignatureConfirmation.
+
+2007-01-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs : refactoring;
+         replaced X509Cert2 ctor() with an already-initialized member.
+         Added CreateAuthenticatorX509().
+
+2007-01-11  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs : added custom token
+         classes and non-finished test. Added Clone() test.
+
+2006-12-04  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostTest.cs : added test for ServiceMetadataBehavior
+         existence check for non-IMetadataExchange type.
+
+2006-10-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingTest.cs : more property check for x509 parameters.
+
+2006-09-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBaseTest.cs, ChannelFactory_1Test.cs :
+         use port 37564 instead of 8080.
+       * WSHttpBindingTest.cs : added MessageSecurityCertificate() test.
+       * ClientCredentialsSecurityTokenManagerTest.cs :
+         Some authenticator tests.
+
+2006-09-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingTest.cs :
+         a bit more details on default message security test.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityVersionTest.cs : test for SecurityTokenVersion.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs :
+         added and fixed some AnonymousSslnego related tests.
+
+2006-09-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IntegratedConnectionTest.cs : enabled with a bit of fixes.
+       * ClientBaseTest.cs : added tests from $(topdir)/samples/clientbase.
+
+2006-09-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs :
+         removed some NotWorking.
+
+2006-09-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UriSchemeKeyedCollectionTest.cs : fix warnings.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactoryTest.cs : ... and namespace fix.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs : added more tests on
+         how it should acquire X509 certificates.
+       * ChannelFactory_1Test.cs : removed NotWorking.
+       * ChannelFactoryTest.cs : moved from Test/S.SM.Channels.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory_1Test.cs : added test for the actual invocation of
+         TChannel (contract) members.
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory_1Test.cs : added test for EnsureOpened().
+
+2006-09-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSFederationHttpBindingTest.cs : new file, mostly copied from
+         WSHttpBindingTest.cs and largely commented out.
+
+2006-09-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TransactionProtocolTest.cs : cleaning up NotWorking.
+
+2006-08-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelFactory_1Test.cs : new test.
+       * ClientBaseTest.cs : added some tests to solve some confusion.
+
+2006-08-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs : added some
+         notworking tests for RecipientServiceModelSecurityTokenParameters.
+
+2006-08-30  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostTest.cs : added another AddServiceEndpoint() case.
+       * ClientCredentialsSecurityTokenManagerTest.cs :
+         added a concept case that remote endpoint identity is nothing to
+         do with required client certificate.
+
+2006-08-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingTest.cs : added test for security parameters in
+         non-NegotiateServiceCredential mode.
+
+2006-08-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs :
+         added minor SecureConversation requirement test, and cosmetic fixes.
+
+2006-08-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHtttpBindingTest.cs : some more tests for message security
+         creation.
+       * ClientCredentialsSecurityTokenManagerTest.cs : removed some
+         NotWorking. Added more secure conversation tests.
+
+2006-08-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BehaviorCollectionTest.cs : removed obsolete test.
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientCredentialsSecurityTokenManagerTest.cs : new test.
+
+2006-08-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHtttpBindingTest.cs : added DefaultMessageSecurity() test.
+
+2006-08-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageSecurityVersionTest.cs : new test.
+
+2006-08-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingTest.cs : fixed CreateMessageSecurity(). for Transport
+         it returns null, so test it as such.
+
+2006-08-01  Ankit Jain  <jankit@novell.com>
+
+       * EndpointAddressTest.cs: New tests for ReadFrom overloads.
+
+2006-07-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingTest.cs :
+         Added notworking BuildListenerWithoutServiceCertificate().
+
+2006-07-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BasicHttpBindingTest.cs : added Security related construction tests.
+
+2006-07-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressBuilderTest.cs : new file.
+       * EndpointAddressTest.cs : added another wrong xml reader test.
+
+2006-07-19  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressTest.cs : added test for WriteTo().
+
+2006-07-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressTest.cs : added test for ReadFrom().
+
+2006-07-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IntegratedConnectionTest.cs : comment out those tests until
+         HTTP connections on NUnit tests got stable.
+       * WSHttpBindingTest.cs : added tests on Security properties. Also
+         added test for different SecurityMode .ctor() parameters.
+
+2006-07-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IntegratedConnectionTest.cs : use different port than 8080 which
+         is likely to be used.
+
+2006-07-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IntegratedConnectionTest.cs : added test for metadata exchange.
+
+2006-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * IntegratedConnectionTest.cs : new test file for connection examples.
+
+2006-07-12  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostTest.cs : added tests for IMetadataExchange handling
+         which seem to be a special case.
+
+2006-07-10  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * WSHttpBindingTest.cs, TransactionProtocolTest.cs :
+         new tests.
+
+2006-07-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BasicHttpBindingTest.cs : June CTP fixes.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingElementTest.cs, BindingTest.cs, InvalidBindingElement.cs,
+         HttpTransportBindingElementTest.cs, EndpointDispatcherTest.cs,
+         CustomBindingTest.cs : namespace fixes. Soon to be moved.
+       * EndpointListenerTest.cs, EndpointListenerCollectionTest.cs :
+         removed unused files.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingElementTest.cs : dependent changes by ChannelManagerBase.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingElementTest.cs : June CTP update madness.
+
+2006-07-05  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceAssert.cs, InvalidBindingElement.cs,
+         HttpTransportBindingElementTest.cs : reflect June CTP updates.
+
+2006-06-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBaseTest.cs : comment out the entire test until I resolve
+         why it breaks NUnit execution under MS.NET.
+
+2006-06-22  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ClientBaseTest.cs : new test file.
+
+2006-05-29  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BasicHttpBindingTest.cs, HttpTransportBindingElementTest.cs :
+         test build fix.
+
+2006-04-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BasicHttpBindingTest.cs : added test for MessageEncoding property.
+
+2006-03-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDescriptionTest.cs DispatcherTest.cs : removed old tests.
+
+2006-03-16  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostTest.cs : removed NotWorking. Added description on why
+         InvalidOperationExceptions are thrown. Commented out extra lines.
+
+         My thought is those tests should be rewritten to use correct
+         service contract implementation type and be used for multiple
+         ServiceEndpoint addition, not just for checking contract 
+         implementation existence.
+
+2006-03-13  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointDispatcherTest.cs : new test.
+
+2006-03-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceAssert.cs : added AssertMessageEncoder().
+
+2006-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingElementTest.cs : added more preparation code (still no test).
+       * HttpTransportBindingElementTest.cs : added tests for
+         CanBuildChannelFactory() and CanBuildChannelListener().
+
+2006-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostTest.cs :
+         Renamed IFoo to IBar since IFoo sounds like it is an interface of
+         Foo (while it isn't).  Added more AddServiceEndpoint() tests.
+
+2006-03-06  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostTest.cs : Added more tests for .ctor().
+       * CustomBindingTest.cs : removed [NotWorking].
+
+2006-03-03  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingTest.cs : Kinda fixed BuildChannelFactoryGeneric2(). That
+         ExpectedException was thrown just because HttpTransportBindingElement
+         does not support IInputChannel. It is not good to test default
+         implementation of BuildChannelFactory().
+
+2006-03-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TextMessageEncodingBindingElementTest.cs :
+         Feb. CTP requires ListenUri arguments to make this test pass.
+         BindingElementTest.cs : removed tests that do not make sense now.
+
+2006-03-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingTest.cs : fixed tests. The original test does not make sense
+         now, so made it into another kind of test (check ArgumentException).
+
+2006-03-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressTest.cs : reflect API fix. Anonymous URI has changed
+         to reasonable URI which does not pretend standards.
+
+2006-03-02  Atsushi Enomoto  <atsushi@ximian.com>
+
+       (back to normal "record-ChangeLogs" mode after the big API change mess)
+       * HttpTransportBindingElementTest.cs : fixed minor API differences.
+
+2006-02-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ActionFilterTest.cs AddressHeaderTest.cs AddressingVersionTest.cs
+         BehaviorCollectionTest.cs BindingElementTest.cs BindingTest.cs
+         ChannelDescriptionTest.cs ChannelFactoryTest.cs 
+         ContractDescriptionTest.cs DispatcherTest.cs
+         EmptyFaultExceptionTest.cs EndpointBehaviorCollectionTest.cs
+         EndpointListenerCollectionTest.cs EndpointListenerTest.cs
+         EnvelopeVersionTest.cs FaultExceptionTest.cs FilterTableTest.cs
+         HttpTransportBindingElementTest.cs InvalidBindingElement.cs
+         InvalidBodyAccessExceptionTest.cs MessageBufferTest.cs
+         MessageEncodingBindingElementTest.cs MessageHeaderTest.cs
+         MessageHeadersTest.cs MessageVersionTest.cs ServiceAssert.cs
+         ServiceAuthorizationBehaviorTest.cs ServiceEndpointTest.cs
+         TextMessageEncodingBindingElementTest.cs
+         UnknownFaultExceptionTest.cs :
+         Feb. CTP API changes - chapter 1.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UriSchemeKeyedCollectionTest.cs EndpointAddressTest.cs
+         DispatcherTest.cs FaultExceptionTest.cs
+         EndpointListenerCollectionTest.cs
+         TextMessageEncodingBindingElementTest.cs EndpointListenerTest.cs
+         HttpTransportBindingElementTest.cs :
+         Removed several [NotWorking]/[Ignore] from tests, including required
+         changes to make tests work fine w/ indigo.
+
+2006-02-15  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceEndpointTest.cs : uncommented some tests.
+       * ActionFilterTest.cs : added CreateFilterTable() test.
+
+2006-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageHeadersTest.cs : enabled some tests.
+       * ActionFilterTest.cs : new test file.
+
+2006-02-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceHostTest.cs : Ignore AddServiceEndpoint(). Maybe IFoo needs
+         to be the interface of Foo, but let's wait for discussion.
+
+2006-02-14  Ankit Jain  <jankit@novell.com>
+
+       *  ServiceHostTest.cs: Enable tests which are dependent on relative
+       Uris.
+
+2006-02-11  Ankit Jain  <jankit@novell.com>
+
+       * ServiceHostTest.cs : Add tests for AddServiceEndpoint ().
+       * UriSchemeKeyedCollectionTest.cs : Add test for Address with query.
+
+2006-02-11  Ankit Jain  <jankit@novell.com>
+
+       * ServiceHostTest.cs : Fix "typo" in last commit.
+       * UriSchemeKeyedCollectionTest.cs : Likewise.
+
+2006-02-11  Ankit Jain  <jankit@novell.com>
+
+       * ServiceHostTest.cs : New.
+       * UriSchemeKeyedCollectionTest.cs : New.
+
+2006-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SynchronizedReadOnlyCollectionTest.cs : added more test for
+         .ctor(object, IEnumerable<T>).
+
+2006-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * FaultReasonTextTest.cs : new file.
+
+2006-02-08  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UniqueIdTest.cs :
+         It should be in System.Runtime.Serialization.dll test.
+
+2006-02-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BindingTest.cs BindingElementTest.cs : new tests, mostly for
+         type derivation.
+       * ChannelDescriptionTest.cs : actually all three .ctor() tests are
+         expected to fail, so split them into 3 tests.
+       * ChannelFactoryTest.cs : There is no public way to create
+         ChannelDescription which results in null ChannelType, so commented
+         ChannelType assertion out.
+
+2006-02-01  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ChannelDescriptionTest.cs ChannelFactoryTest.cs : new tests.
+       * ServiceEndpointTest.cs : enabled CtorNullEndpoint() again.
+
+2006-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * InvalidBindingElement.cs : new file. Represents an invalid binding.
+       * HttpTransportBindingElementTest.cs : Added more tests for
+         BuildChannelFactory().
+
+2006-01-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * HttpTransportBindingElementTest.cs :
+         Added BuildChannelFactory() test, NotWorking.
+
+2006-01-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AddressHeaderTest.cs : WriteAddressHeaderTest() works now. Added
+         string comparison test there.
+
+2006-01-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressTest.cs : Added Headers(). The code was broken in
+         basic level.
+
+2006-01-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressTest.cs : ConstructorTest() is working now.
+
+2006-01-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * UniqueIdTest.cs EndpointAddressTest.cs DispatcherTest.cs
+         FaultExceptionTest.cs MessageHeaderTest.cs
+         TextMessageEncodingBindingElementTest.cs MessageBufferTest.cs
+         MessageHeadersTest.cs EndpointListenerTest.cs AddressHeaderTest.cs
+         CustomBindingTest.cs :
+         several updates to match Dec.CTP. Marked all notworking tests
+         as [Category ("NotWorking")]. Marked all test which got broken in
+         Dec.CTP as [Ignore].
+
+2005-11-22  Duncan Mak  <duncan@novell.com>
+
+       * ContractDescriptionTest.cs: Change from 'null' to
+       ProtectionLevel.None.
+
+       * CustomBindingTest.cs (DefaultCtor, CtorFromAnotherBinding): Fix
+       it up to make it go green.
+
+       * ExceptionListenerTest.cs: Change from ArgumentNullException to
+       ArgumentException.
+
+       * ServiceAssert.cs: Change from 'Session' to 'UseSession'.
+
+       * ServiceEndpointTest.cs (CtorNullBinding, CtorNullEndpoint):
+       Commented out, because they don't apply anymore.
+
+       * TextMessageEncodingBindingElementTest.cs
+       (BuildChannelListenerNoTransport): Change from
+       InvalidOperationException to ArgumentException.
+
+       Moved the tests for classes from System.ServiceModel to
+       MonoTests.System.ServiceModel, instead of
+       MonoTests.System.ServiceModel.Channels.
+       
+       We're down to 3 errors now.
+       
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointListenerTest.cs : fix for Nov. CTP.
+
+2005-11-21  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointListenerCollectionTest.cs,
+         TextMessageEncodingBindingElementTest.cs,
+         EndpointListenerTest.cs : build fix for Nov. RTM
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatcherTest.cs : FilterProvider vanished in Nov. RTM.
+
+2005-11-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * CustomBindingTest.cs : new test.
+
+2005-10-31  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BehaviorCollectionTest.cs : new file.
+
+2005-10-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointAddressTest.cs : only comments lines.
+
+2005-10-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointBehaviorCollectionTest.cs, EndpointListenerTest.cs :
+         new files.
+       * ServiceEndpointTest.cs : replaced CustomBinding with
+         BasicHttpBinding used in tests.
+       * EndpointAddressTest.cs : added more tests.
+
+2005-10-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DispatcherTest.cs, ServiceEndpointTest.cs : new tests
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * AddressingVersionTest.cs, MessageVersionTest.cs,
+         TextMessageEncodingBindingElementTest.cs : new tests.
+       * EnvelopeVersionTest.cs : Added equality tests. tab fix.
+       * EndpointListenerCollectionTest.cs : not working for now.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceEndpointCollectionTest.cs : it was accidentally added, and
+         should be empty for now.
+       * ContractDescriptionTest.cs : added non-contract and
+         duplicate-contract tests.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ContractDescriptionTest.cs : moved from *.Design/TypeLoaderTest.cs.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BasicHttpBindingTest.cs, ServiceEndpointCollectionTest.cs,
+         HttpTransportBindingElementTest.cs : new tests.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * BasicHttpBindingTest.cs, ServiceEndpointCollectionTest.cs,
+         HttpTransportBindingElementTest.cs : new files.
+
+2005-10-26  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * EndpointListenerCollectionTest.cs : new test.
+
+2005-10-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceAssert.cs : new utility class that should be useful for
+         comparing BlahDescription.
+
+2005-10-24  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ServiceAuthorizationBehaviorTest.cs : new file.
+
+2005-10-23  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * MessageBufferTest.cs : disabling AreNotEqual() (it is not supported
+         in current mono nunit20).
+
+2005-10-23  Duncan Mak  <duncan@novell.com>
+
+       * MessageHeadersTest.cs: New test.
+       * UniqueIdTest.cs: Another new one.
+
+2005-10-22  Duncan Mak  <duncan@novell.com>
+
+       * InvalidBodyAccessExceptionTest.cs (TestConstructor): One quick
+       one to find out what the default message is.
+
+       * EmptyFaultExceptionTest.cs (TestDefaults): Add test on Reason.
+
+2005-10-22  Duncan Mak  <duncan@novell.com>
+
+       * EmptyFaultExceptionTest.cs:
+       * FaultExceptionTest.cs (TestCreateMessageFault): Tests the
+       CreateMessageFault method.
+
+2005-10-22  Duncan Mak  <duncan@novell.com>
+
+       * FaultCodeTest.cs (TestNamespace): New test method.
+       * EmptyFaultExceptionTest.cs:
+       * FaultExceptionTest.cs:
+       * UnknownFaultExceptionTest.cs: New tests for the FaultException
+       family of Exceptions.
+
+2005-10-22  Duncan Mak  <duncan@novell.com>
+
+       * FaultCodeTest.cs: New test.
+
+2005-09-29  Duncan Mak  <duncan@novell.com>
+
+       * EndpointAddressTest.cs: Fixed spacing.
+       (GetSchemaTest, GetSchemaTestWithEmptySet): New tests for the
+       GetSchema methods.
+
+       * MessageHeaderTest.cs (TestGenericConstructor): Test for the
+       constructor of MessageHeader<T>. 
+
+2005-09-29  Duncan Mak  <duncan@novell.com>
+
+       * MessageBufferTest.cs: Use tabs instead of spaces.
+       (TestWriteMessage): Work in progress.
+       (TestCreateMessage): Test round-tripping from Message to
+       MessageBuffer and back.
+       (TestWriteMessageNull): Test null argument.
+       (WriteMessageWithDictionaryWriter): non-test method for figuring
+       out how Dictionary XmlDictionaryWriter writes out a Message.
+
+2005-09-28  Duncan Mak  <duncan@novell.com>
+
+       * SynchronizedReadOnlyCollectionTest.cs (TestIListContainsNull): New
+       test for null.
+       (TestICollectionCopyTo): Fixed the test.
+       
+2005-09-28  Duncan Mak  <duncan@novell.com>
+
+       * MessageHeaderTest.cs (TestWriteHeaderAttributes): New test.
+
+       * SynchronizedReadOnlyCollectionTest.cs: Tests for
+       SynchronizedReadOnlyCollection.
+
+2005-09-28  Duncan Mak  <duncan@novell.com>
+
+       * AddressHeaderTest.cs:
+       * EndpointAddressTest.cs:
+       * EnvelopeVersionTest.cs:
+       * FilterTableTest.cs: 
+       * MessageHeaderTest.cs: Fixed indentation.
+
+       * MessageHeaderTest.cs (TestToString):
+       (TestWriteStartHeader, TestWriteHeaderContent): Added new tests.
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ChannelFactoryTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ChannelFactoryTest.cs
new file mode 100644 (file)
index 0000000..24d2acc
--- /dev/null
@@ -0,0 +1,193 @@
+//
+// ChannelFactoryTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ChannelFactoryTest
+       {
+               class SimpleChannelFactory
+                       : ChannelFactory
+               {
+                       public SimpleChannelFactory ()
+                               : base ()
+                       {
+                       }
+
+                       protected override TimeSpan DefaultCloseTimeout {
+                               get { return TimeSpan.FromMinutes (1); }
+                       }
+
+                       protected override TimeSpan DefaultOpenTimeout {
+                               get { return TimeSpan.FromMinutes (1); }
+                       }
+
+                       protected override ServiceEndpoint CreateDescription ()
+                       {
+                               return new ServiceEndpoint (ContractDescription.GetContract (typeof(ICtorUseCase2)));
+                       }
+
+                       public void InitEndpoint (Binding b, EndpointAddress addr)
+                       {
+                               base.InitializeEndpoint (b, addr);
+                       }
+
+                       public void InitEndpoint (string configName, EndpointAddress addr)
+                       {
+                               base.InitializeEndpoint (configName, addr);
+                       }
+
+                       public void ApplyConfig (string configName)
+                       {
+                               base.ApplyConfiguration (configName);
+                       }
+               }
+
+               [Test]
+               public void InitializeEndpointTest1 ()
+               {
+                       SimpleChannelFactory factory = new SimpleChannelFactory ();
+                       Assert.AreEqual (null, factory.Endpoint, "#01");
+                       Binding b = new WSHttpBinding ();
+                       factory.InitEndpoint (b, null);
+                       Assert.AreEqual (b, factory.Endpoint.Binding, "#02");
+                       Assert.AreEqual (null, factory.Endpoint.Address, "#03");
+                       Assert.AreEqual (typeof (ICtorUseCase2), factory.Endpoint.Contract.ContractType, "#04");
+               }
+
+               [Test]
+               public void InitializeEndpointTest2 ()
+               {
+                       SimpleChannelFactory factory = new SimpleChannelFactory ();
+                       Assert.AreEqual (null, factory.Endpoint, "#01");
+                       factory.InitEndpoint ("CtorUseCase2_1", null);
+                       Assert.AreEqual (typeof (BasicHttpBinding), factory.Endpoint.Binding.GetType (), "#02");
+                       Assert.AreEqual (new EndpointAddress ("http://test2_1"), factory.Endpoint.Address, "#03");
+                       Assert.AreEqual (typeof (ICtorUseCase2), factory.Endpoint.Contract.ContractType, "#04");
+               }
+
+               [Test]
+               public void InitializeEndpointTest3 ()
+               {
+                       SimpleChannelFactory factory = new SimpleChannelFactory ();
+                       Assert.AreEqual (null, factory.Endpoint, "#01");
+                       factory.InitEndpoint ("CtorUseCase2_1", null);
+                       Binding b = new WSHttpBinding ();
+                       factory.InitEndpoint (b, null);
+                       Assert.AreEqual (b, factory.Endpoint.Binding, "#02");
+                       Assert.AreEqual (null, factory.Endpoint.Address, "#03");
+               }
+
+               [Test]
+               public void ApplyConfigurationTest1 ()
+               {
+                       SimpleChannelFactory factory = new SimpleChannelFactory ();
+                       Binding b = new WSHttpBinding ();
+                       factory.InitEndpoint (b, null);
+                       factory.ApplyConfig ("CtorUseCase2_1");
+                       Assert.AreEqual (new EndpointAddress ("http://test2_1"), factory.Endpoint.Address, "#03");
+                       Assert.AreEqual (b, factory.Endpoint.Binding, "#02");
+               }
+
+               [Test]
+               public void ApplyConfigurationTest2 ()
+               {
+                       SimpleChannelFactory factory = new SimpleChannelFactory ();
+                       Binding b = new WSHttpBinding ();
+                       factory.InitEndpoint (b, new EndpointAddress ("http://test"));
+                       factory.ApplyConfig ("CtorUseCase2_2");
+                       Assert.AreEqual (new EndpointAddress ("http://test"), factory.Endpoint.Address, "#03");
+                       Assert.IsNotNull (factory.Endpoint.Behaviors.Find <CallbackDebugBehavior> (), "#04");
+                       Assert.AreEqual (true, factory.Endpoint.Behaviors.Find <CallbackDebugBehavior> ().IncludeExceptionDetailInFaults, "#04");
+                       factory.ApplyConfig ("CtorUseCase2_3");
+                       Assert.IsNotNull (factory.Endpoint.Behaviors.Find <CallbackDebugBehavior> (), "#04");
+                       Assert.AreEqual (false, factory.Endpoint.Behaviors.Find <CallbackDebugBehavior> ().IncludeExceptionDetailInFaults, "#04");
+               }
+
+               [Test]
+               public void DescriptionProperties ()
+               {
+                       Binding b = new BasicHttpBinding ();
+                       ChannelFactory<IFoo> f = new ChannelFactory<IFoo> (b);
+
+                       // FIXME: it's not working now (though this test is silly to me.)
+                       //Assert.IsNull (f.Description.ChannelType, "ChannelType");
+
+                       // FIXME: it's not working now
+                       //Assert.AreEqual (1, f.Endpoint.Behaviors.Count, "Behaviors.Count");
+                       //ClientCredentials cred = f.Endpoint.Behaviors [0] as ClientCredentials;
+                       //Assert.IsNotNull (cred, "Behaviors contains ClientCredentials");
+
+                       Assert.IsNotNull (f.Endpoint, "Endpoint");
+                       Assert.AreEqual (b, f.Endpoint.Binding, "Endpoint.Binding");
+                       Assert.IsNull (f.Endpoint.Address, "Endpoint.Address");
+                       // You can examine this silly test on .NET.
+                       // Funky, ContractDescription.GetContract(
+                       //   typeof (IRequestChannel)) also fails to raise an 
+                       // error.
+                       //Assert.AreEqual ("IRequestChannel", f.Description.Endpoint.Contract.Name, "Endpoint.Contract");
+               }
+
+               public class MyChannelFactory<TChannel> 
+                       : ChannelFactory<TChannel>
+               {
+                       public MyChannelFactory (Type type)
+                               : base (type)
+                       {
+                       }
+               }
+
+               [ServiceContract]
+               public interface IFoo
+               {
+                       [OperationContract]
+                       string Echo (string msg);
+               }
+
+               public class Foo : IFoo
+               {
+                       public string Echo (string msg)
+                       {
+                               return msg;
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void ArgumentTypeNotInterface ()
+               {
+                       new MyChannelFactory<IFoo> (typeof (Foo));
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ChannelFactory_1Test.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ChannelFactory_1Test.cs
new file mode 100644 (file)
index 0000000..ab28ec9
--- /dev/null
@@ -0,0 +1,593 @@
+//
+// ChannelFactory_1Test.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Xml;
+using System.Xml.Serialization;
+using MonoTests.System.ServiceModel.Channels;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ChannelFactory_1Test
+       {
+               class MyChannelFactory<T> : ChannelFactory<T>
+               {
+                       public MyChannelFactory (Binding b, EndpointAddress a)
+                               : base (b, a)
+                       {
+                       }
+
+                       public void OpenAnyways ()
+                       {
+                               EnsureOpened ();
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateChannelForClass ()
+               {
+                       //ChannelFactory<TestService> f =
+                               new ChannelFactory<TestService> (
+                                       new BasicHttpBinding (),
+                                       new EndpointAddress ("http://localhost:37564"));
+               }
+
+               [Test]
+               public void CtorNullArgsAllowed ()
+               {
+                       ChannelFactory<ICtorUseCase1> f1;
+                       f1 = new ChannelFactory<ICtorUseCase1> ("CtorUseCase1_1", null);
+                       Assert.AreEqual (new EndpointAddress ("http://test1_1"), f1.Endpoint.Address, "#01");
+                       f1 = new ChannelFactory<ICtorUseCase1> (new BasicHttpBinding (), (EndpointAddress)null);
+                       Assert.AreEqual (null, f1.Endpoint.Address, "#01");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateChannelFromDefaultConfigWithTwoConfigs ()
+               {
+                       new ChannelFactory<ICtorUseCase2> ("*");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateChannelFromDefaultConfigWithNoConfigs ()
+               {
+                       new ChannelFactory<ICtorUseCase3> ("*");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorArgsTest1 ()
+               {
+                       new ChannelFactory<ICtorUseCase1> (new BasicHttpBinding (), (string)null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CtorArgsTest2 ()
+               {
+                       new ChannelFactory<ICtorUseCase1> ("CtorUseCase1_Incorrect");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorArgsTest3 ()
+               {
+                       new ChannelFactory<ICtorUseCase1> ((string)null, new EndpointAddress ("http://test"));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullServiceEndpoint ()
+               {
+                       new ChannelFactory<IFoo> ((ServiceEndpoint) null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullBinding ()
+               {
+                       new ChannelFactory<IFoo> ((Binding) null);
+               }
+
+               [Test]
+               public void ConfigEmptyCtor ()
+               {
+                       new ChannelFactory<ICtorUseCase1> ();
+               }
+
+               [Test]
+               public void ConfigCtor ()
+               {
+                       new ChannelFactory<ICtorUseCase1> ("CtorUseCase1_1");
+               }
+
+               [Test]
+               public void EnsureOpened ()
+               {
+                       MyChannelFactory<ITestService> f =
+                               new MyChannelFactory<ITestService> (
+                                       new BasicHttpBinding (),
+                                       new EndpointAddress ("http://localhost:37564"));
+                       Assert.AreEqual (CommunicationState.Created,
+                               f.State, "#1");
+                       f.OpenAnyways ();
+                       Assert.AreEqual (CommunicationState.Opened,
+                               f.State, "#1");
+               }
+
+               [Test]
+               // I was deceived by MSDN and currently ChannelFactory<T>
+               // only accepts IChannel as T. It will be fixed. -> done.
+               public void CreateChannel ()
+               {
+                       ChannelFactory<ITestService> f =
+                               new ChannelFactory<ITestService> (
+                                       new BasicHttpBinding (),
+                                       new EndpointAddress ("http://localhost:37564"));
+                       f.CreateChannel ();
+               }
+
+               private T CreateChannel<T> (RequestSender handler)
+               {
+                       CustomBinding b = new CustomBinding (new HandlerTransportBindingElement (handler));
+                       ChannelFactory<T> f = new ChannelFactory<T> ( b, new EndpointAddress ("urn:dummy"));
+                       return f.CreateChannel ();
+               }
+
+               [Test]
+               public void InvokeFoo ()
+               {
+                       ITestService ts = CreateChannel<ITestService> (
+                               delegate (Message input) {
+                                       BodyWriter bw = new HandlerBodyWriter (
+                                               delegate (XmlDictionaryWriter writer) {
+                                                       writer.WriteStartElement ("FooResponse", "http://tempuri.org/");
+                                                       writer.WriteElementString ("FooResult", "http://tempuri.org/", "cecil");
+                                                       writer.WriteEndElement ();
+                                               }
+                                       );
+                                       return Message.CreateMessage (input.Version, input.Headers.Action + "Response", bw);
+                               }
+                       );
+                       Assert.AreEqual ("cecil", ts.Foo ("il offre sa confiance et son amour"));
+               }
+
+               [Test]
+               public void InvokeBar ()
+               {
+                       ITestService ts = CreateChannel<ITestService> (
+                               delegate (Message input) {
+                                       BodyWriter bw = new HandlerBodyWriter (
+                                               delegate (XmlDictionaryWriter writer) {
+                                                       writer.WriteStartElement ("BarResponse", "http://tempuri.org/");
+                                                       writer.WriteElementString ("DummyBarResponse", "http://tempuri.org/", "cecil");
+                                                       writer.WriteEndElement ();
+                                               }
+                                       );
+                                       return Message.CreateMessage (input.Version, input.Headers.Action + "Response", bw);
+                               }
+                       );
+                       ts.Bar ("il offre sa confiance et son amour");
+               }
+
+               Message ToMessage<T> (Message input, bool isXml, T val)
+               {
+                       TypedMessageConverter tm;
+                       if (isXml)
+                               tm = TypedMessageConverter.Create (typeof (T),
+                                       input.Headers.Action + "Response", new XmlSerializerFormatAttribute ());
+                       else
+                               tm = TypedMessageConverter.Create (typeof (T),
+                                       input.Headers.Action + "Response");
+                       return tm.ToMessage (val, input.Version);
+               }
+
+               T FromMessage<T> (Message input, bool isXml)
+               {
+                       TypedMessageConverter tm;
+                       if (isXml)
+                               tm = TypedMessageConverter.Create (typeof (T), input.Headers.Action,
+                                       new XmlSerializerFormatAttribute ());
+                       else
+                               tm = TypedMessageConverter.Create (typeof (T), input.Headers.Action);
+                       return (T)tm.FromMessage (input);
+               }
+
+               [Test]
+               public void InvokeFooOutEnumParam ()
+               {
+                       ITestService ts = CreateChannel<ITestService> (
+                               delegate (Message input) {
+                                       // Test input for in and out Enum args.
+                                       XmlDocument doc = new XmlDocument ();
+                                       doc.LoadXml (input.ToString ());
+
+                                       XmlNamespaceManager nss = new XmlNamespaceManager (doc.NameTable);
+                                       nss.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
+                                       nss.AddNamespace ("t", "http://tempuri.org/");
+                                       XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/t:FooOutEnumParam", nss) as XmlElement;
+                                       Assert.IsNotNull (el, "I#0");
+                                       XmlNode arg1 = el.SelectSingleNode ("t:arg1", nss);
+                                       Assert.IsNotNull (arg1, "I#2");
+                                       Assert.AreEqual ("Blue", arg1.InnerText, "I#3");
+
+                                       return ToMessage (input, false,
+                                               new FooOutEnumParamResponse (FooColor.Green, FooColor.Red));
+                               }
+                       );
+
+                       FooColor argOut;
+                       FooColor res = ts.FooOutEnumParam (FooColor.Blue, out argOut);
+                       Assert.AreEqual (FooColor.Green, res, "#1");
+                       Assert.AreEqual (FooColor.Red, argOut, "#2");
+               }
+
+               public T CreateVoidFooOutParamChannel<T> (bool isXml)
+               {
+                       return CreateChannel<T> (
+                               delegate (Message input) {
+                                       // Test input for in and ref args.
+                                       XmlDocument doc = new XmlDocument ();
+                                       doc.LoadXml (input.ToString ());
+
+                                       XmlNamespaceManager nss = new XmlNamespaceManager (doc.NameTable);
+                                       nss.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
+                                       nss.AddNamespace ("t", "http://tempuri.org/");
+                                       XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/t:VoidFooOutParam", nss) as XmlElement;
+                                       Assert.IsNotNull (el, "I#0");
+                                       XmlNode arg1 = el.SelectSingleNode ("t:arg1", nss);
+                                       Assert.IsNotNull (arg1, "I#2");
+                                       Assert.AreEqual ("testIt", arg1.InnerText, "I#3");
+                                       XmlNode arg2 = el.SelectSingleNode ("t:arg2", nss);
+                                       Assert.IsNotNull (arg2, "I#4");
+                                       Assert.AreEqual ("testRef", arg2.InnerText, "I#4");
+
+                                       return ToMessage (input, isXml,
+                                               new VoidFooOutParamResponse ("refArg", "outArg"));
+                               }
+                       );
+               }
+
+               [Test]
+               public void InvokeVoidFooOutParam ()
+               {
+                       ITestService ts = CreateVoidFooOutParamChannel<ITestService> (false);
+                       string argRef = "testRef";
+                       string argOut;
+                       ts.VoidFooOutParam ("testIt", ref argRef, out argOut);
+                       Assert.AreEqual ("refArg", argRef, "#1");
+                       Assert.AreEqual ("outArg", argOut, "#2");
+               }
+
+               [Test]
+               public void XmlInvokeVoidFooOutParam ()
+               {
+                       ITestServiceXml ts = CreateVoidFooOutParamChannel<ITestServiceXml> (true);
+                       string argRef = "testRef";
+                       string argOut;
+                       ts.VoidFooOutParam ("testIt", ref argRef, out argOut);
+                       Assert.AreEqual ("refArg", argRef, "#1");
+                       Assert.AreEqual ("outArg", argOut, "#2");
+               }
+
+               public T CreateFooOutParamChannel<T> (bool isXml)
+               {
+                       return CreateChannel<T> (
+                               delegate (Message input) {
+                                       // Test input for in and ref args.
+                                       XmlDocument doc = new XmlDocument ();
+                                       doc.LoadXml (input.ToString ());
+
+                                       XmlNamespaceManager nss = new XmlNamespaceManager (doc.NameTable);
+                                       nss.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
+                                       nss.AddNamespace ("t", "http://tempuri.org/");
+                                       XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/t:FooOutParam", nss) as XmlElement;
+                                       Assert.IsNotNull (el, "I#0");
+                                       XmlNode arg1 = el.SelectSingleNode ("t:arg1", nss);
+                                       Assert.IsNotNull (arg1, "I#2");
+                                       Assert.AreEqual ("testIt", arg1.InnerText, "I#3");
+                                       XmlNode arg2 = el.SelectSingleNode ("t:arg2", nss);
+                                       Assert.IsNotNull (arg2, "I#4");
+                                       Assert.AreEqual ("testRef", arg2.InnerText, "I#4");
+
+                                       return ToMessage (input, isXml,
+                                               new FooOutParamResponse ("callResult", "refArg", "outArg"));
+                               }
+                       );
+               }
+
+               [Test]
+               public void InvokeFooOutParam ()
+               {
+                       ITestService ts = CreateFooOutParamChannel<ITestService> (false);
+                       string argRef = "testRef";
+                       string argOut;
+                       string res = ts.FooOutParam ("testIt", ref argRef, out argOut);
+                       Assert.AreEqual ("callResult", res, "#1");
+                       Assert.AreEqual ("refArg", argRef, "#2");
+                       Assert.AreEqual ("outArg", argOut, "#3");
+               }
+
+               [Test]
+               public void XmlInvokeFooOutParam ()
+               {
+                       ITestServiceXml ts = CreateFooOutParamChannel<ITestServiceXml> (true);
+                       string argRef = "testRef";
+                       string argOut;
+                       string res = ts.FooOutParam ("testIt", ref argRef, out argOut);
+                       Assert.AreEqual ("callResult", res, "#1");
+                       Assert.AreEqual ("refArg", argRef, "#2");
+                       Assert.AreEqual ("outArg", argOut, "#3");
+               }
+
+               [Test]
+               public void InvokeFooComplex ()
+               {
+                       ITestService ts = CreateChannel<ITestService> (
+                               delegate (Message input) {
+                                       // Test input for in and ref args.
+                                       XmlDocument doc = new XmlDocument ();
+                                       doc.LoadXml (input.ToString ());
+
+                                       XmlNamespaceManager nss = new XmlNamespaceManager (doc.NameTable);
+                                       nss.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
+                                       nss.AddNamespace ("t", "http://tempuri.org/");
+                                       nss.AddNamespace ("v", "http://schemas.datacontract.org/2004/07/MonoTests.System.ServiceModel");
+                                       XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/t:FooComplex", nss) as XmlElement;
+                                       Assert.IsNotNull (el, "I#0");
+                                       XmlNode arg1 = el.SelectSingleNode ("t:arg1/v:val", nss);
+                                       Assert.IsNotNull (arg1, "I#2");
+                                       Assert.AreEqual ("testIt", arg1.InnerText, "I#3");
+
+                                       return ToMessage (input, false, new FooComplexResponse ("callResult"));
+                               }
+                       );
+
+                       TestData res = ts.FooComplex (new TestData ("testIt"));
+                       Assert.IsNotNull (res, "#1");
+                       Assert.AreEqual ("callResult", res.val, "#2");
+               }
+
+               [Test]
+               public void XmlInvokeFooComplex ()
+               {
+                       ITestServiceXml ts = CreateChannel<ITestServiceXml> (
+                               delegate (Message input) {
+                                       // Test input for in and ref args.
+                                       XmlDocument doc = new XmlDocument ();
+                                       doc.LoadXml (input.ToString ());
+
+                                       XmlNamespaceManager nss = new XmlNamespaceManager (doc.NameTable);
+                                       nss.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
+                                       nss.AddNamespace ("t", "http://tempuri.org/");
+                                       XmlElement el = doc.SelectSingleNode ("/s:Envelope/s:Body/t:FooComplex", nss) as XmlElement;
+                                       Assert.IsNotNull (el, "I#0");
+                                       XmlElement arg1 = el.SelectSingleNode ("t:arg1", nss) as XmlElement;
+                                       Assert.IsNotNull (arg1, "I#2");
+                                       Assert.AreEqual ("testIt", arg1.GetAttribute ("val"), "I#3");
+
+                                       return ToMessage (input, true, new FooComplexResponse ("callResult"));
+                               }
+                       );
+
+                       TestData res = ts.FooComplex (new TestData ("testIt"));
+                       Assert.IsNotNull (res, "#1");
+                       Assert.AreEqual ("callResult", res.val, "#2");
+               }
+
+               public T CreateFooComplexMC_Channel<T> (bool isXml)
+               {
+                       return CreateChannel<T> (
+                               delegate (Message input) {
+                                       TestMessage arg = FromMessage<TestMessage> (input, isXml);
+                                       Assert.IsNotNull (arg.data, "I#0");
+                                       Assert.AreEqual (arg.data.val, "testIt", "I#1");
+                                       Assert.IsNotNull (arg.msg, "I#2");
+                                       Assert.AreEqual (arg.msg.val, "testMsg", "I#3");
+
+                                       return ToMessage (input, isXml, new TestResult ("callResult", "callArg"));
+                               }
+                       );
+               }
+
+               [Test]
+               public void InvokeFooComplexMC ()
+               {
+                       ITestService ts = CreateFooComplexMC_Channel<ITestService> (false);
+                       TestResult res = ts.FooComplexMC (new TestMessage ("testIt", "testMsg"));
+                       Assert.IsNotNull (res, "#1");
+                       Assert.AreEqual ("callResult", res.resData.val, "#2");
+                       Assert.AreEqual ("callArg", res.resMsg.val, "#3");
+               }
+
+               [Test]
+               public void XmlInvokeFooComplexMC ()
+               {
+                       ITestServiceXml ts = CreateFooComplexMC_Channel<ITestServiceXml> (true);
+                       TestResult res = ts.FooComplexMC (new TestMessage ("testIt", "testMsg"));
+                       Assert.IsNotNull (res, "#1");
+                       Assert.AreEqual ("callResult", res.resData.val, "#2");
+                       Assert.AreEqual ("callArg", res.resMsg.val, "#3");
+               }
+
+               [ServiceContract]
+               public interface ITestService
+               {
+                       [OperationContract]
+                       string Foo (string arg);
+
+                       [OperationContract]
+                       void Bar (string arg);
+
+                       [OperationContract]
+                       void Foo1 (string arg1, string arg2);
+
+                       [OperationContract]
+                       FooColor FooOutEnumParam (FooColor arg1, out FooColor arg2);
+
+                       [OperationContract]
+                       string FooOutParam (string arg1, ref string arg2, out string arg3);
+
+                       [OperationContract]
+                       void VoidFooOutParam (string arg1, ref string arg2, out string arg3);
+
+                       [OperationContract]
+                       TestData FooComplex (TestData arg1);
+
+                       [OperationContract]
+                       TestResult FooComplexMC (TestMessage arg1);
+               }
+
+               [ServiceContract]
+               public interface ITestServiceXml
+               {
+                       [OperationContract]
+                       string FooOutParam (string arg1, ref string arg2, out string arg3);
+
+                       [OperationContract]
+                       void VoidFooOutParam (string arg1, ref string arg2, out string arg3);
+
+                       [OperationContract]
+                       [XmlSerializerFormat]
+                       TestData FooComplex (TestData arg1);
+
+                       [OperationContract]
+                       [XmlSerializerFormat]
+                       TestResult FooComplexMC (TestMessage arg1);
+               }
+
+               public enum FooColor { Red = 1, Green, Blue }
+
+               [DataContract]
+               public class TestData
+               {
+                       TestData () {}
+                       public TestData (string val) { this.val = val; }
+
+                       [DataMember]
+                       [XmlAttribute]
+                       public string val;
+               }
+
+               [MessageContract]
+               public class TestMessage
+               {
+                       TestMessage () {}
+                       public TestMessage (string a, string b) { data = new TestData (a); msg = new TestData (b); }
+
+                       [MessageBodyMember]
+                       public TestData data;
+
+                       [MessageBodyMember]
+                       public TestData msg;
+               }
+
+               [MessageContract]
+               public class TestResult
+               {
+                       TestResult () {}
+                       public TestResult (string a, string b) { resData = new TestData (a); resMsg = new TestData (b); }
+
+                       [MessageBodyMember]
+                       public TestData resData;
+
+                       [MessageBodyMember]
+                       public TestData resMsg;
+               }
+
+               [MessageContract (WrapperNamespace = "http://tempuri.org/")]
+               class FooOutParamResponse
+               {
+                       FooOutParamResponse () {}
+                       public FooOutParamResponse (string ret, string refArg, string outArg) { FooOutParamResult = ret; this.arg2 = refArg; this.arg3 = outArg; }
+
+                       [MessageBodyMember]
+                       public string FooOutParamResult;
+
+                       [MessageBodyMember]
+                       public string arg2;
+
+                       [MessageBodyMember]
+                       public string arg3;
+               }
+
+               [MessageContract (WrapperNamespace = "http://tempuri.org/")]
+               class FooOutEnumParamResponse
+               {
+                       FooOutEnumParamResponse () {}
+                       public FooOutEnumParamResponse (FooColor ret, FooColor outArg) { FooOutEnumParamResult = ret; this.arg2 = outArg; }
+
+                       [MessageBodyMember]
+                       public FooColor FooOutEnumParamResult;
+
+                       [MessageBodyMember]
+                       public FooColor arg2;
+               }
+
+               [MessageContract (WrapperNamespace = "http://tempuri.org/")]
+               class VoidFooOutParamResponse
+               {
+                       VoidFooOutParamResponse () {}
+                       public VoidFooOutParamResponse (string refArg, string outArg) { this.arg2 = refArg; this.arg3 = outArg; }
+
+                       [MessageBodyMember]
+                       public string arg2;
+
+                       [MessageBodyMember]
+                       public string arg3;
+               }
+
+               [MessageContract (WrapperNamespace = "http://tempuri.org/")]
+               class FooComplexResponse
+               {
+                       FooComplexResponse () {}
+                       public FooComplexResponse (string val) { FooComplexResult  = new TestData (val); }
+
+                       [MessageBodyMember]
+                       public TestData FooComplexResult;
+               }
+
+               class TestService
+               {
+                       public string Foo (string arg)
+                       {
+                               return arg;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ClientBaseTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ClientBaseTest.cs
new file mode 100644 (file)
index 0000000..6a0d55e
--- /dev/null
@@ -0,0 +1,474 @@
+//
+// ClientBaseTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net.Sockets;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ClientBaseTest
+       {
+/*
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void GenericTypeArgumentIsServiceContract ()
+               {
+                       new MyClientBase<ICloneable> (new BasicHttpBinding (), new EndpointAddress ("http://localhost:4126"));
+               }
+*/
+
+/*
+               public class MyClientBase<T> : ClientBase<T>
+               {
+                       public MyClientBase (Binding binding, EndpointAddress address)
+                               : base (binding, address)
+                       {
+                       }
+               }
+
+               public class MyClientBase1 : ClientBase<TestService>
+               {
+                       public MyClientBase1 (Binding binding, EndpointAddress address)
+                               : base (binding, address)
+                       {
+                       }
+               }
+
+               [Test]
+               public void ClassTypeArg ()
+               {
+                       new MyClientBase1 (new BasicHttpBinding (), new EndpointAddress ("urn:dummy"));
+               }
+*/
+
+               [ServiceContract]
+               public interface ITestService
+               {
+                       [OperationContract]
+                       string Foo (string arg);
+               }
+
+               public class TestService : ITestService
+               {
+                       public string Foo (string arg)
+                       {
+                               return arg;
+                       }
+               }
+
+               [ServiceContract]
+               public interface ITestService2
+               {
+                       [OperationContract]
+                       void Bar (string arg);
+               }
+
+               public class TestService2 : ITestService2
+               {
+                       public void Bar (string arg)
+                       {
+                       }
+               }
+
+               [Test]
+               [Ignore ("hmm, this test shows that MSDN documentation does not match the fact.")]
+               public void Foo ()
+               {
+                       Type t = typeof (ClientBase<ITestService>).GetGenericTypeDefinition ().GetGenericArguments () [0];
+                       Assert.IsTrue (t.IsGenericParameter);
+                       Assert.AreEqual (GenericParameterAttributes.None, t.GenericParameterAttributes);
+               }
+
+               class MyChannelFactory<T> : ChannelFactory<T>
+               {
+                       public MyChannelFactory (Binding b, EndpointAddress e)
+                               : base (b, e)
+                       {
+                       }
+
+                       public IChannelFactory GimmeFactory ()
+                       {
+                               return CreateFactory ();
+                       }
+               }
+
+               #region UseCase1
+
+               ServiceHost host;
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ClientBaseCtorArgsTest1 ()
+               {
+                       new CtorUseCase1 (null, new BasicHttpBinding (), new EndpointAddress ("http://test"));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ClientBaseCtorArgsTest2 ()
+               {
+                       new CtorUseCase1 (null, new EndpointAddress ("http://test"));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ClientBaseCtorArgsTest3 ()
+               {
+                       new CtorUseCase1 (null, "http://test");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ClientBaseCtorArgsTest4 ()
+               {
+                       new CtorUseCase1 ("CtorUseCase1_1", null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ClientBaseCtorArgsTest5 ()
+               {
+                       new CtorUseCase1 (new BasicHttpBinding (), null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void ClientBaseCtorArgsTest6 ()
+               {
+                       new CtorUseCase1 ("CtorUseCase1_Incorrect");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void ClientBaseCtorArgsTest7 ()
+               {
+                       new CtorUseCase3 ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void ClientBaseCtorConfigAmbiguityTest ()
+               {
+                       new CtorUseCase2 ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void ClientBaseCtorConfigAmbiguityTest2 ()
+               {
+                       new CtorUseCase2 ("*");
+               }
+
+               [Test]
+               public void ClientBaseConfigEmptyCtor ()
+               {
+                       new CtorUseCase1 ();
+               }
+
+               [Test]
+               public void ClientBaseConfigCtor ()
+               {
+                       new CtorUseCase1 ("CtorUseCase1_1");
+               }
+
+               [Test]
+               public void ClientBaseConfigCtorUsingDefault ()
+               {
+                       new CtorUseCase1 ("*");
+               }
+
+               [Test]
+               [Ignore ("With Orcas it does not work fine")]
+               public void UseCase1Test ()
+               {
+                       // almost equivalent to samples/clientbase/samplesvc.cs
+                       using (host = new ServiceHost (typeof (UseCase1))) {
+                               Binding binding = new BasicHttpBinding ();
+                               binding.ReceiveTimeout = TimeSpan.FromSeconds (15);
+                               host.AddServiceEndpoint (typeof (IUseCase1).FullName, binding, new Uri ("http://localhost:37564"));
+
+                               host.Open ();
+                               // almost equivalent to samples/clientbase/samplecli.cs
+                               using (UseCase1Proxy proxy = new UseCase1Proxy (
+                                       new BasicHttpBinding (),
+                                       new EndpointAddress ("http://localhost:37564"))) {
+                                       proxy.Open ();
+                                       Assert.AreEqual ("TEST FOR ECHOTEST FOR ECHO", proxy.Echo ("TEST FOR ECHO"));
+                               }
+                       }
+                       EnsurePortNonBlocking (37564);
+               }
+
+               void EnsurePortNonBlocking (int port)
+               {
+                       TcpListener l = new TcpListener (port);
+                       l.ExclusiveAddressUse = true;
+                       l.Start ();
+                       l.Stop ();
+               }
+
+               [ServiceContract]
+               public interface IUseCase1
+               {
+                       [OperationContract]
+                       string Echo (string msg);
+               }
+
+               public class UseCase1 : IUseCase1
+               {
+                       public string Echo (string msg)
+                       {
+                               return msg + msg;
+                       }
+               }
+
+               public class UseCase1Proxy : ClientBase<IUseCase1>, IUseCase1
+               {
+                       public UseCase1Proxy (Binding binding, EndpointAddress address)
+                               : base (binding, address)
+                       {
+                       }
+
+                       public string Echo (string msg)
+                       {
+                               return Channel.Echo (msg);
+                       }
+               }
+
+               public class CtorUseCase1 : ClientBase<ICtorUseCase1>, ICtorUseCase1
+               {
+                       public CtorUseCase1 ()
+                               : base ()
+                       {
+                       }
+
+                       public CtorUseCase1 (string configName)
+                               : base (configName)
+                       {
+                       }
+
+                       public CtorUseCase1 (string configName, string address)
+                               : base (configName, address)
+                       {
+                       }
+
+                       public CtorUseCase1 (Binding binding, EndpointAddress address)
+                               : base (binding, address)
+                       {
+                       }
+
+                       public CtorUseCase1 (InstanceContext i, Binding binding, EndpointAddress address)
+                               : base (i, binding, address)
+                       {
+                       }
+
+                       public string Echo (string msg)
+                       {
+                               return Channel.Echo (msg);
+                       }
+               }
+
+               public class CtorUseCase2 : ClientBase<ICtorUseCase2>, ICtorUseCase2
+               {
+                       public CtorUseCase2 ()
+                               : base ()
+                       {
+                       }
+
+                       public CtorUseCase2 (string configName)
+                               : base (configName)
+                       {
+                       }
+
+                       public CtorUseCase2 (string configName, string address)
+                               : base (configName, address)
+                       {
+                       }
+
+                       public CtorUseCase2 (Binding binding, EndpointAddress address)
+                               : base (binding, address)
+                       {
+                       }
+
+                       public CtorUseCase2 (InstanceContext i, Binding binding, EndpointAddress address)
+                               : base (i, binding, address)
+                       {
+                       }
+
+                       public string Echo (string msg)
+                       {
+                               return Channel.Echo (msg);
+                       }
+               }
+
+               public class CtorUseCase3 : ClientBase<ICtorUseCase3>, ICtorUseCase3
+               {
+                       public string Echo (string msg)
+                       {
+                               return Channel.Echo (msg);
+                       }
+               }
+
+               #endregion
+
+               // For contract that directly receives and sends Message instances.
+               #region UseCase2
+               [Test]
+               [Ignore ("With Orcas it does not work fine")]
+               public void UseCase2Test ()
+               {
+                       // almost equivalent to samples/clientbase/samplesvc2.cs
+                       ServiceHost host = new ServiceHost (typeof (UseCase2));
+                       Binding binding = new BasicHttpBinding ();
+                       binding.ReceiveTimeout = TimeSpan.FromSeconds (15);
+                       host.AddServiceEndpoint (typeof (IUseCase2).FullName,
+                       binding, new Uri ("http://localhost:37564"));
+
+                       try {
+                               host.Open ();
+                               // almost equivalent to samples/clientbase/samplecli2.cs
+                               Binding b = new BasicHttpBinding ();
+                               b.SendTimeout = TimeSpan.FromSeconds (15);
+                               b.ReceiveTimeout = TimeSpan.FromSeconds (15);
+                               UseCase2Proxy proxy = new UseCase2Proxy (
+                                       b,
+                                       new EndpointAddress ("http://localhost:37564/"));
+                               proxy.Open ();
+                               Message req = Message.CreateMessage (MessageVersion.Soap11, "http://tempuri.org/IUseCase2/Echo");
+                               Message res = proxy.Echo (req);
+                               using (XmlWriter w = XmlWriter.Create (TextWriter.Null)) {
+                                       res.WriteMessage (w);
+                               }
+                       } finally {
+                               if (host.State == CommunicationState.Opened)
+                                       host.Close ();
+                               EnsurePortNonBlocking (37564);
+                       }
+               }
+
+               [ServiceContract]
+               public interface IUseCase2
+               {
+                       [OperationContract]
+                       Message Echo (Message request);
+               }
+
+               class UseCase2 : IUseCase2
+               {
+                       public Message Echo (Message request)
+                       {
+                               Message msg = Message.CreateMessage (request.Version, request.Headers.Action + "Response");
+                               msg.Headers.Add (MessageHeader.CreateHeader ("hoge", "urn:hoge", "heh"));
+                               //msg.Headers.Add (MessageHeader.CreateHeader ("test", "http://schemas.microsoft.com/ws/2005/05/addressing/none", "testing"));
+                               return msg;
+                       }
+               }
+
+               public class UseCase2Proxy : ClientBase<IUseCase2>, IUseCase2
+               {
+                       public UseCase2Proxy (Binding binding, EndpointAddress address)
+                               : base (binding, address)
+                       {
+                       }
+
+                       public Message Echo (Message request)
+                       {
+                               return Channel.Echo (request);
+                       }
+               }
+
+               #endregion
+
+               [Test]
+               [Ignore ("With Orcas it does not work fine")]
+               public void UseCase3 ()
+               {
+                       // almost equivalent to samples/clientbase/samplesvc3.cs
+                       ServiceHost host = new ServiceHost (typeof (MetadataExchange));
+                       host.Description.Behaviors.Find<ServiceDebugBehavior> ()
+                               .IncludeExceptionDetailInFaults = true;
+                       Binding bs = new BasicHttpBinding ();
+                       bs.SendTimeout = TimeSpan.FromSeconds (5);
+                       bs.ReceiveTimeout = TimeSpan.FromSeconds (5);
+                       // magic name that does not require fully qualified name ...
+                       host.AddServiceEndpoint ("IMetadataExchange",
+                               bs, new Uri ("http://localhost:37564"));
+                       try {
+                               host.Open ();
+                               // almost equivalent to samples/clientbase/samplecli3.cs
+                               Binding bc = new BasicHttpBinding ();
+                               bc.SendTimeout = TimeSpan.FromSeconds (5);
+                               bc.ReceiveTimeout = TimeSpan.FromSeconds (5);
+                               MetadataExchangeProxy proxy = new MetadataExchangeProxy (
+                                       bc,
+                                       new EndpointAddress ("http://localhost:37564/"));
+                               proxy.Open ();
+
+                               Message req = Message.CreateMessage (MessageVersion.Soap11, "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get");
+                               Message res = proxy.Get (req);
+                               using (XmlWriter w = XmlWriter.Create (TextWriter.Null)) {
+                                       res.WriteMessage (w);
+                               }
+                       } finally {
+                               if (host.State == CommunicationState.Opened)
+                                       host.Close ();
+                               EnsurePortNonBlocking (37564);
+                       }
+               }
+
+               class MetadataExchange : IMetadataExchange
+               {
+                       public Message Get (Message request)
+                       {
+                               XmlDocument doc = new XmlDocument ();
+                               doc.AppendChild (doc.CreateElement ("Metadata", "http://schemas.xmlsoap.org/ws/2004/09/mex"));
+                               return Message.CreateMessage (request.Version,
+                               "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse",
+                               new XmlNodeReader (doc));
+                       }
+
+                       public IAsyncResult BeginGet (Message request, AsyncCallback cb, object state)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       public Message EndGet (IAsyncResult result)
+                       {
+                               throw new NotImplementedException ();
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ClientCredentialsSecurityTokenManagerTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ClientCredentialsSecurityTokenManagerTest.cs
new file mode 100644 (file)
index 0000000..73041b3
--- /dev/null
@@ -0,0 +1,820 @@
+//
+// ClientCredentialsSecurityTokenManagerTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using System.Xml;
+using NUnit.Framework;
+
+using MonoTests.System.ServiceModel.Channels;
+
+using ReqType = System.ServiceModel.Security.Tokens.ServiceModelSecurityTokenRequirement;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ClientCredentialsSecurityTokenManagerTest
+       {
+               MyManager def_c;
+               X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
+               X509Certificate2 certpub = new X509Certificate2 ("Test/Resources/test.cer");
+
+               [SetUp]
+               public void Initialize ()
+               {
+                       def_c = new MyManager (new MyClientCredentials ());
+               }
+
+               [Test]
+               public void IsIssuedSecurityTokenRequirement ()
+               {
+                       ServiceModelSecurityTokenRequirement r;
+                       MyManager mgr = new MyManager (new MyClientCredentials ());
+
+                       r = new InitiatorServiceModelSecurityTokenRequirement ();
+                       MySslSecurityTokenParameters ssl =
+                               new MySslSecurityTokenParameters ();
+                       ssl.InitRequirement (r);
+                       Assert.IsFalse (mgr.IsIssued (r), "ssl");
+
+                       r = new InitiatorServiceModelSecurityTokenRequirement ();
+                       MySspiSecurityTokenParameters sspi =
+                               new MySspiSecurityTokenParameters ();
+                       sspi.InitRequirement (r);
+                       Assert.IsFalse (mgr.IsIssued (r), "sspi");
+
+                       r = new InitiatorServiceModelSecurityTokenRequirement ();
+                       MyIssuedSecurityTokenParameters issued =
+                               new MyIssuedSecurityTokenParameters ();
+                       issued.InitRequirement (r);
+                       Assert.IsTrue (mgr.IsIssued (r), "issued");
+
+//                     r = new InitiatorServiceModelSecurityTokenRequirement ();
+//                     MySecureConversationSecurityTokenParameters sc =
+//                             new MySecureConversationSecurityTokenParameters ();
+//                     sc.InitRequirement (r);
+//                     Assert.IsFalse (mgr.IsIssued (r), "sc");
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateProviderDefault ()
+               {
+                       SecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateProviderUserNameWithoutName ()
+               {
+                       SecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.UserName;
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               public void CreateProviderUserName ()
+               {
+                       SecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.UserName;
+                       def_c.ClientCredentials.UserName.UserName = "mono";
+                       UserNameSecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r)
+                               as UserNameSecurityTokenProvider;
+                       Assert.IsNotNull (p, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateProviderRsaDefault ()
+               {
+                       // actually is Rsa usable here??
+
+                       SecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.Rsa;
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateProviderX509WithoutCert ()
+               {
+                       SecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateProviderX509WithX509EndpointIdentity ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       // X509CertificateEndpointIdentity does not work like
+                       // a client certificate; it still requires client cert
+                       r.TargetAddress = new EndpointAddress (
+                               new Uri ("http://localhost:8080"),
+                               new X509CertificateEndpointIdentity (cert));
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               public void CreateProviderX509WithX509IdentityKeyExchange ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       // ... however when it is KeyExchange mode, this
+                       // endpoint identity is used.
+                       r.KeyUsage = SecurityKeyUsage.Exchange;
+                       r.TargetAddress = new EndpointAddress (
+                               new Uri ("http://localhost:8080"),
+                               new X509CertificateEndpointIdentity (cert));
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateProviderX509WithClientCertKeyExchange ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       // ... and in such case ClientCertificate makes no sense.
+                       r.KeyUsage = SecurityKeyUsage.Exchange;
+                       def_c.ClientCredentials.ClientCertificate.Certificate = cert;
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               public void CreateProviderX509 ()
+               {
+                       SecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       def_c.ClientCredentials.ClientCertificate.Certificate = cert;
+                       X509SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r)
+                               as X509SecurityTokenProvider;
+                       Assert.IsNotNull (p, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateProviderX509RecipientNoKeyUsage ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       def_c.ClientCredentials.ClientCertificate.Certificate = cert;
+
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               public void CreateProviderX509Recipient ()
+               {
+                       RecipientServiceModelSecurityTokenRequirement r =
+                               new RecipientServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       r.KeyUsage = SecurityKeyUsage.Exchange;
+                       def_c.ClientCredentials.ClientCertificate.Certificate = cert;
+
+                       X509SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r)
+                               as X509SecurityTokenProvider;
+                       Assert.IsNotNull (p, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderAnonSslNoTargetAddress ()
+               {
+                       SecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+//                     r.TokenType = ServiceModelSecurityTokenTypes.AnonymousSslnego;
+                       new MySslSecurityTokenParameters ().InitRequirement (r);
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderAnonSslNoBindingElement ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = ServiceModelSecurityTokenTypes.AnonymousSslnego;
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderAnonSslNoIssuerBindingContext ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+//                     r.TokenType = ServiceModelSecurityTokenTypes.AnonymousSslnego;
+                       new MySslSecurityTokenParameters ().InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderAnonSslNoMessageSecurityVersion ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+//                     r.TokenType = ServiceModelSecurityTokenTypes.AnonymousSslnego;
+                       new MySslSecurityTokenParameters ().InitRequirement (r);
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement = new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (), new BindingParameterCollection ());
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+               }
+
+               EndpointAddress CreateEndpointAddress (string s, bool publicOnly)
+               {
+                       return new EndpointAddress (new Uri (s),
+                               new X509CertificateEndpointIdentity (publicOnly ? certpub : cert));
+               }
+
+               InitiatorServiceModelSecurityTokenRequirement  GetAnonSslProviderRequirement (bool useTransport)
+               {
+                       return GetSslProviderRequirement (useTransport, false);
+               }
+
+               InitiatorServiceModelSecurityTokenRequirement  GetMutualSslProviderRequirement (bool useTransport)
+               {
+                       return GetSslProviderRequirement (useTransport, true);
+               }
+               
+               InitiatorServiceModelSecurityTokenRequirement  GetSslProviderRequirement (bool useTransport, bool mutual)
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       new MySslSecurityTokenParameters (mutual).InitRequirement (r);
+//                     r.TokenType = ServiceModelSecurityTokenTypes.AnonymousSslnego;
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+//                     r.TargetAddress = CreateEndpointAddress ("http://localhost:8080", true);
+                       r.SecurityBindingElement = SecurityBindingElement.CreateUserNameForSslBindingElement ();
+                       CustomBinding binding =
+                               useTransport ?
+                               new CustomBinding (new HandlerTransportBindingElement (null)) :
+                               new CustomBinding ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (binding, new BindingParameterCollection ());
+                       r.MessageSecurityVersion =
+                               MessageSecurityVersion.Default.SecurityTokenVersion;
+                       r.SecurityAlgorithmSuite =
+                               SecurityAlgorithmSuite.Default;
+
+Assert.IsFalse (new MyManager (new MyClientCredentials ()).IsIssued (r), "premise");
+                       return r;
+               }
+
+               [Test]
+               public void CreateProviderAnonSsl ()
+               {
+                       CreateProviderAnonSsl (false);
+                       CreateProviderAnonSsl (true);
+               }
+
+               public void CreateProviderAnonSsl (bool useTransport)
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               GetAnonSslProviderRequirement (useTransport);
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+
+                       ICommunicationObject comm = p as ICommunicationObject;
+                       Assert.IsNotNull (comm, "#2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")]
+               public void GetAnonSslProviderSecurityTokenNoTransport ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               GetAnonSslProviderRequirement (false);
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+
+                       ICommunicationObject comm = p as ICommunicationObject;
+                       Assert.IsNotNull (comm, "#2");
+                       comm.Open ();
+                       try {
+                               p.GetToken (TimeSpan.FromSeconds (5));
+                       } finally {
+                               comm.Close ();
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void GetAnonSslProviderSecurityTokenNoAlgorithmSuite ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               GetAnonSslProviderRequirement (true);
+                       r.Properties.Remove (ReqType.SecurityAlgorithmSuiteProperty);
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+
+                       ICommunicationObject comm = p as ICommunicationObject;
+                       Assert.IsNotNull (comm, "#2");
+                       comm.Open ();
+                       try {
+                               p.GetToken (TimeSpan.FromSeconds (5));
+                       } finally {
+                               comm.Close ();
+                       }
+               }
+
+               [Test]
+               [Ignore ("it somehow causes NRE - smells .NET bug.")]
+               public void GetAnonSslProviderSecurityToken ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               GetAnonSslProviderRequirement (true);
+
+                       // What causes NRE!?
+                       def_c.ClientCredentials.ClientCertificate.Certificate = certpub;
+                       r.Properties [ReqType.IssuedSecurityTokenParametersProperty] =
+                               new X509SecurityTokenParameters ();
+                       r.TargetAddress = CreateEndpointAddress ("http://localhost:8080", true);
+                       r.IssuerAddress = CreateEndpointAddress ("http://localhost:8080", true);
+                       r.IssuerBinding = new CustomBinding (new HandlerTransportBindingElement (null));
+                       def_c.ClientCredentials.ServiceCertificate.DefaultCertificate = certpub;
+
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+
+                       ICommunicationObject comm = p as ICommunicationObject;
+                       Assert.IsNotNull (comm, "#2");
+                       comm.Open ();
+                       try {
+                               p.GetToken (TimeSpan.FromSeconds (5));
+                       } finally {
+                               comm.Close ();
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void CreateProviderMutualSslWithoutClientCert ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               GetMutualSslProviderRequirement (true);
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderSecureConvNoTargetAddress ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               CreateRequirement ();
+                       r.Properties.Remove (ReqType.TargetAddressProperty);
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderSecureConvNoSecurityBindingElement ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               CreateRequirement ();
+                       r.Properties.Remove (ReqType.SecurityBindingElementProperty);
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderSecureConvNoIssuerBindingContext ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               CreateRequirement ();
+                       r.Properties.Remove (ReqType.IssuerBindingContextProperty);
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderSecureConvNoKeySize ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = ServiceModelSecurityTokenTypes.SecureConversation;
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement =
+                               new SymmetricSecurityBindingElement ();
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (), new BindingParameterCollection ());
+/* it somehow does not cause an error ...
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               CreateRequirement ();
+                       r.Properties.Remove (SecurityTokenRequirement.KeySizeProperty);
+*/
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CreateProviderSecureConvNoMessageSecurityVersion ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               CreateRequirement ();
+                       r.Properties.Remove (ReqType.MessageSecurityVersionProperty);
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               InitiatorServiceModelSecurityTokenRequirement CreateRequirement ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = ServiceModelSecurityTokenTypes.SecureConversation;
+                       r.TargetAddress = new EndpointAddress ("http://localhost:8080");
+                       r.SecurityBindingElement =
+                               new SymmetricSecurityBindingElement ();
+
+                       // Without it, mysterious "The key length (blabla) 
+                       // is not a multiple of 8 for symmetric keys." occurs.
+                       r.SecureConversationSecurityBindingElement =
+                               new SymmetricSecurityBindingElement ();
+
+                       r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion;
+                       r.Properties [ReqType.IssuerBindingContextProperty] =
+                               new BindingContext (new CustomBinding (new HttpTransportBindingElement ()), new BindingParameterCollection ());
+                       r.KeySize = 256;
+                       return r;
+               }
+
+               [Test]
+               public void CreateProviderSecureConv ()
+               {
+                       SecurityTokenRequirement r = CreateRequirement ();
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+                       // non-standard provider, it looks similar to IssuedSecurityTokenProvider.
+               }
+
+               [Test]
+               [Ignore ("it ends up to require running service on .NET, and it's anyways too implementation dependent.")]
+               public void SecureConvProviderGetToken ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               CreateRequirement ();
+                       // it still requires SecurityAlgorithmSuite on GetToken().
+                       r.SecurityAlgorithmSuite = SecurityAlgorithmSuite.Default;
+                       // the actual security binding element requires
+                       // ProtectionTokenParameters.
+                       r.SecureConversationSecurityBindingElement =
+                               SecurityBindingElement.CreateAnonymousForCertificateBindingElement ();
+                       // the above requires service certificate
+                       BindingContext ctx = r.GetProperty<BindingContext> (ReqType.IssuerBindingContextProperty);
+                       ClientCredentials cred = new ClientCredentials ();
+                       cred.ServiceCertificate.DefaultCertificate = cert;
+                       ctx.BindingParameters.Add (cred);
+
+                       // without it, identity check fails on IssuerAddress
+                       // (TargetAddress is used when IssuerAddress is not set)
+                       r.TargetAddress = new EndpointAddress (new Uri ("http://localhost:8080"), new X509CertificateEndpointIdentity (cert));
+
+                       SecurityTokenProvider p =
+                               def_c.CreateSecurityTokenProvider (r);
+                       Assert.IsNotNull (p, "#1");
+                       // non-standard provider, it looks similar to IssuedSecurityTokenProvider.
+                       ((ICommunicationObject) p).Open ();
+                       p.GetToken (TimeSpan.FromSeconds (5));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               [Category ("NotWorking")]
+               public void SecureConvProviderOnlyWithIssuedParameters ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = ServiceModelSecurityTokenTypes.SecureConversation;
+                       IssuedSecurityTokenParameters ip =
+                               new IssuedSecurityTokenParameters ();
+                       ip.IssuerAddress = new EndpointAddress ("http://localhost:8080");
+                       ip.IssuerBinding = new WSHttpBinding ();
+
+                       r.Properties [ReqType.IssuedSecurityTokenParametersProperty] = ip;
+
+                       def_c.CreateSecurityTokenProvider (r);
+               }
+
+               // CreateSecurityTokenAuthenticator
+
+               [Test]
+               [ExpectedException (typeof (NotSupportedException))]
+               public void CreateAuthenticatorUserName ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.UserName;
+                       def_c.ClientCredentials.UserName.UserName = "mono";
+                       SecurityTokenResolver resolver;
+                       def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+               }
+
+               [Test]
+               public void CreateAuthenticatorRsa ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.Rsa;
+                       SecurityTokenResolver resolver;
+                       RsaSecurityTokenAuthenticator rsa =
+                               def_c.CreateSecurityTokenAuthenticator (r, out resolver)
+                               as RsaSecurityTokenAuthenticator;
+                       Assert.IsNotNull (rsa, "#1");
+                       Assert.IsNull (resolver, "#2"); // but probably non-null if there is RsaSecurityToken that could be somehow created from the credential.
+               }
+
+               [Test]
+               public void CreateAuthenticatorX509 ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       r.TokenType = SecurityTokenTypes.X509Certificate;
+                       def_c.ClientCredentials.ClientCertificate.Certificate = cert;
+                       SecurityTokenResolver resolver;
+                       SecurityTokenAuthenticator x509 =
+                               def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+                       Assert.IsNotNull (x509, "#1");
+                       Assert.IsNull (resolver, "#2"); // hmm...
+
+                       def_c.ClientCredentials.ServiceCertificate.DefaultCertificate = cert;
+                       x509 = def_c.CreateSecurityTokenAuthenticator (r, out resolver);
+                       Assert.IsNotNull (x509, "#3");
+                       Assert.IsNull (resolver, "#4"); // hmmm...
+               }
+
+               [Test]
+               [Ignore ("this test is not fully written yet.")]
+               public void OtherParameterInEndorsingSupport ()
+               {
+                       SymmetricSecurityBindingElement be =
+                               new SymmetricSecurityBindingElement ();
+                       be.ProtectionTokenParameters =
+                               new X509SecurityTokenParameters ();
+                       be.EndpointSupportingTokenParameters.Endorsing.Add (
+                               new MyEndorsingTokenParameters ());
+                       Binding b = new CustomBinding (be, new HttpTransportBindingElement ());
+                       EndpointAddress ea = new EndpointAddress (new Uri ("http://localhost:37564"), new X509CertificateEndpointIdentity (cert));
+                       CalcProxy client = new CalcProxy (b, ea);
+                       client.Endpoint.Behaviors.RemoveAll<ClientCredentials> ();
+                       client.Endpoint.Behaviors.Add (new MyClientCredentials ());
+                       client.Sum (1, 2);
+               }
+
+               [Test]
+               [ExpectedException (typeof (NotImplementedException))]
+               public void MissingCloneCore ()
+               {
+                       new MyClientCredentials2 ().Clone ();
+               }
+
+               [Test]
+               public void AnonSslIsIssued ()
+               {
+                       InitiatorServiceModelSecurityTokenRequirement r =
+                               new InitiatorServiceModelSecurityTokenRequirement ();
+                       new MySslSecurityTokenParameters ().InitRequirement (r);
+                       Assert.IsFalse (new MyManager (new MyClientCredentials ()).IsIssued (r), "#1");
+               }
+       }
+
+       class MyClientCredentials : ClientCredentials
+       {
+               public override SecurityTokenManager CreateSecurityTokenManager ()
+               {
+                       return new MyManager (this);
+               }
+
+               protected override ClientCredentials CloneCore ()
+               {
+                       return new MyClientCredentials ();
+               }
+       }
+
+       class MyClientCredentials2 : ClientCredentials
+       {
+               public override SecurityTokenManager CreateSecurityTokenManager ()
+               {
+                       return null;
+               }
+       }
+
+       class MyManager : ClientCredentialsSecurityTokenManager
+       {
+               public MyManager (MyClientCredentials cred)
+                       : base (cred)
+               {
+               }
+
+               public bool IsIssued (SecurityTokenRequirement r)
+               {
+                       return IsIssuedSecurityTokenRequirement (r);
+               }
+
+               public override SecurityTokenProvider CreateSecurityTokenProvider (SecurityTokenRequirement tokenRequirement
+)
+               {
+                       if (tokenRequirement.TokenType == "urn:my")
+                               return new MySecurityTokenProvider ();
+                       return base.CreateSecurityTokenProvider (tokenRequirement);
+               }
+
+               public override SecurityTokenSerializer CreateSecurityTokenSerializer (SecurityTokenVersion ver)
+               {
+                       return new MySecurityTokenSerializer ();
+               }
+       }
+
+       class MySslSecurityTokenParameters : SslSecurityTokenParameters
+       {
+               public MySslSecurityTokenParameters ()
+               {
+               }
+
+               public MySslSecurityTokenParameters (bool mutual)
+                       : base (mutual)
+               {
+               }
+
+               public void InitRequirement (SecurityTokenRequirement r)
+               {
+                       InitializeSecurityTokenRequirement (r);
+               }
+       }
+
+       class MySspiSecurityTokenParameters : SspiSecurityTokenParameters
+       {
+               public void InitRequirement (SecurityTokenRequirement r)
+               {
+                       InitializeSecurityTokenRequirement (r);
+               }
+       }
+
+       class MyIssuedSecurityTokenParameters : IssuedSecurityTokenParameters
+       {
+               public void InitRequirement (SecurityTokenRequirement r)
+               {
+                       InitializeSecurityTokenRequirement (r);
+               }
+       }
+
+       class MySecureConversationSecurityTokenParameters : SecureConversationSecurityTokenParameters
+       {
+               public MySecureConversationSecurityTokenParameters ()
+               {
+               }
+
+               public MySecureConversationSecurityTokenParameters (SecurityBindingElement element)
+                       : base (element)
+               {
+               }
+
+               public MySecureConversationSecurityTokenParameters (SecurityBindingElement element, bool requireCancel, ChannelProtectionRequirements cpr)
+                       : base (element, requireCancel, cpr)
+               {
+               }
+
+               public void InitRequirement (SecurityTokenRequirement r)
+               {
+                       InitializeSecurityTokenRequirement (r);
+               }
+       }
+
+       class MySecurityTokenProvider : SecurityTokenProvider
+       {
+               public MySecurityTokenProvider ()
+               {
+               }
+
+               protected override SecurityToken GetTokenCore (TimeSpan timeout)
+               {
+                       return new RsaSecurityToken (RSA.Create ());
+               }
+       }
+
+       class MySecurityTokenSerializer : WSSecurityTokenSerializer
+       {
+               protected override void WriteTokenCore (XmlWriter w, SecurityToken token)
+               {
+                       RsaSecurityToken r = token as RsaSecurityToken;
+                       w.Flush ();
+                       if (r != null)
+                               w.WriteRaw (r.Rsa.ToXmlString (false));
+                       else
+                               base.WriteTokenCore (w, token);
+               }
+       }
+
+       class MyEndorsingTokenParameters : SecurityTokenParameters
+       {
+               public MyEndorsingTokenParameters ()
+               {
+               }
+
+               protected MyEndorsingTokenParameters (MyEndorsingTokenParameters source)
+               {
+               }
+
+               protected override bool HasAsymmetricKey {
+                       get { return true; }
+               }
+
+               protected override bool SupportsClientAuthentication {
+                       get { return true; }
+               }
+
+               protected override bool SupportsClientWindowsIdentity {
+                       get { return false; }
+               }
+
+               protected override bool SupportsServerAuthentication {
+                       get { return true; }
+               }
+
+               protected override SecurityTokenParameters CloneCore ()
+               {
+                       return new MyEndorsingTokenParameters (this);
+               }
+
+               protected override SecurityKeyIdentifierClause CreateKeyIdentifierClause (
+                       SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
+               {
+                       RsaSecurityToken r = token as RsaSecurityToken;
+                       return r.CreateKeyIdentifierClause <RsaKeyIdentifierClause> ();
+               }
+
+               protected override void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
+               {
+                       // If there were another token type that supports protection
+                       // and does not require X509, it should be used instead ...
+                       requirement.TokenType = "urn:my";
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/CommonUseCases.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/CommonUseCases.cs
new file mode 100644 (file)
index 0000000..bba5212
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// CommonUseCases.cs
+//
+// Author:
+//     Eyal Alaluf
+//
+// Copyright (C) 2008 Mainsoft Co. http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       // Use case with one endpoint configuration.
+       [ServiceContract]
+       public interface ICtorUseCase1
+       {
+               [OperationContract]
+               string Echo (string msg);
+       }
+
+       // Use case with multiple endpoint configurations.
+       [ServiceContract(ConfigurationName = "CtorUseCase2")]
+       public interface ICtorUseCase2
+       {
+               [OperationContract]
+               string Echo (string msg);
+       }
+
+       // Use case without endpoint configuration.
+       [ServiceContract(ConfigurationName = "CtorUseCase3")]
+       public interface ICtorUseCase3
+       {
+               [OperationContract]
+               string Echo (string msg);
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointAddress10Test.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointAddress10Test.cs
new file mode 100755 (executable)
index 0000000..b7d446b
--- /dev/null
@@ -0,0 +1,109 @@
+//
+// EndpointAddress10Test.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class EndpointAddress10Test
+       {
+               [Test]
+               public void ReadWriteXml ()
+               {
+                       StringWriter sw = new StringWriter ();
+
+                       EndpointAddress10 e = EndpointAddress10.FromEndpointAddress (new EndpointAddress ("http://localhost:8080"));
+
+                       using (XmlWriter xw = XmlWriter.Create (sw)) {
+                               ((IXmlSerializable) e).WriteXml (xw);
+                       }
+                       Assert.AreEqual (@"<?xml version=""1.0"" encoding=""utf-16""?><Address xmlns=""http://www.w3.org/2005/08/addressing"">http://localhost:8080/</Address>", sw.ToString ());
+
+                       // unlike WriteXml, ReadXml expects the root element.
+                       StringReader sr = new StringReader (@"<EndpointReference xmlns=""http://www.w3.org/2005/08/addressing""><Address>http://localhost:8080/</Address></EndpointReference>");
+                       using (XmlReader xr = XmlReader.Create (sr)) {
+                               ((IXmlSerializable) e).ReadXml (xr);
+                       }
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void SerializeDeserialize ()
+               {
+                       StringWriter sw = new StringWriter ();
+
+                       EndpointAddress10 e = EndpointAddress10.FromEndpointAddress (new EndpointAddress ("http://localhost:8080"));
+
+                       XmlSerializer xs = new XmlSerializer (typeof (EndpointAddress10));
+
+                       sw = new StringWriter ();
+
+                       using (XmlWriter xw = XmlWriter.Create (sw)) {
+                               xs.Serialize (xw, e);
+                       }
+                       Assert.AreEqual (@"<?xml version=""1.0"" encoding=""utf-16""?><EndpointReference xmlns=""http://www.w3.org/2005/08/addressing""><Address>http://localhost:8080/</Address></EndpointReference>", sw.ToString ());
+                       StringReader sr = new StringReader (sw.ToString ());
+                       using (XmlReader xr = XmlReader.Create (sr)) {
+                               xs.Deserialize (xr);
+                       }
+               }
+
+               [Test]
+               public void GetSchema ()
+               {
+                       // actually it just returns null. That makes sense
+                       // since there's no way to include reasonable claim
+                       // schemas.
+                       EndpointAddress10.FromEndpointAddress (new EndpointAddress ("http://localhost:8080"));
+                       XmlSchemaSet xss = new XmlSchemaSet ();
+                       XmlQualifiedName q = EndpointAddress10.GetSchema (xss);
+                       Assert.AreEqual (1, xss.Count, "#1");
+                       Assert.AreEqual ("EndpointReferenceType", q.Name, "#2");
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing", q.Namespace, "#2");
+                       foreach (XmlSchema xs in xss.Schemas ()) {
+                               Assert.AreEqual ("http://www.w3.org/2005/08/addressing", xs.TargetNamespace, "#4");
+                       }
+               }
+
+               [Test]
+               public void IXmlSerializableGetSchema ()
+               {
+                       // actually it just returns null.
+                       EndpointAddress10 e = EndpointAddress10.FromEndpointAddress (new EndpointAddress ("http://localhost:8080"));
+                       XmlSchema xs = ((IXmlSerializable) e).GetSchema ();
+                       Assert.IsNull (xs);
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointAddressBuilderTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointAddressBuilderTest.cs
new file mode 100644 (file)
index 0000000..0290c2d
--- /dev/null
@@ -0,0 +1,48 @@
+//
+// EndpointAddressBuilderTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class EndpointAddressBuilderTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ToEndpointAddressWithoutReader ()
+               {
+                       new EndpointAddressBuilder ().ToEndpointAddress ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointAddressTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointAddressTest.cs
new file mode 100644 (file)
index 0000000..ef707c8
--- /dev/null
@@ -0,0 +1,409 @@
+//
+// EndpointBehaviorCollectionTest.cs
+//
+// Authors:
+//     Duncan Mak <duncan@ximian.com>
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.Text;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class EndpointAddressTest
+       {
+               EndpointAddress address;
+               string namespace_uri = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
+
+               [Test]
+               public void AnonymousUri ()
+               {
+                       Assert.AreEqual ("http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/Anonymous", EndpointAddress.AnonymousUri.AbsoluteUri, "#1");
+
+                       address = new EndpointAddress ("http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/Anonymous");
+                       Assert.IsTrue (address.IsAnonymous, "#2");
+                       Assert.IsFalse (address.IsNone, "#3");
+               }
+
+               [Test]
+               public void AnonymousUri2 ()
+               {
+                       address = new EndpointAddress ("http://www.w3.org/2005/08/addressing/anonymous");
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing/anonymous", address.Uri.AbsoluteUri, "#1");
+                       Assert.IsFalse (address.IsAnonymous, "#2");
+                       Assert.IsFalse (address.IsNone, "#3");
+               }
+
+               [Test]
+               public void NoneUri ()
+               {
+                       Assert.AreEqual ("http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/None", EndpointAddress.NoneUri.AbsoluteUri, "#1");
+
+                       address = new EndpointAddress ("http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/None");
+                       Assert.IsFalse (address.IsAnonymous, "#2");
+                       Assert.IsTrue (address.IsNone, "#3");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ConstructorNullString ()
+               {
+                       new EndpointAddress ((string) null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void ConstructorRelativeUri ()
+               {
+                       new EndpointAddress (new Uri (String.Empty, UriKind.RelativeOrAbsolute));
+               }
+
+               [Test]
+               public void Headers ()
+               {
+                       EndpointAddress e = new EndpointAddress ("urn:foo");
+                       Assert.IsNotNull (e.Headers, "#1");
+                       // This code results in NullReferenceException, which
+                       // is nasty.
+                       //Assert.AreEqual (0, e.Headers.Count, "#2");
+               }
+
+               [Test]
+               public void EqualsTest ()
+               {
+                       address = new EndpointAddress ("urn:foo");
+                       Assert.IsFalse (address == null, "#1"); // don't throw NullReferenceException
+                       Assert.IsTrue ((EndpointAddress) null == null, "#2");
+
+                       Assert.IsTrue (address == new EndpointAddress ("urn:foo"), "#3");
+               }
+
+               [Test]
+               public void ReadFrom0 ()
+               {
+                       string xml = @"<a:ReplyTo xmlns:a='http://www.w3.org/2005/08/addressing'><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>";
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+                       EndpointAddress a = EndpointAddress.ReadFrom (reader);
+                       Assert.IsNotNull (a, "#1");
+                       Assert.AreEqual ("http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/Anonymous", a.Uri.AbsoluteUri, "#2");
+                       Assert.IsTrue (a.IsAnonymous, "#3");
+               }
+
+               [Test]
+               public void ReadFrom1 ()
+               {
+                       string xml = @"<a:ReplyTo xmlns:a='http://schemas.xmlsoap.org/ws/2004/08/addressing'><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>";
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+                       EndpointAddress a = EndpointAddress.ReadFrom (reader);
+                       Assert.IsNotNull (a, "#1");
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing/anonymous", a.Uri.AbsoluteUri, "#2");
+                       Assert.IsFalse (a.IsAnonymous, "#3");
+               }
+
+               [Test]
+               public void ReadFrom2 ()
+               {
+                       string xml = @"<a:ReplyTo xmlns:a='http://www.w3.org/2005/08/addressing'><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>";
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+                       EndpointAddress a = EndpointAddress.ReadFrom (AddressingVersion.WSAddressing10, reader);
+
+                       Assert.IsNotNull (a, "#1");
+                       Assert.AreEqual ("http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/Anonymous", a.Uri.AbsoluteUri, "#2");
+                       Assert.IsTrue (a.IsAnonymous, "#3");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void ReadFrom2Error ()
+               {
+                       
+                       string xml = @"<a:ReplyTo xmlns:a='http://www.w3.org/2005/08/addressing'><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>";
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+
+                       //Reading address with e10 address!
+                       EndpointAddress.ReadFrom (AddressingVersion.WSAddressingAugust2004, reader);
+               }
+
+               [Test]
+               public void ReadFrom3 ()
+               {
+                       string xml = @"<a:ReplyTo xmlns:a='http://schemas.xmlsoap.org/ws/2004/08/addressing'><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>";
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+                       EndpointAddress a = EndpointAddress.ReadFrom (AddressingVersion.WSAddressingAugust2004, reader);
+                       
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing/anonymous", a.Uri.AbsoluteUri, "#1");
+                       Assert.IsFalse (a.IsAnonymous, "#2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void ReadFrom3Error ()
+               {
+                       string xml = @"<a:ReplyTo xmlns:a='http://schemas.xmlsoap.org/ws/2004/08/addressing'><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>";
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+                       EndpointAddress.ReadFrom (AddressingVersion.WSAddressing10, reader);
+               }
+
+               [Test]
+               public void ReadFromE10 ()
+               {
+                       string xml = @"<a:ReplyTo xmlns:a='http://www.w3.org/2005/08/addressing'><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>";
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+                       
+                       EndpointAddress10 e10 = EndpointAddress10.FromEndpointAddress (new EndpointAddress (("http://test")));
+                       ((IXmlSerializable) e10).ReadXml (reader);
+
+                       EndpointAddress a = e10.ToEndpointAddress ();
+                       Assert.AreEqual ("http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/Anonymous", a.Uri.AbsoluteUri, "#1");
+                       Assert.IsTrue (a.IsAnonymous, "#2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void ReadFromE10Error ()
+               {
+                       //Address is from August2004 namespace, but reading it with EndpointAddress10
+                       string xml = @"<a:ReplyTo xmlns:a='http://schemas.xmlsoap.org/ws/2004/08/addressing'><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>";
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+
+                       EndpointAddress10 e10 = EndpointAddress10.FromEndpointAddress (new EndpointAddress (("http://test")));
+                       ((IXmlSerializable) e10).ReadXml (reader);
+                       
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void ReadFromE10Error2 ()
+               {
+                       //Missing <Address> element
+                       string xml = @"<a:ReplyTo xmlns:a='http://www.w3.org/2005/08/addressing'>http://www.w3.org/2005/08/addressing/anonymous</a:ReplyTo>";
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+
+                       EndpointAddress10 e10 = EndpointAddress10.FromEndpointAddress (new EndpointAddress (("http://test")));
+                       ((IXmlSerializable) e10).ReadXml (reader);
+
+               }
+
+               [Test]
+               public void ReadFromAugust2004 ()
+               {
+                       string xml = @"<a:ReplyTo xmlns:a='http://schemas.xmlsoap.org/ws/2004/08/addressing'><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>";
+                       
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+
+                       EndpointAddressAugust2004 e2k4 = EndpointAddressAugust2004.FromEndpointAddress (new EndpointAddress ("http://test"));
+                       
+                       ((IXmlSerializable) e2k4).ReadXml (reader);
+                       Console.WriteLine (e2k4.ToEndpointAddress ().Uri.AbsoluteUri);
+
+                       EndpointAddress a = e2k4.ToEndpointAddress ();
+                       Assert.AreEqual ("http://www.w3.org/2005/08/addressing/anonymous", a.Uri.AbsoluteUri, "#1");
+                       Assert.IsFalse (a.IsAnonymous, "#2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void ReadFromAugust2004Error ()
+               {
+                       //Reading address from EndpointAddress10 namespace with EndpointAddressAugust2004
+                       string xml = @"<a:ReplyTo xmlns:a='http://www.w3.org/2005/08/addressing'><a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address></a:ReplyTo>";
+
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+
+                       EndpointAddressAugust2004 e2k4 = EndpointAddressAugust2004.FromEndpointAddress (new EndpointAddress ("http://test"));
+
+                       ((IXmlSerializable) e2k4).ReadXml (reader);
+               }
+
+               [Test]
+               [ExpectedException (typeof (XmlException))]
+               public void ReadFromAugust2004Error2 ()
+               {
+                       //Missing <Address> element
+                       string xml = @"<a:ReplyTo xmlns:a='http://schemas.xmlsoap.org/ws/2004/08/addressing'>http://www.w3.org/2005/08/addressing/anonymous</a:ReplyTo>";
+
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+
+                       EndpointAddressAugust2004 e2k4 = EndpointAddressAugust2004.FromEndpointAddress (new EndpointAddress ("http://test"));
+
+                       ((IXmlSerializable) e2k4).ReadXml (reader);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void ReadFromWrongXml ()
+               {
+                       string xml = @"<a:Address xmlns:a='http://www.w3.org/2005/08/addressing'>http://www.w3.org/2005/08/addressing/anonymous</a:Address>";
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+                       EndpointAddress.ReadFrom (reader);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void ReadFromWrongXml2 ()
+               {
+                       string xml = @"<a:ReplyTo xmlns:a='http://www.w3.org/2005/08/addressing'>http://www.w3.org/2005/08/addressing/anonymous</a:ReplyTo>";
+                       XmlReader src = XmlReader.Create (new StringReader (xml));
+                       XmlDictionaryReader reader =
+                               XmlDictionaryReader.CreateDictionaryReader (src);
+                       EndpointAddress.ReadFrom (reader);
+               }
+
+               [Test]
+               public void WriteToAddressingNone ()
+               {
+                       EndpointAddress a = new EndpointAddress ("http://localhost:8080");
+                       StringWriter sw = new StringWriter ();
+                       XmlWriterSettings xws = new XmlWriterSettings ();
+                       xws.OmitXmlDeclaration = true;
+                       // #1
+                       using (XmlDictionaryWriter xw = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (sw, xws))) {
+                               a.WriteTo (AddressingVersion.None, xw, "From", "http://www.w3.org/2005/08/addressing");
+                       }
+                       Assert.AreEqual ("<From xmlns=\"http://www.w3.org/2005/08/addressing\">http://localhost:8080/</From>", sw.ToString (), "#1");
+
+                       // #2
+                       sw = new StringWriter ();
+                       using (XmlDictionaryWriter xw = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (sw, xws))) {
+                               a.WriteTo (AddressingVersion.None, xw);
+                       }
+                       Assert.AreEqual ("<EndpointReference xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\">http://localhost:8080/</EndpointReference>", sw.ToString (), "#2");
+               }
+
+               string identity1 = "<Identity xmlns=\"http://schemas.xmlsoap.org/ws/2006/02/addressingidentity\"><KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509Data><X509Certificate>MIIBxTCCAS6gAwIBAgIQEOvBwzgWq0aTzEi0qgWLBTANBgkqhkiG9w0BAQUFADAgMR4wHAYDVQQDExVNb25vIFRlc3QgUm9vdCBBZ2VuY3kwHhcNMDYwNzMxMDYxMDI4WhcNMzkxMjMxMDk1OTU5WjAkMSIwIAYDVQQDExlQb3Vwb3Uncy1Tb2Z0d2FyZS1GYWN0b3J5MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQCJI5sOaaEOCuXg2Itq+IVym/g13KwFYlyqJXPcBBs91qO1dpBDxUl19GSLFqHXfbIo4UYJZmEdLcS48yHx1w3AbC1raeH6bYhXqS3Mjj6ZnsJI0CyaUNjQkj4fwC3W8q80CuULmORUa6WJiugl5JT80s8s1iCymLtO1cbL1F+6DwIBETANBgkqhkiG9w0BAQUFAAOBgQA5IxtEKCgG0o6YxVDKRRTfiQY4QiCkHxqgfP2E+Cm6guuHykAFvWFqMUtGZq3yco8u83ZgXtjPphhPuzl8fdJsLTXieERsAbfZwcbp6cssTwsSl4JJviHSN17G3qbo0LH9u1QJHesBaH52Hz2iZaBfClxgUQGeWvO0SW+hZo75hg==</X509Certificate></X509Data></KeyInfo></Identity>";
+
+               string C14N (string xml)
+               {
+                       XmlDsigExcC14NTransform t = new XmlDsigExcC14NTransform ();
+                       XmlDocument doc = new XmlDocument ();
+                       doc.LoadXml (xml);
+                       t.LoadInput (doc);
+                       return new StreamReader (t.GetOutput () as Stream).ReadToEnd ();
+               }
+
+               [Test]
+               public void WriteToWSA10 ()
+               {
+                       X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.cer");
+                       EndpointAddress a = new EndpointAddress (
+                               new Uri ("http://localhost:8080"),
+                               new X509CertificateEndpointIdentity (cert));
+                       StringWriter sw = new StringWriter ();
+                       XmlWriterSettings xws = new XmlWriterSettings ();
+                       xws.OmitXmlDeclaration = true;
+                       using (XmlDictionaryWriter xw = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (sw, xws))) {
+                               a.WriteTo (AddressingVersion.WSAddressing10, xw);
+                       }
+                       Assert.AreEqual (C14N ("<EndpointReference xmlns=\"http://www.w3.org/2005/08/addressing\"><Address>http://localhost:8080/</Address>" + identity1 + "</EndpointReference>"), C14N (sw.ToString ()), "#2");
+               }
+
+               [Test]
+               public void WriteContentsToWSA10 ()
+               {
+                       X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.cer");
+                       EndpointAddress a = new EndpointAddress (
+                               new Uri ("http://localhost:8080"),
+                               new X509CertificateEndpointIdentity (cert));
+                       StringWriter sw = new StringWriter ();
+                       XmlWriterSettings xws = new XmlWriterSettings ();
+                       xws.OmitXmlDeclaration = true;
+                       using (XmlDictionaryWriter xw = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (sw, xws))) {
+                               xw.WriteStartElement ("root");
+                               a.WriteContentsTo (AddressingVersion.WSAddressing10, xw);
+                               xw.WriteEndElement ();
+                       }
+                       Assert.AreEqual (C14N ("<root><Address xmlns=\"http://www.w3.org/2005/08/addressing\">http://localhost:8080/</Address>" + identity1 + "</root>"), C14N (sw.ToString ()), "#2");
+               }
+
+/* GetSchema() does not exist anymore
+               [Test]
+               public void GetSchemaTest ()
+               {
+                       address = new EndpointAddress ("http://tempuri.org/foo");
+                       Assert.IsNull (address.GetSchema ());
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void GetSchemaTestWithEmptySet ()
+               {
+                       XmlSchemaSet set = new XmlSchemaSet ();
+                       Assert.AreEqual (0, set.Count, "#1");
+                       Assert.IsFalse (set.Contains (namespace_uri), "#2");
+
+                       XmlQualifiedName n = EndpointAddress.GetSchema (set);
+
+                       // A complete copy of the schema for EndpointReference is added.
+                       Assert.AreEqual (1, set.Count, "#3");
+                       Assert.IsTrue (set.Contains (namespace_uri), "#4");
+
+                       int count = 5;
+                       foreach (XmlSchema schema in set.Schemas ()) {
+                               Assert.AreEqual (schema.TargetNamespace, n.Namespace, "#" + count++);
+                               Assert.IsTrue (schema.SchemaTypes.Contains (n), "#" + count++);
+                               // This prints out the entire Schema!
+                               // schema.Write (Console.Out);
+                       }
+               }
+*/
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointBehaviorCollectionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointBehaviorCollectionTest.cs
new file mode 100644 (file)
index 0000000..40f9f93
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// EndpointBehaviorCollectionTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if USE_DEPRECATED
+using System;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class EndpointBehaviorCollectionTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               [Ignore ("It throws NullReferenceException instead")]
+               public void CtorNullArg ()
+               {
+                       new EndpointBehaviorCollection (null);
+               }
+       }
+}
+#endif
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointIdentityTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/EndpointIdentityTest.cs
new file mode 100644 (file)
index 0000000..0d65970
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// EndpointIdentityTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.IO;
+using System.IdentityModel.Claims;
+using System.Runtime.Serialization;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography.Xml;
+using System.ServiceModel;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class EndpointIdentityTest
+       {
+               static readonly X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.cer");
+
+               [Test]
+               [Category ("NotWorking")] // DataContractSerializer+base64 issue
+               public void CreateX509CertificateIdentity ()
+               {
+                       X509CertificateEndpointIdentity identity =
+                               EndpointIdentity.CreateX509CertificateIdentity (cert)
+                               as X509CertificateEndpointIdentity;
+                       Claim c = identity.IdentityClaim;
+                       Assert.IsNotNull (c, "#1");
+                       Assert.AreEqual (ClaimTypes.Thumbprint, c.ClaimType, "#2");
+                       DataContractSerializer ser = new DataContractSerializer (c.GetType ());
+                       StringWriter sw = new StringWriter ();
+                       XmlWriter xw = XmlWriter.Create (sw);
+                       ser.WriteObject (xw, c);
+                       xw.Close ();
+                       string xml = @"<?xml version=""1.0"" encoding=""utf-16""?><Claim xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.xmlsoap.org/ws/2005/05/identity""><ClaimType>http://schemas.xmlsoap.org/ws/2005/05/identity/claims/thumbprint</ClaimType><Resource xmlns:d2p1=""http://www.w3.org/2001/XMLSchema"" i:type=""d2p1:base64Binary"">GQ3YHlGQhDF1bvMixHliX4uLjlY=</Resource><Right>http://schemas.xmlsoap.org/ws/2005/05/identity/right/possessproperty</Right></Claim>";
+                       Assert.AreEqual (C14N (xml), C14N (sw.ToString ()), "#3");
+                       Assert.AreEqual ("identity(" + c + ")", identity.ToString (), "#4");
+               }
+
+               string C14N (string xml)
+               {
+                       XmlDsigExcC14NTransform t = new XmlDsigExcC14NTransform ();
+                       XmlDocument doc = new XmlDocument ();
+                       doc.LoadXml (xml);
+                       t.LoadInput (doc);
+                       return new StreamReader (t.GetOutput () as Stream).ReadToEnd ();
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ExtensionCollectionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ExtensionCollectionTest.cs
new file mode 100644 (file)
index 0000000..d363aa2
--- /dev/null
@@ -0,0 +1,104 @@
+//
+// ExtensionCollectionTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ExtensionCollectionTest
+       {
+               class MyExtensibleObject : IExtensibleObject<MyExtensibleObject>
+               {
+                       IExtensionCollection<MyExtensibleObject> _extensions;
+
+                       public IExtensionCollection<MyExtensibleObject> Extensions {
+                               get {
+                                       if (_extensions == null)
+                                               _extensions = new ExtensionCollection<MyExtensibleObject> (this);
+                                       return _extensions;
+                               }
+                       }
+               }
+
+               abstract class MyExtensionBase : IExtension<MyExtensibleObject>
+               {
+                       public bool IsAttached {
+                               get;
+                               private set;
+                       }
+
+                       public void Attach (MyExtensibleObject owner) {
+                               IsAttached = true;
+                       }
+
+                       public void Detach (MyExtensibleObject owner) {
+                               IsAttached = false;
+                       }
+               }
+
+               class MyExtension1 : MyExtensionBase
+               {
+               }
+
+               class MyExtension2 : MyExtensionBase
+               {
+               }
+
+               [Test]
+               public void Add_Remove_Call_Attach () {
+
+                       MyExtensibleObject extObj = new MyExtensibleObject ();
+                       MyExtension1 ext = new MyExtension1 ();
+                       Assert.AreEqual (false, ext.IsAttached, "IsAttached #1");
+                       extObj.Extensions.Add (ext);
+                       Assert.AreEqual (true, ext.IsAttached, "IsAttached #2");
+                       extObj.Extensions.Remove (ext);
+                       Assert.AreEqual (false, ext.IsAttached, "IsAttached #3");
+               }
+
+               [Test]
+               public void Clear_Calls_Attach () {
+
+                       MyExtensibleObject extObj = new MyExtensibleObject ();
+                       MyExtension1 ext1 = new MyExtension1 ();
+                       MyExtension2 ext2 = new MyExtension2 ();
+                       extObj.Extensions.Add (ext1);
+                       extObj.Extensions.Add (ext2);
+                       Assert.AreEqual (true, ext1.IsAttached, "IsAttached #1");
+                       Assert.AreEqual (true, ext2.IsAttached, "IsAttached #2");
+                       extObj.Extensions.Clear ();
+                       Assert.AreEqual (false, ext1.IsAttached, "IsAttached #3");
+                       Assert.AreEqual (false, ext2.IsAttached, "IsAttached #4");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/FaultCodeTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/FaultCodeTest.cs
new file mode 100644 (file)
index 0000000..24f1783
--- /dev/null
@@ -0,0 +1,85 @@
+using System;
+using System.ServiceModel;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class FaultCodeTest
+       {
+               FaultCode code;
+
+               [Test]
+               public void TestDefaults ()
+               {
+                       code = new FaultCode ("foo");
+                       Assert.AreEqual ("foo", code.Name);
+                       Assert.AreEqual (String.Empty, code.Namespace);
+                       Assert.AreEqual (null, code.SubCode);                   
+               }
+
+               [Test]
+               public void TestReceiverFaultCode ()
+               {
+                       code = FaultCode.CreateReceiverFaultCode ("foo", "bar");
+                       Assert.IsTrue (code.IsReceiverFault);   
+                       Assert.AreEqual ("Receiver", code.Name);
+                       Assert.AreEqual (String.Empty, code.Namespace);
+                       Assert.AreEqual ("foo", code.SubCode.Name);
+                       Assert.AreEqual ("bar", code.SubCode.Namespace);                                                                
+                       
+                       code = new FaultCode ("Receiver");                      
+                       Assert.IsTrue (code.IsReceiverFault);
+
+                       code = new FaultCode ("something else");                        
+                       Assert.IsFalse (code.IsReceiverFault);
+               }
+
+               [Test]
+               public void TestSenderFaultCode ()
+               {
+                       code = FaultCode.CreateSenderFaultCode ("foo", "bar");
+                       Assert.IsTrue (code.IsSenderFault);     
+                       Assert.AreEqual ("Sender", code.Name);
+                       Assert.AreEqual (String.Empty, code.Namespace);
+                       Assert.AreEqual ("foo", code.SubCode.Name);
+                       Assert.AreEqual ("bar", code.SubCode.Namespace);                                                                
+                       
+                       code = new FaultCode ("Sender");                        
+                       Assert.IsTrue (code.IsSenderFault);
+
+                       code = new FaultCode ("something else");                        
+                       Assert.IsFalse (code.IsReceiverFault);
+               }
+
+               [Test]
+               public void TestIsPredefinedCode ()
+               {
+                       code = new FaultCode ("foo");
+                       Assert.IsTrue (code.IsPredefinedFault);
+
+                       code = new FaultCode ("foo", String.Empty);
+                       Assert.IsTrue (code.IsPredefinedFault);
+
+                       code = new FaultCode ("foo", "bar");
+                       Assert.IsFalse (code.IsPredefinedFault);
+
+                       code = FaultCode.CreateReceiverFaultCode (new FaultCode ("foo", "bar"));
+                       Assert.IsTrue (code.IsPredefinedFault);
+                       Assert.IsFalse (code.SubCode.IsPredefinedFault);
+
+                       code = FaultCode.CreateReceiverFaultCode (new FaultCode ("foo"));
+                       Assert.IsTrue (code.IsPredefinedFault);
+                       Assert.IsTrue (code.SubCode.IsPredefinedFault);
+
+               }
+
+               [Test]
+               public void TestNamespace ()
+               {
+                       code = new FaultCode ("foo");
+                       Assert.AreEqual (String.Empty, code.Namespace);
+                       Assert.IsTrue (code.IsPredefinedFault);                 
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/FaultReasonTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/FaultReasonTest.cs
new file mode 100644 (file)
index 0000000..933ec71
--- /dev/null
@@ -0,0 +1,136 @@
+//
+// FaultReasonTest.cs
+//
+// Author:
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.ServiceModel;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class FaultReasonTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorNullFaultReasonText ()
+               {
+                       new FaultReason ((FaultReasonText) null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorNullEnumerable ()
+               {
+                       new FaultReason ((IEnumerable<FaultReasonText>) null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CtorEmptyEnumerable ()
+               {
+                       new FaultReason (new List<FaultReasonText> ());
+               }
+
+               [Test]
+               public void Simple ()
+               {
+                       FaultReason r = new FaultReason ("testing");
+                       FaultReasonText t = r.GetMatchingTranslation ();
+                       Assert.IsNotNull (t);
+                       Assert.AreEqual ("testing", t.Text, "#1");
+                       Assert.AreEqual (CultureInfo.CurrentCulture.Name,
+                               t.XmlLang, "#2");
+               }
+
+               [Test]
+               public void MultipleLanguages ()
+               {
+                       string current = CultureInfo.CurrentCulture.Name;
+
+                       FaultReason r = new FaultReason (new FaultReasonText [] {
+                               new FaultReasonText ("hello"),
+                               new FaultReasonText ("hola", "es-ES"),
+                               new FaultReasonText ("bonjour", "fr")});
+
+                       // CurrentCulture
+                       FaultReasonText t = r.GetMatchingTranslation (
+                               CultureInfo.CurrentCulture);
+                       Assert.IsNotNull (t);
+                       Assert.AreEqual ("hello", t.Text, "#1");
+                       Assert.AreEqual (current, t.XmlLang, "#2");
+
+                       // non-neutral name, get by non-neutral culture
+                       t = r.GetMatchingTranslation (
+                               new CultureInfo ("es-ES"));
+                       Assert.IsNotNull (t);
+                       Assert.AreEqual ("hola", t.Text, "#3");
+                       Assert.AreEqual ("es-ES", t.XmlLang, "#4");
+
+                       // .ctor(non-neutral name), get by neutral culture
+                       t = r.GetMatchingTranslation (new CultureInfo ("es"));
+                       Assert.IsNotNull (t);
+                       Assert.AreEqual ("hello", t.Text, "#5");
+                       Assert.AreEqual (current, t.XmlLang, "#6");
+
+                       // .ctor(neutral name), get by non-neutral culture
+                       t = r.GetMatchingTranslation (
+                               new CultureInfo ("fr-FR"));
+                       Assert.IsNotNull (t);
+                       Assert.AreEqual ("bonjour", t.Text, "#7");
+                       Assert.AreEqual ("fr", t.XmlLang, "#8");
+               }
+
+               [Test]
+               public void NoCurrentCulture ()
+               {
+                       string current = CultureInfo.CurrentCulture.Name;
+
+                       FaultReason r = new FaultReason (new FaultReasonText [] {
+                               new FaultReasonText ("hola", "es-ES"),
+                               new FaultReasonText ("bonjour", "fr")});
+
+                       // CurrentCulture
+                       FaultReasonText t = r.GetMatchingTranslation (
+                               CultureInfo.CurrentCulture);
+                       Assert.IsNotNull (t);
+                       // seems like the first item is used.
+                       Assert.AreEqual ("hola", t.Text, "#1");
+                       Assert.AreEqual ("es-ES", t.XmlLang, "#2");
+
+                       // InvariantCulture
+                       t = r.GetMatchingTranslation (
+                               CultureInfo.InvariantCulture);
+                       Assert.IsNotNull (t);
+                       // seems like the first item is used.
+                       Assert.AreEqual ("hola", t.Text, "#3");
+                       Assert.AreEqual ("es-ES", t.XmlLang, "#4");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/IntegratedConnectionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/IntegratedConnectionTest.cs
new file mode 100644 (file)
index 0000000..7273340
--- /dev/null
@@ -0,0 +1,251 @@
+//
+// IntegratedConnectionTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Net;
+using System.Net.Security;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.Xml;
+using NUnit.Framework;
+
+
+namespace MonoTests.System.ServiceModel
+{
+       // FIXME: uncomment when NUnit tests on HTTP connection got as
+       // stable as non-nunit samples.
+       
+       [TestFixture]
+       public class IntegratedConnectionTest
+       {
+               [Test]
+               [Ignore ("With Orcas it does not work fine")]
+               // It is almost identical to samples/basic-http-binding
+               public void SimpleHttpConnection ()
+               {
+                       // Service
+                       ServiceHost host = new ServiceHost (typeof (Foo));
+                       try {
+                               Binding binding = new BasicHttpBinding ();
+                               binding.SendTimeout = binding.ReceiveTimeout = TimeSpan.FromSeconds (5);
+                               ServiceEndpoint se = host.AddServiceEndpoint ("MonoTests.System.ServiceModel.IFoo",
+                                       binding, new Uri ("http://localhost:37564"));
+                               host.Open ();
+
+                               // Client
+                               ChannelFactory<IFoo> cf = new ChannelFactory<IFoo> (
+                                       new BasicHttpBinding (),
+                                       new EndpointAddress ("http://localhost:37564/"));
+                               IFoo foo  = cf.CreateChannel ();
+                               Assert.AreEqual ("Test for EchoTest for Echo", foo.Echo ("Test for Echo"));
+                       } finally {
+                               if (host.State == CommunicationState.Opened)
+                                       host.Close ();
+                       }
+               }
+
+               [Test]
+               [Ignore ("With Orcas it does not work fine")]
+               public void SimpleClientBase ()
+               {
+                       // Service
+                       ServiceHost host = new ServiceHost (typeof (Foo2));
+                       try {
+                               Binding binding = new BasicHttpBinding ();
+                               binding.SendTimeout = binding.ReceiveTimeout = TimeSpan.FromSeconds (5);
+                               host.AddServiceEndpoint ("MonoTests.System.ServiceModel.IFoo2",
+                               binding, new Uri ("http://localhost:37564"));
+                               host.Open ();
+
+                               // Client
+                               Foo2Proxy proxy = new Foo2Proxy (
+                                       new BasicHttpBinding (),
+                                       new EndpointAddress ("http://localhost:37564/"));
+                               proxy.Open ();
+                               try {
+                                       Assert.AreEqual ("TEST FOR ECHOTEST FOR ECHO",
+                                               proxy.Echo ("TEST FOR ECHO"));
+                               } finally {
+                                       proxy.Close ();
+                               }
+                       } finally {
+                               // Service
+                               if (host.State == CommunicationState.Opened)
+                                       host.Close ();
+                       }
+               }
+
+               [Test]
+               [Ignore ("With Orcas it does not work fine")]
+               public void ExchangeMetadata ()
+               {
+                       // Service
+                       ServiceHost host = new ServiceHost (typeof (MetadataExchange));
+                       try {
+                               Binding binding = new BasicHttpBinding ();
+                               binding.ReceiveTimeout = TimeSpan.FromSeconds (5);
+                               host.AddServiceEndpoint ("IMetadataExchange",
+                               binding, new Uri ("http://localhost:37564"));
+                               host.Open ();
+                               // Client
+
+                               MetadataExchangeProxy proxy = new MetadataExchangeProxy (
+                                       new BasicHttpBinding (),
+                                       new EndpointAddress ("http://localhost:37564/"));
+                               proxy.Open ();
+
+                               try {
+                                       Message req = Message.CreateMessage (MessageVersion.Soap11, "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get");
+                                       Message res = proxy.Get (req);
+                               } finally {
+                                       proxy.Close ();
+                               }
+                       } finally {
+                               // Service
+                               if (host.State == CommunicationState.Opened)
+                                       host.Close ();
+                       }
+               }
+       }
+
+       #region SimpleConnection classes
+
+       [ServiceContract]
+       public interface IFoo
+       {
+               [OperationContract]
+               string Echo (string msg);
+       }
+
+       class Foo : IFoo
+       {
+               public string Echo (string msg)
+               {
+                       return msg + msg;
+               }
+       }
+
+       // This is manually created type for strongly typed request.
+       [DataContract (Name = "Echo", Namespace = "http://tempuri.org/")]
+       public class EchoType
+       {
+               public EchoType (string msg)
+               {
+                       this.msg = msg;
+               }
+
+               [DataMember]
+               public string msg = "test";
+       }
+
+       #endregion
+
+       #region SampleClientBase classes
+
+       [ServiceContract]
+       public interface IFoo2
+       {
+               [OperationContract]
+               string Echo (string msg);
+       }
+
+       class Foo2 : IFoo2
+       {
+               public string Echo (string msg)
+               {
+                       return msg + msg;
+               }
+       }
+
+       public class Foo2Proxy : ClientBase<IFoo2>, IFoo2
+       {
+               public Foo2Proxy (Binding binding, EndpointAddress address)
+                       : base (binding, address)
+               {
+               }
+
+               public string Echo (string msg)
+               {
+                       return Channel.Echo (msg);
+               }
+       }
+
+       #endregion
+
+       #region ExchangeMetadata classes
+
+       class MetadataExchange : IMetadataExchange
+       {
+               public Message Get (Message request)
+               {
+                       XmlDocument doc = new XmlDocument ();
+                       doc.AppendChild (doc.CreateElement ("Metadata", "http://schemas.xmlsoap.org/ws/2004/09/mex"));
+                       return Message.CreateMessage (request.Version,
+                               "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse",
+                               new XmlNodeReader (doc));
+               }
+
+               public IAsyncResult BeginGet (Message request, AsyncCallback cb, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public Message EndGet (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
+       public class MetadataExchangeProxy : ClientBase<IMetadataExchange>, IMetadataExchange
+       {
+               public MetadataExchangeProxy (Binding binding, EndpointAddress address)
+                       : base (binding, address)
+               {
+               }
+
+               public Message Get (Message request)
+               {
+                       return Channel.Get (request);
+               }
+
+               public IAsyncResult BeginGet (Message request, AsyncCallback callback, object state)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public Message EndGet (IAsyncResult result)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
+       #endregion
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/MessageSecurityVersionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/MessageSecurityVersionTest.cs
new file mode 100644 (file)
index 0000000..35c241a
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// MessageSecurityVersionTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class MessageSecurityVersionTest
+       {
+               [Test]
+               public void Default ()
+               {
+                       Assert.AreEqual (
+                               MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11,
+                               MessageSecurityVersion.Default,
+                               "dude, stop using crappy lengthy name");
+               }
+
+               [Test]
+               public void SecurityTokenVersion ()
+               {
+                       ReadOnlyCollection<string> specs = 
+                               MessageSecurityVersion.Default.SecurityTokenVersion.GetSecuritySpecifications ();
+                       Assert.AreEqual (3, specs.Count, "#1");
+                       // Not sure why MS limits the results to them. This 
+                       // result rather means that it is not worthy of
+                       // testing strictly.
+                       string [] expected = new string [] {
+                               "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd",
+                               "http://schemas.xmlsoap.org/ws/2005/02/trust",
+                               "http://schemas.xmlsoap.org/ws/2005/02/sc"
+                               };
+                       foreach (string spec in specs)
+                               if (!Array.Exists<string> (expected, delegate (string s) { return s == spec; }))
+                                       Assert.Fail (String.Format ("Unexpected spec '{0}'", spec), "#2");
+
+                       specs = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10.SecurityTokenVersion.GetSecuritySpecifications ();
+                       Assert.AreEqual (4, specs.Count, "#3");
+                       // Not sure why MS limits the results to them. This 
+                       // result rather means that it is not worthy of testing.
+                       expected = new string [] {
+                               "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd",
+                               "http://schemas.xmlsoap.org/ws/2005/02/trust",
+                               "http://schemas.xmlsoap.org/ws/2005/02/sc",
+                               "http://ws-i.org/profiles/basic-security/core/1.0",
+                               };
+                       foreach (string spec in specs)
+                               if (!Array.Exists<string> (expected, delegate (string s) { return s == spec; }))
+                                       Assert.Fail (String.Format ("Unexpected spec '{0}'", spec), "#4");
+
+                       specs = MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10.SecurityTokenVersion.GetSecuritySpecifications ();
+                       Assert.AreEqual (4, specs.Count, "#5");
+                       // Not sure why MS limits the results to them. This 
+                       // result rather means that it is not worthy of testing.
+                       expected = new string [] {
+                               "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
+                               "http://schemas.xmlsoap.org/ws/2005/02/trust",
+                               "http://schemas.xmlsoap.org/ws/2005/02/sc",
+                               "http://ws-i.org/profiles/basic-security/core/1.0",
+                               };
+                       foreach (string spec in specs)
+                               if (!Array.Exists<string> (expected, delegate (string s) { return s == spec; }))
+                                       Assert.Fail (String.Format ("Unexpected spec '{0}'", spec), "#6");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/NetMsmqBindingTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/NetMsmqBindingTest.cs
new file mode 100644 (file)
index 0000000..7a6d258
--- /dev/null
@@ -0,0 +1,110 @@
+//
+// NetMsmqBindingTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2007 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class NetMsmqBindingTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       NetMsmqBinding b = new NetMsmqBinding ();
+                       Assert.AreEqual (EnvelopeVersion.Soap12, b.EnvelopeVersion, "#1");
+                       Assert.AreEqual (0x80000, b.MaxBufferPoolSize, "#2");
+                       Assert.AreEqual (QueueTransferProtocol.Native, b.QueueTransferProtocol, "#2");
+                       Assert.IsNotNull (b.ReaderQuotas, "#3");
+                       Assert.IsFalse (b.UseActiveDirectory, "#4");
+
+                       Assert.IsNull (b.CustomDeadLetterQueue, "#5");
+                       Assert.AreEqual (DeadLetterQueue.System, b.DeadLetterQueue, "#6");
+                       Assert.IsTrue (b.Durable, "#7");
+                       Assert.IsTrue (b.ExactlyOnce, "#8");
+                       Assert.AreEqual (0x10000, b.MaxReceivedMessageSize, "#9");
+                       Assert.AreEqual (2, b.MaxRetryCycles, "#10");
+                       Assert.AreEqual (ReceiveErrorHandling.Fault, b.ReceiveErrorHandling, "#11");
+                       Assert.AreEqual (5, b.ReceiveRetryCount, "#12");
+                       // hmm, it is documented as 10 minutes but ...
+                       Assert.AreEqual (TimeSpan.FromMinutes (30), b.RetryCycleDelay, "#13");
+                       Assert.AreEqual ("net.msmq", b.Scheme, "#14");
+                       Assert.AreEqual (TimeSpan.FromDays (1), b.TimeToLive, "#15");
+                       Assert.IsFalse (b.UseMsmqTracing, "#16");
+                       Assert.IsFalse (b.UseSourceJournal, "#17");
+               }
+
+/*
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void DefaultValueSecurityModeMessageError ()
+               {
+                       NetMsmqBinding b = new NetMsmqBinding (BasicHttpSecurityMode.Message);
+                       // "BasicHttp binding requires that NetMsmqBinding.Security.Message.ClientCredentialType be equivalent to the BasicHttpMessageCredentialType.Certificate credential type for secure messages. Select Transport or TransportWithMessageCredential security for UserName credentials."
+                       b.CreateBindingElements ();
+               }
+*/
+
+               [Test]
+               public void CreateBindingElements ()
+               {
+                       BindingElementCollection bl = new NetMsmqBinding ().CreateBindingElements ();
+                       Assert.AreEqual (2, bl.Count, "#1");
+                       Assert.IsTrue (bl [0] is BinaryMessageEncodingBindingElement, "#2");
+                       Assert.IsTrue (bl [1] is MsmqTransportBindingElement, "#3");
+               }
+
+/*
+               [Test]
+               public void MessageEncoding ()
+               {
+                       NetMsmqBinding b = new NetMsmqBinding ();
+                       foreach (BindingElement be in b.CreateBindingElements ()) {
+                               MessageEncodingBindingElement mbe =
+                                       be as MessageEncodingBindingElement;
+                               if (mbe != null) {
+                                       MessageEncoderFactory f = mbe.CreateMessageEncoderFactory ();
+                                       MessageEncoder e = f.Encoder;
+
+                                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement), mbe.GetType (), "#1-1");
+                                       Assert.AreEqual (MessageVersion.Soap11, f.MessageVersion, "#2-1");
+                                       Assert.AreEqual ("text/xml; charset=utf-8", e.ContentType, "#3-1");
+                                       Assert.AreEqual ("text/xml", e.MediaType, "#3-2");
+                                       return;
+                               }
+                       }
+                       Assert.Fail ("No message encodiing binding element.");
+               }
+*/
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceAssert.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceAssert.cs
new file mode 100644 (file)
index 0000000..5b17d5d
--- /dev/null
@@ -0,0 +1,115 @@
+//
+// ServiceAssert.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       public static class ServiceAssert
+       {
+               public static void AssertOperationDescription (
+                       string name, MethodInfo begin,
+                       MethodInfo end, MethodInfo sync,
+                       bool isInitiating, bool isOneWay, bool isTerminating,
+                       OperationDescription od, string label)
+               {
+                       Assert.AreEqual (name, od.Name, label + " Name");
+                       Assert.AreEqual (begin, od.BeginMethod, label + " BeginMethod");
+                       Assert.AreEqual (end, od.EndMethod, label + " EndMethod");
+                       Assert.AreEqual (sync, od.SyncMethod, label + " SyncMethod");
+                       Assert.AreEqual (isInitiating, od.IsInitiating, label + " IsInitiating");
+                       Assert.AreEqual (isOneWay, od.IsOneWay, label + " IsOneWay");
+                       Assert.AreEqual (isTerminating, od.IsTerminating, label + " IsTerminating");
+               }
+
+               public static void AssertContractDescription (
+                       string name, string ns,
+                       SessionMode session, Type contractType,
+                       Type callbackContractType,
+                       ContractDescription cd, string label)
+               {
+                       Assert.AreEqual (name, cd.Name, label + " Name");
+                       Assert.AreEqual (ns, cd.Namespace, label + " Namespace");
+                       Assert.AreEqual (session, cd.SessionMode, label + " Session");
+                       Assert.AreEqual (contractType, cd.ContractType,
+                               label + " ContractType");
+                       Assert.AreEqual (callbackContractType, cd.CallbackContractType,
+                               label + " CallbackContractType");
+               }
+
+               public static void AssertMessageAndBodyDescription (
+                       string action, MessageDirection dir,
+                       Type messageType, string bodyWrapperName,
+                       string bodyWrapperNS, bool bodyHasReturn,
+                       MessageDescription md, string label)
+               {
+                       Assert.AreEqual (action, md.Action, label + " Action");
+                       Assert.AreEqual (dir, md.Direction, label + " Direction");
+                       Assert.AreEqual (messageType, md.MessageType, label + " MessageType");
+                       Assert.AreEqual (bodyWrapperName, md.Body.WrapperName,
+                               label + " Body.WrapperName");
+                       Assert.AreEqual (bodyWrapperNS, md.Body.WrapperNamespace,
+                               label + " Body.WrapperNamespace");
+                       Assert.AreEqual (bodyHasReturn, md.Body.ReturnValue != null,
+                               label + "Body hasReturn");
+               }
+
+               public static void AssertMessagePartDescription (
+                       string name, string ns, int index, bool multiple,
+                       ProtectionLevel? protectionLevel, Type type,
+                       MessagePartDescription mp, string label)
+               {
+                       Assert.AreEqual (name, mp.Name, label + " Name");
+                       Assert.AreEqual (ns, mp.Namespace, label + " Namespace");
+                       Assert.AreEqual (index, mp.Index, label + " Index");
+                       Assert.AreEqual (multiple, mp.Multiple,
+                               label + " Multiple");
+                       Assert.AreEqual (protectionLevel, mp.ProtectionLevel,
+                               label + " ProtectionLevel");
+                       Assert.AreEqual (type, mp.Type, label + " Type");
+               }
+
+               public static void AssertMessageEncoder (
+                       string contentType, string mediaType, MessageVersion version,
+                       MessageEncoder encoder, string label)
+               {
+                       // Those curly double quotations are smelly, so just remove them out.
+                       Assert.AreEqual (contentType.Replace ("\"", ""),
+                               encoder.ContentType.Replace ("\"", ""),
+                               label + " ContentType");
+                       Assert.AreEqual (mediaType, encoder.MediaType, label + " MediaType");
+                       Assert.AreEqual (version, encoder.MessageVersion, label + " MessageVersion");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceEndpointCollectionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceEndpointCollectionTest.cs
new file mode 100644 (file)
index 0000000..9c0dc8c
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// ServiceEndpointCollectionTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ServiceEndpointCollectionTest
+       {
+               // add tests.
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceEndpointTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceEndpointTest.cs
new file mode 100644 (file)
index 0000000..988d06c
--- /dev/null
@@ -0,0 +1,89 @@
+//
+// ServiceEndpointTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net.Security;
+using System.Reflection;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ServiceEndpointTest
+       {
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorNullContract ()
+               {
+                       new ServiceEndpoint (null, new BasicHttpBinding (),
+                               new EndpointAddress ("http://localhost"));
+               }
+
+               [Test]
+               // null Binding is allowed, dunno how it should be handled tho
+               public void CtorNullBinding ()
+               {
+                       ServiceEndpoint ep = new ServiceEndpoint (
+                               ContractDescription.GetContract (typeof (Foo)),
+                               null,
+                               new EndpointAddress ("http://localhost"));
+                       Assert.IsNull (ep.Binding, "#1");
+               }
+
+               [Test]
+               // null endpoint is allowed.
+               public void CtorNullEndpoint ()
+               {
+                       new ServiceEndpoint (
+                               ContractDescription.GetContract (typeof (Foo)),
+                               new BasicHttpBinding (),
+                               null);
+               }
+
+               [Test]
+               public void DefaultValues ()
+               {
+                       ServiceEndpoint ep = new ServiceEndpoint (
+                               ContractDescription.GetContract (typeof (Foo)),
+                               new BasicHttpBinding (),
+                               new EndpointAddress ("http://localhost"));
+                       Assert.IsNotNull (ep.Behaviors, "#1");
+                       Assert.AreEqual (0, ep.Behaviors.Count, "#2");
+               }
+
+
+               [ServiceContract]
+               class Foo
+               {
+                       [OperationContract]
+                       public void SayWhat () { }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceHostBaseTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceHostBaseTest.cs
new file mode 100644 (file)
index 0000000..922e474
--- /dev/null
@@ -0,0 +1,543 @@
+//
+// ServiceHostBaseTest.cs
+//
+// Author:
+//     Igor Zelmanovich <igorz@mainsoft.com>
+//
+// Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using System.ServiceModel;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using SMMessage = System.ServiceModel.Channels.Message;
+using System.ServiceModel.Channels;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ServiceHostBaseTest
+       {
+               class Poker : ServiceHostBase
+               {
+                       public event EventHandler OnApplyConfiguration;
+
+                       protected override ServiceDescription CreateDescription (out IDictionary<string, ContractDescription> implementedContracts) {
+                               implementedContracts = new Dictionary<string, ContractDescription> ();
+                               ServiceDescription description = new ServiceDescription ();
+                               description.ServiceType = typeof (MyService);
+                               description.Behaviors.Add (new ServiceBehaviorAttribute ());
+                               return description;
+                       }
+
+                       protected override void ApplyConfiguration () {
+                               if (OnApplyConfiguration != null)
+                                       OnApplyConfiguration (this, EventArgs.Empty);
+                               base.ApplyConfiguration ();
+                       }
+
+                       public void CallInitializeDescription () {
+                               InitializeDescription (new UriSchemeKeyedCollection ());
+                       }
+
+                       protected override void InitializeRuntime () {
+                               base.InitializeRuntime ();
+                       }
+
+                       public void CallInitializeRuntime () {
+                               InitializeRuntime ();
+                       }
+               }
+
+               [Test]
+               public void Ctor () {
+                       Poker host = new Poker ();
+
+                       Assert.AreEqual (null, host.Description, "Description");
+                       Assert.AreEqual (null, host.Authorization, "Authorization");
+               }
+
+               [Test]
+               public void DefaultConfiguration () {
+                       Poker host = new Poker ();
+                       host.OnApplyConfiguration += delegate (object sender, EventArgs e) {
+                               Assert.AreEqual (1, host.Description.Behaviors.Count, "Description.Behaviors.Count #1");
+                       };
+                       host.CallInitializeDescription ();
+
+                       Assert.AreEqual (true, host.Description.Behaviors.Count > 1, "Description.Behaviors.Count #2");
+
+                       Assert.IsNotNull (host.Description.Behaviors.Find<ServiceDebugBehavior> (), "ServiceDebugBehavior");
+                       Assert.IsNotNull (host.Description.Behaviors.Find<ServiceAuthorizationBehavior> (), "ServiceDebugBehavior");
+                       Assert.IsNotNull (host.Authorization, "Authorization #1");
+
+                       Assert.AreEqual (host.Description.Behaviors.Find<ServiceAuthorizationBehavior> (), host.Authorization, "Authorization #2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void ApplyConfigurationNoDescription () {
+                       CustomServiceHost customHost = new CustomServiceHost ();
+                       customHost.ApplyConfiguration ();
+               }
+
+               class CustomServiceHost : ServiceHostBase
+               {
+
+                       public CustomServiceHost () {
+
+                       }
+
+                       public new void ApplyConfiguration () {
+                               base.ApplyConfiguration ();
+                       }
+
+                       protected override ServiceDescription CreateDescription (out IDictionary<string, ContractDescription> implementedContracts) {
+                               throw new NotImplementedException ();
+                       }
+               }
+
+               [Test]
+               public void InitializeRuntime () {
+                       Poker host = new Poker ();
+                       host.CallInitializeDescription ();
+                       EndpointAddress address = new EndpointAddress ("http://localhost:8090/");
+                       ContractDescription contract = ContractDescription.GetContract (typeof (IMyContract));
+                       ServiceEndpoint endpoint = new ServiceEndpoint (contract, new BasicHttpBinding (), address);
+                       endpoint.ListenUri = address.Uri;
+                       host.Description.Endpoints.Add (endpoint);
+
+                       Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");
+
+                       host.CallInitializeRuntime ();
+
+                       Assert.AreEqual (1, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");
+                       Assert.AreEqual (CommunicationState.Created, host.ChannelDispatchers [0].State, "ChannelDispatchers.Count #1");
+               }
+
+               [ServiceContract]
+               interface IMyContract
+               {
+                       [OperationContract]
+                       string GetData ();
+               }
+
+               class MyService : IMyContract
+               {
+                       public string GetData () {
+                               return "Hello World";
+                       }
+               }
+
+               [Test]
+               public void ChannelDispatchers_NoDebug () {
+                       ServiceHost h = new ServiceHost (typeof (AllActions), new Uri ("http://localhost:8080"));
+                       h.AddServiceEndpoint (typeof (AllActions).FullName, new BasicHttpBinding (), "address");
+
+                       ServiceDebugBehavior b = h.Description.Behaviors.Find<ServiceDebugBehavior> ();
+                       b.HttpHelpPageEnabled = false;                                          
+
+                       h.Open ();
+                       Assert.AreEqual (h.ChannelDispatchers.Count, 1);
+                       ChannelDispatcher channelDispatcher =  h.ChannelDispatchers[0] as ChannelDispatcher;
+                       Assert.IsNotNull (channelDispatcher, "#1");
+                       Assert.IsTrue (channelDispatcher.Endpoints.Count == 1, "#2");
+                       EndpointAddressMessageFilter filter = channelDispatcher.Endpoints [0].AddressFilter as EndpointAddressMessageFilter;
+                       Assert.IsNotNull (filter, "#3");
+                       Assert.IsTrue (filter.Address.Equals (new EndpointAddress ("http://localhost:8080/address")), "#4");
+                       Assert.IsFalse (filter.IncludeHostNameInComparison, "#5");
+                       Assert.IsTrue (channelDispatcher.Endpoints [0].ContractFilter is MatchAllMessageFilter, "#6");
+                       h.Close ();
+               }
+
+               [Test]
+               public void ChannelDispatchers_WithDebug () {
+                       ServiceHost h = new ServiceHost (typeof (AllActions), new Uri ("http://localhost:8080"));
+                       h.AddServiceEndpoint (typeof (AllActions).FullName, new BasicHttpBinding (), "address");
+                       ServiceMetadataBehavior b = new ServiceMetadataBehavior ();
+                       b.HttpGetEnabled = true;
+                       b.HttpGetUrl = new Uri( "http://localhost:8080" );
+                       h.Description.Behaviors.Add (b);
+                       h.Open ();
+
+                       Assert.AreEqual (h.ChannelDispatchers.Count, 2, "#1");
+                       ChannelDispatcher channelDispatcher = h.ChannelDispatchers[1] as ChannelDispatcher;
+                       Assert.IsNotNull (channelDispatcher, "#2");
+                       Assert.IsTrue (channelDispatcher.Endpoints.Count == 1, "#3");
+                       EndpointAddressMessageFilter filter = channelDispatcher.Endpoints [0].AddressFilter as EndpointAddressMessageFilter;
+                       Assert.IsNotNull (filter, "#4");
+                       Assert.IsTrue (filter.Address.Equals (new EndpointAddress ("http://localhost:8080")), "#5");
+                       Assert.IsFalse (filter.IncludeHostNameInComparison, "#6");
+                       Assert.IsTrue (channelDispatcher.Endpoints [0].ContractFilter is MatchAllMessageFilter, "#7");
+                       h.Close ();
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void SpecificActionTest () {
+                       //EndpointDispatcher d = new EndpointDispatcher(
+                       ServiceHost h = new ServiceHost (typeof (SpecificAction), new Uri ("http://localhost:8080"));
+                       h.AddServiceEndpoint (typeof (Action1Interface), new BasicHttpBinding (), "address");
+                                               
+                       h.Open ();
+                       ChannelDispatcher d = h.ChannelDispatchers [0] as ChannelDispatcher;
+                       EndpointDispatcher ed = d.Endpoints [0] as EndpointDispatcher;
+                       ActionMessageFilter actionFilter = ed.ContractFilter as ActionMessageFilter;
+                       Assert.IsNotNull (actionFilter, "#1");
+                       Assert.IsTrue (actionFilter.Actions.Count == 1, "#2");
+                       h.Close();
+               }
+
+               [Test]
+               public void InitializeRuntimeBehaviors1 () {
+                       HostState st = new HostState ();
+                       ServiceHost h = new ServiceHost (typeof (SpecificAction2), new Uri ("http://localhost:8080"));
+                       h.AddServiceEndpoint (typeof (SpecificAction2), new BasicHttpBinding (), "temp");                       
+
+                       h.Description.Behaviors.Add (new MyServiceBehavior (st, h));
+
+                       h.Description.Endpoints [0].Behaviors.Add (new MyEndpointBehavior (st, h));
+                       h.Description.Endpoints [0].Contract.Behaviors.Add (new MyContractBehavior (st, h));
+                       h.Description.Endpoints [0].Contract.Operations [0].Behaviors.Add (new MyOperationBehavior (st, h));
+                       
+                       h.Open ();
+                       h.Close ();
+                       
+                       string expected = "Start, IServiceBehavior.Validate, IContractBehavior.Validate, IEndpointBehavior.Validate, IOperationBehavior.ApplyDispatchBehavior, IServiceBehavior.AddBindingParameters, IContractBehavior.AddBindingParameters, IEndpointBehavior.AddBindingParameters, IOperationBehavior.AddBindingParameters, IServiceBehavior.ApplyDispatchBehavior, IContractBehavior.ApplyDispatchBehavior, IEndpointBehavior.ApplyDispatchBehavior, IOperationBehavior.ApplyDispatchBehavior";
+                       Assert.AreEqual (expected, st.CurrentStage);
+               }
+
+               [Test]
+               [Category("NotWorking")]
+               public void InitializeRuntimeBehaviors2 () {
+                       HostState st = new HostState ();
+                       ServiceHost h = new ServiceHost (typeof (SpecificAction), new Uri ("http://localhost:8080"));
+                       h.AddServiceEndpoint (typeof (Action1Interface), new BasicHttpBinding (), "temp");
+                       h.AddServiceEndpoint (typeof (Action2Interface), new BasicHttpBinding (), "temp2");
+
+                       h.Description.Behaviors.Add (new MyServiceBehavior (st, h));                    
+                       
+                       h.Description.Endpoints [0].Behaviors.Add (new MyEndpointBehavior (st, h));
+                       h.Description.Endpoints [0].Contract.Behaviors.Add (new MyContractBehavior (st, h));
+                       h.Description.Endpoints [0].Contract.Operations [0].Behaviors.Add (new MyOperationBehavior (st, h));
+
+                       h.Description.Endpoints [1].Behaviors.Add (new MyEndpointBehavior (st, h));
+                       h.Description.Endpoints [1].Contract.Behaviors.Add (new MyContractBehavior (st, h));
+                       h.Description.Endpoints [1].Contract.Operations [0].Behaviors.Add (new MyOperationBehavior (st, h));
+                       h.Open ();
+                       h.Close ();
+
+                       string expected = "Start, IServiceBehavior.Validate, IContractBehavior.Validate, IEndpointBehavior.Validate, IOperationBehavior.ApplyDispatchBehavior, IContractBehavior.Validate, IEndpointBehavior.Validate, IOperationBehavior.ApplyDispatchBehavior, IServiceBehavior.AddBindingParameters, IContractBehavior.AddBindingParameters, IEndpointBehavior.AddBindingParameters, IOperationBehavior.AddBindingParameters, IServiceBehavior.AddBindingParameters, IContractBehavior.AddBindingParameters, IEndpointBehavior.AddBindingParameters, IOperationBehavior.AddBindingParameters, IServiceBehavior.ApplyDispatchBehavior, IContractBehavior.ApplyDispatchBehavior, IEndpointBehavior.ApplyDispatchBehavior, IOperationBehavior.ApplyDispatchBehavior, IContractBehavior.ApplyDispatchBehavior, IEndpointBehavior.ApplyDispatchBehavior, IOperationBehavior.ApplyDispatchBehavior";
+                       Assert.AreEqual (expected, st.CurrentStage);
+               }
+
+               #region helpers
+
+               public enum Stage
+               {
+               }
+
+               public class HostState
+               {
+                       public string CurrentStage = "Start";
+               }
+
+               public class MyServiceBehavior : IServiceBehavior
+               {
+                       #region IServiceBehavior Members
+
+                       HostState _state;
+                       ServiceHost _host;
+                       public MyServiceBehavior (HostState state, ServiceHost h) {
+                               _state = state;
+                               _host = h;
+                       }
+
+                       public void AddBindingParameters (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, global::System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) {                         
+                               _state.CurrentStage += ", IServiceBehavior.AddBindingParameters";                               
+                               bindingParameters.Add (this);
+                       }
+
+                       public void ApplyDispatchBehavior (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) {                            
+                               _state.CurrentStage += ", IServiceBehavior.ApplyDispatchBehavior";                              
+                       }
+
+                       public void Validate (ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) {
+                               _state.CurrentStage += ", IServiceBehavior.Validate";
+                               Assert.AreEqual (_host.ChannelDispatchers.Count, 0);
+                       }
+
+                       #endregion
+               }
+
+               public class MyEndpointBehavior : IEndpointBehavior
+               {
+                       #region IEndpointBehavior Members
+                       HostState _state;
+                       ServiceHost _host;
+                       public MyEndpointBehavior (HostState state, ServiceHost h) {
+                               _state = state;
+                               _host = h;
+                       }
+
+                       public void AddBindingParameters (ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) {
+                               Console.WriteLine ("IEndpointBehavior - AddBindingParameters " + _host.ChannelDispatchers.Count);
+                               _state.CurrentStage += ", IEndpointBehavior.AddBindingParameters";                              
+                               bindingParameters.Add (this);
+                       }
+
+                       public void ApplyClientBehavior (ServiceEndpoint endpoint, ClientRuntime clientRuntime) {
+                               Console.WriteLine ("IEndpointBehavior - ApplyClientBehavior " + _host.ChannelDispatchers.Count);
+                       }
+
+                       public void ApplyDispatchBehavior (ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) {
+                               Console.WriteLine ("IEndpointBehavior - ApplyDispatchBehavior " + _host.ChannelDispatchers.Count);
+                               _state.CurrentStage += ", IEndpointBehavior.ApplyDispatchBehavior";                             
+                       }
+
+                       public void Validate (ServiceEndpoint endpoint) {
+                               Console.WriteLine ("IEndpointBehavior - Validate " + _host.ChannelDispatchers.Count);
+                               _state.CurrentStage += ", IEndpointBehavior.Validate";
+                               Assert.AreEqual (_host.ChannelDispatchers.Count, 0);                            
+                       }
+
+                       #endregion
+               }
+
+               public class MyContractBehavior : IContractBehavior
+               {
+                       #region IContractBehavior Members
+                       HostState _state;
+                       ServiceHost _host;
+                       public MyContractBehavior (HostState state, ServiceHost h) {
+                               _state = state;
+                               _host = h;
+                       }
+
+                       public void AddBindingParameters (ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) {
+                               Console.WriteLine ("Contract - AddBindingParameters " + _host.ChannelDispatchers.Count);
+                               _state.CurrentStage += ", IContractBehavior.AddBindingParameters";                              
+                               bindingParameters.Add (this);
+                       }
+
+                       public void ApplyClientBehavior (ContractDescription contractDescription, ServiceEndpoint endpoint, ClientRuntime clientRuntime) {
+                               Console.WriteLine ("Contract - ApplyClientBehavior " + _host.ChannelDispatchers.Count);
+                       }
+
+                       public void ApplyDispatchBehavior (ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime) {
+                               Console.WriteLine ("Contract - ApplyDispatchBehavior " + _host.ChannelDispatchers.Count);
+                               _state.CurrentStage += ", IContractBehavior.ApplyDispatchBehavior";                             
+                       }
+
+                       public void Validate (ContractDescription contractDescription, ServiceEndpoint endpoint) {
+                               Console.WriteLine ("Contract - Validate " + _host.ChannelDispatchers.Count);
+                               _state.CurrentStage += ", IContractBehavior.Validate";          
+                               Assert.AreEqual (_host.ChannelDispatchers.Count, 0);                            
+                       }
+
+                       #endregion
+               }
+
+               public class MyOperationBehavior : IOperationBehavior
+               {
+                       #region IOperationBehavior Members
+                       HostState _state;
+                       ServiceHost _host;
+                       public MyOperationBehavior (HostState state, ServiceHost h) {
+                               _state = state;
+                               _host = h;
+                       }
+
+                       public void AddBindingParameters (OperationDescription operationDescription, BindingParameterCollection bindingParameters) {
+                               Console.WriteLine ("IOperationBehavior - AddBindingParameters " + _host.ChannelDispatchers.Count);
+                               _state.CurrentStage += ", IOperationBehavior.AddBindingParameters";                                     
+                               bindingParameters.Add (this);
+                       }
+
+                       public void ApplyClientBehavior (OperationDescription operationDescription, ClientOperation clientOperation) {
+                               Console.WriteLine ("IOperationBehavior - ApplyClientBehavior " + _host.ChannelDispatchers.Count);
+                       }
+
+                       public void ApplyDispatchBehavior (OperationDescription operationDescription, DispatchOperation dispatchOperation) {
+                               Console.WriteLine ("IOperationBehavior - ApplyDispatchBehavior " + _host.ChannelDispatchers.Count);
+                               _state.CurrentStage += ", IOperationBehavior.ApplyDispatchBehavior";                            
+                       }
+
+                       public void Validate (OperationDescription operationDescription) {
+                               Console.WriteLine ("IOperationBehavior - Validate " + _host.ChannelDispatchers.Count);
+                               _state.CurrentStage += ", IOperationBehavior.ApplyDispatchBehavior";
+                               Assert.AreEqual (_host.ChannelDispatchers.Count, 0);
+                       }
+
+                       #endregion
+               }
+
+               [ServiceContract]
+               class AllActions
+               {
+                       [OperationContract (Action = "*", ReplyAction = "*")]
+                       public SMMessage Get (SMMessage req) {
+                               return null;
+                       }
+               }
+
+               [ServiceContract]
+               interface Action1Interface
+               {
+                       [OperationContract (Action = "Specific1", ReplyAction = "*")]
+                       SMMessage GetMessage1 (SMMessage req);
+               }
+
+               [ServiceContract]
+               interface Action2Interface
+               {
+                       [OperationContract (Action = "Specific2", ReplyAction = "*")]
+                       SMMessage GetMessage2 (SMMessage req);
+               }
+               
+               class SpecificAction : Action1Interface, Action2Interface
+               {                       
+                       public SMMessage GetMessage1 (SMMessage req) {
+                               return null;
+                       }
+
+                       public SMMessage GetMessage2 (SMMessage req) {
+                               return null;
+                       }
+               }
+
+               [ServiceContract]
+               class SpecificAction2
+               {
+                       [OperationContract (Action = "Specific", ReplyAction = "*")]
+                       public SMMessage GetMessage1 (SMMessage req) {
+                               return null;
+                       }
+               }
+
+               class MyChannelDispatcher : ChannelDispatcher
+               {
+                       public bool Attached = false;
+
+                       public MyChannelDispatcher (IChannelListener l) : base (l) { }
+                       protected override void Attach (ServiceHostBase host) {
+                               base.Attach (host);
+                               Attached = true;
+                       }
+               }
+
+               class MyChannelListener : IChannelListener
+               {
+                       #region IChannelListener Members
+
+                       public IAsyncResult BeginWaitForChannel (TimeSpan timeout, AsyncCallback callback, object state) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public bool EndWaitForChannel (IAsyncResult result) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public T GetProperty<T> () where T : class {
+                               throw new NotImplementedException ();
+                       }
+
+                       public Uri Uri {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       public bool WaitForChannel (TimeSpan timeout) {
+                               throw new NotImplementedException ();
+                       }
+
+                       #endregion
+
+                       #region ICommunicationObject Members
+
+                       public void Abort () {
+                               throw new NotImplementedException ();
+                       }
+
+                       public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public IAsyncResult BeginClose (AsyncCallback callback, object state) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public IAsyncResult BeginOpen (AsyncCallback callback, object state) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public void Close (TimeSpan timeout) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public void Close () {
+                               throw new NotImplementedException ();
+                       }
+
+                       public event EventHandler Closed;
+
+                       public event EventHandler Closing;
+
+                       public void EndClose (IAsyncResult result) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public void EndOpen (IAsyncResult result) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public event EventHandler Faulted;
+
+                       public void Open (TimeSpan timeout) {
+                               throw new NotImplementedException ();
+                       }
+
+                       public void Open () {
+                               throw new NotImplementedException ();
+                       }
+
+                       public event EventHandler Opened;
+
+                       public event EventHandler Opening;
+
+                       public CommunicationState State {
+                               get { throw new NotImplementedException (); }
+                       }
+
+                       #endregion
+               }
+               #endregion
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceHostTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ServiceHostTest.cs
new file mode 100644 (file)
index 0000000..a469c82
--- /dev/null
@@ -0,0 +1,324 @@
+//
+// ServiceHostTest.cs
+//
+// Author:
+//     Ankit Jain  <jankit@novell.com>
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//
+// Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.Generic;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
+using System.ServiceModel.Dispatcher;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class ServiceHostTest
+       {
+               class MyHost : ServiceHost
+               {
+                       public MyHost (Type type, Uri uri)
+                               : base (type, uri)
+                       {
+                       }
+
+                       public IDictionary<string,ContractDescription> ExposedContracts {
+                               get { return ImplementedContracts; }
+                       }
+               }
+
+               [Test]
+               public void Ctor ()
+               {
+                       MyHost host = new MyHost (typeof (Foo), new Uri ("http://localhost"));
+                       Assert.IsNotNull (host.Description, "#1");
+                       Assert.AreEqual (typeof (Foo), host.Description.ServiceType, "#1-2");
+                       Assert.IsNotNull (host.BaseAddresses, "#2");
+                       Assert.AreEqual (1, host.BaseAddresses.Count, "#3");
+
+                       Assert.IsNotNull (host.ChannelDispatchers, "#4");
+                       Assert.AreEqual (0, host.ChannelDispatchers.Count, "#5");
+                       Assert.IsNotNull (host.Authorization, "#6");
+                       Assert.IsNotNull (host.ExposedContracts, "#7");
+                       // Foo is already in the contracts.
+                       Assert.AreEqual (1, host.ExposedContracts.Count, "#8");
+                       // this loop iterates only once.
+                       foreach (KeyValuePair<string,ContractDescription> e in host.ExposedContracts) {
+                               // hmm... so, seems like the key is just the full name of the contract type.
+                               Assert.AreEqual ("MonoTests.System.ServiceModel.ServiceHostTest+Foo", e.Key, "#9");
+                               ContractDescription cd = e.Value;
+                               Assert.AreEqual ("Foo", cd.Name, "#10");
+                               Assert.AreEqual ("http://tempuri.org/", cd.Namespace, "#11");
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorNull ()
+               {
+                       new ServiceHost (typeof (Foo), null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CtorServiceTypeNotClass ()
+               {
+                       new ServiceHost (typeof (IBar), new Uri ("http://localhost"));
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CtorRelativeBaseAddress ()
+               {
+                       new ServiceHost (typeof (Foo), new Uri ("test", UriKind.Relative));
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CtorMultipleAddressPerScheme ()
+               {
+                       new ServiceHost ( typeof (Foo), 
+                                       new Uri ("http://localhost", UriKind.Absolute),
+                                       new Uri ("http://someotherhost", UriKind.Absolute));
+               }
+
+               [Test]
+               [Ignore ("AddServiceEndpoint part does not work")]
+               public void AddServiceEndpoint ()
+               {
+                       ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
+                       host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "rel");
+                       host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "svc");
+
+                       Assert.IsNotNull (host.Description, "#6");
+                       Assert.IsNotNull (host.Description.Endpoints, "#7");
+                       Assert.AreEqual (host.Description.Endpoints.Count, 2, "#8");
+                       Assert.AreEqual ("http://localhost/echo/rel", host.Description.Endpoints [0].Address.Uri.AbsoluteUri,  "#9");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddServiceEndpoint1 ()
+               {
+                       ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("ftp://localhost/echo"));
+                       // ftp does not match BasicHttpBinding
+                       host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "rel");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddServiceEndpoint2 ()
+               {
+                       // IBar is not part of the contract
+                       ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
+                       host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "rel");
+                       //host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "rel");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddServiceEndpoint3 ()
+               {
+                       // IBar is not part of the contract
+                       ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
+                       host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "rel");
+                       // host.AddServiceEndpoint ("IBar", new BasicHttpBinding (), "http://localhost/echo/rel");
+               }
+
+               [Test]
+               public void AddServiceEndpoint4 ()
+               {
+                       ServiceHost host = new ServiceHost (typeof (Baz), new Uri ("http://localhost/echo"));
+                       host.AddServiceEndpoint ("MonoTests.System.ServiceModel.ServiceHostTest+IBaz", new BasicHttpBinding (), "rel");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddServiceEndpoint5 ()
+               {
+                       ServiceHost host = new ServiceHost (typeof (Baz), new Uri ("http://localhost/echo"));
+                       // Full type name is expected here.
+                       host.AddServiceEndpoint ("IBaz", new BasicHttpBinding (), "rel");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddServiceEndpoint6 ()
+               {
+                       ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
+                       host.AddServiceEndpoint ("ISuchTypeDoesNotExist", new BasicHttpBinding (), "rel");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddServiceEndpointMex ()
+               {
+                       using (ServiceHost h = new ServiceHost (typeof (Foo), new Uri ("http://localhost:8080"))) {
+                               // it expects ServiceMetadataBehavior
+                               h.AddServiceEndpoint (ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpBinding (), "mex");
+                       }
+               }
+
+               [Test]
+               public void AddServiceEndpointMetadataExchange ()
+               {
+                       ServiceHost host = new ServiceHost (typeof (MyMetadataExchange));
+                       host.AddServiceEndpoint ("IMetadataExchange",
+                                                new BasicHttpBinding (),
+                                                "http://localhost:8080");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void AddServiceEndpointMetadataExchangeFullNameFails ()
+               {
+                       ServiceHost host = new ServiceHost (typeof (MyMetadataExchange));
+                       host.AddServiceEndpoint ("System.ServiceModel.Description.IMetadataExchange",
+                                                new BasicHttpBinding (),
+                                                "http://localhost:8080");
+               }
+
+               [Test]
+               public void InstanceWithNonSingletonMode ()
+               {
+                       ServiceHost host = new ServiceHost (
+                               new NonSingletonService ());
+                       Assert.IsNotNull (host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().GetWellKnownSingleton (), "premise1");
+                       host.AddServiceEndpoint (
+                               typeof (NonSingletonService),
+                               new BasicHttpBinding (),
+                               new Uri ("http://localhost:37564/s1"));
+
+                       // in case Open() didn't fail, we need to close the host.
+                       // And even if Close() caused the expected exception,
+                       // the test should still fail.
+                       try {
+                               host.Open ();
+                               try {
+                                       if (host.State == CommunicationState.Opened)
+                                               host.Close ();
+                               } catch (InvalidOperationException) {
+                               }
+                               Assert.Fail ("InstanceContextMode was not checked");
+                       } catch (InvalidOperationException) {
+                       }
+               }
+
+
+               [Test]
+               public void InstanceWithSingletonMode ()
+               {
+                       SingletonService instance = new SingletonService ();
+                       ServiceHost host = new ServiceHost (instance);
+                       Assert.IsNotNull (host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().GetWellKnownSingleton (), "#1");
+                       host.AddServiceEndpoint (
+                               typeof (SingletonService),
+                               new BasicHttpBinding (),
+                               new Uri ("http://localhost:37564/s2"));
+
+                       // in case Open() didn't fail, we need to close the host.
+                       // And even if Close() caused the expected exception,
+                       // the test should still fail.
+                       try {
+                               host.Open ();
+                               ChannelDispatcher cd = (ChannelDispatcher) host.ChannelDispatchers [0];
+                               DispatchRuntime dr = cd.Endpoints [0].DispatchRuntime;
+                               Assert.IsNotNull (dr.InstanceContextProvider, "#2");
+                               InstanceContext ctx = dr.InstanceContextProvider.GetExistingInstanceContext (null, null);
+                               Assert.IsNotNull (ctx, "#3");
+                               Assert.AreEqual (instance, ctx.GetServiceInstance (), "#4");
+                       } finally {
+                               if (host.State == CommunicationState.Opened)
+                                       host.Close ();
+                       }
+               }
+
+               [ServiceContract]
+               interface IBar
+               {
+               }
+
+               [ServiceContract]
+               class Foo
+               {
+                       [OperationContract]
+                       public void SayWhat () { }
+               }
+
+               [ServiceContract]
+               interface IBaz
+               {
+                       [OperationContract]
+                       string Echo (string source);
+               }
+
+               class Baz : IBaz
+               {
+                       public string Echo (string source)
+                       {
+                               return source;
+                       }
+               }
+
+               class MyMetadataExchange : IMetadataExchange
+               {
+                       public Message Get (Message req)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       public IAsyncResult BeginGet (Message request, AsyncCallback cb, object state)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       public Message EndGet (IAsyncResult result)
+                       {
+                               throw new NotImplementedException ();
+                       }
+               }
+
+               [ServiceContract]
+               public class NonSingletonService
+               {
+                       [OperationContract]
+                       public void Process (string input)
+                       {
+                       }
+               }
+
+               [ServiceContract]
+               [ServiceBehavior (InstanceContextMode = InstanceContextMode.Single)]
+               public class SingletonService
+               {
+                       [OperationContract]
+                       public void Process (string input)
+                       {
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/SynchronizedReadOnlyCollectionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/SynchronizedReadOnlyCollectionTest.cs
new file mode 100644 (file)
index 0000000..2867a63
--- /dev/null
@@ -0,0 +1,75 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ServiceModel;
+using NUnit.Framework;
+
+using ObjectList = System.Collections.Generic.SynchronizedReadOnlyCollection<object>;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class SynchronizedReadOnlyCollectionTest
+       {
+               [Test, ExpectedException (typeof (ArgumentException))]
+               public void TestIListIndexOf ()
+               {
+                       SynchronizedReadOnlyCollection<int> c = new SynchronizedReadOnlyCollection<int> ();
+
+                       ((IList) c).IndexOf ("foo");
+               }
+
+               [Test, ExpectedException (typeof (ArgumentException))]
+               public void TestIListContainsWrongType()
+               {
+                       SynchronizedReadOnlyCollection<int> c = new SynchronizedReadOnlyCollection<int> ();
+
+                       ((IList) c).Contains ("foo");
+               }
+
+               [Test]
+               public void TestIListContainsNull ()
+               {                        
+                       ObjectList c = new ObjectList ();
+                       Assert.IsFalse (((IList) c).Contains (null));
+
+                       SynchronizedReadOnlyCollection<ValueType> d = new SynchronizedReadOnlyCollection<ValueType> ();
+                       Assert.IsFalse (((IList) d).Contains (null));
+               }
+
+               [Test, ExpectedException (typeof (ArgumentException))]
+               public void TestICollectionCopyTo ()
+               {
+                       SynchronizedReadOnlyCollection<int> c = new SynchronizedReadOnlyCollection<int> ();
+                       Array a = Array.CreateInstance (typeof (String), 10);
+
+                       ((ICollection) c).CopyTo (a, 0);
+               }
+
+               [Test]
+               public void TestCtorListArg ()
+               {
+                       object x = new object ();
+                       object y = new object ();
+                       ObjectList c = new ObjectList (new object (),
+                               new object [] {x, y});
+                       Assert.AreEqual (2, c.Count, "#1");
+                       // indexer
+                       Assert.AreEqual (x, c [0], "#2");
+                       Assert.AreEqual (y, c [1], "#3");
+                       // GetEnumerator
+                       IEnumerator<object> ge = c.GetEnumerator ();
+                       Assert.IsTrue (ge.MoveNext (), "#8");
+                       Assert.AreEqual (x, ge.Current, "#9");
+                       Assert.IsTrue (ge.MoveNext (), "#10");
+                       Assert.AreEqual (y, ge.Current, "#11");
+                       // IEnumerable.GetEnumerator
+                       IEnumerable enu = c;
+                       IEnumerator e = enu.GetEnumerator ();
+                       Assert.IsTrue (e.MoveNext (), "#4");
+                       Assert.AreEqual (x, e.Current, "#5");
+                       Assert.IsTrue (e.MoveNext (), "#6");
+                       Assert.AreEqual (y, e.Current, "#7");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/TransactionProtocolTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/TransactionProtocolTest.cs
new file mode 100644 (file)
index 0000000..c8968d1
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// TransactionProtocolTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class TransactionProtocolTest
+       {
+               [Test]
+               public void StaticMembers ()
+               {
+                       Assert.IsNotNull (TransactionProtocol.WSAtomicTransactionOctober2004, "#1");
+
+                       // This is not worthy of assuring, just for checking
+                       // implementation details.
+                       //
+                       // ... and anyways it is not testable under Mono since
+                       // access to Default raises an exception.
+                       //
+                       Assert.IsTrue (TransactionProtocol.WSAtomicTransactionOctober2004 != TransactionProtocol.Default, "#2");
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/UriSchemeKeyedCollectionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/UriSchemeKeyedCollectionTest.cs
new file mode 100644 (file)
index 0000000..05375ef
--- /dev/null
@@ -0,0 +1,82 @@
+//
+// UriSchemeKeyedCollectionTest.cs
+//
+// Author:
+//     Ankit Jain  <jankit@novell.com>
+//
+// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.ServiceModel;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class UriSchemeKeyedCollectionTest
+       {
+               [Test]
+               public void Ctor ()
+               {
+                       UriSchemeKeyedCollection u = new UriSchemeKeyedCollection ( new Uri [] { 
+                               new Uri ("http://localhost", UriKind.Absolute),
+                               new Uri ("ftp://someotherhost", UriKind.Absolute) } );
+                       Assert.AreEqual (u.Count, 2, "#1");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void CtorNull ()
+               {
+                       new UriSchemeKeyedCollection (null);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CtorRelativeBaseAddress ()
+               {
+                       /* Only an absolute URI can be a base address */
+                       new UriSchemeKeyedCollection (
+                                       new Uri [] { new Uri ("rel", UriKind.Relative) });
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CtorMultipleAddressPerScheme ()
+               {
+                       /* Collection can have only one URI per scheme */
+                       new UriSchemeKeyedCollection ( new Uri [] { 
+                                       new Uri ("http://localhost", UriKind.Absolute),
+                                       new Uri ("http://someotherhost", UriKind.Absolute) } );
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void CtorAddressWithQuery ()
+               {
+                       /* Base address cannot contain query string */
+                       new UriSchemeKeyedCollection ( new Uri [] { 
+                                       new Uri ("http://localhost/echo?a=5", UriKind.Absolute) });
+               }
+
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/WSFederationHttpBindingTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/WSFederationHttpBindingTest.cs
new file mode 100644 (file)
index 0000000..d4f4162
--- /dev/null
@@ -0,0 +1,323 @@
+//
+// WSFederationHttpBindingTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.IdentityModel.Tokens;
+using System.Net;
+using System.Net.Security;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class WSFederationHttpBindingTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       WSFederationHttpBinding b= new WSFederationHttpBinding ();
+                       // common tests
+                       DefaultValues (b, "http");
+
+                       // WSFederationHttpSecurity
+                       WSFederationHttpSecurity sec = b.Security;
+                       Assert.IsNotNull (sec, "#2-1");
+                       Assert.AreEqual (WSFederationHttpSecurityMode.Message, sec.Mode, "#2-2");
+                       // Security.Message
+                       FederatedMessageSecurityOverHttp msg = sec.Message;
+                       Assert.IsNotNull (msg, "#2-3");
+                       Assert.AreEqual (SecurityAlgorithmSuite.Default,
+                                        msg.AlgorithmSuite, "#2-3-2");
+                       Assert.AreEqual (SecurityKeyType.SymmetricKey,
+                                        msg.IssuedKeyType, "#2-3-3");
+                       Assert.AreEqual (true, msg.NegotiateServiceCredential, "#2-3-4");
+
+                       // Binding elements
+
+                       BindingElementCollection bec = b.CreateBindingElements ();
+                       Assert.AreEqual (4, bec.Count, "#5-1");
+                       Assert.AreEqual (typeof (TransactionFlowBindingElement),
+                               bec [0].GetType (), "#5-2");
+                       Assert.AreEqual (typeof (SymmetricSecurityBindingElement),
+                               bec [1].GetType (), "#5-3");
+                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement),
+                               bec [2].GetType (), "#5-4");
+                       Assert.AreEqual (typeof (HttpTransportBindingElement),
+                               bec [3].GetType (), "#5-5");
+               }
+
+               [Test]
+               [Category ("NotWorking")] // transport security
+               public void DefaultValuesSecurityModeTransport ()
+               {
+                       WSFederationHttpBinding b = new WSFederationHttpBinding (WSFederationHttpSecurityMode.TransportWithMessageCredential);
+                       // common tests.
+                       DefaultValues (b, "https");
+
+                       // WSFederationHttpSecurity
+                       WSFederationHttpSecurity sec = b.Security;
+                       Assert.IsNotNull (sec, "#2-1");
+                       Assert.AreEqual (WSFederationHttpSecurityMode.TransportWithMessageCredential, sec.Mode, "#2-2");
+                       // Security.Message
+                       FederatedMessageSecurityOverHttp msg = sec.Message;
+                       Assert.IsNotNull (msg, "#2-3");
+                       Assert.AreEqual (SecurityAlgorithmSuite.Default,
+                                        msg.AlgorithmSuite, "#2-3-2");
+                       Assert.AreEqual (SecurityKeyType.SymmetricKey,
+                                        msg.IssuedKeyType, "#2-3-3");
+                       Assert.AreEqual (true, msg.NegotiateServiceCredential, "#2-3-4");
+
+                       // Binding elements
+                       BindingElementCollection bec = b.CreateBindingElements ();
+                       Assert.AreEqual (4, bec.Count, "#5-1");
+                       Assert.AreEqual (typeof (TransactionFlowBindingElement),
+                               bec [0].GetType (), "#5-2");
+                       Assert.AreEqual (typeof (TransportSecurityBindingElement),
+                               bec [1].GetType (), "#5-3");
+                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement),
+                               bec [2].GetType (), "#5-4");
+                       Assert.AreEqual (typeof (HttpsTransportBindingElement),
+                               bec [3].GetType (), "#5-5");
+               }
+
+               void DefaultValues (WSFederationHttpBinding b, string scheme)
+               {
+                       Assert.AreEqual (false, b.BypassProxyOnLocal, "#1");
+                       Assert.AreEqual (HostNameComparisonMode.StrongWildcard,
+                               b.HostNameComparisonMode, "#2");
+                       Assert.AreEqual (0x80000, b.MaxBufferPoolSize, "#3");
+                       Assert.AreEqual (0x10000, b.MaxReceivedMessageSize, "#5");
+                       Assert.AreEqual (WSMessageEncoding.Text, b.MessageEncoding, "#6");
+                       Assert.IsNull (b.ProxyAddress, "#7");
+                       // FIXME: test b.ReaderQuotas
+                       Assert.AreEqual (scheme, b.Scheme, "#8");
+                       Assert.AreEqual (EnvelopeVersion.Soap12, b.EnvelopeVersion, "#9");
+                       Assert.AreEqual (65001, b.TextEncoding.CodePage, "#10"); // utf-8
+                       Assert.AreEqual (false, b.TransactionFlow, "#11");
+                       Assert.AreEqual (true, b.UseDefaultWebProxy, "#12");
+                       Assert.AreEqual (MessageVersion.Default, b.MessageVersion, "#14");
+                       Assert.IsNotNull (b.ReliableSession, "#15");
+               }
+
+/*
+               [Test]
+               public void DefaultMessageEncoding ()
+               {
+                       WSHttpBinding b = new WSHttpBinding ();
+                       foreach (BindingElement be in b.CreateBindingElements ()) {
+                               MessageEncodingBindingElement mbe =
+                                       be as MessageEncodingBindingElement;
+                               if (mbe == null)
+                                       continue;
+                               MessageEncoderFactory f = mbe.CreateMessageEncoderFactory ();
+                               MessageEncoder e = f.Encoder;
+
+                               Assert.AreEqual (typeof (TextMessageEncodingBindingElement), mbe.GetType (), "#1-1");
+                               Assert.AreEqual (MessageVersion.Default, f.MessageVersion, "#2-1");
+                               Assert.AreEqual ("application/soap+xml; charset=utf-8", e.ContentType, "#3-1");
+                               Assert.AreEqual ("application/soap+xml", e.MediaType, "#3-2");
+                               return;
+                       }
+                       Assert.Fail ("No message encodiing binding element.");
+               }
+
+               [Test]
+               public void DefaultHttpTransport ()
+               {
+                       WSHttpBinding b = new WSHttpBinding ();
+                       foreach (BindingElement be in b.CreateBindingElements ()) {
+                               HttpTransportBindingElement tbe =
+                                       be as HttpTransportBindingElement;
+                               if (tbe == null)
+                                       continue;
+
+                               Assert.AreEqual (false, tbe.AllowCookies, "#1");
+                               Assert.AreEqual (AuthenticationSchemes.Anonymous, tbe.AuthenticationScheme, "#2");
+                               Assert.AreEqual (false, tbe.BypassProxyOnLocal, "#3");
+                               Assert.AreEqual (HostNameComparisonMode.StrongWildcard, tbe.HostNameComparisonMode, "#4");
+                               Assert.AreEqual (true, tbe.KeepAliveEnabled, "#5");
+                               Assert.AreEqual (false, tbe.ManualAddressing, "#6");
+                               Assert.AreEqual (0x80000, tbe.MaxBufferPoolSize, "#7");
+                               Assert.AreEqual (0x10000, tbe.MaxBufferSize, "#8");
+                               Assert.AreEqual (0x10000, tbe.MaxReceivedMessageSize, "#9");
+                               Assert.IsNull (tbe.ProxyAddress, "#10");
+                               Assert.AreEqual (AuthenticationSchemes.Anonymous, tbe.ProxyAuthenticationScheme, "#11");
+                               Assert.AreEqual ("", tbe.Realm, "#12");
+                               Assert.AreEqual (TransferMode.Buffered, tbe.TransferMode, "#13");
+                               Assert.AreEqual (true, tbe.UseDefaultWebProxy, "#14");
+
+                               return;
+                       }
+                       Assert.Fail ("No transport binding element.");
+               }
+
+               [Test]
+               public void DefaultTransactionFlow ()
+               {
+                       WSHttpBinding b = new WSHttpBinding ();
+                       foreach (BindingElement be in b.CreateBindingElements ()) {
+                               TransactionFlowBindingElement tbe =
+                                       be as TransactionFlowBindingElement;
+                               if (tbe == null)
+                                       continue;
+
+                               Assert.AreEqual (TransactionProtocol.WSAtomicTransactionOctober2004,
+                                       tbe.TransactionProtocol, "#1");
+
+                               return;
+                       }
+                       Assert.Fail ("No transaction flow binding element.");
+               }
+
+               [Test]
+               public void CreateMessageSecurity ()
+               {
+                       Assert.IsNull (new MyWSBinding (SecurityMode.None).CreateMessageSecurityEx (), "None");
+                       Assert.IsNotNull (new MyWSBinding (SecurityMode.Message).CreateMessageSecurityEx (), "Message");
+                       Assert.IsNull (new MyWSBinding (SecurityMode.Transport).CreateMessageSecurityEx (), "Transport");
+               }
+
+               [Test]
+               public void DefaultMessageSecurity ()
+               {
+                       WSHttpBinding b = new WSHttpBinding ();
+                       SymmetricSecurityBindingElement sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       Assert.IsNotNull (sbe, "#0");
+
+                       SecureConversationSecurityTokenParameters p =
+                               sbe.ProtectionTokenParameters as SecureConversationSecurityTokenParameters;
+                       Assert.IsNotNull (p, "#1");
+
+                       Assert.AreEqual (SecurityAlgorithmSuite.Default,
+                               sbe.DefaultAlgorithmSuite, "#2");
+
+                       SupportingTokenParameters s =
+                               sbe.EndpointSupportingTokenParameters;
+                       Assert.IsNotNull (s, "#3");
+                       Assert.AreEqual (0, s.Endorsing.Count, "#3-1");
+                       Assert.AreEqual (0, s.Signed.Count, "#3-2");
+                       Assert.AreEqual (0, s.SignedEndorsing.Count, "#3-3");
+                       Assert.AreEqual (0, s.SignedEncrypted.Count, "#3-4");
+
+                       Assert.AreEqual (0, sbe.OperationSupportingTokenParameters.Count, "#4");
+
+                       s = sbe.OptionalEndpointSupportingTokenParameters;
+                       Assert.IsNotNull (s, "#5");
+                       Assert.AreEqual (0, s.Endorsing.Count, "#5-1");
+                       Assert.AreEqual (0, s.Signed.Count, "#5-2");
+                       Assert.AreEqual (0, s.SignedEndorsing.Count, "#5-3");
+                       Assert.AreEqual (0, s.SignedEncrypted.Count, "#5-4");
+                       Assert.AreEqual (0, sbe.OptionalOperationSupportingTokenParameters.Count, "#6");
+               }
+
+               [Test]
+               public void MessageSecurityNoSecureConversation ()
+               {
+                       WSHttpBinding b = new WSHttpBinding ();
+                       b.Security.Message.EstablishSecurityContext = false;
+                       SymmetricSecurityBindingElement sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       Assert.IsNotNull (sbe, "#0");
+
+                       Assert.AreEqual (
+                               typeof (SspiSecurityTokenParameters),
+                               sbe.ProtectionTokenParameters.GetType (), "#1");
+                       // no worthy to check SSPI security as we never support it.
+
+                       b.Security.Message.ClientCredentialType = MessageCredentialType.None;
+                       sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       SslSecurityTokenParameters ssltp =
+                               sbe.ProtectionTokenParameters
+                               as SslSecurityTokenParameters;
+                       Assert.IsNotNull(ssltp, "#2-1");
+                       Assert.AreEqual (true, ssltp.RequireCancellation, "#2-2");
+                       Assert.AreEqual (false, ssltp.RequireClientCertificate, "#2-3");
+
+                       b.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
+                       sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       ssltp = sbe.ProtectionTokenParameters as SslSecurityTokenParameters;
+                       Assert.IsNotNull(ssltp, "#3-1");
+
+                       // No NegotiateServiceCredential modes ...
+
+                       b.Security.Message.NegotiateServiceCredential = false;
+                       b.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
+                       sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       KerberosSecurityTokenParameters ktp =
+                               sbe.ProtectionTokenParameters
+                               as KerberosSecurityTokenParameters;
+                       Assert.IsNotNull (ktp, "#4-1");
+                       // no worthy of testing windows-only Kerberos stuff
+
+                       b.Security.Message.ClientCredentialType = MessageCredentialType.None;
+                       sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       X509SecurityTokenParameters x509tp =
+                               sbe.ProtectionTokenParameters
+                               as X509SecurityTokenParameters;
+                       Assert.IsNotNull (x509tp, "#5-1");
+                       Assert.AreEqual (X509KeyIdentifierClauseType.Thumbprint, x509tp.X509ReferenceStyle, "#5-2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("NotWorking")]
+               public void BuildListenerWithoutServiceCertificate ()
+               {
+                       ServiceHost host = new ServiceHost (typeof (Foo));
+                       WSHttpBinding binding = new WSHttpBinding ();
+                       binding.Security.Message.ClientCredentialType =
+                               MessageCredentialType.IssuedToken;
+                       host.AddServiceEndpoint ("Foo", binding, "http://localhost:8080");
+                       host.Open ();
+               }
+*/
+
+               [ServiceContract]
+               class Foo
+               {
+                       [OperationContract]
+                       public void SayWhat () { }
+               }
+
+               class MyWSBinding : WSHttpBinding
+               {
+                       public MyWSBinding (SecurityMode mode)
+                               : base (mode)
+                       {
+                       }
+
+                       public SecurityBindingElement CreateMessageSecurityEx ()
+                       {
+                               return CreateMessageSecurity ();
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/WSHttpBindingTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/WSHttpBindingTest.cs
new file mode 100644 (file)
index 0000000..0e5cb97
--- /dev/null
@@ -0,0 +1,479 @@
+//
+// WSHttpBindingTest.cs
+//
+// Author:
+//     Atsushi Enomoto <atsushi@ximian.com>
+//
+// Copyright (C) 2006 Novell, Inc.  http://www.novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections.ObjectModel;
+using System.Net;
+using System.Net.Security;
+using System.IdentityModel.Claims;
+using System.IdentityModel.Selectors;
+using System.IdentityModel.Tokens;
+using System.ServiceModel;
+using System.ServiceModel.Channels;
+using System.ServiceModel.Security;
+using System.ServiceModel.Security.Tokens;
+using NUnit.Framework;
+
+namespace MonoTests.System.ServiceModel
+{
+       [TestFixture]
+       public class WSHttpBindingTest
+       {
+               [Test]
+               public void DefaultValues ()
+               {
+                       WSHttpBinding b= new WSHttpBinding ();
+                       // common tests
+                       DefaultValues (b, "http");
+
+                       // WSHttpSecurity
+                       WSHttpSecurity sec = b.Security;
+                       Assert.IsNotNull (sec, "#2-1");
+                       Assert.AreEqual (SecurityMode.Message, sec.Mode, "#2-2");
+                       // Security.Message
+                       NonDualMessageSecurityOverHttp msg = sec.Message;
+                       Assert.IsNotNull (msg, "#2-3");
+                       Assert.AreEqual (true, msg.EstablishSecurityContext, "#2-3-1");
+                       Assert.AreEqual (SecurityAlgorithmSuite.Default,
+                                        msg.AlgorithmSuite, "#2-3-2");
+                       // it is not worthy of test, just for checking default value.
+                       Assert.AreEqual (MessageCredentialType.Windows,
+                                        msg.ClientCredentialType, "#2-3-3");
+                       Assert.AreEqual (true, msg.NegotiateServiceCredential, "#2-3-4");
+                       // FIXME: test Security.Transport
+                       Assert.IsNotNull (sec.Transport, "#2-4");
+
+                       // Binding elements
+
+                       BindingElementCollection bec = b.CreateBindingElements ();
+                       Assert.AreEqual (4, bec.Count, "#5-1");
+                       Assert.AreEqual (typeof (TransactionFlowBindingElement),
+                               bec [0].GetType (), "#5-2");
+                       Assert.AreEqual (typeof (SymmetricSecurityBindingElement),
+                               bec [1].GetType (), "#5-3");
+                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement),
+                               bec [2].GetType (), "#5-4");
+                       Assert.AreEqual (typeof (HttpTransportBindingElement),
+                               bec [3].GetType (), "#5-5");
+               }
+
+               [Test]
+               public void DefaultValuesSecurityModeTransport ()
+               {
+                       WSHttpBinding b = new WSHttpBinding (SecurityMode.Transport);
+                       // common tests.
+                       DefaultValues (b, "https");
+
+                       // WSHttpSecurity
+                       WSHttpSecurity sec = b.Security;
+                       Assert.IsNotNull (sec, "#2-1");
+                       Assert.AreEqual (SecurityMode.Transport, sec.Mode, "#2-2");
+                       // Security.Message
+                       NonDualMessageSecurityOverHttp msg = sec.Message;
+                       Assert.IsNotNull (msg, "#2-3");
+                       Assert.AreEqual (true, msg.EstablishSecurityContext, "#2-3-1");
+                       Assert.AreEqual (SecurityAlgorithmSuite.Default,
+                                        msg.AlgorithmSuite, "#2-3-2");
+                       // it is not worthy of test, just for checking default value.
+                       Assert.AreEqual (MessageCredentialType.Windows,
+                                        msg.ClientCredentialType, "#2-3-3");
+                       Assert.AreEqual (true, msg.NegotiateServiceCredential, "#2-3-4");
+                       // FIXME: test Security.Transport
+                       Assert.IsNotNull (sec.Transport, "#2-4");
+
+                       // Binding elements
+                       BindingElementCollection bec = b.CreateBindingElements ();
+                       Assert.AreEqual (3, bec.Count, "#5-1");
+                       Assert.AreEqual (typeof (TransactionFlowBindingElement),
+                               bec [0].GetType (), "#5-2");
+                       Assert.AreEqual (typeof (TextMessageEncodingBindingElement),
+                               bec [1].GetType (), "#5-3");
+                       Assert.AreEqual (typeof (HttpsTransportBindingElement),
+                               bec [2].GetType (), "#5-4");
+               }
+
+               void DefaultValues (WSHttpBinding b, string scheme)
+               {
+                       Assert.AreEqual (false, b.BypassProxyOnLocal, "#1");
+                       Assert.AreEqual (HostNameComparisonMode.StrongWildcard,
+                               b.HostNameComparisonMode, "#2");
+                       Assert.AreEqual (0x80000, b.MaxBufferPoolSize, "#3");
+                       Assert.AreEqual (0x10000, b.MaxReceivedMessageSize, "#5");
+                       Assert.AreEqual (WSMessageEncoding.Text, b.MessageEncoding, "#6");
+                       Assert.IsNull (b.ProxyAddress, "#7");
+                       // FIXME: test b.ReaderQuotas
+                       Assert.AreEqual (scheme, b.Scheme, "#8");
+                       Assert.AreEqual (EnvelopeVersion.Soap12, b.EnvelopeVersion, "#9");
+                       Assert.AreEqual (65001, b.TextEncoding.CodePage, "#10"); // utf-8
+                       Assert.AreEqual (false, b.TransactionFlow, "#11");
+                       Assert.AreEqual (true, b.UseDefaultWebProxy, "#12");
+                       Assert.AreEqual (false, b.AllowCookies, "#13");
+                       Assert.AreEqual (MessageVersion.Default, b.MessageVersion, "#14");
+                       Assert.IsNotNull (b.ReliableSession, "#15");
+               }
+
+               [Test]
+               public void DefaultMessageEncoding ()
+               {
+                       WSHttpBinding b = new WSHttpBinding ();
+                       foreach (BindingElement be in b.CreateBindingElements ()) {
+                               MessageEncodingBindingElement mbe =
+                                       be as MessageEncodingBindingElement;
+                               if (mbe == null)
+                                       continue;
+                               MessageEncoderFactory f = mbe.CreateMessageEncoderFactory ();
+                               MessageEncoder e = f.Encoder;
+
+                               Assert.AreEqual (typeof (TextMessageEncodingBindingElement), mbe.GetType (), "#1-1");
+                               Assert.AreEqual (MessageVersion.Default, f.MessageVersion, "#2-1");
+                               Assert.AreEqual ("application/soap+xml; charset=utf-8", e.ContentType, "#3-1");
+                               Assert.AreEqual ("application/soap+xml", e.MediaType, "#3-2");
+                               return;
+                       }
+                       Assert.Fail ("No message encodiing binding element.");
+               }
+
+               [Test]
+               public void DefaultHttpTransport ()
+               {
+                       WSHttpBinding b = new WSHttpBinding ();
+                       foreach (BindingElement be in b.CreateBindingElements ()) {
+                               HttpTransportBindingElement tbe =
+                                       be as HttpTransportBindingElement;
+                               if (tbe == null)
+                                       continue;
+
+                               Assert.AreEqual (false, tbe.AllowCookies, "#1");
+                               Assert.AreEqual (AuthenticationSchemes.Anonymous, tbe.AuthenticationScheme, "#2");
+                               Assert.AreEqual (false, tbe.BypassProxyOnLocal, "#3");
+                               Assert.AreEqual (HostNameComparisonMode.StrongWildcard, tbe.HostNameComparisonMode, "#4");
+                               Assert.AreEqual (true, tbe.KeepAliveEnabled, "#5");
+                               Assert.AreEqual (false, tbe.ManualAddressing, "#6");
+                               Assert.AreEqual (0x80000, tbe.MaxBufferPoolSize, "#7");
+                               Assert.AreEqual (0x10000, tbe.MaxBufferSize, "#8");
+                               Assert.AreEqual (0x10000, tbe.MaxReceivedMessageSize, "#9");
+                               Assert.IsNull (tbe.ProxyAddress, "#10");
+                               Assert.AreEqual (AuthenticationSchemes.Anonymous, tbe.ProxyAuthenticationScheme, "#11");
+                               Assert.AreEqual ("", tbe.Realm, "#12");
+                               Assert.AreEqual (TransferMode.Buffered, tbe.TransferMode, "#13");
+                               Assert.AreEqual (true, tbe.UseDefaultWebProxy, "#14");
+
+                               return;
+                       }
+                       Assert.Fail ("No transport binding element.");
+               }
+
+               [Test]
+               public void DefaultTransactionFlow ()
+               {
+                       WSHttpBinding b = new WSHttpBinding ();
+                       foreach (BindingElement be in b.CreateBindingElements ()) {
+                               TransactionFlowBindingElement tbe =
+                                       be as TransactionFlowBindingElement;
+                               if (tbe == null)
+                                       continue;
+
+                               Assert.AreEqual (TransactionProtocol.WSAtomicTransactionOctober2004,
+                                       tbe.TransactionProtocol, "#1");
+
+                               return;
+                       }
+                       Assert.Fail ("No transaction flow binding element.");
+               }
+
+               [Test]
+               public void CreateMessageSecurity ()
+               {
+                       Assert.IsNull (new MyWSBinding (SecurityMode.None).CreateMessageSecurityEx (), "None");
+                       Assert.IsNotNull (new MyWSBinding (SecurityMode.Message).CreateMessageSecurityEx (), "Message");
+                       Assert.IsNull (new MyWSBinding (SecurityMode.Transport).CreateMessageSecurityEx (), "Transport");
+               }
+
+               [Test]
+               public void DefaultMessageSecurity ()
+               {
+                       WSHttpBinding b = new WSHttpBinding ();
+                       SymmetricSecurityBindingElement sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       Assert.IsNotNull (sbe, "#0");
+
+                       SecureConversationSecurityTokenParameters p =
+                               sbe.ProtectionTokenParameters as SecureConversationSecurityTokenParameters;
+                       Assert.IsNotNull (p, "#1");
+                       SymmetricSecurityBindingElement scbe =
+                               p.BootstrapSecurityBindingElement as SymmetricSecurityBindingElement;
+                       Assert.IsNotNull (scbe, "#1.1");
+                       // since the default w/o SecureConv is SSPI ...
+                       Assert.IsTrue (scbe.ProtectionTokenParameters is SspiSecurityTokenParameters, "#1.2");
+
+                       Assert.AreEqual (SecurityAlgorithmSuite.Default,
+                               sbe.DefaultAlgorithmSuite, "#2");
+
+                       SupportingTokenParameters s =
+                               sbe.EndpointSupportingTokenParameters;
+                       Assert.IsNotNull (s, "#3");
+                       Assert.AreEqual (0, s.Endorsing.Count, "#3-1");
+                       Assert.AreEqual (0, s.Signed.Count, "#3-2");
+                       Assert.AreEqual (0, s.SignedEndorsing.Count, "#3-3");
+                       Assert.AreEqual (0, s.SignedEncrypted.Count, "#3-4");
+
+                       Assert.AreEqual (0, sbe.OperationSupportingTokenParameters.Count, "#4");
+
+                       s = sbe.OptionalEndpointSupportingTokenParameters;
+                       Assert.IsNotNull (s, "#5");
+                       Assert.AreEqual (0, s.Endorsing.Count, "#5-1");
+                       Assert.AreEqual (0, s.Signed.Count, "#5-2");
+                       Assert.AreEqual (0, s.SignedEndorsing.Count, "#5-3");
+                       Assert.AreEqual (0, s.SignedEncrypted.Count, "#5-4");
+                       Assert.AreEqual (0, sbe.OptionalOperationSupportingTokenParameters.Count, "#6");
+               }
+
+               [Test]
+               public void MessageSecurityNoSecureConversation ()
+               {
+                       WSHttpBinding b = new WSHttpBinding ();
+                       b.Security.Message.EstablishSecurityContext = false;
+                       SymmetricSecurityBindingElement sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       Assert.IsNotNull (sbe, "#0");
+
+                       Assert.AreEqual (
+                               typeof (SspiSecurityTokenParameters),
+                               sbe.ProtectionTokenParameters.GetType (), "#1");
+                       // no worthy to check SSPI security as we never support it.
+
+                       b.Security.Message.ClientCredentialType = MessageCredentialType.None;
+                       sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       SslSecurityTokenParameters ssltp =
+                               sbe.ProtectionTokenParameters
+                               as SslSecurityTokenParameters;
+                       Assert.IsNotNull(ssltp, "#2-1");
+                       Assert.AreEqual (true, ssltp.RequireCancellation, "#2-2");
+                       Assert.AreEqual (false, ssltp.RequireClientCertificate, "#2-3");
+
+                       b.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
+                       sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       ssltp = sbe.ProtectionTokenParameters as SslSecurityTokenParameters;
+                       Assert.IsNotNull(ssltp, "#3-1");
+
+                       // No NegotiateServiceCredential modes ...
+
+                       b.Security.Message.NegotiateServiceCredential = false;
+                       b.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
+                       sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       KerberosSecurityTokenParameters ktp =
+                               sbe.ProtectionTokenParameters
+                               as KerberosSecurityTokenParameters;
+                       Assert.IsNotNull (ktp, "#4-1");
+                       // no worthy of testing windows-only Kerberos stuff
+
+                       b.Security.Message.ClientCredentialType = MessageCredentialType.None;
+                       sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       X509SecurityTokenParameters x509tp =
+                               sbe.ProtectionTokenParameters
+                               as X509SecurityTokenParameters;
+                       Assert.IsNotNull (x509tp, "#5-1");
+                       Assert.AreEqual (X509KeyIdentifierClauseType.Thumbprint, x509tp.X509ReferenceStyle, "#5-2");
+                       Assert.AreEqual (SecurityTokenInclusionMode.Never, x509tp.InclusionMode, "#5-3");
+
+                       b.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
+                       sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       Assert.AreEqual (1, sbe.EndpointSupportingTokenParameters.Endorsing.Count, "#6-0");
+                       x509tp = sbe.EndpointSupportingTokenParameters.Endorsing [0] as X509SecurityTokenParameters;
+                       Assert.IsNotNull (x509tp, "#6-1");
+                       Assert.AreEqual (X509KeyIdentifierClauseType.Thumbprint, x509tp.X509ReferenceStyle, "#6-2");
+                       Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient, x509tp.InclusionMode, "#6-3");
+                       Assert.AreEqual (false, x509tp.RequireDerivedKeys, "#6-4");
+                       x509tp = sbe.ProtectionTokenParameters as X509SecurityTokenParameters;
+                       Assert.IsNotNull (x509tp, "#7-1");
+                       Assert.AreEqual (X509KeyIdentifierClauseType.Thumbprint, x509tp.X509ReferenceStyle, "#7-2");
+                       Assert.AreEqual (SecurityTokenInclusionMode.Never, x509tp.InclusionMode, "#7-3");
+                       Assert.AreEqual (true, x509tp.RequireDerivedKeys, "#7-4");
+                       Assert.AreEqual (true, sbe.RequireSignatureConfirmation, "#8");
+               }
+
+               [Test]
+               public void MessageSecurityCertificateNego ()
+               {
+                       WSHttpBinding binding = new WSHttpBinding ();
+                       binding.Security.Message.ClientCredentialType =
+                               MessageCredentialType.Certificate;
+                       SymmetricSecurityBindingElement sbe =
+                               binding.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       Assert.IsNotNull (sbe, "#1");
+                       Assert.AreEqual (false, sbe.RequireSignatureConfirmation, "#1-2");
+
+                       SecureConversationSecurityTokenParameters sp =
+                               sbe.ProtectionTokenParameters
+                               as SecureConversationSecurityTokenParameters;
+                       Assert.IsNotNull (sp, "#2");
+                       SymmetricSecurityBindingElement spbe =
+                               sp.BootstrapSecurityBindingElement
+                               as SymmetricSecurityBindingElement;
+                       Assert.IsNotNull (spbe, "#3");
+                       SslSecurityTokenParameters p =
+                               spbe.ProtectionTokenParameters
+                               as SslSecurityTokenParameters;
+                       Assert.IsNotNull (p, "#4");
+                       Assert.AreEqual (SecurityTokenReferenceStyle.Internal,
+                                        p.ReferenceStyle, "#5");
+                       Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient,
+                                        p.InclusionMode, "#6");
+               }
+
+               [Test]
+               public void MessageSecuritySPNego ()
+               {
+                       WSHttpBinding binding = new WSHttpBinding ();
+                       SymmetricSecurityBindingElement sbe =
+                               binding.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       Assert.IsNotNull (sbe, "#1");
+                       Assert.AreEqual (false, sbe.RequireSignatureConfirmation, "#1-2");
+
+                       SecureConversationSecurityTokenParameters sp =
+                               sbe.ProtectionTokenParameters
+                               as SecureConversationSecurityTokenParameters;
+                       Assert.IsNotNull (sp, "#2");
+                       SymmetricSecurityBindingElement spbe =
+                               sp.BootstrapSecurityBindingElement
+                               as SymmetricSecurityBindingElement;
+                       Assert.IsNotNull (spbe, "#3");
+                       SspiSecurityTokenParameters p =
+                               spbe.ProtectionTokenParameters
+                               as SspiSecurityTokenParameters;
+                       Assert.IsNotNull (p, "#4");
+                       Assert.AreEqual (SecurityTokenReferenceStyle.Internal,
+                                        p.ReferenceStyle, "#5");
+                       Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient,
+                                        p.InclusionMode, "#6");
+                       Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.Signed.Count, "#7");
+                       Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.SignedEncrypted.Count, "#8");
+                       Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.Endorsing.Count, "#9");
+                       Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.SignedEndorsing.Count, "#10");
+                       Assert.AreEqual (0, spbe.EndpointSupportingTokenParameters.Signed.Count, "#11");
+                       Assert.AreEqual (0, spbe.EndpointSupportingTokenParameters.SignedEncrypted.Count, "#12");
+                       Assert.AreEqual (0, spbe.EndpointSupportingTokenParameters.Endorsing.Count, "#13");
+                       Assert.AreEqual (0, spbe.EndpointSupportingTokenParameters.SignedEndorsing.Count, "#14");
+
+                       Assert.AreEqual (0, sbe.OptionalEndpointSupportingTokenParameters.Signed.Count, "#17");
+                       Assert.AreEqual (0, sbe.OptionalEndpointSupportingTokenParameters.SignedEncrypted.Count, "#18");
+                       Assert.AreEqual (0, sbe.OptionalEndpointSupportingTokenParameters.Endorsing.Count, "#19");
+                       Assert.AreEqual (0, sbe.OptionalEndpointSupportingTokenParameters.SignedEndorsing.Count, "#110");
+                       Assert.AreEqual (0, spbe.OptionalEndpointSupportingTokenParameters.Signed.Count, "#21");
+                       Assert.AreEqual (0, spbe.OptionalEndpointSupportingTokenParameters.SignedEncrypted.Count, "#22");
+                       Assert.AreEqual (0, spbe.OptionalEndpointSupportingTokenParameters.Endorsing.Count, "#23");
+                       Assert.AreEqual (0, spbe.OptionalEndpointSupportingTokenParameters.SignedEndorsing.Count, "#24");
+               }
+
+               [Test]
+               public void MessageSecurityUserName ()
+               {
+                       WSHttpBinding binding = new WSHttpBinding ();
+                       binding.Security.Message.NegotiateServiceCredential = false;
+                       binding.Security.Message.EstablishSecurityContext = false;
+                       binding.Security.Message.ClientCredentialType =
+                               MessageCredentialType.UserName;
+                       SymmetricSecurityBindingElement sbe =
+                               binding.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       Assert.IsNotNull (sbe, "#1");
+                       Assert.AreEqual (false, sbe.RequireSignatureConfirmation, "#1-2");
+
+                       X509SecurityTokenParameters sp =
+                               sbe.ProtectionTokenParameters
+                               as X509SecurityTokenParameters;
+                       Assert.IsNotNull (sp, "#2");
+                       Assert.AreEqual (SecurityTokenReferenceStyle.Internal,
+                                        sp.ReferenceStyle, "#3");
+                       Assert.AreEqual (SecurityTokenInclusionMode.Never,
+                                        sp.InclusionMode, "#4");
+
+                       UserNameSecurityTokenParameters up =
+                               sbe.EndpointSupportingTokenParameters.SignedEncrypted [0]
+                               as UserNameSecurityTokenParameters;
+                       Assert.AreEqual (SecurityTokenReferenceStyle.Internal,
+                                        up.ReferenceStyle, "#5");
+                       Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient,
+                                        up.InclusionMode, "#6");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void MessageSecurityIssuedToken ()
+               {
+                       WSHttpBinding binding = new WSHttpBinding ();
+                       binding.Security.Message.EstablishSecurityContext = false;
+                       binding.Security.Message.ClientCredentialType =
+                               MessageCredentialType.IssuedToken;
+                       SymmetricSecurityBindingElement sbe =
+                               binding.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
+                       Assert.IsNotNull (sbe, "#1");
+                       Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.Signed.Count, "#1-1");
+                       Assert.AreEqual (1, sbe.EndpointSupportingTokenParameters.Endorsing.Count, "#1-2");
+                       Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.SignedEndorsing.Count, "#1-3");
+                       Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.SignedEncrypted.Count, "#1-4");
+                       IssuedSecurityTokenParameters p =
+                               sbe.EndpointSupportingTokenParameters.Endorsing [0]
+                               as IssuedSecurityTokenParameters;
+                       Assert.IsNotNull (p, "#2");
+                       Assert.IsNotNull (p.ClaimTypeRequirements, "#2-1");
+                       Assert.AreEqual (1, p.ClaimTypeRequirements.Count, "#2-2");
+                       ClaimTypeRequirement r = p.ClaimTypeRequirements [0];
+                       Assert.AreEqual (ClaimTypes.PPID, r.ClaimType, "#3-1");
+                       Assert.IsFalse (r.IsOptional, "#3-2");
+               }
+
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void BuildListenerWithoutServiceCertificate ()
+               {
+                       ServiceHost host = new ServiceHost (typeof (Foo));
+                       WSHttpBinding binding = new WSHttpBinding ();
+                       binding.Security.Message.ClientCredentialType =
+                               MessageCredentialType.IssuedToken;
+                       host.AddServiceEndpoint ("Foo", binding, "http://localhost:8080");
+                       host.Open ();
+               }
+
+               [ServiceContract]
+               class Foo
+               {
+                       [OperationContract]
+                       public void SayWhat () { }
+               }
+
+               class MyWSBinding : WSHttpBinding
+               {
+                       public MyWSBinding (SecurityMode mode)
+                               : base (mode)
+                       {
+                       }
+
+                       public SecurityBindingElement CreateMessageSecurityEx ()
+                       {
+                               return CreateMessageSecurity ();
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System.ServiceModel/Test/WCFServers/Program.cs b/mcs/class/System.ServiceModel/Test/WCFServers/Program.cs
new file mode 100644 (file)
index 0000000..b058706
--- /dev/null
@@ -0,0 +1,106 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using System.Reflection;\r
+using System.IO;\r
+using System.Diagnostics;\r
+\r
+namespace WCFServers\r
+{\r
+       class Program\r
+       {\r
+               List<object> initialized = new List<object> ();\r
+\r
+               object getInstance (Type type) {\r
+                       try {\r
+                               return Activator.CreateInstance (type);\r
+                       }\r
+                       catch (Exception e) {\r
+                               Console.WriteLine ("Failed to initialize object. Skipping");\r
+                               return null;\r
+                       } finally {\r
+                               Console.Write ("Initialized....");\r
+                       }\r
+               }\r
+               void runSetUp (object t) {\r
+                       Console.Write ("Attempting to start type " + t.GetType().FullName + " ....");\r
+                       var methods = from method in t.GetType ().GetMethods (BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)\r
+                                                 where method.GetCustomAttributes (typeof (NUnit.Framework.SetUpAttribute), true).Length > 0\r
+                                                 select method;\r
+                       if (methods.Count () == 0) {\r
+                               Console.WriteLine ("No SetUp methods. Skipping");\r
+                               return;\r
+                       }\r
+                       bool good = false;\r
+                       foreach (var method in methods)\r
+                               try {\r
+                                       method.Invoke (t, null);\r
+                                       good = true;\r
+                               }\r
+                               catch (Exception e) {\r
+                                       Console.Write ("Failed to call method " + method.Name);\r
+                               }\r
+                       if (good) {\r
+                               Console.WriteLine ("Success.");\r
+                               initialized.Add (t);\r
+                       }\r
+                       else {\r
+                               Console.WriteLine ("No setup methods successfully called. Skipping");\r
+                       }\r
+               }\r
+               void runInit (Type type) {\r
+                       object t = getInstance (type);\r
+                       if (t == null)\r
+                               return;\r
+                       runSetUp (t);\r
+               }\r
+               void runAllInits (Assembly assem) {\r
+                       var types = from type in assem.GetTypes ()\r
+                                               where type.GetCustomAttributes (typeof (NUnit.Framework.TestFixtureAttribute), true).Length > 0\r
+                                               select type;\r
+                       foreach (Type type in types) {\r
+                               runInit (type);\r
+                       }\r
+                       Console.WriteLine ("Successfully initialized " + initialized.Count + " types: ");\r
+                       {\r
+                               foreach (object o in initialized)\r
+                                       Console.WriteLine (o.GetType ().FullName);\r
+                       }\r
+               }\r
+\r
+               static void Main (string [] args) {\r
+\r
+                       if (args.Count() > 0 && args [0] == "shutdown") {\r
+                               MonoTests.Features.Configuration.onlyClients = true;\r
+                               MonoTests.Features.Serialization.ExitProcessHelper exiter = new MonoTests.Features.Serialization.ExitProcessHelper ();\r
+                               exiter.Run ();                 // initialize the client\r
+                               exiter.Client.ExitProcess (0); // exit the server\r
+                               Environment.Exit (0);          // exit this process\r
+                       }\r
+                               \r
+                       string assemblyName = "System.ServiceModel_test_net_3_0.dll";\r
+                       Assembly assem;\r
+                       try {\r
+                               System.IO.FileInfo fi = new FileInfo (Assembly.GetEntryAssembly ().Location);\r
+\r
+                               assem = Assembly.LoadFrom (Path.Combine (fi.Directory.FullName, assemblyName));\r
+                       }\r
+                       catch (Exception e) {\r
+                               Console.WriteLine ("Could not start server. Could not load: " + assemblyName);\r
+                               return;\r
+                       }\r
+\r
+                       // Run only the servers. No need to initialize the clients.\r
+                       MonoTests.Features.Configuration.onlyServers = true;\r
+\r
+                       Program p = new Program ();\r
+                       p.runAllInits (assem);\r
+\r
+                       Console.WriteLine ("Press any key to continue...");\r
+                       Console.ReadKey ();\r
+                       Console.WriteLine ("Bye bye");\r
+                       Environment.Exit (0);\r
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/System.ServiceModel/Test/WCFServers/Properties/AssemblyInfo.cs b/mcs/class/System.ServiceModel/Test/WCFServers/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..4cd4648
--- /dev/null
@@ -0,0 +1,36 @@
+using System.Reflection;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+\r
+// General Information about an assembly is controlled through the following \r
+// set of attributes. Change these attribute values to modify the information\r
+// associated with an assembly.\r
+[assembly: AssemblyTitle ("WCFServers")]\r
+[assembly: AssemblyDescription ("")]\r
+[assembly: AssemblyConfiguration ("")]\r
+[assembly: AssemblyCompany ("MainSoft")]\r
+[assembly: AssemblyProduct ("WCFServers")]\r
+[assembly: AssemblyCopyright ("Copyright © MainSoft 2008")]\r
+[assembly: AssemblyTrademark ("")]\r
+[assembly: AssemblyCulture ("")]\r
+\r
+// Setting ComVisible to false makes the types in this assembly not visible \r
+// to COM components.  If you need to access a type in this assembly from \r
+// COM, set the ComVisible attribute to true on that type.\r
+[assembly: ComVisible (false)]\r
+\r
+// The following GUID is for the ID of the typelib if this project is exposed to COM\r
+[assembly: Guid ("24c73825-c70b-4bf4-b161-d715e9a9a3bf")]\r
+\r
+// Version information for an assembly consists of the following four values:\r
+//\r
+//      Major Version\r
+//      Minor Version \r
+//      Build Number\r
+//      Revision\r
+//\r
+// You can specify all the values or you can default the Build and Revision Numbers \r
+// by using the '*' as shown below:\r
+// [assembly: AssemblyVersion("1.0.*")]\r
+[assembly: AssemblyVersion ("1.0.0.0")]\r
+[assembly: AssemblyFileVersion ("1.0.0.0")]\r
diff --git a/mcs/class/System.ServiceModel/Test/WCFServers/WCFServers.csproj b/mcs/class/System.ServiceModel/Test/WCFServers/WCFServers.csproj
new file mode 100644 (file)
index 0000000..fa6ba8a
--- /dev/null
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProductVersion>9.0.21022</ProductVersion>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectGuid>{88AB909A-C341-4639-B99C-729AC1581E7D}</ProjectGuid>\r
+    <OutputType>Exe</OutputType>\r
+    <AppDesignerFolder>Properties</AppDesignerFolder>\r
+    <RootNamespace>WCFServers</RootNamespace>\r
+    <AssemblyName>WCFServers</AssemblyName>\r
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>\r
+    <FileAlignment>512</FileAlignment>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>..\..\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="System" />\r
+    <Reference Include="System.Core">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.ServiceModel">\r
+      <RequiredTargetFramework>3.0</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Xml.Linq">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Data.DataSetExtensions">\r
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>\r
+    </Reference>\r
+    <Reference Include="System.Data" />\r
+    <Reference Include="System.Xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="Program.cs" />\r
+    <Compile Include="Properties\AssemblyInfo.cs" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ProjectReference Include="..\..\..\..\nunit20\framework\nunit.framework.dll20.csproj">\r
+      <Project>{83DD7E12-A705-4DBA-9D71-09C8973D9382}</Project>\r
+      <Name>nunit.framework.dll20</Name>\r
+    </ProjectReference>\r
+    <ProjectReference Include="..\..\..\..\nunit20\nunit-console\nunit-console20.csproj">\r
+      <Project>{9367EC89-6A38-42BA-9607-0DC288E4BC3A}</Project>\r
+      <Name>nunit-console20</Name>\r
+    </ProjectReference>\r
+    <ProjectReference Include="..\..\System.ServiceModel_Test.csproj">\r
+      <Project>{05A2DAF1-316D-4350-B07B-B73BE591DE57}</Project>\r
+      <Name>System.ServiceModel_Test</Name>\r
+    </ProjectReference>\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+       Other similar extension points exist, see Microsoft.Common.targets.\r
+  <Target Name="BeforeBuild">\r
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
+  -->\r
+</Project>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/ChangeLog b/mcs/class/System.ServiceModel/Test/config/ChangeLog
new file mode 100644 (file)
index 0000000..e4fc821
--- /dev/null
@@ -0,0 +1,33 @@
+2008-04-02  Vladimir Krasnov  <vladimirk@mainsoft.com>
+
+       * basicHttpBinding.config: added biding config for testing
+
+2008-04-01  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * service.config: more configuration.
+       
+2008-03-27  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * customBinding.config: change value of messageSecurityVersion attribute
+       due to some API still not implemented.
+
+2008-03-27  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * customBinding.config: more configuration.
+
+2008-03-26  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * client.metadata:
+       * client.metadata.config:
+       * empty:
+       * empty.config:
+       add config files for tests.
+
+2008-03-24  Igor Zelmanovich <igorz@mainsoft.com>
+
+       * userBinding.config: 
+       consider test's assembly name System.ServiceModel_test_net_3_0.
+
+2006-06-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * test1.config : config file for test.
diff --git a/mcs/class/System.ServiceModel/Test/config/basicHttpBinding b/mcs/class/System.ServiceModel/Test/config/basicHttpBinding
new file mode 100644 (file)
index 0000000..cd6f69c
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/basicHttpBinding.config b/mcs/class/System.ServiceModel/Test/config/basicHttpBinding.config
new file mode 100644 (file)
index 0000000..a377fd7
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <system.serviceModel>
+        <bindings>
+            <basicHttpBinding>
+                <binding name="BasicHttpBinding_Service" closeTimeout="00:01:00"
+                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
+                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
+                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
+                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
+                    useDefaultWebProxy="true">
+                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
+                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
+                    <security mode="None">
+                        <transport clientCredentialType="None" proxyCredentialType="None"
+                            realm="" />
+                        <message clientCredentialType="UserName" algorithmSuite="Default" />
+                    </security>
+                </binding>
+                <binding name="BasicHttpBinding2_Service" closeTimeout="00:02:00"
+                    openTimeout="00:02:00" receiveTimeout="00:12:00" sendTimeout="00:07:00"
+                    allowCookies="true" bypassProxyOnLocal="true" hostNameComparisonMode="Exact"
+                    maxBufferSize="32768" maxBufferPoolSize="262144" maxReceivedMessageSize="32768"
+                    messageEncoding="Text" textEncoding="utf-16" transferMode="Streamed"
+                    useDefaultWebProxy="false" proxyAddress="proxy">
+                    <readerQuotas maxDepth="64" maxStringContentLength="16384" maxArrayLength="4096"
+                        maxBytesPerRead="8192" maxNameTableCharCount="8192" />
+                    <security mode="None">
+                        <transport clientCredentialType="None" proxyCredentialType="None"
+                            realm="" />
+                        <message clientCredentialType="UserName" algorithmSuite="Default" />
+                    </security>
+                </binding>
+            </basicHttpBinding>
+        </bindings>
+        <client>
+            <endpoint address="http://localhost:2160/WCFWebApp/Service.svc"
+                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service"
+                contract="ServiceReference1.Service" name="BasicHttpBinding_Service" />
+        </client>
+    </system.serviceModel>
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/client.endpoint b/mcs/class/System.ServiceModel/Test/config/client.endpoint
new file mode 100644 (file)
index 0000000..cd6f69c
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/client.endpoint.config b/mcs/class/System.ServiceModel/Test/config/client.endpoint.config
new file mode 100644 (file)
index 0000000..2ea9102
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8" ?>\r
+<configuration>\r
+       <system.serviceModel>\r
+               <client>\r
+                       <endpoint address="http://igorxp:8080/" binding="basicHttpBinding"\r
+                contract="WCFClient.IHelloWorldService" name="BasicHttpBinding_IHelloWorldService">\r
+                               <identity>\r
+                                       <userPrincipalName value="igorz@iloffice.mainsoft.com" />\r
+                               </identity>\r
+                               <headers>\r
+                                       <Header1>Header1-Value</Header1>\r
+                                       <myns:Header2 xmlns:myns="uri:my.custom.manespace">Header2-Value</myns:Header2>\r
+                               </headers>\r
+                       </endpoint>\r
+               </client>\r
+       </system.serviceModel>\r
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/client.metadata b/mcs/class/System.ServiceModel/Test/config/client.metadata
new file mode 100644 (file)
index 0000000..737bcc8
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.\r
diff --git a/mcs/class/System.ServiceModel/Test/config/client.metadata.config b/mcs/class/System.ServiceModel/Test/config/client.metadata.config
new file mode 100644 (file)
index 0000000..8dde9ff
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<configuration>\r
+       <system.serviceModel>\r
+               <client>\r
+                       <metadata>\r
+                               <policyImporters>\r
+                                       <clear/>\r
+                                       <extension type="PolicyImporterType1" />\r
+                                       <extension type="PolicyImporterType2" />\r
+                               </policyImporters>\r
+                               <wsdlImporters>\r
+                                       <clear/>\r
+                                       <extension type="WSDLImporter1" />\r
+                                       <extension type="WSDLImporter2" />\r
+                               </wsdlImporters>\r
+                       </metadata>\r
+               </client>\r
+       </system.serviceModel>\r
+</configuration>\r
diff --git a/mcs/class/System.ServiceModel/Test/config/customBinding b/mcs/class/System.ServiceModel/Test/config/customBinding
new file mode 100644 (file)
index 0000000..cd6f69c
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/customBinding.config b/mcs/class/System.ServiceModel/Test/config/customBinding.config
new file mode 100644 (file)
index 0000000..a23ff7f
--- /dev/null
@@ -0,0 +1,217 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<configuration>\r
+       <system.serviceModel>\r
+               <bindings>\r
+                       <customBinding>\r
+                               <binding name="CustomBinding_1" closeTimeout="00:02:00" openTimeout="00:02:00"\r
+                                receiveTimeout="00:20:00" sendTimeout="00:02:00">\r
+                                       <binaryMessageEncoding maxReadPoolSize="128" maxWritePoolSize="32"\r
+                                        maxSessionSize="1024">\r
+                                               <readerQuotas maxDepth="1024" maxStringContentLength="1024" maxArrayLength="1024"\r
+                                                maxBytesPerRead="1024" maxNameTableCharCount="1024" />\r
+                                       </binaryMessageEncoding>\r
+                                       <compositeDuplex clientBaseAddress="http://client.base.address" />\r
+                                       <oneWay maxAcceptedChannels="5" packetRoutable="true">\r
+                                               <channelPoolSettings idleTimeout="00:01:00" leaseTimeout="00:12:00"\r
+                                                maxOutboundChannelsPerEndpoint="5" />\r
+                                       </oneWay>\r
+                                       <httpTransport manualAddressing="true" maxBufferPoolSize="262144"\r
+                                        maxReceivedMessageSize="32768" allowCookies="true" authenticationScheme="None"\r
+                                        bypassProxyOnLocal="true" hostNameComparisonMode="Exact" keepAliveEnabled="false"\r
+                                        maxBufferSize="32768" proxyAddress="http://proxy.address" proxyAuthenticationScheme="None"\r
+                                        realm="Realm" transferMode="Streamed" unsafeConnectionNtlmAuthentication="true"\r
+                                        useDefaultWebProxy="false" />\r
+                                       <pnrpPeerResolver />\r
+                                       <privacyNoticeAt url="http://url" version="5" />\r
+                                       <reliableSession acknowledgementInterval="00:00:00.4000000" flowControlEnabled="false"\r
+                                        inactivityTimeout="00:15:00" maxPendingChannels="8" maxRetryCount="16"\r
+                                        maxTransferWindowSize="16" ordered="false" reliableMessagingVersion="WSReliableMessaging11" />\r
+                                       <security defaultAlgorithmSuite="Basic256Rsa15" allowSerializedSigningTokenOnReply="true"\r
+                                        authenticationMode="UserNameForCertificate" requireDerivedKeys="false"\r
+                                        securityHeaderLayout="Lax" includeTimestamp="false" keyEntropyMode="ClientEntropy"\r
+                                        messageProtectionOrder="EncryptBeforeSign" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11"\r
+                                        requireSecurityContextCancellation="false" requireSignatureConfirmation="true">\r
+                                               <issuedTokenParameters keySize="6" keyType="AsymmetricKey" tokenType="TokenType">\r
+                                                       <additionalRequestParameters>\r
+                                                               <myxml>myinnertext</myxml>\r
+                                                       </additionalRequestParameters>\r
+                                                       <claimTypeRequirements>\r
+                                                               <add claimType="NewClaimType" isOptional="true" />\r
+                                                       </claimTypeRequirements>\r
+                                                       <issuer address="http://address" binding="customBinding" bindingConfiguration="CustomBinding_1">\r
+                                                               <headers>\r
+                                                                       <Tag1>Value1</Tag1>\r
+                                                                       <Tag2>Value2</Tag2>\r
+                                                               </headers>\r
+                                                               <identity>\r
+                                                                       <userPrincipalName value="UserProncipalName" />\r
+                                                                       <servicePrincipalName value="ServicePrincipalName" />\r
+                                                                       <dns value="Dns" />\r
+                                                                       <rsa value="Rsa" />\r
+                                                                       <certificate encodedValue="Certificate" />\r
+                                                                       <certificateReference storeName="Root" storeLocation="CurrentUser"\r
+                                                                        x509FindType="FindByIssuerName" findValue="FindValue" isChainIncluded="true" />\r
+                                                               </identity>\r
+                                                       </issuer>\r
+                                                       <issuerMetadata address="http://address">\r
+                                                               <headers>\r
+                                                                       <Tag>Value</Tag>\r
+                                                               </headers>\r
+                                                               <identity>\r
+                                                                       <userPrincipalName value="UserPrincipalName" />\r
+                                                                       <servicePrincipalName value="ServicePrincipalName" />\r
+                                                                       <dns value="Dns" />\r
+                                                                       <rsa value="Rsa" />\r
+                                                                       <certificate encodedValue="Certificate" />\r
+                                                                       <certificateReference storeName="Root" storeLocation="CurrentUser"\r
+                                                                        x509FindType="FindByIssuerName" findValue="FindValue" isChainIncluded="true" />\r
+                                                               </identity>\r
+                                                       </issuerMetadata>\r
+                                               </issuedTokenParameters>\r
+                                               <localClientSettings cacheCookies="false" detectReplays="false"\r
+                                                replayCacheSize="600000" maxClockSkew="00:06:00" replayWindow="00:06:00"\r
+                                                sessionKeyRenewalInterval="15:00:00" sessionKeyRolloverInterval="00:06:00"\r
+                                                reconnectTransportOnFailure="true" timestampValidityDuration="00:06:00"\r
+                                                cookieRenewalThresholdPercentage="70" />\r
+                                               <localServiceSettings detectReplays="false" issuedCookieLifetime="15:00:00"\r
+                                                maxStatefulNegotiations="256" replayCacheSize="600000" maxClockSkew="00:10:00"\r
+                                                negotiationTimeout="00:02:00" replayWindow="00:08:00" inactivityTimeout="00:04:00"\r
+                                                sessionKeyRenewalInterval="10:00:00" sessionKeyRolloverInterval="00:06:00"\r
+                                                reconnectTransportOnFailure="false" maxPendingSessions="256"\r
+                                                maxCachedCookies="2000" timestampValidityDuration="00:06:00" />\r
+                                               <secureConversationBootstrap defaultAlgorithmSuite="Basic256Rsa15"\r
+                                                allowSerializedSigningTokenOnReply="true" authenticationMode="UserNameForCertificate"\r
+                                                requireDerivedKeys="false" securityHeaderLayout="Lax" includeTimestamp="false"\r
+                                                keyEntropyMode="ClientEntropy" messageProtectionOrder="EncryptBeforeSign"\r
+                                                messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11"\r
+                                                requireSecurityContextCancellation="false" requireSignatureConfirmation="true">\r
+                                                       <issuedTokenParameters keySize="6" keyType="AsymmetricKey" tokenType="TokenType">\r
+                                                               <additionalRequestParameters>\r
+                                                                       <myxml>myinnertext</myxml>\r
+                                                               </additionalRequestParameters>\r
+                                                               <claimTypeRequirements>\r
+                                                                       <add claimType="NewClaimType" isOptional="true" />\r
+                                                               </claimTypeRequirements>\r
+                                                               <issuer address="http://address" binding="customBinding" bindingConfiguration="CustomBinding_1">\r
+                                                                       <headers>\r
+                                                                               <Tag1>Value1</Tag1>\r
+                                                                               <Tag2>Value2</Tag2>\r
+                                                                       </headers>\r
+                                                                       <identity>\r
+                                                                               <userPrincipalName value="UserProncipalName" />\r
+                                                                               <servicePrincipalName value="ServicePrincipalName" />\r
+                                                                               <dns value="Dns" />\r
+                                                                               <rsa value="Rsa" />\r
+                                                                               <certificate encodedValue="Certificate" />\r
+                                                                               <certificateReference storeName="Root" storeLocation="CurrentUser"\r
+                                                                                x509FindType="FindByIssuerName" findValue="FindValue" isChainIncluded="true" />\r
+                                                                       </identity>\r
+                                                               </issuer>\r
+                                                               <issuerMetadata address="http://address">\r
+                                                                       <headers>\r
+                                                                               <Tag>Value</Tag>\r
+                                                                       </headers>\r
+                                                                       <identity>\r
+                                                                               <userPrincipalName value="UserPrincipalName" />\r
+                                                                               <servicePrincipalName value="ServicePrincipalName" />\r
+                                                                               <dns value="Dns" />\r
+                                                                               <rsa value="Rsa" />\r
+                                                                               <certificate encodedValue="Certificate" />\r
+                                                                               <certificateReference storeName="Root" storeLocation="CurrentUser"\r
+                                                                                x509FindType="FindByIssuerName" findValue="FindValue" isChainIncluded="true" />\r
+                                                                       </identity>\r
+                                                               </issuerMetadata>\r
+                                                       </issuedTokenParameters>\r
+                                                       <localClientSettings cacheCookies="false" detectReplays="false"\r
+                                                        replayCacheSize="600000" maxClockSkew="00:06:00" replayWindow="00:06:00"\r
+                                                        sessionKeyRenewalInterval="15:00:00" sessionKeyRolloverInterval="00:06:00"\r
+                                                        reconnectTransportOnFailure="true" timestampValidityDuration="00:06:00"\r
+                                                        cookieRenewalThresholdPercentage="70" />\r
+                                                       <localServiceSettings detectReplays="false" issuedCookieLifetime="15:00:00"\r
+                                                        maxStatefulNegotiations="256" replayCacheSize="600000" maxClockSkew="00:10:00"\r
+                                                        negotiationTimeout="00:02:00" replayWindow="00:08:00" inactivityTimeout="00:04:00"\r
+                                                        sessionKeyRenewalInterval="10:00:00" sessionKeyRolloverInterval="00:06:00"\r
+                                                        reconnectTransportOnFailure="false" maxPendingSessions="256"\r
+                                                        maxCachedCookies="2000" timestampValidityDuration="00:06:00" />\r
+                                               </secureConversationBootstrap>\r
+                                       </security>\r
+                                       <sslStreamSecurity requireClientCertificate="true" />\r
+                                       <transactionFlow transactionProtocol="WSAtomicTransactionOctober2004" />\r
+                                       <useManagedPresentation />\r
+                               </binding>\r
+                               <binding name="CustomBinding_2">\r
+                                       <textMessageEncoding maxReadPoolSize="128" maxWritePoolSize="32"\r
+                                        messageVersion="Soap11WSAddressingAugust2004" writeEncoding="utf-32">\r
+                                               <readerQuotas maxDepth="128" maxStringContentLength="128" maxArrayLength="128"\r
+                                                maxBytesPerRead="128" maxNameTableCharCount="128" />\r
+                                       </textMessageEncoding>\r
+                                       <windowsStreamSecurity protectionLevel="None" />\r
+                                       <httpsTransport manualAddressing="true" maxBufferPoolSize="262144"\r
+                                        maxReceivedMessageSize="32768" allowCookies="true" authenticationScheme="None"\r
+                                        bypassProxyOnLocal="true" hostNameComparisonMode="Exact" keepAliveEnabled="true"\r
+                                        maxBufferSize="32768" proxyAddress="https://proxy.address" proxyAuthenticationScheme="None"\r
+                                        realm="Realm" transferMode="Streamed" unsafeConnectionNtlmAuthentication="true"\r
+                                        useDefaultWebProxy="false" requireClientCertificate="true" />\r
+                               </binding>\r
+                               <binding name="CustomBinding_3">\r
+                                       <mtomMessageEncoding maxReadPoolSize="128" maxWritePoolSize="32"\r
+                                        messageVersion="Soap11WSAddressingAugust2004" maxBufferSize="32768"\r
+                                        writeEncoding="utf-32">\r
+                                               <readerQuotas maxDepth="256" maxStringContentLength="256" maxArrayLength="256"\r
+                                                maxBytesPerRead="256" maxNameTableCharCount="256" />\r
+                                       </mtomMessageEncoding>\r
+                                       <msmqIntegration manualAddressing="true" maxBufferPoolSize="262144"\r
+                                        maxReceivedMessageSize="32768" customDeadLetterQueue="http://CustomDeadLetterQueue"\r
+                                        deadLetterQueue="Custom" durable="false" exactlyOnce="false"\r
+                                        maxRetryCycles="3" receiveErrorHandling="Drop" receiveRetryCount="10"\r
+                                        retryCycleDelay="00:15:00" timeToLive="1.12:00:00" useSourceJournal="true"\r
+                                        useMsmqTracing="true" serializationFormat="Binary">\r
+                                               <msmqTransportSecurity msmqAuthenticationMode="Certificate" msmqEncryptionAlgorithm="Aes"\r
+                                                msmqProtectionLevel="EncryptAndSign" msmqSecureHashAlgorithm="Sha256" />\r
+                                       </msmqIntegration>\r
+                               </binding>\r
+                               <binding name="CustomBinding_4">\r
+                                       <msmqTransport manualAddressing="true" maxBufferPoolSize="262144"\r
+                                        maxReceivedMessageSize="262144" customDeadLetterQueue="http://CustomDeadLetterQueue"\r
+                                        deadLetterQueue="Custom" durable="false" exactlyOnce="false"\r
+                                        maxRetryCycles="3" receiveErrorHandling="Drop" receiveRetryCount="9"\r
+                                        retryCycleDelay="00:15:00" timeToLive="1.12:00:00" useSourceJournal="true"\r
+                                        useMsmqTracing="true" maxPoolSize="16" queueTransferProtocol="Srmp"\r
+                                        useActiveDirectory="true">\r
+                                               <msmqTransportSecurity msmqAuthenticationMode="Certificate" msmqEncryptionAlgorithm="Aes"\r
+                                                msmqProtectionLevel="EncryptAndSign" msmqSecureHashAlgorithm="Sha256" />\r
+                                       </msmqTransport>\r
+                               </binding>\r
+                               <binding name="CustomBinding_5">\r
+                                       <namedPipeTransport manualAddressing="true" maxBufferPoolSize="262144"\r
+                                        maxReceivedMessageSize="32768" connectionBufferSize="4096" hostNameComparisonMode="Exact"\r
+                                        channelInitializationTimeout="00:00:20" maxBufferSize="32768"\r
+                                        maxPendingConnections="5" maxOutputDelay="00:00:01.2000000" maxPendingAccepts="3"\r
+                                        transferMode="Streamed">\r
+                                               <connectionPoolSettings groupName="GroupName" idleTimeout="00:06:00"\r
+                                                maxOutboundConnectionsPerEndpoint="20" />\r
+                                       </namedPipeTransport>\r
+                               </binding>\r
+                               <binding name="CustomBinding_6">\r
+                                       <tcpTransport manualAddressing="true" maxBufferPoolSize="262144"\r
+                                        maxReceivedMessageSize="32768" connectionBufferSize="4096" hostNameComparisonMode="Exact"\r
+                                        channelInitializationTimeout="00:00:15" maxBufferSize="32768"\r
+                                        maxPendingConnections="20" maxOutputDelay="00:00:01.2000000"\r
+                                        maxPendingAccepts="3" transferMode="Streamed" listenBacklog="20"\r
+                                        portSharingEnabled="true" teredoEnabled="true">\r
+                                               <connectionPoolSettings groupName="GroupName" leaseTimeout="00:15:00"\r
+                                                idleTimeout="00:02:30" maxOutboundConnectionsPerEndpoint="30" />\r
+                                       </tcpTransport>\r
+                               </binding>\r
+                               <binding name="CustomBinding_7">\r
+                                       <peerTransport listenIPAddress="192.168.0.1" maxBufferPoolSize="262144"\r
+                                        maxReceivedMessageSize="32768" port="88">\r
+                                               <security mode="Message">\r
+                                                       <transport credentialType="Certificate" />\r
+                                               </security>\r
+                                       </peerTransport>\r
+                               </binding>\r
+                       </customBinding>\r
+               </bindings>\r
+       </system.serviceModel>\r
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/empty b/mcs/class/System.ServiceModel/Test/config/empty
new file mode 100644 (file)
index 0000000..737bcc8
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.\r
diff --git a/mcs/class/System.ServiceModel/Test/config/empty.config b/mcs/class/System.ServiceModel/Test/config/empty.config
new file mode 100644 (file)
index 0000000..5bf9740
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<configuration>\r
+</configuration>\r
diff --git a/mcs/class/System.ServiceModel/Test/config/endpointBehaviors b/mcs/class/System.ServiceModel/Test/config/endpointBehaviors
new file mode 100644 (file)
index 0000000..cd6f69c
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/endpointBehaviors.config b/mcs/class/System.ServiceModel/Test/config/endpointBehaviors.config
new file mode 100644 (file)
index 0000000..59af5ae
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<configuration>\r
+       <system.serviceModel>\r
+               <behaviors>\r
+                       <endpointBehaviors>\r
+                               <behavior name="NewBehavior">\r
+                                       <callbackDebug includeExceptionDetailInFaults="true" />\r
+                                       <callbackTimeouts transactionTimeout="00:02:30" />\r
+                                       <clientCredentials type="ClientCredentialType" supportInteractive="false">\r
+                                               <clientCertificate findValue="findValue" storeLocation="LocalMachine"\r
+                                                storeName="Root" x509FindType="FindByExtension" />\r
+                                               <serviceCertificate>\r
+                                                       <defaultCertificate findValue="findValue" storeLocation="LocalMachine"\r
+                                                        storeName="Root" x509FindType="FindByExtension" />\r
+                                                       <scopedCertificates>\r
+                                                               <add targetUri="http://target.uri" findValue="findValue" storeLocation="LocalMachine"\r
+                                                                storeName="Root" x509FindType="FindByExtension" />\r
+                                                       </scopedCertificates>\r
+                                                       <authentication customCertificateValidatorType="CustomCertificateValidatorType"\r
+                                                        certificateValidationMode="None" revocationMode="Offline" trustedStoreLocation="LocalMachine" />\r
+                                               </serviceCertificate>\r
+                                               <windows allowNtlm="false" allowedImpersonationLevel="None" />\r
+                                               <issuedToken cacheIssuedTokens="false" defaultKeyEntropyMode="ClientEntropy"\r
+                                                issuedTokenRenewalThresholdPercentage="30" />\r
+                                               <httpDigest impersonationLevel="None" />\r
+                                       </clientCredentials>\r
+                                       <clientVia viaUri="http://via.uri" />\r
+                                       <dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="32768" />\r
+                                       <synchronousReceive />\r
+                                       <transactedBatching maxBatchSize="16" />\r
+                               </behavior>\r
+                       </endpointBehaviors>\r
+               </behaviors>\r
+       </system.serviceModel>\r
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/extensions b/mcs/class/System.ServiceModel/Test/config/extensions
new file mode 100644 (file)
index 0000000..cd6f69c
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/extensions.config b/mcs/class/System.ServiceModel/Test/config/extensions.config
new file mode 100644 (file)
index 0000000..46abf97
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>\r
+<configuration>\r
+       <system.serviceModel>\r
+               <extensions>\r
+                       <bindingElementExtensions>\r
+                               <add name="bindingElementExtensions1" type="MyBindingElementElement" />\r
+                               <add name="bindingElementExtensions2" type="AnotherBindingElementElement" />\r
+                       </bindingElementExtensions>\r
+                       <behaviorExtensions>\r
+                               <add name="behaviorExtensions1" type="MyBehaviorElement" />\r
+                               <add name="behaviorExtensions2" type="AnotherBehaviorElement" />\r
+                       </behaviorExtensions>\r
+                       <bindingExtensions>\r
+                               <add name="bindingExtensions1" type="MyBindingCollectionElement" />\r
+                               <add name="bindingExtensions2" type="AnotherBindingCollectionElement" />\r
+                       </bindingExtensions>\r
+               </extensions>\r
+       </system.serviceModel>\r
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/netTcpBinding b/mcs/class/System.ServiceModel/Test/config/netTcpBinding
new file mode 100644 (file)
index 0000000..cd6f69c
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/netTcpBinding.config b/mcs/class/System.ServiceModel/Test/config/netTcpBinding.config
new file mode 100644 (file)
index 0000000..e5cd54a
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8" ?>\r
+<configuration>\r
+       <system.serviceModel>\r
+               <bindings>\r
+                       <netTcpBinding>\r
+                               <binding name="NetTcpBinding_IHelloWorldService" closeTimeout="00:01:00"\r
+                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"\r
+                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"\r
+                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"\r
+                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"\r
+                    maxReceivedMessageSize="65536">\r
+                                       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"\r
+                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />\r
+                                       <reliableSession ordered="true" inactivityTimeout="00:10:00"\r
+                        enabled="false" />\r
+                                       <security mode="Transport">\r
+                                               <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />\r
+                                               <message clientCredentialType="Windows" />\r
+                                       </security>\r
+                               </binding>\r
+                       </netTcpBinding>\r
+               </bindings>\r
+               <client>\r
+                       <endpoint address="net.tcp://igorxp:8081/" binding="netTcpBinding"\r
+                bindingConfiguration="NetTcpBinding_IHelloWorldService" contract="WCFClient.IHelloWorldService"\r
+                name="NetTcpBinding_IHelloWorldService">\r
+                               <identity>\r
+                                       <userPrincipalName value="igorz@iloffice.mainsoft.com" />\r
+                               </identity>\r
+                       </endpoint>\r
+               </client>\r
+       </system.serviceModel>\r
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/service b/mcs/class/System.ServiceModel/Test/config/service
new file mode 100644 (file)
index 0000000..cd6f69c
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/service.config b/mcs/class/System.ServiceModel/Test/config/service.config
new file mode 100644 (file)
index 0000000..60171f0
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<configuration>\r
+       <system.serviceModel>\r
+               <services>\r
+                       <service name="ServiceType">\r
+                               <endpoint address="/rooted.path" \r
+                                                 binding="basicHttpBinding"\r
+                                                 name="basicHttp" \r
+                                                 contract="HttpServiceContract">\r
+                                       <headers>\r
+                                               <Tag>Value</Tag>\r
+                                       </headers>\r
+                               </endpoint>\r
+                               <endpoint  binding="wsHttpBinding"\r
+                                                  address="http://other.endpoint.com"\r
+                                                  contract="WSServiceContract">\r
+                               </endpoint>\r
+                               <endpoint address="path" \r
+                                                 binding="netTcpBinding"\r
+                                                 bindingConfiguration="" \r
+                                                 name="netTcp"\r
+                                                 contract="TcpServiceContract" />\r
+                               <host>\r
+                                       <baseAddresses>\r
+                                               <add baseAddress="http://endpoint.com/some.path" />\r
+                                               <add baseAddress="net.tcp://endpoint.com" />\r
+                                       </baseAddresses>\r
+                                       <timeouts closeTimeout="00:00:20" openTimeout="00:02:00" />\r
+                               </host>\r
+                       </service>\r
+                       <service name="AnotherServiceType">\r
+                               <endpoint binding="basicHttpBinding" contract="HttpServiceContract"></endpoint>\r
+                               <endpoint binding="basicHttpBinding" bindingName="MyBinding" contract="HttpServiceContract"></endpoint>\r
+                               <endpoint binding="basicHttpBinding" address="aaa" contract="HttpServiceContract"></endpoint>\r
+                               <host>\r
+                                       <baseAddresses>\r
+                                               <add baseAddress="http://kuku.com"/>\r
+                                       </baseAddresses>\r
+                               </host>\r
+                       </service>\r
+               </services>\r
+       </system.serviceModel>\r
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/serviceBehaviors b/mcs/class/System.ServiceModel/Test/config/serviceBehaviors
new file mode 100644 (file)
index 0000000..cd6f69c
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/serviceBehaviors.config b/mcs/class/System.ServiceModel/Test/config/serviceBehaviors.config
new file mode 100644 (file)
index 0000000..3c49ad2
--- /dev/null
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<configuration>\r
+       <system.serviceModel>\r
+               <behaviors>\r
+                       <serviceBehaviors>\r
+                               <behavior name="NewBehavior">\r
+                                       <serviceAuthorization principalPermissionMode="UseAspNetRoles"\r
+                                        roleProviderName="RoleProvider" impersonateCallerForAllOperations="true"\r
+                                        serviceAuthorizationManagerType="SerAuthManagType">\r
+                                               <authorizationPolicies>\r
+                                                       <add policyType="PolicyType1" />\r
+                                                       <add policyType="PolicyType2" />\r
+                                               </authorizationPolicies>\r
+                                       </serviceAuthorization>\r
+                                       <dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="32768" />\r
+                                       <serviceCredentials type="ServiceCredentialsType">\r
+                                               <clientCertificate>\r
+                                                       <certificate findValue="FindValue" storeLocation="CurrentUser"\r
+                                                        storeName="Root" x509FindType="FindByIssuerName" />\r
+                                                       <authentication customCertificateValidatorType="CustomCertificateValidationType"\r
+                                                        certificateValidationMode="PeerOrChainTrust" revocationMode="Offline"\r
+                                                        trustedStoreLocation="CurrentUser" includeWindowsGroups="false"\r
+                                                        mapClientCertificateToWindowsAccount="true" />\r
+                                               </clientCertificate>\r
+                                               <serviceCertificate findValue="FindValue" storeLocation="CurrentUser"\r
+                                                storeName="Root" x509FindType="FindByIssuerName" />\r
+                                               <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"\r
+                                                includeWindowsGroups="false" membershipProviderName="MembershipProviderName"\r
+                                                customUserNamePasswordValidatorType="CustomUserNamePasswordValidatorType"\r
+                                                cacheLogonTokens="true" maxCachedLogonTokens="252" cachedLogonTokenLifetime="00:30:00" />\r
+                                               <windowsAuthentication includeWindowsGroups="false" allowAnonymousLogons="true" />\r
+                                               <peer>\r
+                                                       <certificate findValue="FindValue" storeLocation="LocalMachine"\r
+                                                        storeName="Root" x509FindType="FindByIssuerName" />\r
+                                                       <peerAuthentication customCertificateValidatorType="CustomCertificateValidatorType"\r
+                                                        certificateValidationMode="Custom" revocationMode="Offline" trustedStoreLocation="LocalMachine" />\r
+                                                       <messageSenderAuthentication customCertificateValidatorType="CustomCertificateValidatorType"\r
+                                                        certificateValidationMode="None" revocationMode="Offline" trustedStoreLocation="LocalMachine" />\r
+                                               </peer>\r
+                                               <issuedTokenAuthentication customCertificateValidatorType="CustomCertificateValidatorType"\r
+                                                certificateValidationMode="PeerOrChainTrust" revocationMode="Offline"\r
+                                                trustedStoreLocation="CurrentUser" samlSerializerType="SalmSerializerType"\r
+                                                allowUntrustedRsaIssuers="true">\r
+                                                       <knownCertificates>\r
+                                                               <add findValue="FindValue" storeLocation="CurrentUser" storeName="Root"\r
+                                                                x509FindType="FindByIssuerName" />\r
+                                                       </knownCertificates>\r
+                                               </issuedTokenAuthentication>\r
+                                               <secureConversationAuthentication securityStateEncoderType="SecurityStateEncoderType" />\r
+                                       </serviceCredentials>\r
+                                       <serviceDebug httpHelpPageEnabled="false" httpHelpPageUrl="http://help.page.url"\r
+                                        httpsHelpPageEnabled="false" httpsHelpPageUrl="https://help.page.url"\r
+                                        includeExceptionDetailInFaults="true" />\r
+                                       <serviceMetadata externalMetadataLocation="http://external.metadata.location"\r
+                                        httpGetEnabled="true" httpGetUrl="http://get.url" httpsGetEnabled="true"\r
+                                        httpsGetUrl="https://get.url" policyVersion="Default" />\r
+                                       <serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="false"\r
+                                        serviceAuthorizationAuditLevel="Success" messageAuthenticationAuditLevel="Success" />\r
+                                       <serviceThrottling maxConcurrentCalls="32" maxConcurrentSessions="20"\r
+                                        maxConcurrentInstances="14" />\r
+                                       <serviceTimeouts transactionTimeout="00:03:00" />\r
+                               </behavior>\r
+                       </serviceBehaviors>\r
+               </behaviors>\r
+       </system.serviceModel>\r
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/test1 b/mcs/class/System.ServiceModel/Test/config/test1
new file mode 100644 (file)
index 0000000..cd6f69c
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/test1.config b/mcs/class/System.ServiceModel/Test/config/test1.config
new file mode 100644 (file)
index 0000000..4a287e5
--- /dev/null
@@ -0,0 +1,8 @@
+<configuration>
+  <system.serviceModel>
+    <client>
+      <endpoint address="http://localhost:8080" binding="basicHttpBinding" contract="IFoo" />
+    </client>
+  </system.serviceModel>
+</configuration>
+
diff --git a/mcs/class/System.ServiceModel/Test/config/userBinding b/mcs/class/System.ServiceModel/Test/config/userBinding
new file mode 100644 (file)
index 0000000..cd6f69c
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/userBinding.config b/mcs/class/System.ServiceModel/Test/config/userBinding.config
new file mode 100644 (file)
index 0000000..0c7bf5c
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<configuration>\r
+       <system.serviceModel>\r
+               <bindings>\r
+                       <userBinding>\r
+                               <binding name="UserBinding_1" closeTimeout="00:02:00" openTimeout="00:01:30"\r
+                    receiveTimeout="00:15:00" sendTimeout="00:01:30" />\r
+                               <binding name="UserBinding_2" closeTimeout="00:03:00" openTimeout="00:01:40"\r
+                    receiveTimeout="00:13:00" sendTimeout="00:02:30" />\r
+                       </userBinding>\r
+               </bindings>\r
+               <extensions>\r
+                       <bindingExtensions>\r
+                               <add name="userBinding" type="MonoTests.System.ServiceModel.Configuration.UserBindingCollectionElement, System.ServiceModel_test_net_3_0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" />\r
+                       </bindingExtensions>\r
+               </extensions>\r
+       </system.serviceModel>\r
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/wsHttpBinding b/mcs/class/System.ServiceModel/Test/config/wsHttpBinding
new file mode 100644 (file)
index 0000000..cd6f69c
--- /dev/null
@@ -0,0 +1,3 @@
+DO NOT DELETE,\r
+IT IS PLACEHOLDER, REQUIRED FOR READING *.config FILE\r
+USING ConfigurationManager.OpenExeConfiguration API.
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/Test/config/wsHttpBinding.config b/mcs/class/System.ServiceModel/Test/config/wsHttpBinding.config
new file mode 100644 (file)
index 0000000..59a5425
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8" ?>\r
+<configuration>\r
+       <system.serviceModel>\r
+               <bindings>\r
+                       <wsHttpBinding>\r
+                               <binding name="WSHttpBinding_IHelloWorldService" closeTimeout="00:01:00"\r
+                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"\r
+                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"\r
+                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"\r
+                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"\r
+                    allowCookies="false">\r
+                                       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"\r
+                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />\r
+                                       <reliableSession ordered="true" inactivityTimeout="00:10:00"\r
+                        enabled="false" />\r
+                                       <security mode="Message">\r
+                                               <transport clientCredentialType="Windows" proxyCredentialType="None"\r
+                            realm="" />\r
+                                               <message clientCredentialType="Windows" negotiateServiceCredential="true"\r
+                            algorithmSuite="Default" establishSecurityContext="true" />\r
+                                       </security>\r
+                               </binding>\r
+                       </wsHttpBinding>\r
+               </bindings>\r
+               <client>\r
+                       <endpoint address="http://localhost:2160/WCFWebApp/Service.svc"\r
+                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service"\r
+                contract="ServiceReference1.Service" name="BasicHttpBinding_Service" />\r
+               </client>\r
+       </system.serviceModel>\r
+</configuration>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/fixup-config.cs b/mcs/class/System.ServiceModel/fixup-config.cs
new file mode 100644 (file)
index 0000000..d1ff541
--- /dev/null
@@ -0,0 +1,28 @@
+using System;
+using System.Xml;
+
+public class FixupXml
+{
+       public static void Main (string [] args)
+       {
+               if (args.Length == 0) {
+                       Console.WriteLine ("pass path-to-machine.config.");
+                       return;
+               }
+               XmlDocument doc = new XmlDocument ();
+               doc.Load (args [0]);
+               XmlElement el = doc.SelectSingleNode ("/configuration/configSections") as XmlElement;
+               XmlElement old = el.SelectSingleNode ("sectionGroup[@name='system.serviceModel']") as XmlElement;
+               XmlNode up = doc.ReadNode (new XmlTextReader ("fixup-config.xml"));
+               if (old != null)
+                       el.RemoveChild (old);
+               el.InsertAfter (up, null);
+               XmlTextWriter w = new XmlTextWriter (args [0], null);
+               w.Formatting = Formatting.Indented;
+               w.IndentChar = '\t';
+               w.Indentation = 1;
+               doc.Save (w);
+               w.Close ();
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/fixup-config.xml b/mcs/class/System.ServiceModel/fixup-config.xml
new file mode 100644 (file)
index 0000000..0ba3a0d
--- /dev/null
@@ -0,0 +1,11 @@
+<sectionGroup name="system.serviceModel" type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+                       <section name="behaviors" type="System.ServiceModel.Configuration.BehaviorsSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+                       <section name="bindings" type="System.ServiceModel.Configuration.BindingsSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+                       <section name="client" type="System.ServiceModel.Configuration.ClientSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+                       <section name="commonBehaviors" type="System.ServiceModel.Configuration.CommonBehaviorsSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+                       <section name="diagnostic" type="System.ServiceModel.Configuration.DiagnosticSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+                       <section name="extensions" type="System.ServiceModel.Configuration.ExtensionsSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+                       <section name="serviceModelHostingEnvironment" type="System.ServiceModel.Configuration.ServiceHostingEnvironmentSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+                       <section name="services" type="System.ServiceModel.Configuration.ServicesSection, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+</sectionGroup>
+
diff --git a/mcs/class/System.ServiceModel/fixup-config2.cs b/mcs/class/System.ServiceModel/fixup-config2.cs
new file mode 100644 (file)
index 0000000..7aa4442
--- /dev/null
@@ -0,0 +1,28 @@
+using System;
+using System.Xml;
+
+public class FixupXml
+{
+       public static void Main (string [] args)
+       {
+               if (args.Length == 0) {
+                       Console.WriteLine ("pass path-to-web.config.");
+                       return;
+               }
+               XmlDocument doc = new XmlDocument ();
+               doc.Load (args [0]);
+               XmlElement el = doc.SelectSingleNode ("/configuration/system.web/httpHandlers") as XmlElement;
+               XmlElement old = el.SelectSingleNode ("add[@path='*.svc']") as XmlElement;
+               XmlNode up = doc.ReadNode (new XmlTextReader ("fixup-config2.xml"));
+               if (old != null)
+                       el.RemoveChild (old);
+               el.InsertAfter (up, null);
+               XmlTextWriter w = new XmlTextWriter (args [0], null);
+               w.Formatting = Formatting.Indented;
+               w.IndentChar = '\t';
+               w.Indentation = 1;
+               doc.Save (w);
+               w.Close ();
+       }
+}
+
diff --git a/mcs/class/System.ServiceModel/fixup-config2.xml b/mcs/class/System.ServiceModel/fixup-config2.xml
new file mode 100644 (file)
index 0000000..dd0e79b
--- /dev/null
@@ -0,0 +1,2 @@
+<add verb="*" path="*.svc" type="System.ServiceModel.Channels.SvcHttpHandlerFactory, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+
diff --git a/mcs/class/System.ServiceModel/resources/ChangeLog b/mcs/class/System.ServiceModel/resources/ChangeLog
new file mode 100755 (executable)
index 0000000..77b4b80
--- /dev/null
@@ -0,0 +1,3 @@
+2007-04-20  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ws-addr.xsd : new file for WSA10 schema (DTD removed).
diff --git a/mcs/class/System.ServiceModel/resources/WS-Addressing.schema b/mcs/class/System.ServiceModel/resources/WS-Addressing.schema
new file mode 100644 (file)
index 0000000..4e2a44a
--- /dev/null
@@ -0,0 +1,91 @@
+<?xml version="1.0"?>
+<xs:schema targetNamespace="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" elementFormDefault="qualified" blockDefault="#all">
+  <xs:element name="EndpointReference" type="wsa:EndpointReferenceType" />
+  <xs:complexType name="EndpointReferenceType">
+    <xs:sequence>
+      <xs:element name="Address" type="wsa:AttributedURI" />
+      <xs:element name="ReferenceProperties" type="wsa:ReferencePropertiesType" minOccurs="0" />
+      <xs:element name="ReferenceParameters" type="wsa:ReferenceParametersType" minOccurs="0" />
+      <xs:element name="PortType" type="wsa:AttributedQName" minOccurs="0" />
+      <xs:element name="ServiceName" type="wsa:ServiceNameType" minOccurs="0" />
+      <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>\r
+                                        If "Policy" elements from namespace "http://schemas.xmlsoap.org/ws/2002/12/policy#policy" are used, they must appear first (before any extensibility elements).\r
+                                       </xs:documentation>
+        </xs:annotation>
+      </xs:any>
+    </xs:sequence>
+    <xs:anyAttribute namespace="##other" processContents="lax" />
+  </xs:complexType>
+  <xs:complexType name="ReferencePropertiesType">
+    <xs:sequence>
+      <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="ReferenceParametersType">
+    <xs:sequence>
+      <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="ServiceNameType">
+    <xs:simpleContent>
+      <xs:extension base="xs:QName">
+        <xs:attribute name="PortName" type="xs:NCName" />
+        <xs:anyAttribute namespace="##other" processContents="lax" />
+      </xs:extension>
+    </xs:simpleContent>
+  </xs:complexType>
+  <xs:element name="MessageID" type="wsa:AttributedURI" />
+  <xs:element name="RelatesTo" type="wsa:Relationship" />
+  <xs:element name="To" type="wsa:AttributedURI" />
+  <xs:element name="Action" type="wsa:AttributedURI" />
+  <xs:element name="From" type="wsa:EndpointReferenceType" />
+  <xs:element name="ReplyTo" type="wsa:EndpointReferenceType" />
+  <xs:element name="FaultTo" type="wsa:EndpointReferenceType" />
+  <xs:complexType name="Relationship">
+    <xs:simpleContent>
+      <xs:extension base="xs:anyURI">
+        <xs:attribute name="RelationshipType" type="xs:QName" use="optional" />
+        <xs:anyAttribute namespace="##other" processContents="lax" />
+      </xs:extension>
+    </xs:simpleContent>
+  </xs:complexType>
+  <xs:simpleType name="RelationshipTypeValues">
+    <xs:restriction base="xs:QName">
+      <xs:enumeration value="wsa:Reply" />
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:element name="ReplyAfter" type="wsa:ReplyAfterType" />
+  <xs:complexType name="ReplyAfterType">
+    <xs:simpleContent>
+      <xs:extension base="xs:nonNegativeInteger">
+        <xs:anyAttribute namespace="##other" />
+      </xs:extension>
+    </xs:simpleContent>
+  </xs:complexType>
+  <xs:simpleType name="FaultSubcodeValues">
+    <xs:restriction base="xs:QName">
+      <xs:enumeration value="wsa:InvalidMessageInformationHeader" />
+      <xs:enumeration value="wsa:MessageInformationHeaderRequired" />
+      <xs:enumeration value="wsa:DestinationUnreachable" />
+      <xs:enumeration value="wsa:ActionNotSupported" />
+      <xs:enumeration value="wsa:EndpointUnavailable" />
+    </xs:restriction>
+  </xs:simpleType>
+  <xs:attribute name="Action" type="xs:anyURI" />
+  <xs:complexType name="AttributedQName">
+    <xs:simpleContent>
+      <xs:extension base="xs:QName">
+        <xs:anyAttribute namespace="##other" processContents="lax" />
+      </xs:extension>
+    </xs:simpleContent>
+  </xs:complexType>
+  <xs:complexType name="AttributedURI">
+    <xs:simpleContent>
+      <xs:extension base="xs:anyURI">
+        <xs:anyAttribute namespace="##other" processContents="lax" />
+      </xs:extension>
+    </xs:simpleContent>
+  </xs:complexType>
+</xs:schema>
\ No newline at end of file
diff --git a/mcs/class/System.ServiceModel/resources/ws-addr.xsd b/mcs/class/System.ServiceModel/resources/ws-addr.xsd
new file mode 100755 (executable)
index 0000000..a48178c
--- /dev/null
@@ -0,0 +1,137 @@
+<!-- doctype declaration has been removed -->
+<!--
+    W3C XML Schema defined in the Web Services Addressing 1.0 specification
+    http://www.w3.org/TR/ws-addr-core
+
+   Copyright © 2005 World Wide Web Consortium,
+
+   (Massachusetts Institute of Technology, European Research Consortium for
+   Informatics and Mathematics, Keio University). All Rights Reserved. This
+   work is distributed under the W3C® Software License [1] in the hope that
+   it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+   [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+   $Id: ws-addr.xsd,v 1.1 2006/03/21 10:19:47 hugo Exp $
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.w3.org/2005/08/addressing" targetNamespace="http://www.w3.org/2005/08/addressing" blockDefault="#all" elementFormDefault="qualified" finalDefault="" attributeFormDefault="unqualified">
+       
+       <!-- Constructs from the WS-Addressing Core -->
+
+       <xs:element name="EndpointReference" type="tns:EndpointReferenceType"/>
+       <xs:complexType name="EndpointReferenceType" mixed="false">
+               <xs:sequence>
+                       <xs:element name="Address" type="tns:AttributedURIType"/>
+                       <xs:element ref="tns:ReferenceParameters" minOccurs="0"/>
+                       <xs:element ref="tns:Metadata" minOccurs="0"/>
+                       <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+               </xs:sequence>
+               <xs:anyAttribute namespace="##other" processContents="lax"/>
+       </xs:complexType>
+       
+       <xs:element name="ReferenceParameters" type="tns:ReferenceParametersType"/>
+       <xs:complexType name="ReferenceParametersType" mixed="false">
+               <xs:sequence>
+                       <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+               </xs:sequence>
+               <xs:anyAttribute namespace="##other" processContents="lax"/>
+       </xs:complexType>
+       
+       <xs:element name="Metadata" type="tns:MetadataType"/>
+       <xs:complexType name="MetadataType" mixed="false">
+               <xs:sequence>
+                       <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+               </xs:sequence>
+               <xs:anyAttribute namespace="##other" processContents="lax"/>
+       </xs:complexType>
+       
+       <xs:element name="MessageID" type="tns:AttributedURIType"/>
+       <xs:element name="RelatesTo" type="tns:RelatesToType"/>
+       <xs:complexType name="RelatesToType" mixed="false">
+               <xs:simpleContent>
+                       <xs:extension base="xs:anyURI">
+                               <xs:attribute name="RelationshipType" type="tns:RelationshipTypeOpenEnum" use="optional" default="http://www.w3.org/2005/08/addressing/reply"/>
+                               <xs:anyAttribute namespace="##other" processContents="lax"/>
+                       </xs:extension>
+               </xs:simpleContent>
+       </xs:complexType>
+       
+       <xs:simpleType name="RelationshipTypeOpenEnum">
+               <xs:union memberTypes="tns:RelationshipType xs:anyURI"/>
+       </xs:simpleType>
+       
+       <xs:simpleType name="RelationshipType">
+               <xs:restriction base="xs:anyURI">
+                       <xs:enumeration value="http://www.w3.org/2005/08/addressing/reply"/>
+               </xs:restriction>
+       </xs:simpleType>
+       
+       <xs:element name="ReplyTo" type="tns:EndpointReferenceType"/>
+       <xs:element name="From" type="tns:EndpointReferenceType"/>
+       <xs:element name="FaultTo" type="tns:EndpointReferenceType"/>
+       <xs:element name="To" type="tns:AttributedURIType"/>
+       <xs:element name="Action" type="tns:AttributedURIType"/>
+
+       <xs:complexType name="AttributedURIType" mixed="false">
+               <xs:simpleContent>
+                       <xs:extension base="xs:anyURI">
+                               <xs:anyAttribute namespace="##other" processContents="lax"/>
+                       </xs:extension>
+               </xs:simpleContent>
+       </xs:complexType>
+       
+       <!-- Constructs from the WS-Addressing SOAP binding -->
+
+       <xs:attribute name="IsReferenceParameter" type="xs:boolean"/>
+       
+       <xs:simpleType name="FaultCodesOpenEnumType">
+               <xs:union memberTypes="tns:FaultCodesType xs:QName"/>
+       </xs:simpleType>
+       
+       <xs:simpleType name="FaultCodesType">
+               <xs:restriction base="xs:QName">
+                       <xs:enumeration value="tns:InvalidAddressingHeader"/>
+                       <xs:enumeration value="tns:InvalidAddress"/>
+                       <xs:enumeration value="tns:InvalidEPR"/>
+                       <xs:enumeration value="tns:InvalidCardinality"/>
+                       <xs:enumeration value="tns:MissingAddressInEPR"/>
+                       <xs:enumeration value="tns:DuplicateMessageID"/>
+                       <xs:enumeration value="tns:ActionMismatch"/>
+                       <xs:enumeration value="tns:MessageAddressingHeaderRequired"/>
+                       <xs:enumeration value="tns:DestinationUnreachable"/>
+                       <xs:enumeration value="tns:ActionNotSupported"/>
+                       <xs:enumeration value="tns:EndpointUnavailable"/>
+               </xs:restriction>
+       </xs:simpleType>
+       
+       <xs:element name="RetryAfter" type="tns:AttributedUnsignedLongType"/>
+       <xs:complexType name="AttributedUnsignedLongType" mixed="false">
+               <xs:simpleContent>
+                       <xs:extension base="xs:unsignedLong">
+                               <xs:anyAttribute namespace="##other" processContents="lax"/>
+                       </xs:extension>
+               </xs:simpleContent>
+       </xs:complexType>
+       
+       <xs:element name="ProblemHeaderQName" type="tns:AttributedQNameType"/>
+       <xs:complexType name="AttributedQNameType" mixed="false">
+               <xs:simpleContent>
+                       <xs:extension base="xs:QName">
+                               <xs:anyAttribute namespace="##other" processContents="lax"/>
+                       </xs:extension>
+               </xs:simpleContent>
+       </xs:complexType>
+       
+       <xs:element name="ProblemIRI" type="tns:AttributedURIType"/>
+       
+       <xs:element name="ProblemAction" type="tns:ProblemActionType"/>
+       <xs:complexType name="ProblemActionType" mixed="false">
+               <xs:sequence>
+                       <xs:element ref="tns:Action" minOccurs="0"/>
+                       <xs:element name="SoapAction" minOccurs="0" type="xs:anyURI"/>
+               </xs:sequence>
+               <xs:anyAttribute namespace="##other" processContents="lax"/>
+       </xs:complexType>
+       
+</xs:schema>
diff --git a/mcs/class/System.ServiceModel/run-tests.client.bat b/mcs/class/System.ServiceModel/run-tests.client.bat
new file mode 100644 (file)
index 0000000..c9b5932
--- /dev/null
@@ -0,0 +1,4 @@
+Test\SwitchMode\bin\Debug\SwitchMode.exe System.ServiceModel_test_net_3_0.dll.config client
+start WCFServers.exe
+nunit-console.exe System.ServiceModel_test_net_3_0.dll  /out:TestResults.txt /exclude:NotWorking
+WCFServers.exe shutdown
diff --git a/mcs/class/System.ServiceModel/run-tests.inproc.bat b/mcs/class/System.ServiceModel/run-tests.inproc.bat
new file mode 100644 (file)
index 0000000..b62fa0d
--- /dev/null
@@ -0,0 +1,2 @@
+Test\SwitchMode\bin\Debug\SwitchMode.exe System.ServiceModel_test_net_3_0.dll.config inproc
+nunit-console.exe System.ServiceModel_test_net_3_0.dll  /out:TestResults.txt /exclude:NotWorking